mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Make sure we don't include Math.h or math.h from KERNEL
This commit is contained in:
parent
bc7c8879c5
commit
83603d68d2
Notes:
sideshowbarker
2024-07-17 11:35:03 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/83603d68d2 Pull-request: https://github.com/SerenityOS/serenity/pull/13671 Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/timschumi ✅
4 changed files with 19 additions and 6 deletions
|
@ -9,10 +9,13 @@
|
||||||
#include <AK/Concepts.h>
|
#include <AK/Concepts.h>
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <AK/IntegralMath.h>
|
#include <AK/IntegralMath.h>
|
||||||
#include <AK/Math.h>
|
|
||||||
#include <AK/NumericLimits.h>
|
#include <AK/NumericLimits.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
|
# include <AK/Math.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
// FIXME: this always uses round to nearest break-tie to even
|
// FIXME: this always uses round to nearest break-tie to even
|
||||||
|
@ -45,11 +48,14 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
template<FloatingPoint F>
|
template<FloatingPoint F>
|
||||||
explicit ALWAYS_INLINE operator F() const
|
explicit ALWAYS_INLINE operator F() const
|
||||||
{
|
{
|
||||||
return (F)m_value * pow<F>(0.5, precision);
|
return (F)m_value * pow<F>(0.5, precision);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<Integral I>
|
template<Integral I>
|
||||||
explicit constexpr operator I() const
|
explicit constexpr operator I() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include <AK/Concepts.h>
|
#include <AK/Concepts.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
#include <AK/Format.h>
|
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<Integral T>
|
template<Integral T>
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <AK/StdLibExtraDetails.h>
|
#include <AK/StdLibExtraDetails.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
#ifdef KERNEL
|
||||||
|
# error "Including AK/Math.h from the Kernel is never correct! Floating point is disabled."
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<FloatingPoint T>
|
template<FloatingPoint T>
|
||||||
|
|
|
@ -9,10 +9,13 @@
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <math.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
|
# include <math.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __serenity__
|
#ifdef __serenity__
|
||||||
extern "C" size_t strlen(char const*);
|
extern "C" size_t strlen(char const*);
|
||||||
#else
|
#else
|
||||||
|
@ -159,7 +162,7 @@ ALWAYS_INLINE int print_decimal(PutChFunc putch, CharType*& bufptr, u64 number,
|
||||||
|
|
||||||
return field_width;
|
return field_width;
|
||||||
}
|
}
|
||||||
|
#ifndef KERNEL
|
||||||
template<typename PutChFunc, typename CharType>
|
template<typename PutChFunc, typename CharType>
|
||||||
ALWAYS_INLINE int print_double(PutChFunc putch, CharType*& bufptr, double number, bool always_sign, bool left_pad, bool zero_pad, u32 field_width, u32 precision)
|
ALWAYS_INLINE int print_double(PutChFunc putch, CharType*& bufptr, double number, bool always_sign, bool left_pad, bool zero_pad, u32 field_width, u32 precision)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +212,7 @@ ALWAYS_INLINE int print_double(PutChFunc putch, CharType*& bufptr, double number
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
template<typename PutChFunc, typename CharType>
|
template<typename PutChFunc, typename CharType>
|
||||||
ALWAYS_INLINE int print_octal_number(PutChFunc putch, CharType*& bufptr, u64 number, bool alternate_form, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
ALWAYS_INLINE int print_octal_number(PutChFunc putch, CharType*& bufptr, u64 number, bool alternate_form, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
||||||
{
|
{
|
||||||
|
@ -387,6 +390,7 @@ struct PrintfImpl {
|
||||||
{
|
{
|
||||||
return print_hex(m_putch, m_bufptr, NextArgument<u64>()(ap), false, false, state.left_pad, state.zero_pad, 16, false, 1);
|
return print_hex(m_putch, m_bufptr, NextArgument<u64>()(ap), false, false, state.left_pad, state.zero_pad, 16, false, 1);
|
||||||
}
|
}
|
||||||
|
#ifndef KERNEL
|
||||||
ALWAYS_INLINE int format_g(ModifierState const& state, ArgumentListRefT ap) const
|
ALWAYS_INLINE int format_g(ModifierState const& state, ArgumentListRefT ap) const
|
||||||
{
|
{
|
||||||
return format_f(state, ap);
|
return format_f(state, ap);
|
||||||
|
@ -395,6 +399,7 @@ struct PrintfImpl {
|
||||||
{
|
{
|
||||||
return print_double(m_putch, m_bufptr, NextArgument<double>()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.precision);
|
return print_double(m_putch, m_bufptr, NextArgument<double>()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.precision);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ALWAYS_INLINE int format_o(ModifierState const& state, ArgumentListRefT ap) const
|
ALWAYS_INLINE int format_o(ModifierState const& state, ArgumentListRefT ap) const
|
||||||
{
|
{
|
||||||
return print_octal_number(m_putch, m_bufptr, NextArgument<u32>()(ap), state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
return print_octal_number(m_putch, m_bufptr, NextArgument<u32>()(ap), state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||||
|
|
Loading…
Reference in a new issue