Rudiments: /home/dmuse/src/rudiments/include/rudiments/private/inttypes.h Source File

Rudiments

- Main Page
- Classes

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 // define [u]int(8|16|32|64)_t...
23
24 #if defined(RUDIMENTS_HAVE_STDINT_H)
25 #include <stdint.h>
26 #elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
27 // Tru64 needs __arch64__ for int64_t and uint64_t typedefs
28 #ifndef __arch64__
29 #define __arch64__
30 #endif
31 #include <sys/bitypes.h>
32 #elif defined(RUDIMENTS_HAVE_INTTYPES_H)
33 #include <inttypes.h>
34 #endif
35
36 #ifndef RUDIMENTS_HAVE_INT8_T
37 typedef signed char int8_t;
38 #endif
39 #ifndef RUDIMENTS_HAVE_UINT8_T
40 typedef unsigned char uint8_t;
41 #endif
42 #ifndef RUDIMENTS_HAVE_INT16_T
43 typedef signed short int16_t;
44 #endif
45 #ifndef RUDIMENTS_HAVE_UINT16_T
46 typedef unsigned short uint16_t;
47 #endif
48 #ifndef RUDIMENTS_HAVE_INT32_T
49 typedef signed int int32_t;
50 #endif
51 #ifndef RUDIMENTS_HAVE_UINT32_T
52 typedef unsigned int uint32_t;
53 // older versions of solaris require this to prevent a pthreads conflict
54 #define _UINT32_T 1
55 #endif
56 #ifndef RUDIMENTS_HAVE_INT64_T
57 #ifdef RUDIMENTS_HAVE_LONG_LONG
58 typedef signed long long int64_t;
59 #else
60 typedef signed long int64_t;
61 #endif
62 #endif
63 #ifndef RUDIMENTS_HAVE_UINT64_T
64 #ifdef RUDIMENTS_HAVE_LONG_LONG
65 typedef unsigned long long uint64_t;
66 #else
67 typedef unsigned long uint64_t;
68 #endif
69 #endif
70
71 #ifndef RUDIMENTS_HAVE_BOOL
72 class bool {
73 public:
74 bool(const bool &b) {
75 value=b.value;
76 }
77 bool(const long &b) {
78 value=b;
79 }
80 bool(const int &b) {
81 value=b;
82 }
83 bool(const short &b) {
84 value=b;
85 }
86 bool(const char &b) {
87 value=b;
88 }
89 bool(const unsigned long &b) {
90 value=b;
91 }
92 bool(const unsigned int &b) {
93 value=b;
94 }
95 bool(const unsigned short &b) {
96 value=b;
97 }
98 bool(const unsigned char &b) {
99 value=b;
100 }
101 bool &operator=(const bool &b) {
102 value=b.value;
103 return *this;
104 }
105 bool &operator=(const long &b) {
106 value=b;
107 return *this;
108 }
109 bool &operator=(const int &b) {
110 value=b;
111 return *this;
112 }
113 bool &operator=(const short &b) {
114 value=b;
115 return *this;
116 }
117 bool &operator=(const char &b) {
118 value=b;
119 return *this;
120 }
121 bool &operator=(const unsigned long &b) {
122 value=b;
123 return *this;
124 }
125 bool &operator=(const unsigned int &b) {
126 value=b;
127 return *this;
128 }
129 bool &operator=(const unsigned short &b) {
130 value=b;
131 return *this;
132 }
133 bool &operator=(const unsigned char &b) {
134 value=b;
135 return *this;
136 }
137 operator long() const {
138 return value;
139 }
140 int operator!() {
141 value=!value;
142 return value;
143 }
144 int operator==(const bool &b) {
145 return value==b.value;
146 }
147 int operator!=(const bool &b) {
148 return value!=b.value;
149 }
150 private:
151 long value;
152 };
153 #endif
154 #ifndef RUDIMENTS_HAVE_TRUE_FALSE
155 #define true 1
156 #define false 0
157 #endif
158
159 #endif
bool
Definition: inttypes.h:72