Rudiments
include
rudiments
private
inttypes.h
1
// Copyright (c) 2005 David Muse
2
// See the COPYING file for more information.
3
4
#ifndef RUDIMENTS_INTTYPES_H
5
#define RUDIMENTS_INTTYPES_H
6
7
#include <rudiments/private/config.h>
8
9
// define NULL...
10
11
// NULL is typically defined in stddef.h
12
#include <stddef.h>
13
14
// Certain versions of gcc define NULL as ((void *)0) and then complain when
15
// you set a const pointer to it. Work around that.
16
#ifdef RUDIMENTS_REDEFINE_NULL
17
#undef NULL
18
#define NULL 0
19
#endif
20
21
22
// some platforms define types like char16_t in their new or new.h
23
// (some firstworks C code uses inttypes.h to make sure types are defined
24
// though, and we don't want that code to include new.h)
25
#ifdef __cplusplus
26
#include <rudiments/private/new.h>
27
#endif
28
29
30
// define [u]int(8|16|32|64)_t...
31
32
#if defined(RUDIMENTS_HAVE_STDINT_H)
33
#include <stdint.h>
34
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
35
// Tru64 needs __arch64__ for int64_t and uint64_t typedefs
36
#ifndef __arch64__
37
#define __arch64__
38
#endif
39
#include <sys/bitypes.h>
40
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
41
#include <inttypes.h>
42
#endif
43
44
#if defined(RUDIMENTS_HAVE_UCHAR_H)
45
#include <uchar.h>
46
#endif
47
48
#ifndef RUDIMENTS_HAVE_INT8_T
49
typedef
signed
char
int8_t;
50
#endif
51
#ifndef RUDIMENTS_HAVE_UINT8_T
52
typedef
unsigned
char
uint8_t;
53
#endif
54
#ifndef RUDIMENTS_HAVE_INT16_T
55
typedef
signed
short
int16_t;
56
#endif
57
#ifndef RUDIMENTS_HAVE_UINT16_T
58
typedef
unsigned
short
uint16_t;
59
#endif
60
#if !defined(RUDIMENTS_HAVE_CHAR16_T) && \
61
defined(__cplusplus) && (__cplusplus<201103L)
62
typedef
unsigned
short
char16_t;
63
#endif
64
#ifndef RUDIMENTS_HAVE_INT32_T
65
typedef
signed
int
int32_t;
66
#endif
67
#ifndef RUDIMENTS_HAVE_UINT32_T
68
typedef
unsigned
int
uint32_t;
69
// older versions of solaris require this to prevent a pthreads conflict
70
#define _UINT32_T 1
71
#endif
72
#ifndef RUDIMENTS_HAVE_INT64_T
73
#ifdef RUDIMENTS_HAVE_LONG_LONG
74
typedef
signed
long
long
int64_t;
75
#else
76
typedef
signed
long
int64_t;
77
#endif
78
#endif
79
#ifndef RUDIMENTS_HAVE_UINT64_T
80
#ifdef RUDIMENTS_HAVE_LONG_LONG
81
typedef
unsigned
long
long
uint64_t;
82
#else
83
typedef
unsigned
long
uint64_t;
84
#endif
85
#endif
86
87
#ifndef RUDIMENTS_HAVE_BOOL
88
class
bool
{
89
public
:
90
bool
(
const
bool
&b) {
91
value=b.value;
92
}
93
bool
(
const
long
&b) {
94
value=b;
95
}
96
bool
(
const
int
&b) {
97
value=b;
98
}
99
bool
(
const
short
&b) {
100
value=b;
101
}
102
bool
(
const
char
&b) {
103
value=b;
104
}
105
bool
(
const
unsigned
long
&b) {
106
value=b;
107
}
108
bool
(
const
unsigned
int
&b) {
109
value=b;
110
}
111
bool
(
const
unsigned
short
&b) {
112
value=b;
113
}
114
bool
(
const
unsigned
char
&b) {
115
value=b;
116
}
117
bool
&operator=(
const
bool
&b) {
118
value=b.value;
119
return
*
this
;
120
}
121
bool
&operator=(
const
long
&b) {
122
value=b;
123
return
*
this
;
124
}
125
bool
&operator=(
const
int
&b) {
126
value=b;
127
return
*
this
;
128
}
129
bool
&operator=(
const
short
&b) {
130
value=b;
131
return
*
this
;
132
}
133
bool
&operator=(
const
char
&b) {
134
value=b;
135
return
*
this
;
136
}
137
bool
&operator=(
const
unsigned
long
&b) {
138
value=b;
139
return
*
this
;
140
}
141
bool
&operator=(
const
unsigned
int
&b) {
142
value=b;
143
return
*
this
;
144
}
145
bool
&operator=(
const
unsigned
short
&b) {
146
value=b;
147
return
*
this
;
148
}
149
bool
&operator=(
const
unsigned
char
&b) {
150
value=b;
151
return
*
this
;
152
}
153
operator
long()
const
{
154
return
value;
155
}
156
int
operator!() {
157
value=!value;
158
return
value;
159
}
160
int
operator==(
const
bool
&b) {
161
return
value==b.value;
162
}
163
int
operator!=(
const
bool
&b) {
164
return
value!=b.value;
165
}
166
private
:
167
long
value;
168
};
169
#endif
170
#ifndef RUDIMENTS_HAVE_TRUE_FALSE
171
#define true 1
172
#define false 0
173
#endif
174
175
#endif
bool
Definition:
inttypes.h:88
Generated on Tue Sep 11 2018 11:36:51 for Rudiments by
1.8.13