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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef _SAL_TYPES_H_
21 #define _SAL_TYPES_H_
22 
23 #include <sal/config.h>
24 #include <sal/macros.h>
25 
26 /* Grab __SIZEOFxxx constants from typesconfig tool on Unix */
27 #if defined UNX
28  #include <sal/typesizes.h>
29 #elif defined(WNT)
30  /* FIXME: autogeneration of type sizes on Win32/Win64? */
31  #define SAL_TYPES_ALIGNMENT2 1
32  #define SAL_TYPES_ALIGNMENT4 1
33  #define SAL_TYPES_ALIGNMENT8 1
34  #define SAL_TYPES_SIZEOFSHORT 2
35  #define SAL_TYPES_SIZEOFINT 4
36  #define SAL_TYPES_SIZEOFLONG 4
37  #define SAL_TYPES_SIZEOFLONGLONG 8
38  #ifdef _WIN64
39  #define SAL_TYPES_SIZEOFPOINTER 8
40  #else
41  #define SAL_TYPES_SIZEOFPOINTER 4
42  #endif
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /********************************************************************************/
50 /* Data types
51 */
52 
53 /* Boolean */
54 typedef unsigned char sal_Bool;
55 # define sal_False ((sal_Bool)0)
56 # define sal_True ((sal_Bool)1)
57 
58 /* char is assumed to always be 1 byte long */
59 typedef signed char sal_Int8;
60 typedef unsigned char sal_uInt8;
61 
62 #if SAL_TYPES_SIZEOFSHORT == 2
63  typedef signed short sal_Int16;
64  typedef unsigned short sal_uInt16;
65 #else
66  #error "Could not find 16-bit type, add support for your architecture"
67 #endif
68 
69 #if SAL_TYPES_SIZEOFLONG == 4
70  typedef signed long sal_Int32;
71  typedef unsigned long sal_uInt32;
72  #define SAL_PRIdINT32 "ld"
73  #define SAL_PRIuUINT32 "lu"
74  #define SAL_PRIxUINT32 "lx"
75  #define SAL_PRIXUINT32 "lX"
76 #elif SAL_TYPES_SIZEOFINT == 4
77  typedef signed int sal_Int32;
78  typedef unsigned int sal_uInt32;
79  #define SAL_PRIdINT32 "d"
80  #define SAL_PRIuUINT32 "u"
81  #define SAL_PRIxUINT32 "x"
82  #define SAL_PRIXUINT32 "X"
83 #else
84  #error "Could not find 32-bit type, add support for your architecture"
85 #endif
86 
87 #ifdef _MSC_VER
88  typedef __int64 sal_Int64;
89  typedef unsigned __int64 sal_uInt64;
90 
91  /* The following are macros that will add the 64 bit constant suffix. */
92  #define SAL_CONST_INT64(x) x##i64
93  #define SAL_CONST_UINT64(x) x##ui64
94 
95  #define SAL_PRIdINT64 "I64d"
96  #define SAL_PRIuUINT64 "I64u"
97  #define SAL_PRIxUINT64 "I64x"
98  #define SAL_PRIXUINT64 "I64X"
99 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi)
100  #if SAL_TYPES_SIZEOFLONG == 8
101  typedef signed long int sal_Int64;
102  typedef unsigned long int sal_uInt64;
103 
104 
105  /* The following are macros that will add the 64 bit constant suffix. */
106  #define SAL_CONST_INT64(x) x##l
107  #define SAL_CONST_UINT64(x) x##ul
108 
109  #define SAL_PRIdINT64 "ld"
110  #define SAL_PRIuUINT64 "lu"
111  #define SAL_PRIxUINT64 "lx"
112  #define SAL_PRIXUINT64 "lX"
113  #elif SAL_TYPES_SIZEOFLONGLONG == 8
114  typedef signed long long sal_Int64;
115  typedef unsigned long long sal_uInt64;
116 
117  /* The following are macros that will add the 64 bit constant suffix. */
118  #define SAL_CONST_INT64(x) x##ll
119  #define SAL_CONST_UINT64(x) x##ull
120 
121  #ifdef __MINGW32__
122  #define SAL_PRIdINT64 "I64d"
123  #define SAL_PRIuUINT64 "I64u"
124  #define SAL_PRIxUINT64 "I64x"
125  #define SAL_PRIXUINT64 "I64X"
126  #else
127  #define SAL_PRIdINT64 "lld"
128  #define SAL_PRIuUINT64 "llu"
129  #define SAL_PRIxUINT64 "llx"
130  #define SAL_PRIXUINT64 "llX"
131  #endif
132  #else
133  #error "Could not find 64-bit type, add support for your architecture"
134  #endif
135 #else
136  #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
137 #endif
138 
139 typedef char sal_Char;
140 typedef signed char sal_sChar;
141 typedef unsigned char sal_uChar;
142 
143 #if ( defined(SAL_W32) && !defined(__MINGW32__) )
144  // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
145  // "By default wchar_t is a typedef for unsigned short."
146  // But MinGW has a native wchar_t, and on many places, we cannot deal with
147  // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
148  typedef wchar_t sal_Unicode;
149 #else
150  #define SAL_UNICODE_NOTEQUAL_WCHAR_T
151  typedef sal_uInt16 sal_Unicode;
152 #endif
153 
154 typedef void * sal_Handle;
155 
156 /* sal_Size should currently be the native width of the platform */
157 #if SAL_TYPES_SIZEOFPOINTER == 4
158  typedef sal_uInt32 sal_Size;
159  typedef sal_Int32 sal_sSize;
160 #elif SAL_TYPES_SIZEOFPOINTER == 8
161  typedef sal_uInt64 sal_Size;
162  typedef sal_Int64 sal_sSize;
163 #else
164  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
165 #endif
166 
167 /* sal_PtrDiff holds the result of a pointer subtraction */
168 #if SAL_TYPES_SIZEOFPOINTER == 4
169  typedef sal_Int32 sal_PtrDiff;
170 #elif SAL_TYPES_SIZEOFPOINTER == 8
171  typedef sal_Int64 sal_PtrDiff;
172 #else
173  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
174 #endif
175 
176 /* printf-style conversion specification length modifiers for size_t and
177  ptrdiff_t (most platforms support C99, MSC has its own extension) */
178 #if defined(_MSC_VER) || defined(__MINGW32__)
179  #define SAL_PRI_SIZET "I"
180  #define SAL_PRI_PTRDIFFT "I"
181 #else
182  #define SAL_PRI_SIZET "z"
183  #define SAL_PRI_PTRDIFFT "t"
184 #endif
185 
186 /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
187  * pointer to void can be converted to this type and back to a pointer to void and the
188  * result will compare to the original pointer */
189 #if SAL_TYPES_SIZEOFPOINTER == 4
190  typedef sal_Int32 sal_IntPtr;
191  typedef sal_uInt32 sal_uIntPtr;
192  #define SAL_PRIdINTPTR SAL_PRIdINT32
193  #define SAL_PRIuUINTPTR SAL_PRIuUINT32
194  #define SAL_PRIxUINTPTR SAL_PRIxUINT32
195  #define SAL_PRIXUINTPTR SAL_PRIXUINT32
196 #elif SAL_TYPES_SIZEOFPOINTER == 8
197  typedef sal_Int64 sal_IntPtr;
198  typedef sal_uInt64 sal_uIntPtr;
199  #define SAL_PRIdINTPTR SAL_PRIdINT64
200  #define SAL_PRIuUINTPTR SAL_PRIuUINT64
201  #define SAL_PRIxUINTPTR SAL_PRIxUINT64
202  #define SAL_PRIXUINTPTR SAL_PRIXUINT64
203 #else
204  #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
205 #endif
206 
207 /********************************************************************************/
208 /* Useful defines
209  */
210 
211 /* The following SAL_MIN_INTn defines codify the assumption that the signed
212  * sal_Int types use two's complement representation. Defining them as
213  * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
214  * unary minus operator to unsigned quantities.
215  */
216 #define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
217 #define SAL_MAX_INT8 ((sal_Int8) 0x7F)
218 #define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
219 #define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
220 #define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
221 #define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
222 #define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
223 #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
224 #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
225 #define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
226 #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
227 #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
228 
229 #if SAL_TYPES_SIZEOFLONG == 4
230 #define SAL_MAX_SSIZE SAL_MAX_INT32
231 #define SAL_MAX_SIZE SAL_MAX_UINT32
232 #elif SAL_TYPES_SIZEOFLONG == 8
233 #define SAL_MAX_SSIZE SAL_MAX_INT64
234 #define SAL_MAX_SIZE SAL_MAX_UINT64
235 #endif
236 
237 #if defined(SAL_W32) || defined(SAL_UNX)
238 # define SAL_MAX_ENUM 0x7fffffff
239 #endif
240 
241 #if defined(_MSC_VER) || defined(__MINGW32__)
242 # define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
243 # define SAL_JNI_EXPORT __declspec(dllexport)
244 #if defined(_MSC_VER)
245 # define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
246 #else
247 # define SAL_DLLPUBLIC_IMPORT
248 #endif // defined(_MSC_VER)
249 # define SAL_DLLPRIVATE
250 # define SAL_DLLPUBLIC_TEMPLATE
251 # define SAL_CALL __cdecl
252 # define SAL_CALL_ELLIPSE __cdecl
253 #elif defined SAL_UNX
254 # if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
255 # define SAL_DLLPUBLIC_EXPORT __global
256 # define SAL_JNI_EXPORT __global
257 # define SAL_DLLPUBLIC_IMPORT
258 # define SAL_DLLPRIVATE __hidden
259 # define SAL_DLLPUBLIC_TEMPLATE
260 # elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550)
261 # define SAL_DLLPUBLIC_EXPORT __global
262 # define SAL_JNI_EXPORT __global
263 # define SAL_DLLPUBLIC_IMPORT
264 # define SAL_DLLPRIVATE __hidden
265 # define SAL_DLLPUBLIC_TEMPLATE
266 # elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
267 # if defined(DISABLE_DYNLOADING)
268 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
269 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
270 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
271 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
272 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
273 # else
274 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
275 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
276 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
277 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
278 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
279 # endif
280 # else
281 # define SAL_DLLPUBLIC_EXPORT
282 # define SAL_JNI_EXPORT
283 # define SAL_DLLPUBLIC_IMPORT
284 # define SAL_DLLPRIVATE
285 # define SAL_DLLPUBLIC_TEMPLATE
286 # endif
287 # define SAL_CALL
288 # define SAL_CALL_ELLIPSE
289 #else
290 # error("unknown platform")
291 #endif
292 
299 #if defined(__GNUC__) && ! defined(__MINGW32__)
300 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
301 #define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
302 #else
303 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT
304 #define SAL_EXCEPTION_DLLPRIVATE
305 #endif
306 
313 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
314 # define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
315 #else
316 # define SAL_WARN_UNUSED_RESULT
317 #endif
318 
323 #ifdef _MSC_VER
324 # define SAL_NO_VTABLE __declspec(novtable)
325 #else
326 # define SAL_NO_VTABLE
327 #endif
328 
329 #ifdef SAL_W32
330 # pragma pack(push, 8)
331 #endif
332 
336 typedef struct _sal_Sequence
337 {
340  sal_Int32 nRefCount;
343  sal_Int32 nElements;
346  char elements[1];
347 } sal_Sequence;
348 
349 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
350 
351 #if defined( SAL_W32)
352 #pragma pack(pop)
353 #endif
354 
365 #ifdef __cplusplus
366 #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
367 #define SAL_THROW( exc )
368 #else /* MSVC, all other */
369 #define SAL_THROW( exc ) throw exc
370 #endif /* __GNUC__, __SUNPRO_CC */
371 #define SAL_THROW_EXTERN_C() throw ()
372 #else /* ! __cplusplus */
373 /* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
374 #define SAL_THROW_EXTERN_C()
375 #endif
376 
377 #ifdef __cplusplus
378 }
379 #endif /* __cplusplus */
380 
381 #ifdef __cplusplus
382 
384 {
388 };
389 
390 namespace com { namespace sun { namespace star { } } }
391 
396 namespace css = ::com::sun::star;
397 
398 #endif /* __cplusplus */
399 
400 #ifdef __cplusplus
401 
402 namespace sal {
403 
415 template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
416  return static_cast< T1 >(n);
417 }
418 
419 }
420 
421 #else /* __cplusplus */
422 
435 #define SAL_INT_CAST(type, expr) ((type) (expr))
436 
437 #endif /* __cplusplus */
438 
444 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
445 # define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
446 #elif (__GNUC__)
447 # define SAL_DEPRECATED(message) __attribute__((deprecated))
448 #elif defined(_MSC_VER)
449 # define SAL_DEPRECATED(message) __declspec(deprecated(message))
450 #else
451 # define SAL_DEPRECATED(message)
452 #endif
453 
463 #ifdef LIBO_INTERNAL_ONLY
464 # define SAL_DEPRECATED_INTERNAL(message)
465 #else
466 # define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
467 #endif
468 
476 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
477 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
478  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
479  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
480 #define SAL_WNODEPRECATED_DECLARATIONS_POP \
481  _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
482 #else
483 # define SAL_WNODEPRECATED_DECLARATIONS_PUSH
484 # define SAL_WNODEPRECATED_DECLARATIONS_POP
485 #endif
486 
510 #if defined __cplusplus
511 #if defined __GNUC__
512 #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
513 #else
514 #define SAL_UNUSED_PARAMETER
515 #endif
516 #endif
517 
532 #if defined __clang__
533 #define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
534 #else
535 #define SAL_WARN_UNUSED
536 #endif
537 
538 #endif /*_SAL_TYPES_H_ */
539 
540 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */