Loading...
Searching...
No Matches
Go to the documentation of this file.
46#if defined(BRLCADBUILD) && defined(HAVE_CONFIG_H)
48# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
49# include "brlcad_config.h"
53# include "config_win.h"
55# include "brlcad_config.h"
61# if !defined(HAVE_DRAND48) && !defined(drand48)
62# define drand48() ((double)rand() / (double)(RAND_MAX + 1))
63# define HAVE_DRAND48 1
64# define srand48(seed) (srand(seed))
65# define HAVE_DECL_DRAND48 1
66# elif !defined(HAVE_DECL_DRAND48) && !defined(__cplusplus)
70# if !defined(__cplusplus) || defined(HAVE_SHARED_RINT_TEST)
73# if !defined(HAVE_LRINT)
74# define lrint(_x) (((_x) < 0.0) ? (long int)ceil((_x)-0.5) : (long int)floor((_x)+0.5))
75# elif !defined(HAVE_WINDOWS_H) && !defined(HAVE_DECL_LRINT)
76long int lrint(
double x);
77# define HAVE_DECL_LRINT 1
81# if !defined(HAVE_LRINT)
87# if !defined(HAVE_RINT)
88# define rint(_x) (((_x) < 0.0) ? ceil((_x)-0.5) : floor((_x)+0.5))
89# elif !defined(HAVE_WINDOWS_H) && !defined(HAVE_DECL_RINT)
91# define HAVE_DECL_RINT 1
95# if !defined(HAVE_RINT)
108# if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
109# define THREADLOCAL thread_local
110# elif !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
111# define THREADLOCAL thread_local
112# elif !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
113# define THREADLOCAL _Thread_local
114# elif defined(HAVE_WINDOWS_H)
115# define THREADLOCAL __declspec(thread)
116# elif defined(__GNUC__) || defined(__clang__)
117# define THREADLOCAL __thread
119# error "Cannot define THREADLOCAL for this compiler/platform"
124# if defined(HAVE_SNPRINTF) && !defined(HAVE_DECL_SNPRINTF) && !defined(snprintf) && !defined(__cplusplus)
126extern int snprintf(
char *str,
size_t size,
const char *format, ...);
134# define __BEGIN_DECLS extern "C" {
135# define __END_DECLS }
137# define __BEGIN_DECLS
150# define C_DECL extern "C"
162#if !defined __cplusplus && (defined(__STRICT_ANSI__) || defined(__GNUC_GNU_INLINE__))
170# define FMAX(a, b) (((a)>(b))?(a):(b))
174# define FMIN(a, b) (((a)<(b))?(a):(b))
178#if defined(BRLCADBUILD) && defined(HAVE_CONFIG_H)
179# if !defined(HAVE_U_TYPES)
180typedef unsigned char u_char;
181typedef unsigned int u_int;
182typedef unsigned long u_long;
184# define HAVE_U_TYPES 1
190#ifndef _FILE_OFFSET_BITS
191# define _FILE_OFFSET_BITS 64
199#if defined(_MSC_VER) && !defined(HAVE_SSIZE_T)
200# ifdef HAVE_SYS_TYPES_H
201# include <sys/types.h>
206# define HAVE_SSIZE_T 1
208# if defined(LONG_MAX)
209# define SSIZE_MAX LONG_MAX
210# elif defined(INT_MAX)
211# define SSIZE_MAX INT_MAX
212# elif defined(_POSIX_SSIZE_MAX)
213# define SSIZE_MAX _POSIX_SSIZE_MAX
218# define SSIZE_MAX 32767
226#if !defined(INT8_MAX) || !defined(INT16_MAX) || !defined(INT32_MAX) || !defined(INT64_MAX)
227# if (defined _MSC_VER && (_MSC_VER <= 1500))
232# elif defined(__STDC__) || defined(__STRICT_ANSI__) || defined(__SIZE_TYPE__) || defined(HAVE_STDINT_H)
233# if !defined(__STDC_LIMIT_MACROS)
234# define __STDC_LIMIT_MACROS 1
236# if !defined(__STDC_CONSTANT_MACROS)
237# define __STDC_CONSTANT_MACROS 1
250# include <sys/stat.h>
251# define b_off_t __int64
252# define fstat _fstati64
253# define stat _stati64
254#elif defined (_WIN32)
255# include <sys/stat.h>
256# define b_off_t _off_t
260# define b_off_t off_t
270# define MAXPATHLEN PATH_MAX
271# elif defined(MAX_PATH)
272# define MAXPATHLEN MAX_PATH
273# elif defined(_MAX_PATH)
274# define MAXPATHLEN _MAX_PATH
276# define MAXPATHLEN 2048
294# warning "GCC_PREREQ unexpectedly defined. Ensure common.h is included first."
298# define GCC_PREREQ(major, minor) __GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
300# define GCC_PREREQ(major, minor) 0
318# warning "ICC_PREREQ unexpectedly defined. Ensure common.h is included first."
321#if defined __INTEL_COMPILER
322# define ICC_PREREQ(version) (__INTEL_COMPILER >= (version))
324# define ICC_PREREQ(version) 0
332# if !GCC_PREREQ(2, 5)
333# define __attribute__(ignore)
338# if !GCC_PREREQ(2, 7)
339# define __format__ format
340# define __printf__ printf
341# define __noreturn__ noreturn
349# define always_inline noinline
364# warning "UNUSED unexpectedly defined. Ensure common.h is included first."
369# define UNUSED(parameter) UNUSED_ ## parameter __attribute__((unused))
370#elif defined(__cplusplus)
372# define UNUSED(parameter)
375# define UNUSED(parameter) (parameter)
391# warning "LIKELY unexpectedly defined. Ensure common.h is included first."
393#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
394# define LIKELY(expression) __builtin_expect((expression), 1)
396# define LIKELY(expression) (expression)
412# warning "UNLIKELY unexpectedly defined. Ensure common.h is included first."
414#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
415# define UNLIKELY(expression) __builtin_expect((expression), 0)
417# define UNLIKELY(expression) (expression)
431# warning "DEPRECATED unexpectedly defined. Ensure common.h is included first."
433#if GCC_PREREQ(3, 1) || ICC_PREREQ(800)
434# define DEPRECATED __attribute__((deprecated))
436# define DEPRECATED __declspec(deprecated("This function is DEPRECATED. Please update code to new API."))
458# warning "NORETURN unexpectedly defined. Ensure common.h is included first."
460#if defined(HAVE_NORETURN_ATTRIBUTE)
461# define NORETURN __attribute__((__noreturn__))
462#elif defined(HAVE_NORETURN_DECLSPEC)
463# define NORETURN __declspec(noreturn)
488# warning "FAUX_NORETURN unexpectedly defined. Ensure common.h is included first."
490#ifdef HAVE_ANALYZER_NORETURN_ATTRIBUTE
491# define FAUX_NORETURN __attribute__((analyzer_noreturn))
493# define FAUX_NORETURN
500#if defined(_MSC_VER) && defined(__STDC__)
509#if !defined(__STDC_VERSION__)
510# define __STDC_VERSION__ 0
515#if defined(__APPLE__) && !defined(alloca)
516# define alloca(x) malloc(x)
541# pragma warning( disable : 4351 )
550# pragma warning( disable : 5105 )
585#if defined(__cplusplus)
586# define EXTERNCPP extern
600# define CPP_STR(x) # x
612# define CPP_XSTR(x) CPP_STR(x)
628# define CPP_GLUE(a, b) a ## b
642# define CPP_XGLUE(a, b) CPP_GLUE(a, b)
655# define CPP_SCAN(sz) "%" CPP_XSTR(sz) "s"
663# define CPP_FILELINE __FILE__ ":" CPP_XSTR(__LINE__)
672# define COMPILER_DLLEXPORT __declspec(dllexport)
673# define COMPILER_DLLIMPORT __declspec(dllimport)
674#elif defined(__GNUC__) || defined(__clang__)
675# define COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
676# define COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
678# define COMPILER_DLLEXPORT
679# define COMPILER_DLLIMPORT