118 #else |
118 #else |
119 #error Unknown pointer size or missing size macros! |
119 #error Unknown pointer size or missing size macros! |
120 #endif |
120 #endif |
121 |
121 |
122 // --------------------------------------------------------------------------- |
122 // --------------------------------------------------------------------------- |
123 // Missing Defines |
|
124 // --------------------------------------------------------------------------- |
|
125 |
|
126 #ifndef SSIZE_MAX // not defined in glibc since C23 and MSVC |
|
127 #if CX_WORDSIZE == 64 |
|
128 /** |
|
129 * The maximum representable value in ssize_t. |
|
130 */ |
|
131 #define SSIZE_MAX 0x7fffffffffffffffll |
|
132 #else |
|
133 #define SSIZE_MAX 0x7fffffffl |
|
134 #endif |
|
135 #endif |
|
136 |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // Attribute definitions |
123 // Attribute definitions |
140 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
141 |
125 |
142 #ifndef __GNUC__ |
126 #ifndef __GNUC__ |
143 /** |
127 /** |
279 * Warn about discarded return value. |
263 * Warn about discarded return value. |
280 */ |
264 */ |
281 #define cx_attr_nodiscard __attribute__((__warn_unused_result__)) |
265 #define cx_attr_nodiscard __attribute__((__warn_unused_result__)) |
282 |
266 |
283 #endif // __STDC_VERSION__ |
267 #endif // __STDC_VERSION__ |
|
268 |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // MSVC specifics |
|
272 // --------------------------------------------------------------------------- |
|
273 |
|
274 #ifdef _MSC_VER |
|
275 // fix missing _Thread_local support |
|
276 #define _Thread_local __declspec(thread) |
|
277 #endif // _MSC_VER |
|
278 |
|
279 #if defined(CX_WINDLL_EXPORT) |
|
280 #define cx_attr_export __declspec(dllexport) |
|
281 #elif defined(CX_WINDLL) |
|
282 #define cx_attr_export __declspec(dllimport) |
|
283 #else |
|
284 /** Only used for building Windows DLLs. */ |
|
285 #define cx_attr_export |
|
286 #endif // CX_WINDLL / CX_WINDLL_EXPORT |
284 |
287 |
285 // --------------------------------------------------------------------------- |
288 // --------------------------------------------------------------------------- |
286 // Useful function pointers |
289 // Useful function pointers |
287 // --------------------------------------------------------------------------- |
290 // --------------------------------------------------------------------------- |
288 |
291 |
354 * @retval non-zero the multiplication would overflow |
357 * @retval non-zero the multiplication would overflow |
355 */ |
358 */ |
356 #if __cplusplus |
359 #if __cplusplus |
357 extern "C" |
360 extern "C" |
358 #endif |
361 #endif |
359 int cx_szmul_impl(size_t a, size_t b, size_t *result); |
362 cx_attr_export int cx_szmul_impl(size_t a, size_t b, size_t *result); |
360 #endif // cx_szmul |
363 #endif // cx_szmul |
361 |
364 |
362 |
365 |
363 // --------------------------------------------------------------------------- |
|
364 // Fixes for MSVC incompatibilities |
|
365 // --------------------------------------------------------------------------- |
|
366 |
|
367 #ifdef _MSC_VER |
|
368 // fix missing ssize_t definition |
|
369 #include <BaseTsd.h> |
|
370 typedef SSIZE_T ssize_t; |
|
371 |
|
372 // fix missing _Thread_local support |
|
373 #define _Thread_local __declspec(thread) |
|
374 #endif // _MSC_VER |
|
375 |
366 |
376 #endif // UCX_COMMON_H |
367 #endif // UCX_COMMON_H |