acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
types.h
1// Created acme/prototype/numeric by camilo on 2022-11-08 18:20 <3ThomasBorregaardSorensen!!
2// Created acme/prototype/numeric/types.h by camilo on 2022-11-08 18:21 <3ThomasBorregaardSorensen!!
3#pragma once
4
5
6#if OSBIT == 32
7
8
9using iptr = ::i32;
10using uptr = ::u32;
11
12
13#define IPTR_MAXIMUM I32_MAXIMUM
14#define UPTR_MAXIMUM U32_MAXIMUM
15#define IPTR_MINIMUM I32_MINIMUM
16
17
18#elif OSBIT == 64
19
20
21// #ifdef __APPLE__
22
23
24// typedef long iptr;
25// typedef ulong uptr;
26
27
28// #else
29//using ::i64 = ::i64 ::i32;
30//using ::u64 = ::u64 ::i32;
31//#if defined(HAS_HYPER_INTEGER)
32//using hyper_integer = __int128;
33//using hyper_natural = ::u32 __int128;
34//#endif
35typedef i64 iptr;
36typedef u64 uptr;
37
38
39#define IPTR_MAXIMUM I64_MAXIMUM
40#define UPTR_MAXIMUM U64_MAXIMUM
41#define IPTR_MINIMUM I64_MINIMUM
42
43
44//#if defined(__APPLE__) || defined(__ANDROID__) || defined(RASPBERRYPIOS)
45//
46//#define DO_FOR_NUMBER_TYPES(DO) \
47//DO(::i8, ::i8, ch, CHAR); \
48//DO(::u8, unsigned_char, uch, UNSIGNED_CHAR); \
49//DO(::i16, ::i16, sh, SHORT); \
50//DO(::u16, unsigned_short, ush, UNSIGNED_SHORT); \
51//DO(::i32, ::i32, i, INT); \
52//DO(::u32, u32, ui, UNSIGNED_INT); \
53//DO(long, long, l, LONG); \
54//DO(ulong, unsigned_long, ul, UNSIGNED_LONG); \
55//DO(::i64, ::i64, hi, HUGE_INTEGER); \
56//DO(::u64, ::u64, hn, HUGE_NATURAL); \
57//DO(::f32, ::f32, f, FLOAT); \
58//DO(::f64, ::f64, d, DOUBLE);
59//
60//#else
61
62
63//#endif
64
65
66
67// #endif
68
69
70#else
71
72
73#error "OSBIT should be defined with system default pointer size in bit count."
74
75
76#endif
77
78#define DO_FOR_NUMBER_TYPES(DO) \
79DO(i8, i8, i8, CHAR); \
80DO(u8, u8, u8, UNSIGNED_CHAR); \
81DO(i16, i16, i16, SHORT); \
82DO(u16, u16, u16, UNSIGNED_SHORT); \
83DO(i32, i32, i32, INT); \
84DO(u32, u32, u32, UNSIGNED_INT); \
85DO(i64, i64, i64, LONG_LONG); \
86DO(u64, u64, u64, UNSIGNED_LONG_LONG); \
87DO(f32, f32, f32, FLOAT); \
88DO(f64, f64, f64, DOUBLE);
89
90//
91//
92//#if OSBIT == 64
93//
94//typedef ::u64 rtptr;
95//typedef ::u64 ulong_ptr;
96//typedef ::u64 dword_ptr;
97//
98//#else
99//
100//typedef ::u32 rtptr;
101//typedef ::u32 ulong_ptr;
102//typedef ::u32 dword_ptr;
103//
104//#endif
105
106//
107//
108//#if !defined(__APPLE__) && !defined(OPENBSD)
109//
110//
111//#define ssize_t iptr
112//
113//
114//#endif
115
116
117#define __priindex PRIiPTR
118
119
120#define __pricount PRIiPTR
121
122
123// insight by listening lastmiles (Dennis Clarke) talk about pthread_equal (it may end up not to be an ::i32 but a pointer in some implementations ?, so should use pthread_equal...)
125typedef u64 task_index;
126
127
128