File tree Expand file tree Collapse file tree 6 files changed +65
-2
lines changed
examples/standalone_examples/math_test/src Expand file tree Collapse file tree 6 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,12 @@ static int24_t iabs(int24_t x)
9595{
9696 return x < 0 ? (int24_t )- x : x ;
9797}
98+ #ifndef _EZ80
9899static int48_t i48abs (int48_t x )
99100{
100101 return x < 0 ? (int48_t )- x : x ;
101102}
103+ #endif
102104
103105
104106#if INTERACTIVE && defined(_EZ80 )
Original file line number Diff line number Diff line change 1+ assume adl=1
2+
3+ section .text
4+
5+ public _i48abs
6+
7+ ; int48_t i48abs(int48_t)
8+ _i48abs:
9+ pop bc
10+ pop de
11+ ex (sp), hl
12+
13+ ; read the signbit
14+ push hl
15+ add hl, hl
16+ ex (sp), hl
17+
18+ push bc
19+ ex de, hl
20+ ret nc ; positive
21+ jp __i48neg
22+
23+ extern __i48neg
Original file line number Diff line number Diff line change 1+ assume adl=1
2+
3+ section .text
4+
5+ ; public _i48div
6+
7+ ; i48div_t i48div(int48_t numer, int48_t denom);
8+ ; _i48div:
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ typedef struct {
1313 long rem ;
1414} ldiv_t ;
1515
16+ #ifdef __SIZEOF_INT48__
17+ typedef struct {
18+ signed __int48 quot ;
19+ signed __int48 rem ;
20+ } i48div_t ;
21+ #endif /* __SIZEOF_INT48__ */
22+
1623typedef struct {
1724 long long rem ;
1825 long long quot ;
@@ -95,9 +102,15 @@ void _Exit(int) __NOEXCEPT __attribute__((noreturn));
95102
96103#ifndef _ABS_INT_DEFINED
97104#define _ABS_INT_DEFINED
105+
98106int abs (int n );
99107long labs (long n );
100108long long llabs (long long n );
109+
110+ #ifdef __SIZEOF_INT48__
111+ signed __int48 i48abs (signed __int48 n );
112+ #endif /* __SIZEOF_INT48__ */
113+
101114#endif /* _ABS_INT_DEFINED */
102115
103116div_t div (int numer , int denom );
@@ -106,6 +119,10 @@ ldiv_t ldiv(long numer, long denom);
106119
107120lldiv_t lldiv (long long numer , long long denom );
108121
122+ #ifdef __SIZEOF_INT48__
123+ i48div_t i48div (signed __int48 numer , signed __int48 denom );
124+ #endif /* __SIZEOF_INT48__ */
125+
109126__END_DECLS
110127
111128#endif /* _STDLIB_H */
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ int abs(int n);
1717long labs (long n);
1818long long llabs (long long n);
1919
20+ #ifdef __SIZEOF_INT48__
21+ signed __int48 i48abs (signed __int48 n);
22+ #endif // __SIZEOF_INT48__
23+
2024__END_DECLS
2125
2226#endif // _ABS_INT_DEFINED
@@ -36,6 +40,12 @@ namespace std {
3640using ::abs;
3741inline constexpr long abs (long __x) { return labs (__x); }
3842inline constexpr long long abs (long long __x) { return llabs (__x); }
43+
44+ #ifdef __SIZEOF_INT48__
45+ using ::i48abs;
46+ inline signed __int48 abs (signed __int48 __x) { return i48abs (__x); }
47+ #endif // __SIZEOF_INT48__
48+
3949inline constexpr float abs (float __x) { return fabsf (__x); }
4050inline constexpr double abs (double __x) { return fabs (__x); }
4151inline constexpr long double abs (long double __x) { return fabsl (__x); }
Original file line number Diff line number Diff line change 33#define _EZCXX_CSTDLIB
44
55#include < stdlib.h>
6+ #include < __abs_overloads>
67
78#pragma clang system_header
89
9- #include < __abs_overloads>
10-
1110namespace std {
1211using ::calloc;
1312using ::malloc;
@@ -48,6 +47,10 @@ using ::ldiv;
4847using ::lldiv;
4948inline constexpr ldiv_t div (long __x, long __y) { return ldiv (__x, __y); }
5049inline constexpr lldiv_t div (long long __x, long long __y) { return lldiv (__x, __y); }
50+ #ifdef __SIZEOF_INT48__
51+ using ::i48div;
52+ inline i48div_t div (signed __int48 __x, signed __int48 __y) { return i48div (__x, __y); }
53+ #endif // __SIZEOF_INT48__
5154
5255} // namespace std
5356
You can’t perform that action at this time.
0 commit comments