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)
102# if defined(__cplusplus) && __cplusplus >= 201103L
103# define THREADLOCAL thread_local
104# elif !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
105# define THREADLOCAL thread_local
106# elif !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
107# define THREADLOCAL _Thread_local
108# elif defined(HAVE_WINDOWS_H)
109# define THREADLOCAL __declspec(thread)
110# elif defined(__GNUC__) || defined(__clang__)
111# define THREADLOCAL __thread
113# error "Cannot define THREADLOCAL for this compiler/platform"
118# if defined(HAVE_SNPRINTF) && !defined(HAVE_DECL_SNPRINTF) && !defined(snprintf) && !defined(__cplusplus)
120extern int snprintf(
char *str,
size_t size,
const char *format, ...);
128# define __BEGIN_DECLS extern "C" {
129# define __END_DECLS }
131# define __BEGIN_DECLS
144# define C_DECL extern "C"
156#if !defined __cplusplus && (defined(__STRICT_ANSI__) || defined(__GNUC_GNU_INLINE__))
164# define FMAX(a, b) (((a)>(b))?(a):(b))
168# define FMIN(a, b) (((a)<(b))?(a):(b))
172#if defined(BRLCADBUILD) && defined(HAVE_CONFIG_H)
173# if !defined(HAVE_U_TYPES)
174typedef unsigned char u_char;
175typedef unsigned int u_int;
176typedef unsigned long u_long;
178# define HAVE_U_TYPES 1
184#ifndef _FILE_OFFSET_BITS
185# define _FILE_OFFSET_BITS 64
193#if defined(_MSC_VER) && !defined(HAVE_SSIZE_T)
194# ifdef HAVE_SYS_TYPES_H
195# include <sys/types.h>
200# define HAVE_SSIZE_T 1
202# if defined(LONG_MAX)
203# define SSIZE_MAX LONG_MAX
204# elif defined(INT_MAX)
205# define SSIZE_MAX INT_MAX
206# elif defined(_POSIX_SSIZE_MAX)
207# define SSIZE_MAX _POSIX_SSIZE_MAX
212# define SSIZE_MAX 32767
220#if !defined(INT8_MAX) || !defined(INT16_MAX) || !defined(INT32_MAX) || !defined(INT64_MAX)
221# if (defined _MSC_VER && (_MSC_VER <= 1500))
226# elif defined(__STDC__) || defined(__STRICT_ANSI__) || defined(__SIZE_TYPE__) || defined(HAVE_STDINT_H)
227# if !defined(__STDC_LIMIT_MACROS)
228# define __STDC_LIMIT_MACROS 1
230# if !defined(__STDC_CONSTANT_MACROS)
231# define __STDC_CONSTANT_MACROS 1
244# include <sys/stat.h>
245# define b_off_t __int64
246# define fstat _fstati64
247# define stat _stati64
248#elif defined (_WIN32)
249# include <sys/stat.h>
250# define b_off_t _off_t
254# define b_off_t off_t
264# define MAXPATHLEN PATH_MAX
265# elif defined(MAX_PATH)
266# define MAXPATHLEN MAX_PATH
267# elif defined(_MAX_PATH)
268# define MAXPATHLEN _MAX_PATH
270# define MAXPATHLEN 2048
288# warning "GCC_PREREQ unexpectedly defined. Ensure common.h is included first."
292# define GCC_PREREQ(major, minor) __GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
294# define GCC_PREREQ(major, minor) 0
312# warning "ICC_PREREQ unexpectedly defined. Ensure common.h is included first."
315#if defined __INTEL_COMPILER
316# define ICC_PREREQ(version) (__INTEL_COMPILER >= (version))
318# define ICC_PREREQ(version) 0
326# if !GCC_PREREQ(2, 5)
327# define __attribute__(ignore)
332# if !GCC_PREREQ(2, 7)
333# define __format__ format
334# define __printf__ printf
335# define __noreturn__ noreturn
343# define always_inline noinline
358# warning "UNUSED unexpectedly defined. Ensure common.h is included first."
363# define UNUSED(parameter) UNUSED_ ## parameter __attribute__((unused))
364#elif defined(__cplusplus)
366# define UNUSED(parameter)
369# define UNUSED(parameter) (parameter)
385# warning "LIKELY unexpectedly defined. Ensure common.h is included first."
387#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
388# define LIKELY(expression) __builtin_expect((expression), 1)
390# define LIKELY(expression) (expression)
406# warning "UNLIKELY unexpectedly defined. Ensure common.h is included first."
408#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
409# define UNLIKELY(expression) __builtin_expect((expression), 0)
411# define UNLIKELY(expression) (expression)
425# warning "DEPRECATED unexpectedly defined. Ensure common.h is included first."
427#if GCC_PREREQ(3, 1) || ICC_PREREQ(800)
428# define DEPRECATED __attribute__((deprecated))
430# define DEPRECATED __declspec(deprecated("This function is DEPRECATED. Please update code to new API."))
452# warning "NORETURN unexpectedly defined. Ensure common.h is included first."
454#if defined(HAVE_NORETURN_ATTRIBUTE)
455# define NORETURN __attribute__((__noreturn__))
456#elif defined(HAVE_NORETURN_DECLSPEC)
457# define NORETURN __declspec(noreturn)
482# warning "FAUX_NORETURN unexpectedly defined. Ensure common.h is included first."
484#ifdef HAVE_ANALYZER_NORETURN_ATTRIBUTE
485# define FAUX_NORETURN __attribute__((analyzer_noreturn))
487# define FAUX_NORETURN
494#if defined(_MSC_VER) && defined(__STDC__)
503#if !defined(__STDC_VERSION__)
504# define __STDC_VERSION__ 0
509#if defined(__APPLE__) && !defined(alloca)
510# define alloca(x) malloc(x)
535# pragma warning( disable : 4351 )
544# pragma warning( disable : 5105 )
579#if defined(__cplusplus)
580# define EXTERNCPP extern
594# define CPP_STR(x) # x
606# define CPP_XSTR(x) CPP_STR(x)
622# define CPP_GLUE(a, b) a ## b
636# define CPP_XGLUE(a, b) CPP_GLUE(a, b)
649# define CPP_SCAN(sz) "%" CPP_XSTR(sz) "s"
657# define CPP_FILELINE __FILE__ ":" CPP_XSTR(__LINE__)
666# define COMPILER_DLLEXPORT __declspec(dllexport)
667# define COMPILER_DLLIMPORT __declspec(dllimport)
668#elif defined(__GNUC__) || defined(__clang__)
669# define COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
670# define COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
672# define COMPILER_DLLEXPORT
673# define COMPILER_DLLIMPORT