UDK 3.2.7 C/C++ API Reference

sal/types.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 
00020 #ifndef _SAL_TYPES_H_
00021 #define _SAL_TYPES_H_
00022 
00023 #include <sal/config.h>
00024 #include <sal/macros.h>
00025 
00026 /* Grab __SIZEOFxxx constants from typesconfig tool on Unix */
00027 #if defined UNX
00028   #include <sal/typesizes.h>
00029 #elif defined(WNT)
00030   /* FIXME: autogeneration of type sizes on Win32/Win64? */
00031   #define SAL_TYPES_ALIGNMENT2      1
00032   #define SAL_TYPES_ALIGNMENT4      1
00033   #define SAL_TYPES_ALIGNMENT8      1
00034   #define SAL_TYPES_SIZEOFSHORT     2
00035   #define SAL_TYPES_SIZEOFINT       4
00036   #define SAL_TYPES_SIZEOFLONG      4
00037   #define SAL_TYPES_SIZEOFLONGLONG  8
00038   #ifdef _WIN64
00039     #define SAL_TYPES_SIZEOFPOINTER 8
00040   #else
00041     #define SAL_TYPES_SIZEOFPOINTER 4
00042   #endif
00043 #endif
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 /********************************************************************************/
00050 /* Data types
00051 */
00052 
00053 /* Boolean */
00054 typedef unsigned char sal_Bool;
00055 #   define sal_False ((sal_Bool)0)
00056 #   define sal_True  ((sal_Bool)1)
00057 
00058 /* char is assumed to always be 1 byte long */
00059 typedef signed char         sal_Int8;
00060 typedef unsigned char       sal_uInt8;
00061 
00062 #if SAL_TYPES_SIZEOFSHORT == 2
00063     typedef signed short      sal_Int16;
00064     typedef unsigned short    sal_uInt16;
00065 #else
00066      #error "Could not find 16-bit type, add support for your architecture"
00067 #endif
00068 
00069 #if SAL_TYPES_SIZEOFLONG == 4
00070     typedef signed long       sal_Int32;
00071     typedef unsigned long     sal_uInt32;
00072     #define SAL_PRIdINT32 "ld"
00073     #define SAL_PRIuUINT32 "lu"
00074     #define SAL_PRIxUINT32 "lx"
00075     #define SAL_PRIXUINT32 "lX"
00076 #elif SAL_TYPES_SIZEOFINT == 4
00077     typedef signed int        sal_Int32;
00078     typedef unsigned int      sal_uInt32;
00079     #define SAL_PRIdINT32 "d"
00080     #define SAL_PRIuUINT32 "u"
00081     #define SAL_PRIxUINT32 "x"
00082     #define SAL_PRIXUINT32 "X"
00083 #else
00084      #error "Could not find 32-bit type, add support for your architecture"
00085 #endif
00086 
00087 #ifdef _MSC_VER
00088     typedef __int64                  sal_Int64;
00089     typedef unsigned __int64         sal_uInt64;
00090 
00091     /*  The following are macros that will add the 64 bit constant suffix. */
00092     #define SAL_CONST_INT64(x)       x##i64
00093     #define SAL_CONST_UINT64(x)      x##ui64
00094 
00095     #define SAL_PRIdINT64 "I64d"
00096     #define SAL_PRIuUINT64 "I64u"
00097     #define SAL_PRIxUINT64 "I64x"
00098     #define SAL_PRIXUINT64 "I64X"
00099 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi)
00100     #if SAL_TYPES_SIZEOFLONG == 8
00101         typedef signed long int         sal_Int64;
00102         typedef unsigned long int       sal_uInt64;
00103 
00104 
00105         /*  The following are macros that will add the 64 bit constant suffix. */
00106         #define SAL_CONST_INT64(x)       x##l
00107         #define SAL_CONST_UINT64(x)      x##ul
00108 
00109         #define SAL_PRIdINT64 "ld"
00110         #define SAL_PRIuUINT64 "lu"
00111         #define SAL_PRIxUINT64 "lx"
00112         #define SAL_PRIXUINT64 "lX"
00113     #elif SAL_TYPES_SIZEOFLONGLONG == 8
00114         typedef signed long long    sal_Int64;
00115         typedef unsigned long long  sal_uInt64;
00116 
00117         /*  The following are macros that will add the 64 bit constant suffix. */
00118         #define SAL_CONST_INT64(x)       x##ll
00119         #define SAL_CONST_UINT64(x)      x##ull
00120 
00121     #ifdef __MINGW32__
00122     #define SAL_PRIdINT64 "I64d"
00123     #define SAL_PRIuUINT64 "I64u"
00124     #define SAL_PRIxUINT64 "I64x"
00125     #define SAL_PRIXUINT64 "I64X"
00126     #else
00127         #define SAL_PRIdINT64 "lld"
00128         #define SAL_PRIuUINT64 "llu"
00129         #define SAL_PRIxUINT64 "llx"
00130         #define SAL_PRIXUINT64 "llX"
00131     #endif
00132     #else
00133         #error "Could not find 64-bit type, add support for your architecture"
00134     #endif
00135 #else
00136     #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
00137 #endif
00138 
00139 typedef char                     sal_Char;
00140 typedef signed char              sal_sChar;
00141 typedef unsigned char            sal_uChar;
00142 
00143 #if ( defined(SAL_W32) && !defined(__MINGW32__) )
00144     // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
00145     // "By default wchar_t is a typedef for unsigned short."
00146     // But MinGW has a native wchar_t, and on many places, we cannot deal with
00147     // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
00148     typedef wchar_t             sal_Unicode;
00149 #else
00150     #define SAL_UNICODE_NOTEQUAL_WCHAR_T
00151     typedef sal_uInt16          sal_Unicode;
00152 #endif
00153 
00154 typedef void *                   sal_Handle;
00155 
00156 /* sal_Size should currently be the native width of the platform */
00157 #if SAL_TYPES_SIZEOFPOINTER == 4
00158     typedef sal_uInt32          sal_Size;
00159     typedef sal_Int32           sal_sSize;
00160 #elif SAL_TYPES_SIZEOFPOINTER == 8
00161     typedef sal_uInt64          sal_Size;
00162     typedef sal_Int64           sal_sSize;
00163 #else
00164     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
00165 #endif
00166 
00167 /* sal_PtrDiff holds the result of a pointer subtraction */
00168 #if SAL_TYPES_SIZEOFPOINTER == 4
00169     typedef sal_Int32           sal_PtrDiff;
00170 #elif SAL_TYPES_SIZEOFPOINTER == 8
00171     typedef sal_Int64           sal_PtrDiff;
00172 #else
00173     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
00174 #endif
00175 
00176 /* printf-style conversion specification length modifiers for size_t and
00177    ptrdiff_t (most platforms support C99, MSC has its own extension) */
00178 #if defined(_MSC_VER) || defined(__MINGW32__)
00179     #define SAL_PRI_SIZET "I"
00180     #define SAL_PRI_PTRDIFFT "I"
00181 #else
00182     #define SAL_PRI_SIZET "z"
00183     #define SAL_PRI_PTRDIFFT "t"
00184 #endif
00185 
00186 /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
00187  * pointer to void can be converted to this type and back to a pointer to void and the
00188  * result will compare to the original pointer */
00189 #if SAL_TYPES_SIZEOFPOINTER == 4
00190     typedef sal_Int32           sal_IntPtr;
00191     typedef sal_uInt32          sal_uIntPtr;
00192     #define SAL_PRIdINTPTR SAL_PRIdINT32
00193     #define SAL_PRIuUINTPTR SAL_PRIuUINT32
00194     #define SAL_PRIxUINTPTR SAL_PRIxUINT32
00195     #define SAL_PRIXUINTPTR SAL_PRIXUINT32
00196 #elif SAL_TYPES_SIZEOFPOINTER == 8
00197     typedef sal_Int64           sal_IntPtr;
00198     typedef sal_uInt64          sal_uIntPtr;
00199     #define SAL_PRIdINTPTR SAL_PRIdINT64
00200     #define SAL_PRIuUINTPTR SAL_PRIuUINT64
00201     #define SAL_PRIxUINTPTR SAL_PRIxUINT64
00202     #define SAL_PRIXUINTPTR SAL_PRIXUINT64
00203 #else
00204     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
00205 #endif
00206 
00207 /********************************************************************************/
00208 /* Useful defines
00209  */
00210 
00211 /* The following SAL_MIN_INTn defines codify the assumption that the signed
00212  * sal_Int types use two's complement representation.  Defining them as
00213  * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
00214  * unary minus operator to unsigned quantities.
00215  */
00216 #define SAL_MIN_INT8          ((sal_Int8)   (-0x7F - 1))
00217 #define SAL_MAX_INT8          ((sal_Int8)   0x7F)
00218 #define SAL_MAX_UINT8         ((sal_uInt8)  0xFF)
00219 #define SAL_MIN_INT16         ((sal_Int16)  (-0x7FFF - 1))
00220 #define SAL_MAX_INT16         ((sal_Int16)  0x7FFF)
00221 #define SAL_MAX_UINT16        ((sal_uInt16) 0xFFFF)
00222 #define SAL_MIN_INT32         ((sal_Int32)  (-0x7FFFFFFF - 1))
00223 #define SAL_MAX_INT32         ((sal_Int32)  0x7FFFFFFF)
00224 #define SAL_MAX_UINT32        ((sal_uInt32) 0xFFFFFFFF)
00225 #define SAL_MIN_INT64         ((sal_Int64)  (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
00226 #define SAL_MAX_INT64         ((sal_Int64)  SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
00227 #define SAL_MAX_UINT64        ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
00228 
00229 #if SAL_TYPES_SIZEOFLONG == 4
00230 #define SAL_MAX_SSIZE       SAL_MAX_INT32
00231 #define SAL_MAX_SIZE        SAL_MAX_UINT32
00232 #elif SAL_TYPES_SIZEOFLONG == 8
00233 #define SAL_MAX_SSIZE       SAL_MAX_INT64
00234 #define SAL_MAX_SIZE        SAL_MAX_UINT64
00235 #endif
00236 
00237 #if defined(SAL_W32) || defined(SAL_UNX)
00238 #   define SAL_MAX_ENUM 0x7fffffff
00239 #endif
00240 
00241 #if defined(_MSC_VER) || defined(__MINGW32__)
00242 #   define SAL_DLLPUBLIC_EXPORT    __declspec(dllexport)
00243 #   define SAL_JNI_EXPORT          __declspec(dllexport)
00244 #if defined(_MSC_VER)
00245 #   define SAL_DLLPUBLIC_IMPORT    __declspec(dllimport)
00246 #else
00247 #   define SAL_DLLPUBLIC_IMPORT
00248 #endif // defined(_MSC_VER)
00249 #   define SAL_DLLPRIVATE
00250 #   define SAL_DLLPUBLIC_TEMPLATE
00251 #   define SAL_CALL         __cdecl
00252 #   define SAL_CALL_ELLIPSE __cdecl
00253 #elif defined SAL_UNX
00254 #   if   defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
00255 #     define SAL_DLLPUBLIC_EXPORT  __global
00256 #     define SAL_JNI_EXPORT        __global
00257 #     define SAL_DLLPUBLIC_IMPORT
00258 #     define SAL_DLLPRIVATE        __hidden
00259 #     define SAL_DLLPUBLIC_TEMPLATE
00260 #   elif defined(__SUNPRO_C ) && (__SUNPRO_C  >= 0x550)
00261 #     define SAL_DLLPUBLIC_EXPORT  __global
00262 #     define SAL_JNI_EXPORT        __global
00263 #     define SAL_DLLPUBLIC_IMPORT
00264 #     define SAL_DLLPRIVATE        __hidden
00265 #     define SAL_DLLPUBLIC_TEMPLATE
00266 #   elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
00267 #     if defined(DISABLE_DYNLOADING)
00268 #       define SAL_DLLPUBLIC_EXPORT  __attribute__ ((visibility("hidden")))
00269 #       define SAL_JNI_EXPORT        __attribute__ ((visibility("default")))
00270 #       define SAL_DLLPUBLIC_IMPORT  __attribute__ ((visibility("hidden")))
00271 #       define SAL_DLLPRIVATE        __attribute__ ((visibility("hidden")))
00272 #       define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
00273 #     else
00274 #       define SAL_DLLPUBLIC_EXPORT  __attribute__ ((visibility("default")))
00275 #       define SAL_JNI_EXPORT        __attribute__ ((visibility("default")))
00276 #       define SAL_DLLPUBLIC_IMPORT  __attribute__ ((visibility("default")))
00277 #       define SAL_DLLPRIVATE        __attribute__ ((visibility("hidden")))
00278 #       define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
00279 #     endif
00280 #   else
00281 #     define SAL_DLLPUBLIC_EXPORT
00282 #     define SAL_JNI_EXPORT
00283 #     define SAL_DLLPUBLIC_IMPORT
00284 #     define SAL_DLLPRIVATE
00285 #     define SAL_DLLPUBLIC_TEMPLATE
00286 #   endif
00287 #   define SAL_CALL
00288 #   define SAL_CALL_ELLIPSE
00289 #else
00290 #   error("unknown platform")
00291 #endif
00292 
00299 #if defined(__GNUC__) && ! defined(__MINGW32__)
00300 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
00301 #define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
00302 #else
00303 #define SAL_EXCEPTION_DLLPUBLIC_EXPORT
00304 #define SAL_EXCEPTION_DLLPRIVATE
00305 #endif
00306 
00313 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
00314 #   define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
00315 #else
00316 #   define SAL_WARN_UNUSED_RESULT
00317 #endif
00318 
00323 #ifdef _MSC_VER
00324 #   define SAL_NO_VTABLE __declspec(novtable)
00325 #else
00326 #   define SAL_NO_VTABLE
00327 #endif
00328 
00329 #ifdef SAL_W32
00330 #   pragma pack(push, 8)
00331 #endif
00332 
00336 typedef struct _sal_Sequence
00337 {
00340     sal_Int32           nRefCount;
00343     sal_Int32           nElements;
00346     char                elements[1];
00347 } sal_Sequence;
00348 
00349 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
00350 
00351 #if defined( SAL_W32)
00352 #pragma pack(pop)
00353 #endif
00354 
00365 #ifdef __cplusplus
00366 #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
00367 #define SAL_THROW( exc )
00368 #else /* MSVC, all other */
00369 #define SAL_THROW( exc ) throw exc
00370 #endif /* __GNUC__, __SUNPRO_CC */
00371 #define SAL_THROW_EXTERN_C() throw ()
00372 #else /* ! __cplusplus */
00373 /* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
00374 #define SAL_THROW_EXTERN_C()
00375 #endif
00376 
00377 #ifdef __cplusplus
00378 }
00379 #endif /* __cplusplus */
00380 
00381 #ifdef __cplusplus
00382 
00383 enum __sal_NoAcquire
00384 {
00387     SAL_NO_ACQUIRE
00388 };
00389 
00390 namespace com { namespace sun { namespace star { } } }
00391 
00396 namespace css = ::com::sun::star;
00397 
00398 #endif /* __cplusplus */
00399 
00400 #ifdef __cplusplus
00401 
00402 namespace sal {
00403 
00415 template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
00416     return static_cast< T1 >(n);
00417 }
00418 
00419 }
00420 
00421 #else /* __cplusplus */
00422 
00435 #define SAL_INT_CAST(type, expr) ((type) (expr))
00436 
00437 #endif /* __cplusplus */
00438 
00444 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
00445 #    define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
00446 #elif (__GNUC__)
00447 #    define SAL_DEPRECATED(message) __attribute__((deprecated))
00448 #elif defined(_MSC_VER)
00449 #    define SAL_DEPRECATED(message) __declspec(deprecated(message))
00450 #else
00451 #    define SAL_DEPRECATED(message)
00452 #endif
00453 
00463 #ifdef LIBO_INTERNAL_ONLY
00464 #    define SAL_DEPRECATED_INTERNAL(message)
00465 #else
00466 #    define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
00467 #endif
00468 
00476 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
00477 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
00478     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
00479     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
00480 #define SAL_WNODEPRECATED_DECLARATIONS_POP \
00481     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
00482 #else
00483 #   define SAL_WNODEPRECATED_DECLARATIONS_PUSH
00484 #   define SAL_WNODEPRECATED_DECLARATIONS_POP
00485 #endif
00486 
00510 #if defined __cplusplus
00511 #if defined __GNUC__
00512 #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
00513 #else
00514 #define SAL_UNUSED_PARAMETER
00515 #endif
00516 #endif
00517 
00532 #if defined __clang__
00533 #define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
00534 #else
00535 #define SAL_WARN_UNUSED
00536 #endif
00537 
00538 #endif /*_SAL_TYPES_H_ */
00539 
00540 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines