24#ifndef INCLUDED_SAL_TYPES_H
25#define INCLUDED_SAL_TYPES_H
39# define sal_False ((sal_Bool)0)
40# define sal_True ((sal_Bool)1)
46#if SAL_TYPES_SIZEOFSHORT == 2
47 typedef signed short sal_Int16;
48 typedef unsigned short sal_uInt16;
50 #error "Could not find 16-bit type, add support for your architecture"
53#if SAL_TYPES_SIZEOFLONG == 4
54 typedef signed long sal_Int32;
55 typedef unsigned long sal_uInt32;
56 #define SAL_PRIdINT32 "ld"
57 #define SAL_PRIuUINT32 "lu"
58 #define SAL_PRIxUINT32 "lx"
59 #define SAL_PRIXUINT32 "lX"
60#elif SAL_TYPES_SIZEOFINT == 4
61 typedef signed int sal_Int32;
62 typedef unsigned int sal_uInt32;
63 #define SAL_PRIdINT32 "d"
64 #define SAL_PRIuUINT32 "u"
65 #define SAL_PRIxUINT32 "x"
66 #define SAL_PRIXUINT32 "X"
68 #error "Could not find 32-bit type, add support for your architecture"
72 typedef __int64 sal_Int64;
73 typedef unsigned __int64 sal_uInt64;
76 #define SAL_CONST_INT64(x) x##i64
77 #define SAL_CONST_UINT64(x) x##ui64
79 #define SAL_PRIdINT64 "I64d"
80 #define SAL_PRIuUINT64 "I64u"
81 #define SAL_PRIxUINT64 "I64x"
82 #define SAL_PRIXUINT64 "I64X"
83#elif defined (__GNUC__)
84 #if SAL_TYPES_SIZEOFLONG == 8
85 typedef signed long int sal_Int64;
86 typedef unsigned long int sal_uInt64;
90 #define SAL_CONST_INT64(x) x##l
91 #define SAL_CONST_UINT64(x) x##ul
93 #define SAL_PRIdINT64 "ld"
94 #define SAL_PRIuUINT64 "lu"
95 #define SAL_PRIxUINT64 "lx"
96 #define SAL_PRIXUINT64 "lX"
97 #elif SAL_TYPES_SIZEOFLONGLONG == 8
98 typedef signed long long sal_Int64;
99 typedef unsigned long long sal_uInt64;
102 #define SAL_CONST_INT64(x) x##ll
103 #define SAL_CONST_UINT64(x) x##ull
105 #define SAL_PRIdINT64 "lld"
106 #define SAL_PRIuUINT64 "llu"
107 #define SAL_PRIxUINT64 "llx"
108 #define SAL_PRIXUINT64 "llX"
110 #error "Could not find 64-bit type, add support for your architecture"
113 #error "Please define the 64-bit types for your architecture/compiler in include/sal/types.h"
116#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
117 #define SAL_UNICODE_NOTEQUAL_WCHAR_T
122 #define SAL_UNICODE_NOTEQUAL_WCHAR_T
129#if SAL_TYPES_SIZEOFPOINTER == 4
130 typedef sal_uInt32 sal_Size;
131 typedef sal_Int32 sal_sSize;
132#elif SAL_TYPES_SIZEOFPOINTER == 8
133 typedef sal_uInt64 sal_Size;
134 typedef sal_Int64 sal_sSize;
136 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
140#if SAL_TYPES_SIZEOFPOINTER == 4
141 typedef sal_Int32 sal_PtrDiff;
142#elif SAL_TYPES_SIZEOFPOINTER == 8
143 typedef sal_Int64 sal_PtrDiff;
145 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
151 #define SAL_PRI_SIZET "I"
152 #define SAL_PRI_PTRDIFFT "I"
154 #define SAL_PRI_SIZET "z"
155 #define SAL_PRI_PTRDIFFT "t"
161#if SAL_TYPES_SIZEOFPOINTER == 4
162 typedef sal_Int32 sal_IntPtr;
163 typedef sal_uInt32 sal_uIntPtr;
164 #define SAL_PRIdINTPTR SAL_PRIdINT32
165 #define SAL_PRIuUINTPTR SAL_PRIuUINT32
166 #define SAL_PRIxUINTPTR SAL_PRIxUINT32
167 #define SAL_PRIXUINTPTR SAL_PRIXUINT32
168#elif SAL_TYPES_SIZEOFPOINTER == 8
169 typedef sal_Int64 sal_IntPtr;
170 typedef sal_uInt64 sal_uIntPtr;
171 #define SAL_PRIdINTPTR SAL_PRIdINT64
172 #define SAL_PRIuUINTPTR SAL_PRIuUINT64
173 #define SAL_PRIxUINTPTR SAL_PRIxUINT64
174 #define SAL_PRIXUINTPTR SAL_PRIXUINT64
176 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
184#define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
185#define SAL_MAX_INT8 ((sal_Int8) 0x7F)
186#define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
187#define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
188#define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
189#define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
190#define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
191#define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
192#define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
193#define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
194#define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
195#define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
197#if SAL_TYPES_SIZEOFPOINTER == 4
198#define SAL_MAX_SSIZE SAL_MAX_INT32
199#define SAL_MAX_SIZE SAL_MAX_UINT32
200#elif SAL_TYPES_SIZEOFPOINTER == 8
201#define SAL_MAX_SSIZE SAL_MAX_INT64
202#define SAL_MAX_SIZE SAL_MAX_UINT64
205#define SAL_MAX_ENUM 0x7fffffff
208# define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
209# define SAL_JNI_EXPORT __declspec(dllexport)
210# define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
211# define SAL_DLLPRIVATE
212# define SAL_DLLPUBLIC_TEMPLATE
213# define SAL_DLLPUBLIC_RTTI
214# define SAL_CALL __cdecl
216# if defined(__GNUC__)
217# if defined(DISABLE_DYNLOADING)
218# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
219# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
220# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
221# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
222# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
223# define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
225# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
226# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
227# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
228# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
229# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
230# if defined __clang__
231# if __has_attribute(type_visibility)
232# define SAL_DLLPUBLIC_RTTI __attribute__ ((type_visibility("default")))
234# define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
241# define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
245# define SAL_DLLPUBLIC_EXPORT
246# define SAL_JNI_EXPORT
247# define SAL_DLLPUBLIC_IMPORT
248# define SAL_DLLPRIVATE
249# define SAL_DLLPUBLIC_TEMPLATE
250# define SAL_DLLPUBLIC_RTTI
254# error("unknown platform")
264# if defined(DISABLE_DYNLOADING)
265# define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
267# define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
269# define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
271# define SAL_EXCEPTION_DLLPUBLIC_EXPORT
272# define SAL_EXCEPTION_DLLPRIVATE
281#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
282#define SAL_WARN_UNUSED_RESULT [[nodiscard]]
283#elif (defined __GNUC__ \
284 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) \
286# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
288# define SAL_WARN_UNUSED_RESULT
291#if defined LIBO_INTERNAL_ONLY
299# define SAL_RET_MAYBENULL _Ret_maybenull_
301# define SAL_RET_MAYBENULL
310# define SAL_NO_VTABLE __declspec(novtable)
312# define SAL_NO_VTABLE
316# pragma pack(push, 8)
334#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size) offsetof(sal_Sequence,elements))
348#if defined __cplusplus
349#if __cplusplus >= 201103L
350#define SAL_THROW_EXTERN_C() noexcept
352#define SAL_THROW_EXTERN_C() throw ()
355#define SAL_THROW_EXTERN_C()
364#if defined(LIBO_INTERNAL_ONLY) && defined(__COVERITY__) && __COVERITY_MAJOR__ <= 2023
365# define COVERITY_NOEXCEPT_FALSE noexcept(false)
367# define COVERITY_NOEXCEPT_FALSE
377namespace com {
namespace sun {
namespace star { } } }
393#if defined LIBO_INTERNAL_ONLY
394#define SAL_DELETED_FUNCTION = delete
396#define SAL_DELETED_FUNCTION
406#if defined LIBO_INTERNAL_ONLY
407#define SAL_OVERRIDE override
419#if defined LIBO_INTERNAL_ONLY
420#define SAL_CONSTEXPR constexpr
431#if __cplusplus >= 201103L
432#define SAL_NOEXCEPT noexcept
434#define SAL_NOEXCEPT throw ()
455 return static_cast< T1
>(n);
474#define SAL_INT_CAST(type, expr) ((type) (expr))
483#if defined __GNUC__ || defined __clang__
484#if defined LIBO_INTERNAL_ONLY
485# define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
487# define SAL_DEPRECATED(message) __attribute__((deprecated))
489#elif defined(_MSC_VER)
490# define SAL_DEPRECATED(message) __declspec(deprecated(message))
492# define SAL_DEPRECATED(message)
506#ifdef LIBO_INTERNAL_ONLY
507# define SAL_DEPRECATED_INTERNAL(message)
509# define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
519#if defined LIBO_INTERNAL_ONLY && defined __GNUC__
520#define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
521 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
522 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
523#define SAL_WNODEPRECATED_DECLARATIONS_POP \
524 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
525#elif defined LIBO_INTERNAL_ONLY && defined _MSC_VER
526#define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
527 _Pragma(SAL_STRINGIFY_ARG(warning(push))) \
528 _Pragma(SAL_STRINGIFY_ARG(warning(disable : 4996)))
529#define SAL_WNODEPRECATED_DECLARATIONS_POP \
530 _Pragma(SAL_STRINGIFY_ARG(warning(pop)))
532# define SAL_WNODEPRECATED_DECLARATIONS_PUSH
533# define SAL_WNODEPRECATED_DECLARATIONS_POP
553#define SAL_WNOUNREACHABLE_CODE_PUSH \
554 __pragma(warning(push)) \
555 __pragma(warning(disable:4702)) \
556 __pragma(warning(disable:4722))
557#define SAL_WNOUNREACHABLE_CODE_POP \
558 __pragma(warning(pop))
561#define SAL_WNOUNREACHABLE_CODE_PUSH
562#define SAL_WNOUNREACHABLE_CODE_POP
588#if defined __cplusplus
589#if defined __GNUC__ || defined __clang__
590#define SAL_UNUSED_PARAMETER __attribute__ ((unused))
592#define SAL_UNUSED_PARAMETER
608#if defined LIBO_INTERNAL_ONLY && (defined __GNUC__ || defined __clang__)
609#define SAL_WARN_UNUSED __attribute__((warn_unused))
611#define SAL_WARN_UNUSED
616#if defined __GNUC__ || defined __clang__
618# define SAL_DETAIL_BOOLEAN_EXPR(expr) \
620 int sal_boolean_var_; \
622 sal_boolean_var_ = 1; \
624 sal_boolean_var_ = 0; \
638# define SAL_LIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 1)
650# define SAL_UNLIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 0)
663# define SAL_HOT __attribute__((hot))
678# define SAL_COLD __attribute__((cold))
680# define SAL_LIKELY(expr) (expr)
681# define SAL_UNLIKELY(expr) (expr)
698#ifndef __has_attribute
699#define __has_attribute(x) 0
702#if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __has_attribute(returns_nonnull)))
703#define SAL_RETURNS_NONNULL __attribute__((returns_nonnull))
705#define SAL_RETURNS_NONNULL
709#if defined LIBO_INTERNAL_ONLY
715#define SAL_LOPLUGIN_ANNOTATE(id) [[clang::annotate("loplugin:" id)]]
717#define SAL_LOPLUGIN_ANNOTATE(id)
__sal_NoAcquire
Definition types.h:371
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition types.h:374
unsigned char sal_uInt8
Definition types.h:44
struct _sal_Sequence sal_Sequence
This is the binary specification of a SAL sequence.
unsigned char sal_Bool
Definition types.h:38
sal_uInt16 sal_Unicode
Definition types.h:123
void * sal_Handle
Definition types.h:126
signed char sal_Int8
Definition types.h:43
T1 static_int_cast(T2 n)
A static_cast between integral types, to avoid C++ compiler warnings.
Definition types.h:454
This is the binary specification of a SAL sequence.
Definition types.h:322
sal_Int32 nRefCount
reference count of sequence
Definition types.h:325
sal_Int32 nElements
element count
Definition types.h:328
char elements[1]
elements array
Definition types.h:331