Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pointer_typedefs.h
Go to the documentation of this file.
1 #ifndef INCLUDED_POINTER_TYPEDEFS
2 #define INCLUDED_POINTER_TYPEDEFS
3 
4 #include "lib/sysdep/compiler.h" // HAVE_SSE
5 
6 #if HAVE_SSE
7 # include <xmmintrin.h> // __m64, __m128
8 #endif
9 #if HAVE_SSE2
10 # include <emmintrin.h> // __m128i, __m128d
11 #endif
12 
13 // convenience typedefs for shortening parameter lists.
14 // naming convention: [const] [restrict] pointer to [const] type
15 // supported types: void, signed/unsigned 8/16/32/64 integers, float, double, XMM
16 
17 // which general type of pointer should be used in various situations?
18 // it would be convenient (especially for allocators) to allow easy
19 // pointer arithmetic. char* is one such option. However, that type of
20 // pointer (and also u8*) has a special dispensation for aliasing with
21 // _anything_ [C99 6.5(7) - we refer to that standard because __restrict
22 // compiler extensions are most likely to conform to its semantics],
23 // which might prevent optimizations.
24 //
25 // storing the address in uintptr_t (signed integers must never overflow)
26 // does allow easy arithmetic. unfortunately, the ASSUME_ALIGNED macro
27 // requires a pointer type. it is not clear whether casting to a pointer
28 // provides the same benefit.
29 //
30 // GCC and MSVC also provide a function attribute indicating a
31 // non-aliased pointer is being returned. however, this propagation
32 // does not seem to be reliable, especially because compilers may
33 // lose track of pointers [1]. it is therefore a waste of effort to
34 // annotate ALL pointers with cumbersome declarations, or pollute
35 // public interfaces with the following (little-known) typedefs.
36 //
37 // performance-critical code should instead introduce restricted
38 // pointers immediately before they are used to access memory.
39 // when combined with ASSUME_ALIGNED annotations, this would seem to
40 // provide all of the benefits of pointer analysis. it is therefore
41 // safe to use uintptr_t wherever convenient. however, callers usually
42 // expect a void* parameter or return value (e.g. in STL allocators).
43 // that seems a reasonable convention without any apparent downsides.
44 //
45 // in summary:
46 // - void* for public allocator interfaces;
47 // - uintptr_t for variables/arguments (even some public ones)
48 // which are frequently the subject of address manipulations;
49 // - restrict-qualified pointers via the following typedefs
50 // [plus ASSUME_ALIGNED, if applicable] shortly before
51 // accessing the underlying storage.
52 //
53 // 1: http://drdobbs.com/cpp/184403676?pgno=3
54 
55 // NB: `restrict' is not going into C++0x, so use __restrict to
56 // maintain compatibility with VC2010.
57 
58 typedef void* pVoid;
59 typedef void* const cpVoid;
60 typedef void* __restrict rpVoid;
61 typedef void* const __restrict crpVoid;
62 typedef const void* pcVoid;
63 typedef const void* const cpcVoid;
64 typedef const void* __restrict rpcVoid;
65 typedef const void* const __restrict crpcVoid;
66 
67 typedef int8_t* pI8;
68 typedef int8_t* const cpI8;
69 typedef int8_t* __restrict rpI8;
70 typedef int8_t* const __restrict crpI8;
71 typedef const int8_t* pcI8;
72 typedef const int8_t* const cpcI8;
73 typedef const int8_t* __restrict rpcI8;
74 typedef const int8_t* const __restrict crpcI8;
75 
76 typedef int16_t* pI16;
77 typedef int16_t* const cpI16;
78 typedef int16_t* __restrict rpI16;
79 typedef int16_t* const __restrict crpI16;
80 typedef const int16_t* pcI16;
81 typedef const int16_t* const cpcI16;
82 typedef const int16_t* __restrict rpcI16;
83 typedef const int16_t* const __restrict crpcI16;
84 
85 typedef int32_t* pI32;
86 typedef int32_t* const cpI32;
87 typedef int32_t* __restrict rpI32;
88 typedef int32_t* const __restrict crpI32;
89 typedef const int32_t* pcI32;
90 typedef const int32_t* const cpcI32;
91 typedef const int32_t* __restrict rpcI32;
92 typedef const int32_t* const __restrict crpcI32;
93 
94 typedef int64_t* pI64;
95 typedef int64_t* const cpI64;
96 typedef int64_t* __restrict rpI64;
97 typedef int64_t* const __restrict crpI64;
98 typedef const int64_t* pcI64;
99 typedef const int64_t* const cpcI64;
100 typedef const int64_t* __restrict rpcI64;
101 typedef const int64_t* const __restrict crpcI64;
102 
103 typedef uint8_t* pU8;
104 typedef uint8_t* const cpU8;
105 typedef uint8_t* __restrict rpU8;
106 typedef uint8_t* const __restrict crpU8;
107 typedef const uint8_t* pcU8;
108 typedef const uint8_t* const cpcU8;
109 typedef const uint8_t* __restrict rpcU8;
110 typedef const uint8_t* const __restrict crpcU8;
111 
112 typedef uint16_t* pU16;
113 typedef uint16_t* const cpU16;
114 typedef uint16_t* __restrict rpU16;
115 typedef uint16_t* const __restrict crpU16;
116 typedef const uint16_t* pcU16;
117 typedef const uint16_t* const cpcU16;
118 typedef const uint16_t* __restrict rpcU16;
119 typedef const uint16_t* const __restrict crpcU16;
120 
121 typedef uint32_t* pU32;
122 typedef uint32_t* const cpU32;
123 typedef uint32_t* __restrict rpU32;
124 typedef uint32_t* const __restrict crpU32;
125 typedef const uint32_t* pcU32;
126 typedef const uint32_t* const cpcU32;
127 typedef const uint32_t* __restrict rpcU32;
128 typedef const uint32_t* const __restrict crpcU32;
129 
130 typedef uint64_t* pU64;
131 typedef uint64_t* const cpU64;
132 typedef uint64_t* __restrict rpU64;
133 typedef uint64_t* const __restrict crpU64;
134 typedef const uint64_t* pcU64;
135 typedef const uint64_t* const cpcU64;
136 typedef const uint64_t* __restrict rpcU64;
137 typedef const uint64_t* const __restrict crpcU64;
138 
139 typedef float* pFloat;
140 typedef float* const cpFloat;
141 typedef float* __restrict rpFloat;
142 typedef float* const __restrict crpFloat;
143 typedef const float* pcFloat;
144 typedef const float* const cpcFloat;
145 typedef const float* __restrict rpcFloat;
146 typedef const float* const __restrict crpcFloat;
147 
148 typedef double* pDouble;
149 typedef double* const cpDouble;
150 typedef double* __restrict rpDouble;
151 typedef double* const __restrict crpDouble;
152 typedef const double* pcDouble;
153 typedef const double* const cpcDouble;
154 typedef const double* __restrict rpcDouble;
155 typedef const double* const __restrict crpcDouble;
156 
157 #if HAVE_SSE
158 typedef __m64* pM64;
159 typedef __m64* const cpM64;
160 typedef __m64* __restrict rpM64;
161 typedef __m64* const __restrict crpM64;
162 typedef const __m64* pcM64;
163 typedef const __m64* const cpcM64;
164 typedef const __m64* __restrict rpcM64;
165 typedef const __m64* const __restrict crpcM64;
166 
167 typedef __m128* pM128;
168 typedef __m128* const cpM128;
169 typedef __m128* __restrict rpM128;
170 typedef __m128* const __restrict crpM128;
171 typedef const __m128* pcM128;
172 typedef const __m128* const cpcM128;
173 typedef const __m128* __restrict rpcM128;
174 typedef const __m128* const __restrict crpcM128;
175 #endif // #if HAVE_SSE
176 
177 #if HAVE_SSE2
178 typedef __m128i* pM128I;
179 typedef __m128i* const cpM128I;
180 typedef __m128i* __restrict rpM128I;
181 typedef __m128i* const __restrict crpM128I;
182 typedef const __m128i* pcM128I;
183 typedef const __m128i* const cpcM128I;
184 typedef const __m128i* __restrict rpcM128I;
185 typedef const __m128i* const __restrict crpcM128I;
186 
187 typedef __m128d* pM128D;
188 typedef __m128d* const cpM128D;
189 typedef __m128d* __restrict rpM128D;
190 typedef __m128d* const __restrict crpM128D;
191 typedef const __m128d* pcM128D;
192 typedef const __m128d* const cpcM128D;
193 typedef const __m128d* __restrict rpcM128D;
194 typedef const __m128d* const __restrict crpcM128D;
195 #endif // #if HAVE_SSE2
196 
197 #endif // #ifndef INCLUDED_POINTER_TYPEDEFS
signed char int8_t
Definition: wposix_types.h:37
uint16_t *const __restrict crpU16
void * pVoid
const double * pcDouble
int32_t * pI32
uint32_t * pU32
const int32_t *__restrict rpcI32
const uint32_t *__restrict rpcU32
void *__restrict rpVoid
double *const cpDouble
uint64_t * pU64
const uint32_t *const __restrict crpcU32
int32_t *__restrict rpI32
const int8_t *const __restrict crpcI8
const int16_t *__restrict rpcI16
int8_t *__restrict rpI8
uint8_t *const cpU8
float *const cpFloat
uint16_t *__restrict rpU16
uint64_t *const cpU64
short int16_t
Definition: wposix_types.h:38
const uint8_t *const __restrict crpcU8
int8_t *const __restrict crpI8
float *const __restrict crpFloat
const uint64_t *const __restrict crpcU64
float * pFloat
double *__restrict rpDouble
const int8_t *const cpcI8
const float *const __restrict crpcFloat
const void *__restrict rpcVoid
double * pDouble
uint8_t * pU8
int32_t *const __restrict crpI32
const int64_t * pcI64
const int32_t *const __restrict crpcI32
const uint16_t * pcU16
uint8_t *__restrict rpU8
const uint16_t *const cpcU16
int16_t * pI16
const double *__restrict rpcDouble
unsigned long long uint64_t
Definition: wposix_types.h:57
const float *const cpcFloat
int16_t *const __restrict crpI16
const void *const __restrict crpcVoid
const int32_t * pcI32
const uint8_t *const cpcU8
const double *const __restrict crpcDouble
unsigned char uint8_t
Definition: wposix_types.h:51
uint8_t *const __restrict crpU8
const uint32_t *const cpcU32
int8_t * pI8
void *const cpVoid
const uint16_t *__restrict rpcU16
int64_t * pI64
const uint16_t *const __restrict crpcU16
void *const __restrict crpVoid
const int8_t * pcI8
uint64_t *__restrict rpU64
const void * pcVoid
int32_t *const cpI32
const uint64_t * pcU64
int8_t *const cpI8
const int64_t *const cpcI64
uint16_t *const cpU16
const void *const cpcVoid
unsigned int uint32_t
Definition: wposix_types.h:53
const int8_t *__restrict rpcI8
const int16_t *const cpcI16
const int16_t *const __restrict crpcI16
const int64_t *__restrict rpcI64
const int32_t *const cpcI32
const uint32_t * pcU32
int64_t *__restrict rpI64
const uint64_t *const cpcU64
const uint8_t * pcU8
unsigned short uint16_t
Definition: wposix_types.h:52
uint32_t *__restrict rpU32
uint32_t *const cpU32
int16_t *__restrict rpI16
const float * pcFloat
const uint64_t *__restrict rpcU64
uint64_t *const __restrict crpU64
uint16_t * pU16
double *const __restrict crpDouble
int64_t *const __restrict crpI64
const int64_t *const __restrict crpcI64
int16_t *const cpI16
const int16_t * pcI16
float *__restrict rpFloat
int64_t *const cpI64
long long int64_t
Definition: wposix_types.h:48
uint32_t *const __restrict crpU32
const uint8_t *__restrict rpcU8
const float *__restrict rpcFloat
const double *const cpcDouble