// -*- C++ -*-
#ifndef _EZCXX_ABS_OVERLOADS
#define _EZCXX_ABS_OVERLOADS

#include <cdefs.h>

#pragma clang system_header

// https://cplusplus.github.io/LWG/issue2192

#ifndef _ABS_INT_DEFINED
#define _ABS_INT_DEFINED

__BEGIN_DECLS

int abs(int n);
long labs(long n);
long long llabs(long long n);

#ifdef __SIZEOF_INT48__
signed __int48 i48abs(signed __int48 n) __NOEXCEPT_CONST;
#endif // __SIZEOF_INT48__

__END_DECLS

#endif // _ABS_INT_DEFINED

#ifndef _ABS_FLOAT_DEFINED
#define _ABS_FLOAT_DEFINED

extern "C" {
    float fabsf(float);
    double fabs(double);
    long double fabsl(long double);
} // extern "C"

#endif // _ABS_FLOAT_DEFINED

namespace std {
using ::abs;
inline constexpr long abs(long __x) { return labs(__x); }
inline constexpr long long abs(long long __x) { return llabs(__x); }

#ifdef __SIZEOF_INT48__
using ::i48abs;
inline signed __int48 abs(signed __int48 __x) { return i48abs(__x); }
#endif // __SIZEOF_INT48__

inline constexpr float abs(float __x) { return fabsf(__x); }
inline constexpr double abs(double __x) { return fabs(__x); }
inline constexpr long double abs(long double __x) { return fabsl(__x); }
}

#endif // _EZCXX_ABS_OVERLOADS
