20 #ifndef INCLUDED_SAL_TYPES_H
21 #define INCLUDED_SAL_TYPES_H
35 # define sal_False ((sal_Bool)0)
36 # define sal_True ((sal_Bool)1)
42 #if SAL_TYPES_SIZEOFSHORT == 2
43 typedef signed short sal_Int16;
44 typedef unsigned short sal_uInt16;
46 #error "Could not find 16-bit type, add support for your architecture"
49 #if SAL_TYPES_SIZEOFLONG == 4
50 typedef signed long sal_Int32;
51 typedef unsigned long sal_uInt32;
52 #define SAL_PRIdINT32 "ld"
53 #define SAL_PRIuUINT32 "lu"
54 #define SAL_PRIxUINT32 "lx"
55 #define SAL_PRIXUINT32 "lX"
56 #elif SAL_TYPES_SIZEOFINT == 4
57 typedef signed int sal_Int32;
58 typedef unsigned int sal_uInt32;
59 #define SAL_PRIdINT32 "d"
60 #define SAL_PRIuUINT32 "u"
61 #define SAL_PRIxUINT32 "x"
62 #define SAL_PRIXUINT32 "X"
64 #error "Could not find 32-bit type, add support for your architecture"
68 typedef __int64 sal_Int64;
69 typedef unsigned __int64 sal_uInt64;
72 #define SAL_CONST_INT64(x) x##i64
73 #define SAL_CONST_UINT64(x) x##ui64
75 #define SAL_PRIdINT64 "I64d"
76 #define SAL_PRIuUINT64 "I64u"
77 #define SAL_PRIxUINT64 "I64x"
78 #define SAL_PRIXUINT64 "I64X"
79 #elif defined (__GNUC__)
80 #if SAL_TYPES_SIZEOFLONG == 8
81 typedef signed long int sal_Int64;
82 typedef unsigned long int sal_uInt64;
86 #define SAL_CONST_INT64(x) x##l
87 #define SAL_CONST_UINT64(x) x##ul
89 #define SAL_PRIdINT64 "ld"
90 #define SAL_PRIuUINT64 "lu"
91 #define SAL_PRIxUINT64 "lx"
92 #define SAL_PRIXUINT64 "lX"
93 #elif SAL_TYPES_SIZEOFLONGLONG == 8
94 typedef signed long long sal_Int64;
95 typedef unsigned long long sal_uInt64;
98 #define SAL_CONST_INT64(x) x##ll
99 #define SAL_CONST_UINT64(x) x##ull
101 #define SAL_PRIdINT64 "lld"
102 #define SAL_PRIuUINT64 "llu"
103 #define SAL_PRIxUINT64 "llx"
104 #define SAL_PRIXUINT64 "llX"
106 #error "Could not find 64-bit type, add support for your architecture"
109 #error "Please define the 64-bit types for your architecture/compiler in include/sal/types.h"
130 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
131 #define SAL_UNICODE_NOTEQUAL_WCHAR_T
133 #elif defined(_WIN32)
136 #define SAL_UNICODE_NOTEQUAL_WCHAR_T
143 #if SAL_TYPES_SIZEOFPOINTER == 4
144 typedef sal_uInt32 sal_Size;
145 typedef sal_Int32 sal_sSize;
146 #elif SAL_TYPES_SIZEOFPOINTER == 8
147 typedef sal_uInt64 sal_Size;
148 typedef sal_Int64 sal_sSize;
150 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
154 #if SAL_TYPES_SIZEOFPOINTER == 4
155 typedef sal_Int32 sal_PtrDiff;
156 #elif SAL_TYPES_SIZEOFPOINTER == 8
157 typedef sal_Int64 sal_PtrDiff;
159 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
164 #if defined(_MSC_VER)
165 #define SAL_PRI_SIZET "I"
166 #define SAL_PRI_PTRDIFFT "I"
168 #define SAL_PRI_SIZET "z"
169 #define SAL_PRI_PTRDIFFT "t"
175 #if SAL_TYPES_SIZEOFPOINTER == 4
176 typedef sal_Int32 sal_IntPtr;
177 typedef sal_uInt32 sal_uIntPtr;
178 #define SAL_PRIdINTPTR SAL_PRIdINT32
179 #define SAL_PRIuUINTPTR SAL_PRIuUINT32
180 #define SAL_PRIxUINTPTR SAL_PRIxUINT32
181 #define SAL_PRIXUINTPTR SAL_PRIXUINT32
182 #elif SAL_TYPES_SIZEOFPOINTER == 8
183 typedef sal_Int64 sal_IntPtr;
184 typedef sal_uInt64 sal_uIntPtr;
185 #define SAL_PRIdINTPTR SAL_PRIdINT64
186 #define SAL_PRIuUINTPTR SAL_PRIuUINT64
187 #define SAL_PRIxUINTPTR SAL_PRIxUINT64
188 #define SAL_PRIXUINTPTR SAL_PRIXUINT64
190 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
198 #define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
199 #define SAL_MAX_INT8 ((sal_Int8) 0x7F)
200 #define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
201 #define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
202 #define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
203 #define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
204 #define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
205 #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
206 #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
207 #define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
208 #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
209 #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
211 #if SAL_TYPES_SIZEOFPOINTER == 4
212 #define SAL_MAX_SSIZE SAL_MAX_INT32
213 #define SAL_MAX_SIZE SAL_MAX_UINT32
214 #elif SAL_TYPES_SIZEOFPOINTER == 8
215 #define SAL_MAX_SSIZE SAL_MAX_INT64
216 #define SAL_MAX_SIZE SAL_MAX_UINT64
219 #define SAL_MAX_ENUM 0x7fffffff
221 #if defined(_MSC_VER)
222 # define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
223 # define SAL_JNI_EXPORT __declspec(dllexport)
224 # define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
225 # define SAL_DLLPRIVATE
226 # define SAL_DLLPUBLIC_TEMPLATE
227 # define SAL_DLLPUBLIC_RTTI
228 # define SAL_CALL __cdecl
229 #elif defined SAL_UNX
230 # if defined(__GNUC__)
231 # if defined(DISABLE_DYNLOADING)
232 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
233 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
234 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
235 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
236 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
237 # define SAL_DLLPUBLIC_RTTI
239 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
240 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
241 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
242 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
243 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
244 # if defined __clang__
245 # if __has_attribute(type_visibility)
246 # define SAL_DLLPUBLIC_RTTI __attribute__ ((type_visibility("default")))
248 # define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
251 # define SAL_DLLPUBLIC_RTTI
255 # define SAL_DLLPUBLIC_EXPORT
256 # define SAL_JNI_EXPORT
257 # define SAL_DLLPUBLIC_IMPORT
258 # define SAL_DLLPRIVATE
259 # define SAL_DLLPUBLIC_TEMPLATE
260 # define SAL_DLLPUBLIC_RTTI
264 # error("unknown platform")
273 #if defined(__GNUC__)
274 # if defined(DISABLE_DYNLOADING)
275 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
277 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
279 # define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
281 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT
282 # define SAL_EXCEPTION_DLLPRIVATE
291 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
292 #define SAL_WARN_UNUSED_RESULT [[nodiscard]]
293 #elif (defined __GNUC__ \
294 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) \
296 # define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
298 # define SAL_WARN_UNUSED_RESULT
306 # define SAL_NO_VTABLE __declspec(novtable)
308 # define SAL_NO_VTABLE
312 # pragma pack(push, 8)
330 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size) offsetof(sal_Sequence,elements))
336 #if defined __cplusplus
342 #define SAL_THROW_EXTERN_C() throw ()
348 #if defined(LIBO_INTERNAL_ONLY) && defined(__COVERITY__)
349 # define COVERITY_NOEXCEPT_FALSE noexcept(false)
351 # define COVERITY_NOEXCEPT_FALSE
356 #define SAL_THROW_EXTERN_C()
373 namespace com {
namespace sun {
namespace star { } } }
379 namespace css = ::com::sun::star;
389 #if defined LIBO_INTERNAL_ONLY
390 #define SAL_DELETED_FUNCTION = delete
392 #define SAL_DELETED_FUNCTION
402 #if defined LIBO_INTERNAL_ONLY
403 #define SAL_OVERRIDE override
426 return static_cast< T1
>(n);
445 #define SAL_INT_CAST(type, expr) ((type) (expr))
454 #if defined __GNUC__ || defined __clang__
455 #if defined LIBO_INTERNAL_ONLY
456 # define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
458 # define SAL_DEPRECATED(message) __attribute__((deprecated))
460 #elif defined(_MSC_VER)
461 # define SAL_DEPRECATED(message) __declspec(deprecated(message))
463 # define SAL_DEPRECATED(message)
477 #ifdef LIBO_INTERNAL_ONLY
478 # define SAL_DEPRECATED_INTERNAL(message)
480 # define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
490 #if defined LIBO_INTERNAL_ONLY && defined __GNUC__
491 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
492 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
493 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
494 #define SAL_WNODEPRECATED_DECLARATIONS_POP \
495 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
497 # define SAL_WNODEPRECATED_DECLARATIONS_PUSH
498 # define SAL_WNODEPRECATED_DECLARATIONS_POP
518 #define SAL_WNOUNREACHABLE_CODE_PUSH \
519 __pragma(warning(push)) \
520 __pragma(warning(disable:4702)) \
521 __pragma(warning(disable:4722))
522 #define SAL_WNOUNREACHABLE_CODE_POP \
523 __pragma(warning(pop))
526 #define SAL_WNOUNREACHABLE_CODE_PUSH
527 #define SAL_WNOUNREACHABLE_CODE_POP
553 #if defined __cplusplus
554 #if defined __GNUC__ || defined __clang__
555 #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
557 #define SAL_UNUSED_PARAMETER
573 #if defined LIBO_INTERNAL_ONLY && (defined __GNUC__ || defined __clang__)
574 #define SAL_WARN_UNUSED __attribute__((warn_unused))
576 #define SAL_WARN_UNUSED
581 #if defined __GNUC__ || defined __clang__
583 # define SAL_DETAIL_BOOLEAN_EXPR(expr) \
585 int sal_boolean_var_; \
587 sal_boolean_var_ = 1; \
589 sal_boolean_var_ = 0; \
603 # define SAL_LIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 1)
615 # define SAL_UNLIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 0)
628 # define SAL_HOT __attribute__((hot))
643 # define SAL_COLD __attribute__((cold))
645 # define SAL_LIKELY(expr) (expr)
646 # define SAL_UNLIKELY(expr) (expr)
663 #ifndef __has_attribute
664 #define __has_attribute(x) 0
667 #if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __has_attribute(returns_nonnull)))
668 #define SAL_RETURNS_NONNULL __attribute__((returns_nonnull))
670 #define SAL_RETURNS_NONNULL
unsigned char sal_uChar
A legacy synonym for unsigned char.
Definition: types.h:128
__sal_NoAcquire
Definition: types.h:367
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:370
unsigned char sal_uInt8
Definition: types.h:40
char sal_Char
A legacy synonym for char.
Definition: types.h:116
struct _sal_Sequence sal_Sequence
This is the binary specification of a SAL sequence.
unsigned char sal_Bool
Definition: types.h:34
signed char sal_sChar
A legacy synonym for signed char.
Definition: types.h:122
sal_uInt16 sal_Unicode
Definition: types.h:137
void * sal_Handle
Definition: types.h:140
signed char sal_Int8
Definition: types.h:39
T1 static_int_cast(T2 n)
A static_cast between integral types, to avoid C++ compiler warnings.
Definition: types.h:425
This is the binary specification of a SAL sequence.
Definition: types.h:318
sal_Int32 nRefCount
reference count of sequence
Definition: types.h:321
sal_Int32 nElements
element count
Definition: types.h:324
char elements[1]
elements array
Definition: types.h:327