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)
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
141#if !defined __cplusplus && (defined(__STRICT_ANSI__) || defined(__GNUC_GNU_INLINE__))
149# define FMAX(a, b) (((a)>(b))?(a):(b))
153# define FMIN(a, b) (((a)<(b))?(a):(b))
157#if defined(BRLCADBUILD) && defined(HAVE_CONFIG_H)
158# if !defined(HAVE_U_TYPES)
159typedef unsigned char u_char;
160typedef unsigned int u_int;
161typedef unsigned long u_long;
163# define HAVE_U_TYPES 1
169#ifndef _FILE_OFFSET_BITS
170# define _FILE_OFFSET_BITS 64
178#if defined(_MSC_VER) && !defined(HAVE_SSIZE_T)
179# ifdef HAVE_SYS_TYPES_H
180# include <sys/types.h>
185# define HAVE_SSIZE_T 1
187# if defined(LONG_MAX)
188# define SSIZE_MAX LONG_MAX
189# elif defined(INT_MAX)
190# define SSIZE_MAX INT_MAX
191# elif defined(_POSIX_SSIZE_MAX)
192# define SSIZE_MAX _POSIX_SSIZE_MAX
197# define SSIZE_MAX 32767
205#if !defined(INT8_MAX) || !defined(INT16_MAX) || !defined(INT32_MAX) || !defined(INT64_MAX)
206# if (defined _MSC_VER && (_MSC_VER <= 1500))
211# elif defined(__STDC__) || defined(__STRICT_ANSI__) || defined(__SIZE_TYPE__) || defined(HAVE_STDINT_H)
212# if !defined(__STDC_LIMIT_MACROS)
213# define __STDC_LIMIT_MACROS 1
215# if !defined(__STDC_CONSTANT_MACROS)
216# define __STDC_CONSTANT_MACROS 1
229# include <sys/stat.h>
230# define b_off_t __int64
231# define fstat _fstati64
232# define stat _stati64
233#elif defined (_WIN32)
234# include <sys/stat.h>
235# define b_off_t _off_t
239# define b_off_t off_t
249# define MAXPATHLEN PATH_MAX
250# elif defined(MAX_PATH)
251# define MAXPATHLEN MAX_PATH
252# elif defined(_MAX_PATH)
253# define MAXPATHLEN _MAX_PATH
255# define MAXPATHLEN 2048
273# warning "GCC_PREREQ unexpectedly defined. Ensure common.h is included first."
277# define GCC_PREREQ(major, minor) __GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
279# define GCC_PREREQ(major, minor) 0
297# warning "ICC_PREREQ unexpectedly defined. Ensure common.h is included first."
300#if defined __INTEL_COMPILER
301# define ICC_PREREQ(version) (__INTEL_COMPILER >= (version))
303# define ICC_PREREQ(version) 0
311# if !GCC_PREREQ(2, 5)
312# define __attribute__(ignore)
317# if !GCC_PREREQ(2, 7)
318# define __format__ format
319# define __printf__ printf
320# define __noreturn__ noreturn
328# define always_inline noinline
343# warning "UNUSED unexpectedly defined. Ensure common.h is included first."
348# define UNUSED(parameter) UNUSED_ ## parameter __attribute__((unused))
349#elif defined(__cplusplus)
351# define UNUSED(parameter)
354# define UNUSED(parameter) (parameter)
370# warning "LIKELY unexpectedly defined. Ensure common.h is included first."
372#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
373# define LIKELY(expression) __builtin_expect((expression), 1)
375# define LIKELY(expression) (expression)
391# warning "UNLIKELY unexpectedly defined. Ensure common.h is included first."
393#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
394# define UNLIKELY(expression) __builtin_expect((expression), 0)
396# define UNLIKELY(expression) (expression)
410# warning "DEPRECATED unexpectedly defined. Ensure common.h is included first."
412#if GCC_PREREQ(3, 1) || ICC_PREREQ(800)
413# define DEPRECATED __attribute__((deprecated))
415# define DEPRECATED __declspec(deprecated("This function is DEPRECATED. Please update code to new API."))
437# warning "NORETURN unexpectedly defined. Ensure common.h is included first."
439#if defined(HAVE_NORETURN_ATTRIBUTE)
440# define NORETURN __attribute__((__noreturn__))
441#elif defined(HAVE_NORETURN_DECLSPEC)
442# define NORETURN __declspec(noreturn)
467# warning "FAUX_NORETURN unexpectedly defined. Ensure common.h is included first."
469#ifdef HAVE_ANALYZER_NORETURN_ATTRIBUTE
470# define FAUX_NORETURN __attribute__((analyzer_noreturn))
472# define FAUX_NORETURN
479#if defined(_MSC_VER) && defined(__STDC__)
488#if !defined(__STDC_VERSION__)
489# define __STDC_VERSION__ 0
494#if defined(__APPLE__) && !defined(alloca)
495# define alloca(x) malloc(x)
520# pragma warning( disable : 4351 )
529# pragma warning( disable : 5105 )
560#if defined(__cplusplus)
561# define EXTERNVARINIT extern
563# define EXTERNVARINIT
575# define CPP_STR(x) # x
587# define CPP_XSTR(x) CPP_STR(x)
603# define CPP_GLUE(a, b) a ## b
617# define CPP_XGLUE(a, b) CPP_GLUE(a, b)
630# define CPP_SCAN(sz) "%" CPP_XSTR(sz) "s"
638# define CPP_FILELINE __FILE__ ":" CPP_XSTR(__LINE__)
647# define COMPILER_DLLEXPORT __declspec(dllexport)
648# define COMPILER_DLLIMPORT __declspec(dllimport)
649#elif defined(__GNUC__) || defined(__clang__)
650# define COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
651# define COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
653# define COMPILER_DLLEXPORT
654# define COMPILER_DLLIMPORT
void float float int int int int float * size