aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/types.h
blob: 47eb23f0183b90fcbe1b622da7f082a609bb96ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once

// DO_NOT_STYLE

#include "platform.h"

#include <inttypes.h>

typedef int8_t i8;
typedef int16_t i16;
typedef uint8_t ui8;
typedef uint16_t ui16;

typedef int yssize_t;
#define PRIYSZT "d"

#if defined(_darwin_) && defined(_32_)
typedef unsigned long ui32;
typedef long i32;
#else
typedef uint32_t ui32;
typedef int32_t i32;
#endif

#if defined(_darwin_) && defined(_64_)
typedef unsigned long ui64;
typedef long i64;
#else
typedef uint64_t ui64;
typedef int64_t i64;
#endif

#define LL(number) INT64_C(number)
#define ULL(number) UINT64_C(number)

// Macro for size_t and ptrdiff_t types
#if defined(_32_)
    #if defined(_darwin_)
        #define PRISZT "lu"
        #undef PRIi32
        #define PRIi32 "li"
        #undef SCNi32
        #define SCNi32 "li"
        #undef PRId32
        #define PRId32 "li"
        #undef SCNd32
        #define SCNd32 "li"
        #undef PRIu32
        #define PRIu32 "lu"
        #undef SCNu32
        #define SCNu32 "lu"
        #undef PRIx32
        #define PRIx32 "lx"
        #undef SCNx32
        #define SCNx32 "lx"
    #elif !defined(_cygwin_)
        #define PRISZT PRIu32
    #else
        #define PRISZT "u"
    #endif
    #define SCNSZT SCNu32
    #define PRIPDT PRIi32
    #define SCNPDT SCNi32
    #define PRITMT PRIi32
    #define SCNTMT SCNi32
#elif defined(_64_)
    #if defined(_darwin_)
        #define PRISZT "lu"
        #undef PRIu64
        #define PRIu64 PRISZT
        #undef PRIx64
        #define PRIx64 "lx"
        #undef PRIX64
        #define PRIX64 "lX"
        #undef PRId64
        #define PRId64 "ld"
        #undef PRIi64
        #define PRIi64 "li"
        #undef SCNi64
        #define SCNi64 "li"
        #undef SCNu64
        #define SCNu64 "lu"
        #undef SCNx64
        #define SCNx64 "lx"
    #else
        #define PRISZT PRIu64
    #endif
    #define SCNSZT SCNu64
    #define PRIPDT PRIi64
    #define SCNPDT SCNi64
    #define PRITMT PRIi64
    #define SCNTMT SCNi64
#else
    #error "Unsupported platform"
#endif

// SUPERLONG
#if !defined(DONT_USE_SUPERLONG) && !defined(SUPERLONG_MAX)
    #define SUPERLONG_MAX ~LL(0)
typedef i64 SUPERLONG;
#endif

// UNICODE
#ifdef __cplusplus
// UCS-2, native byteorder
typedef char16_t wchar16;
// internal symbol type: UTF-16LE
typedef wchar16 TChar;
typedef char32_t wchar32;
#endif

#if defined(_MSC_VER)
    #include <basetsd.h>
typedef SSIZE_T ssize_t;
    #define HAVE_SSIZE_T 1
    #include <wchar.h>
#endif

#include <sys/types.h>

// for pb.h/cc
typedef i32 arc_i32;
typedef i64 arc_i64;
typedef ui32 arc_ui32;
typedef ui64 arc_ui64;