File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Expand file tree Collapse file tree 4 files changed +54
-0
lines changed 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 ;
@@ -96,12 +103,20 @@ long labs(long n);
96103
97104long long llabs (long long n );
98105
106+ #ifdef __SIZEOF_INT48__
107+ signed __int48 i48abs (signed __int48 n );
108+ #endif /* __SIZEOF_INT48__ */
109+
99110div_t div (int numer , int denom );
100111
101112ldiv_t ldiv (long numer , long denom );
102113
103114lldiv_t lldiv (long long numer , long long denom );
104115
116+ #ifdef __SIZEOF_INT48__
117+ i48div_t i48div (signed __int48 numer , signed __int48 denom );
118+ #endif /* __SIZEOF_INT48__ */
119+
105120__END_DECLS
106121
107122#endif /* _STDLIB_H */
Original file line number Diff line number Diff line change @@ -42,12 +42,20 @@ using ::labs;
4242using ::llabs;
4343inline constexpr long abs (long __x) { return labs (__x); }
4444inline constexpr long long abs (long long __x) { return llabs (__x); }
45+ #ifdef __SIZEOF_INT48__
46+ using ::i48abs;
47+ inline signed __int48 abs (signed __int48 __x) { return i48abs (__x); }
48+ #endif // __SIZEOF_INT48__
4549
4650using ::div;
4751using ::ldiv;
4852using ::lldiv;
4953inline constexpr ldiv_t div (long __x, long __y) { return ldiv (__x, __y); }
5054inline constexpr lldiv_t div (long long __x, long long __y) { return lldiv (__x, __y); }
55+ #ifdef __SIZEOF_INT48__
56+ using ::i48div;
57+ inline i48div_t div (signed __int48 __x, signed __int48 __y) { return i48div (__x, __y); }
58+ #endif // __SIZEOF_INT48__
5159
5260} // namespace std
5361
You can’t perform that action at this time.
0 commit comments