UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 00029 #ifndef _SAL_TYPES_H_ 00030 #define _SAL_TYPES_H_ 00031 00032 #include <sal/config.h> 00033 #include <sal/macros.h> 00034 00035 /* Grab __SIZEOFxxx constants from typesconfig tool on Unix */ 00036 #if defined UNX 00037 #include <sal/typesizes.h> 00038 #elif defined(WNT) 00039 /* FIXME: autogeneration of type sizes on Win32/Win64? */ 00040 #define SAL_TYPES_ALIGNMENT2 1 00041 #define SAL_TYPES_ALIGNMENT4 1 00042 #define SAL_TYPES_ALIGNMENT8 1 00043 #define SAL_TYPES_SIZEOFSHORT 2 00044 #define SAL_TYPES_SIZEOFINT 4 00045 #define SAL_TYPES_SIZEOFLONG 4 00046 #define SAL_TYPES_SIZEOFLONGLONG 8 00047 #ifdef _WIN64 00048 #define SAL_TYPES_SIZEOFPOINTER 8 00049 #else 00050 #define SAL_TYPES_SIZEOFPOINTER 4 00051 #endif 00052 #endif 00053 00054 #ifdef __cplusplus 00055 extern "C" { 00056 #endif 00057 00058 /********************************************************************************/ 00059 /* Data types 00060 */ 00061 00062 /* Boolean */ 00063 typedef unsigned char sal_Bool; 00064 # define sal_False ((sal_Bool)0) 00065 # define sal_True ((sal_Bool)1) 00066 00067 /* char is assumed to always be 1 byte long */ 00068 typedef signed char sal_Int8; 00069 typedef unsigned char sal_uInt8; 00070 00071 #if SAL_TYPES_SIZEOFSHORT == 2 00072 typedef signed short sal_Int16; 00073 typedef unsigned short sal_uInt16; 00074 #else 00075 #error "Could not find 16-bit type, add support for your architecture" 00076 #endif 00077 00078 #if SAL_TYPES_SIZEOFLONG == 4 00079 typedef signed long sal_Int32; 00080 typedef unsigned long sal_uInt32; 00081 #define SAL_PRIdINT32 "ld" 00082 #define SAL_PRIuUINT32 "lu" 00083 #define SAL_PRIxUINT32 "lx" 00084 #define SAL_PRIXUINT32 "lX" 00085 #elif SAL_TYPES_SIZEOFINT == 4 00086 typedef signed int sal_Int32; 00087 typedef unsigned int sal_uInt32; 00088 #define SAL_PRIdINT32 "d" 00089 #define SAL_PRIuUINT32 "u" 00090 #define SAL_PRIxUINT32 "x" 00091 #define SAL_PRIXUINT32 "X" 00092 #else 00093 #error "Could not find 32-bit type, add support for your architecture" 00094 #endif 00095 00096 #if defined _MSC_VER && _MSC_VER >= 1000 00097 typedef __int64 sal_Int64; 00098 typedef unsigned __int64 sal_uInt64; 00099 00100 /* The following are macros that will add the 64 bit constant suffix. */ 00101 #define SAL_CONST_INT64(x) x##i64 00102 #define SAL_CONST_UINT64(x) x##ui64 00103 00104 #define SAL_PRIdINT64 "I64d" 00105 #define SAL_PRIuUINT64 "I64u" 00106 #define SAL_PRIxUINT64 "I64x" 00107 #define SAL_PRIXUINT64 "I64X" 00108 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi) 00109 #if SAL_TYPES_SIZEOFLONG == 8 00110 typedef signed long int sal_Int64; 00111 typedef unsigned long int sal_uInt64; 00112 00113 00114 /* The following are macros that will add the 64 bit constant suffix. */ 00115 #define SAL_CONST_INT64(x) x##l 00116 #define SAL_CONST_UINT64(x) x##ul 00117 00118 #define SAL_PRIdINT64 "ld" 00119 #define SAL_PRIuUINT64 "lu" 00120 #define SAL_PRIxUINT64 "lx" 00121 #define SAL_PRIXUINT64 "lX" 00122 #elif SAL_TYPES_SIZEOFLONGLONG == 8 00123 typedef signed long long sal_Int64; 00124 typedef unsigned long long sal_uInt64; 00125 00126 /* The following are macros that will add the 64 bit constant suffix. */ 00127 #define SAL_CONST_INT64(x) x##ll 00128 #define SAL_CONST_UINT64(x) x##ull 00129 00130 #ifdef __MINGW32__ 00131 #define SAL_PRIdINT64 "I64d" 00132 #define SAL_PRIuUINT64 "I64u" 00133 #define SAL_PRIxUINT64 "I64x" 00134 #define SAL_PRIXUINT64 "I64X" 00135 #else 00136 #define SAL_PRIdINT64 "lld" 00137 #define SAL_PRIuUINT64 "llu" 00138 #define SAL_PRIxUINT64 "llx" 00139 #define SAL_PRIXUINT64 "llX" 00140 #endif 00141 #else 00142 #error "Could not find 64-bit type, add support for your architecture" 00143 #endif 00144 #else 00145 #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h" 00146 #endif 00147 00148 typedef char sal_Char; 00149 typedef signed char sal_sChar; 00150 typedef unsigned char sal_uChar; 00151 00152 #if ( defined(SAL_W32) && !defined(__MINGW32__) ) 00153 // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx 00154 // "By default wchar_t is a typedef for unsigned short." 00155 // But MinGW has a native wchar_t, and on many places, we cannot deal with 00156 // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there. 00157 typedef wchar_t sal_Unicode; 00158 #else 00159 #define SAL_UNICODE_NOTEQUAL_WCHAR_T 00160 typedef sal_uInt16 sal_Unicode; 00161 #endif 00162 00163 typedef void * sal_Handle; 00164 00165 /* sal_Size should currently be the native width of the platform */ 00166 #if SAL_TYPES_SIZEOFPOINTER == 4 00167 typedef sal_uInt32 sal_Size; 00168 typedef sal_Int32 sal_sSize; 00169 #elif SAL_TYPES_SIZEOFPOINTER == 8 00170 typedef sal_uInt64 sal_Size; 00171 typedef sal_Int64 sal_sSize; 00172 #else 00173 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler" 00174 #endif 00175 00176 /* sal_PtrDiff holds the result of a pointer subtraction */ 00177 #if SAL_TYPES_SIZEOFPOINTER == 4 00178 typedef sal_Int32 sal_PtrDiff; 00179 #elif SAL_TYPES_SIZEOFPOINTER == 8 00180 typedef sal_Int64 sal_PtrDiff; 00181 #else 00182 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler" 00183 #endif 00184 00185 /* printf-style conversion specification length modifiers for size_t and 00186 ptrdiff_t (most platforms support C99, MSC has its own extension) */ 00187 #if defined(_MSC_VER) || defined(__MINGW32__) 00188 #define SAL_PRI_SIZET "I" 00189 #define SAL_PRI_PTRDIFFT "I" 00190 #else 00191 #define SAL_PRI_SIZET "z" 00192 #define SAL_PRI_PTRDIFFT "t" 00193 #endif 00194 00195 /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid 00196 * pointer to void can be converted to this type and back to a pointer to void and the 00197 * result will compare to the original pointer */ 00198 #if SAL_TYPES_SIZEOFPOINTER == 4 00199 typedef sal_Int32 sal_IntPtr; 00200 typedef sal_uInt32 sal_uIntPtr; 00201 #define SAL_PRIdINTPTR SAL_PRIdINT32 00202 #define SAL_PRIuUINTPTR SAL_PRIuUINT32 00203 #define SAL_PRIxUINTPTR SAL_PRIxUINT32 00204 #define SAL_PRIXUINTPTR SAL_PRIXUINT32 00205 #elif SAL_TYPES_SIZEOFPOINTER == 8 00206 typedef sal_Int64 sal_IntPtr; 00207 typedef sal_uInt64 sal_uIntPtr; 00208 #define SAL_PRIdINTPTR SAL_PRIdINT64 00209 #define SAL_PRIuUINTPTR SAL_PRIuUINT64 00210 #define SAL_PRIxUINTPTR SAL_PRIxUINT64 00211 #define SAL_PRIXUINTPTR SAL_PRIXUINT64 00212 #else 00213 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler" 00214 #endif 00215 00216 /********************************************************************************/ 00217 /* Useful defines 00218 */ 00219 00220 /* The following SAL_MIN_INTn defines codify the assumption that the signed 00221 * sal_Int types use two's complement representation. Defining them as 00222 * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the 00223 * unary minus operator to unsigned quantities. 00224 */ 00225 #define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1)) 00226 #define SAL_MAX_INT8 ((sal_Int8) 0x7F) 00227 #define SAL_MAX_UINT8 ((sal_uInt8) 0xFF) 00228 #define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1)) 00229 #define SAL_MAX_INT16 ((sal_Int16) 0x7FFF) 00230 #define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF) 00231 #define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1)) 00232 #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF) 00233 #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF) 00234 #define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1)) 00235 #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF)) 00236 #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF)) 00237 00238 #if SAL_TYPES_SIZEOFLONG == 4 00239 #define SAL_MAX_SSIZE SAL_MAX_INT32 00240 #define SAL_MAX_SIZE SAL_MAX_UINT32 00241 #elif SAL_TYPES_SIZEOFLONG == 8 00242 #define SAL_MAX_SSIZE SAL_MAX_INT64 00243 #define SAL_MAX_SIZE SAL_MAX_UINT64 00244 #endif 00245 00246 #if defined(SAL_W32) || defined(SAL_UNX) 00247 # define SAL_MAX_ENUM 0x7fffffff 00248 #endif 00249 00250 #if defined(_MSC_VER) || defined(__MINGW32__) 00251 # define SAL_DLLPUBLIC_EXPORT __declspec(dllexport) 00252 #if defined(_MSC_VER) 00253 # define SAL_DLLPUBLIC_IMPORT __declspec(dllimport) 00254 #else 00255 # define SAL_DLLPUBLIC_IMPORT 00256 #endif // defined(_MSC_VER) 00257 # define SAL_DLLPRIVATE 00258 # define SAL_DLLPUBLIC_TEMPLATE 00259 # define SAL_CALL __cdecl 00260 # define SAL_CALL_ELLIPSE __cdecl 00261 #elif defined SAL_UNX 00262 # if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550) 00263 # define SAL_DLLPUBLIC_EXPORT __global 00264 # define SAL_DLLPUBLIC_IMPORT 00265 # define SAL_DLLPRIVATE __hidden 00266 # define SAL_DLLPUBLIC_TEMPLATE 00267 # elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550) 00268 # define SAL_DLLPUBLIC_EXPORT __global 00269 # define SAL_DLLPUBLIC_IMPORT 00270 # define SAL_DLLPRIVATE __hidden 00271 # define SAL_DLLPUBLIC_TEMPLATE 00272 # elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE) 00273 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default"))) 00274 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default"))) 00275 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden"))) 00276 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default"))) 00277 # else 00278 # define SAL_DLLPUBLIC_EXPORT 00279 # define SAL_DLLPUBLIC_IMPORT 00280 # define SAL_DLLPRIVATE 00281 # define SAL_DLLPUBLIC_TEMPLATE 00282 # endif 00283 # define SAL_CALL 00284 # define SAL_CALL_ELLIPSE 00285 #else 00286 # error("unknown platform") 00287 #endif 00288 00295 #if defined(__GNUC__) && ! defined(__MINGW32__) 00296 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT 00297 #define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE 00298 #else 00299 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT 00300 #define SAL_EXCEPTION_DLLPRIVATE 00301 #endif 00302 00303 #include <sal/saldllapi.h> 00304 00311 #if defined(__GNUC__) 00312 # define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 00313 #else 00314 # define SAL_WARN_UNUSED_RESULT 00315 #endif 00316 00321 #ifdef _MSC_VER 00322 # define SAL_NO_VTABLE __declspec(novtable) 00323 #else 00324 # define SAL_NO_VTABLE 00325 #endif 00326 00327 #ifdef SAL_W32 00328 # pragma pack(push, 8) 00329 #endif 00330 00334 typedef struct _sal_Sequence 00335 { 00338 sal_Int32 nRefCount; 00341 sal_Int32 nElements; 00344 char elements[1]; 00345 } sal_Sequence; 00346 00347 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements) 00348 00349 #if defined( SAL_W32) 00350 #pragma pack(pop) 00351 #endif 00352 00363 #ifdef __cplusplus 00364 #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi) 00365 #define SAL_THROW( exc ) 00366 #else /* MSVC, all other */ 00367 #define SAL_THROW( exc ) throw exc 00368 #endif /* __GNUC__, __SUNPRO_CC */ 00369 #define SAL_THROW_EXTERN_C() throw () 00370 #else /* ! __cplusplus */ 00371 /* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */ 00372 #define SAL_THROW_EXTERN_C() 00373 #endif 00374 00375 00376 00377 #ifdef __cplusplus 00378 enum __sal_NoAcquire 00379 { 00382 SAL_NO_ACQUIRE 00383 }; 00384 #endif /* __cplusplus */ 00385 00386 00387 #ifdef __cplusplus 00388 } 00389 #endif /* __cplusplus */ 00390 00391 #ifdef __cplusplus 00392 00393 namespace sal { 00394 00406 template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) { 00407 return static_cast< T1 >(n); 00408 } 00409 00410 } 00411 00412 #else /* __cplusplus */ 00413 00426 #define SAL_INT_CAST(type, expr) ((type) (expr)) 00427 00428 #endif /* __cplusplus */ 00429 00435 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) 00436 # define SAL_DEPRECATED(message) __attribute__((deprecated(message))) 00437 #elif (__GNUC__) 00438 # define SAL_DEPRECATED(message) __attribute__((deprecated)) 00439 #elif defined(_MSC_VER) 00440 # define SAL_DEPRECATED(message) __declspec(deprecated(message)) 00441 #else 00442 # define SAL_DEPRECATED(message) 00443 #endif 00444 00452 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 00453 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \ 00454 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \ 00455 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations")) 00456 #define SAL_WNODEPRECATED_DECLARATIONS_POP \ 00457 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop)) 00458 #else 00459 # define SAL_WNODEPRECATED_DECLARATIONS_PUSH 00460 # define SAL_WNODEPRECATED_DECLARATIONS_POP 00461 #endif 00462 00486 #if defined __cplusplus 00487 #if defined __GNUC__ 00488 #define SAL_UNUSED_PARAMETER __attribute__ ((unused)) 00489 #else 00490 #define SAL_UNUSED_PARAMETER 00491 #endif 00492 #endif 00493 00494 #endif /*_SAL_TYPES_H_ */ 00495 00496 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */