ucx/cx/common.h

branch
dav-2
changeset 889
42cdbf9bbd49
parent 886
da79af4baec8
equal deleted inserted replaced
887:26541c37b619 889:42cdbf9bbd49
47 * <a href="https://sourceforge.net/p/ucx/code">https://sourceforge.net/p/ucx/code</a> 47 * <a href="https://sourceforge.net/p/ucx/code">https://sourceforge.net/p/ucx/code</a>
48 * -&nbsp;or&nbsp;- 48 * -&nbsp;or&nbsp;-
49 * <a href="https://uap-core.de/hg/ucx">https://uap-core.de/hg/ucx</a> 49 * <a href="https://uap-core.de/hg/ucx">https://uap-core.de/hg/ucx</a>
50 * </p> 50 * </p>
51 * 51 *
52 * <h2>LICENCE</h2> 52 * <h2>LICENSE</h2>
53 * 53 *
54 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. 54 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
55 * 55 *
56 * Redistribution and use in source and binary forms, with or without 56 * Redistribution and use in source and binary forms, with or without
57 * modification, are permitted provided that the following conditions are met: 57 * modification, are permitted provided that the following conditions are met:
187 /** 187 /**
188 * No support for @c null_terminated_string_arg in clang or GCC below 14. 188 * No support for @c null_terminated_string_arg in clang or GCC below 14.
189 */ 189 */
190 #define cx_attr_cstr_arg(idx) 190 #define cx_attr_cstr_arg(idx)
191 /** 191 /**
192 * No support for access attribute in clang. 192 * No support for the access attribute in clang.
193 */ 193 */
194 #define cx_attr_access(mode, ...) 194 #define cx_attr_access(mode, ...)
195 #else 195 #else
196 #if __GNUC__ < 10 196 #if __GNUC__ < 10
197 /** 197 /**
263 #ifdef _MSC_VER 263 #ifdef _MSC_VER
264 // fix missing _Thread_local support 264 // fix missing _Thread_local support
265 #define _Thread_local __declspec(thread) 265 #define _Thread_local __declspec(thread)
266 #endif // _MSC_VER 266 #endif // _MSC_VER
267 267
268 // ---------------------------------------------------------------------------
269 // Exported and inlined functions
270 // ---------------------------------------------------------------------------
271
268 #if defined(CX_WINDLL_EXPORT) 272 #if defined(CX_WINDLL_EXPORT)
269 #define cx_attr_export __declspec(dllexport) 273 #define CX_EXPORT __declspec(dllexport)
270 #elif defined(CX_WINDLL) 274 #elif defined(CX_WINDLL)
271 #define cx_attr_export __declspec(dllimport) 275 #define CX_EXPORT __declspec(dllimport)
272 #else 276 #else
273 /** Only used for building Windows DLLs. */ 277 /** Only used for building Windows DLLs. */
274 #define cx_attr_export 278 #define CX_EXPORT
275 #endif // CX_WINDLL / CX_WINDLL_EXPORT 279 #endif // CX_WINDLL / CX_WINDLL_EXPORT
276 280
281 #ifdef __GNUC__
282 /**
283 * Declares a function to be inlined.
284 */
285 #define CX_INLINE __attribute__((always_inline)) static inline
286 #else
287 #define CX_INLINE static inline
288 #endif
289 /**
290 * Declares a compatibility function for C++ builds.
291 */
292 #define CX_CPPDECL static inline
293
277 // --------------------------------------------------------------------------- 294 // ---------------------------------------------------------------------------
278 // Useful function pointers 295 // Useful function pointers
279 // --------------------------------------------------------------------------- 296 // ---------------------------------------------------------------------------
280 297
281 /** 298 /**
282 * Function pointer compatible with fwrite-like functions. 299 * Function pointer compatible with fwrite-like functions.
283 */ 300 */
284 typedef size_t (*cx_write_func)( 301 typedef size_t (*cx_write_func)(const void*, size_t, size_t, void*);
285 const void *,
286 size_t,
287 size_t,
288 void *
289 );
290 302
291 /** 303 /**
292 * Function pointer compatible with fread-like functions. 304 * Function pointer compatible with fread-like functions.
293 */ 305 */
294 typedef size_t (*cx_read_func)( 306 typedef size_t (*cx_read_func)(void*, size_t, size_t, void*);
295 void *,
296 size_t,
297 size_t,
298 void *
299 );
300 307
301 // --------------------------------------------------------------------------- 308 // ---------------------------------------------------------------------------
302 // Utility macros 309 // Utility macros
303 // --------------------------------------------------------------------------- 310 // ---------------------------------------------------------------------------
304 311
346 * @retval non-zero the multiplication would overflow 353 * @retval non-zero the multiplication would overflow
347 */ 354 */
348 #if __cplusplus 355 #if __cplusplus
349 extern "C" 356 extern "C"
350 #endif 357 #endif
351 cx_attr_export int cx_szmul_impl(size_t a, size_t b, size_t *result); 358 CX_EXPORT int cx_szmul_impl(size_t a, size_t b, size_t *result);
352 #endif // cx_szmul 359 #endif // cx_szmul
353 360
354
355
356 #endif // UCX_COMMON_H 361 #endif // UCX_COMMON_H

mercurial