My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
types.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef _SAL_TYPES_H_
30 #define _SAL_TYPES_H_
31 
32 #include <sal/config.h>
33 #include <sal/macros.h>
34 
35 /* Grab __SIZEOFxxx constants from typesconfig tool on Unix */
36 #if defined UNX
37  #include <sal/typesizes.h>
38 #elif defined(WNT)
39  /* FIXME: autogeneration of type sizes on Win32/Win64? */
40  #define SAL_TYPES_ALIGNMENT2 1
41  #define SAL_TYPES_ALIGNMENT4 1
42  #define SAL_TYPES_ALIGNMENT8 1
43  #define SAL_TYPES_SIZEOFSHORT 2
44  #define SAL_TYPES_SIZEOFINT 4
45  #define SAL_TYPES_SIZEOFLONG 4
46  #define SAL_TYPES_SIZEOFLONGLONG 8
47  #ifdef _WIN64
48  #define SAL_TYPES_SIZEOFPOINTER 8
49  #else
50  #define SAL_TYPES_SIZEOFPOINTER 4
51  #endif
52 #endif
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /********************************************************************************/
59 /* Data types
60 */
61 
62 /* Boolean */
63 typedef unsigned char sal_Bool;
64 # define sal_False ((sal_Bool)0)
65 # define sal_True ((sal_Bool)1)
66 
67 /* char is assumed to always be 1 byte long */
68 typedef signed char sal_Int8;
69 typedef unsigned char sal_uInt8;
70 
71 #if SAL_TYPES_SIZEOFSHORT == 2
72  typedef signed short sal_Int16;
73  typedef unsigned short sal_uInt16;
74 #else
75  #error "Could not find 16-bit type, add support for your architecture"
76 #endif
77 
78 #if SAL_TYPES_SIZEOFLONG == 4
79  typedef signed long sal_Int32;
80  typedef unsigned long sal_uInt32;
81  #define SAL_PRIdINT32 "ld"
82  #define SAL_PRIuUINT32 "lu"
83  #define SAL_PRIxUINT32 "lx"
84  #define SAL_PRIXUINT32 "lX"
85 #elif SAL_TYPES_SIZEOFINT == 4
86  typedef signed int sal_Int32;
87  typedef unsigned int sal_uInt32;
88  #define SAL_PRIdINT32 "d"
89  #define SAL_PRIuUINT32 "u"
90  #define SAL_PRIxUINT32 "x"
91  #define SAL_PRIXUINT32 "X"
92 #else
93  #error "Could not find 32-bit type, add support for your architecture"
94 #endif
95 
96 #if defined _MSC_VER && _MSC_VER >= 1000
97  typedef __int64 sal_Int64;
98  typedef unsigned __int64 sal_uInt64;
99 
100  /* The following are macros that will add the 64 bit constant suffix. */
101  #define SAL_CONST_INT64(x) x##i64
102  #define SAL_CONST_UINT64(x) x##ui64
103 
104  #define SAL_PRIdINT64 "I64d"
105  #define SAL_PRIuUINT64 "I64u"
106  #define SAL_PRIxUINT64 "I64x"
107  #define SAL_PRIXUINT64 "I64X"
108 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi)
109  #if SAL_TYPES_SIZEOFLONG == 8
110  typedef signed long int sal_Int64;
111  typedef unsigned long int sal_uInt64;
112 
113 
114  /* The following are macros that will add the 64 bit constant suffix. */
115  #define SAL_CONST_INT64(x) x##l
116  #define SAL_CONST_UINT64(x) x##ul
117 
118  #define SAL_PRIdINT64 "ld"
119  #define SAL_PRIuUINT64 "lu"
120  #define SAL_PRIxUINT64 "lx"
121  #define SAL_PRIXUINT64 "lX"
122  #elif SAL_TYPES_SIZEOFLONGLONG == 8
123  typedef signed long long sal_Int64;
124  typedef unsigned long long sal_uInt64;
125 
126  /* The following are macros that will add the 64 bit constant suffix. */
127  #define SAL_CONST_INT64(x) x##ll
128  #define SAL_CONST_UINT64(x) x##ull
129 
130  #ifdef __MINGW32__
131  #define SAL_PRIdINT64 "I64d"
132  #define SAL_PRIuUINT64 "I64u"
133  #define SAL_PRIxUINT64 "I64x"
134  #define SAL_PRIXUINT64 "I64X"
135  #else
136  #define SAL_PRIdINT64 "lld"
137  #define SAL_PRIuUINT64 "llu"
138  #define SAL_PRIxUINT64 "llx"
139  #define SAL_PRIXUINT64 "llX"
140  #endif
141  #else
142  #error "Could not find 64-bit type, add support for your architecture"
143  #endif
144 #else
145  #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
146 #endif
147 
148 typedef char sal_Char;
149 typedef signed char sal_sChar;
150 typedef unsigned char sal_uChar;
151 
152 #if ( defined(SAL_W32) && !defined(__MINGW32__) )
153  // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
154  // "By default wchar_t is a typedef for unsigned short."
155  // But MinGW has a native wchar_t, and on many places, we cannot deal with
156  // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
157  typedef wchar_t sal_Unicode;
158 #else
159  #define SAL_UNICODE_NOTEQUAL_WCHAR_T
160  typedef sal_uInt16 sal_Unicode;
161 #endif
162 
163 typedef void * sal_Handle;
164 
165 /* sal_Size should currently be the native width of the platform */
166 #if SAL_TYPES_SIZEOFPOINTER == 4
167  typedef sal_uInt32 sal_Size;
168  typedef sal_Int32 sal_sSize;
169 #elif SAL_TYPES_SIZEOFPOINTER == 8
170  typedef sal_uInt64 sal_Size;
171  typedef sal_Int64 sal_sSize;
172 #else
173  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
174 #endif
175 
176 /* sal_PtrDiff holds the result of a pointer subtraction */
177 #if SAL_TYPES_SIZEOFPOINTER == 4
178  typedef sal_Int32 sal_PtrDiff;
179 #elif SAL_TYPES_SIZEOFPOINTER == 8
180  typedef sal_Int64 sal_PtrDiff;
181 #else
182  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
183 #endif
184 
185 /* printf-style conversion specification length modifiers for size_t and
186  ptrdiff_t (most platforms support C99, MSC has its own extension) */
187 #if defined(_MSC_VER) || defined(__MINGW32__)
188  #define SAL_PRI_SIZET "I"
189  #define SAL_PRI_PTRDIFFT "I"
190 #else
191  #define SAL_PRI_SIZET "z"
192  #define SAL_PRI_PTRDIFFT "t"
193 #endif
194 
195 /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
196  * pointer to void can be converted to this type and back to a pointer to void and the
197  * result will compare to the original pointer */
198 #if SAL_TYPES_SIZEOFPOINTER == 4
199  typedef sal_Int32 sal_IntPtr;
200  typedef sal_uInt32 sal_uIntPtr;
201  #define SAL_PRIdINTPTR SAL_PRIdINT32
202  #define SAL_PRIuUINTPTR SAL_PRIuUINT32
203  #define SAL_PRIxUINTPTR SAL_PRIxUINT32
204  #define SAL_PRIXUINTPTR SAL_PRIXUINT32
205 #elif SAL_TYPES_SIZEOFPOINTER == 8
206  typedef sal_Int64 sal_IntPtr;
207  typedef sal_uInt64 sal_uIntPtr;
208  #define SAL_PRIdINTPTR SAL_PRIdINT64
209  #define SAL_PRIuUINTPTR SAL_PRIuUINT64
210  #define SAL_PRIxUINTPTR SAL_PRIxUINT64
211  #define SAL_PRIXUINTPTR SAL_PRIXUINT64
212 #else
213  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
214 #endif
215 
216 /********************************************************************************/
217 /* Useful defines
218  */
219 
220 /* The following SAL_MIN_INTn defines codify the assumption that the signed
221  * sal_Int types use two's complement representation. Defining them as
222  * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
223  * unary minus operator to unsigned quantities.
224  */
225 #define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
226 #define SAL_MAX_INT8 ((sal_Int8) 0x7F)
227 #define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
228 #define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
229 #define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
230 #define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
231 #define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
232 #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
233 #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
234 #define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
235 #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
236 #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
237 
238 #if SAL_TYPES_SIZEOFLONG == 4
239 #define SAL_MAX_SSIZE SAL_MAX_INT32
240 #define SAL_MAX_SIZE SAL_MAX_UINT32
241 #elif SAL_TYPES_SIZEOFLONG == 8
242 #define SAL_MAX_SSIZE SAL_MAX_INT64
243 #define SAL_MAX_SIZE SAL_MAX_UINT64
244 #endif
245 
246 #if defined(SAL_W32) || defined(SAL_UNX)
247 # define SAL_MAX_ENUM 0x7fffffff
248 #endif
249 
250 #if defined(_MSC_VER) || defined(__MINGW32__)
251 # define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
252 #if defined(_MSC_VER)
253 # define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
254 #else
255 # define SAL_DLLPUBLIC_IMPORT
256 #endif // defined(_MSC_VER)
257 # define SAL_DLLPRIVATE
258 # define SAL_DLLPUBLIC_TEMPLATE
259 # define SAL_CALL __cdecl
260 # define SAL_CALL_ELLIPSE __cdecl
261 #elif defined SAL_UNX
262 # if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
263 # define SAL_DLLPUBLIC_EXPORT __global
264 # define SAL_DLLPUBLIC_IMPORT
265 # define SAL_DLLPRIVATE __hidden
266 # define SAL_DLLPUBLIC_TEMPLATE
267 # elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550)
268 # define SAL_DLLPUBLIC_EXPORT __global
269 # define SAL_DLLPUBLIC_IMPORT
270 # define SAL_DLLPRIVATE __hidden
271 # define SAL_DLLPUBLIC_TEMPLATE
272 # elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
273 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
274 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
275 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
276 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
277 # else
278 # define SAL_DLLPUBLIC_EXPORT
279 # define SAL_DLLPUBLIC_IMPORT
280 # define SAL_DLLPRIVATE
281 # define SAL_DLLPUBLIC_TEMPLATE
282 # endif
283 # define SAL_CALL
284 # define SAL_CALL_ELLIPSE
285 #else
286 # error("unknown platform")
287 #endif
288 
295 #if defined(__GNUC__) && ! defined(__MINGW32__)
296 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
297 #define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
298 #else
299 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT
300 #define SAL_EXCEPTION_DLLPRIVATE
301 #endif
302 
303 #include <sal/saldllapi.h>
304 
311 #if defined(__GNUC__)
312 # define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
313 #else
314 # define SAL_WARN_UNUSED_RESULT
315 #endif
316 
321 #ifdef _MSC_VER
322 # define SAL_NO_VTABLE __declspec(novtable)
323 #else
324 # define SAL_NO_VTABLE
325 #endif
326 
327 #ifdef SAL_W32
328 # pragma pack(push, 8)
329 #endif
330 
334 typedef struct _sal_Sequence
335 {
338  sal_Int32 nRefCount;
341  sal_Int32 nElements;
344  char elements[1];
345 } sal_Sequence;
346 
347 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
348 
349 #if defined( SAL_W32)
350 #pragma pack(pop)
351 #endif
352 
363 #ifdef __cplusplus
364 #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
365 #define SAL_THROW( exc )
366 #else /* MSVC, all other */
367 #define SAL_THROW( exc ) throw exc
368 #endif /* __GNUC__, __SUNPRO_CC */
369 #define SAL_THROW_EXTERN_C() throw ()
370 #else /* ! __cplusplus */
371 /* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
372 #define SAL_THROW_EXTERN_C()
373 #endif
374 
375 
376 
377 #ifdef __cplusplus
379 {
383 };
384 #endif /* __cplusplus */
385 
386 
387 #ifdef __cplusplus
388 }
389 #endif /* __cplusplus */
390 
391 #ifdef __cplusplus
392 
393 namespace sal {
394 
406 template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
407  return static_cast< T1 >(n);
408 }
409 
410 }
411 
412 #else /* __cplusplus */
413 
426 #define SAL_INT_CAST(type, expr) ((type) (expr))
427 
428 #endif /* __cplusplus */
429 
435 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
436 # define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
437 #elif (__GNUC__)
438 # define SAL_DEPRECATED(message) __attribute__((deprecated))
439 #elif defined(_MSC_VER)
440 # define SAL_DEPRECATED(message) __declspec(deprecated(message))
441 #else
442 # define SAL_DEPRECATED(message)
443 #endif
444 
452 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
453 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
454  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
455  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
456 #define SAL_WNODEPRECATED_DECLARATIONS_POP \
457  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
458 #else
459 # define SAL_WNODEPRECATED_DECLARATIONS_PUSH
460 # define SAL_WNODEPRECATED_DECLARATIONS_POP
461 #endif
462 
486 #if defined __cplusplus
487 #if defined __GNUC__
488 #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
489 #else
490 #define SAL_UNUSED_PARAMETER
491 #endif
492 #endif
493 
494 #endif /*_SAL_TYPES_H_ */
495 
496 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */