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)
67extern double drand48(
void);
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)
101# if defined(HAVE_SNPRINTF) && !defined(HAVE_DECL_SNPRINTF) && !defined(snprintf) && !defined(__cplusplus)
103extern int snprintf(
char *str,
size_t size,
const char *format, ...);
111# define __BEGIN_DECLS extern "C" {
112# define __END_DECLS }
114# define __BEGIN_DECLS
124#if !defined __cplusplus && (defined(__STRICT_ANSI__) || defined(__GNUC_GNU_INLINE__))
132# define FMAX(a, b) (((a)>(b))?(a):(b))
136# define FMIN(a, b) (((a)<(b))?(a):(b))
140#if defined(BRLCADBUILD) && defined(HAVE_CONFIG_H)
141# if !defined(HAVE_U_TYPES)
142typedef unsigned char u_char;
143typedef unsigned int u_int;
144typedef unsigned long u_long;
145typedef unsigned short u_short;
146# define HAVE_U_TYPES 1
152#ifndef _FILE_OFFSET_BITS
153# define _FILE_OFFSET_BITS 64
161#if defined(_MSC_VER) && !defined(HAVE_SSIZE_T)
162# ifdef HAVE_SYS_TYPES_H
163# include <sys/types.h>
167typedef ptrdiff_t ssize_t;
168# define HAVE_SSIZE_T 1
170# if defined(LONG_MAX)
171# define SSIZE_MAX LONG_MAX
172# elif defined(INT_MAX)
173# define SSIZE_MAX INT_MAX
174# elif defined(_POSIX_SSIZE_MAX)
175# define SSIZE_MAX _POSIX_SSIZE_MAX
180# define SSIZE_MAX 32767
188#if !defined(INT8_MAX) || !defined(INT16_MAX) || !defined(INT32_MAX) || !defined(INT64_MAX)
189# if (defined _MSC_VER && (_MSC_VER <= 1500))
194# elif defined(__STDC__) || defined(__STRICT_ANSI__) || defined(__SIZE_TYPE__) || defined(HAVE_STDINT_H)
195# if !defined(__STDC_LIMIT_MACROS)
196# define __STDC_LIMIT_MACROS 1
198# if !defined(__STDC_CONSTANT_MACROS)
199# define __STDC_CONSTANT_MACROS 1
212# include <sys/stat.h>
213# define b_off_t __int64
214# define fstat _fstati64
215# define stat _stati64
216#elif defined (_WIN32)
217# include <sys/stat.h>
218# define b_off_t _off_t
222# define b_off_t off_t
232# define MAXPATHLEN PATH_MAX
233# elif defined(MAX_PATH)
234# define MAXPATHLEN MAX_PATH
235# elif defined(_MAX_PATH)
236# define MAXPATHLEN _MAX_PATH
238# define MAXPATHLEN 2048
256# warning "GCC_PREREQ unexpectedly defined. Ensure common.h is included first."
260# define GCC_PREREQ(major, minor) __GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
262# define GCC_PREREQ(major, minor) 0
280# warning "ICC_PREREQ unexpectedly defined. Ensure common.h is included first."
283#if defined __INTEL_COMPILER
284# define ICC_PREREQ(version) (__INTEL_COMPILER >= (version))
286# define ICC_PREREQ(version) 0
294# if !GCC_PREREQ(2, 5)
295# define __attribute__(ignore)
300# if !GCC_PREREQ(2, 7)
301# define __format__ format
302# define __printf__ printf
303# define __noreturn__ noreturn
311# define always_inline noinline
326# warning "UNUSED unexpectedly defined. Ensure common.h is included first."
331# define UNUSED(parameter) UNUSED_ ## parameter __attribute__((unused))
332#elif defined(__cplusplus)
334# define UNUSED(parameter)
337# define UNUSED(parameter) (parameter)
353# warning "LIKELY unexpectedly defined. Ensure common.h is included first."
355#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
356# define LIKELY(expression) __builtin_expect((expression), 1)
358# define LIKELY(expression) (expression)
374# warning "UNLIKELY unexpectedly defined. Ensure common.h is included first."
376#if GCC_PREREQ(3, 0) || ICC_PREREQ(800)
377# define UNLIKELY(expression) __builtin_expect((expression), 0)
379# define UNLIKELY(expression) (expression)
393# warning "DEPRECATED unexpectedly defined. Ensure common.h is included first."
395#if GCC_PREREQ(3, 1) || ICC_PREREQ(800)
396# define DEPRECATED __attribute__((deprecated))
398# define DEPRECATED __declspec(deprecated("This function is DEPRECATED. Please update code to new API."))
420# warning "NORETURN unexpectedly defined. Ensure common.h is included first."
422#if defined(HAVE_NORETURN_ATTRIBUTE)
423# define NORETURN __attribute__((__noreturn__))
424#elif defined(HAVE_NORETURN_DECLSPEC)
425# define NORETURN __declspec(noreturn)
450# warning "FAUX_NORETURN unexpectedly defined. Ensure common.h is included first."
452#ifdef HAVE_ANALYZER_NORETURN_ATTRIBUTE
453# define FAUX_NORETURN __attribute__((analyzer_noreturn))
455# define FAUX_NORETURN
462#if defined(_MSC_VER) && defined(__STDC__)
471#if !defined(__STDC_VERSION__)
472# define __STDC_VERSION__ 0
497# pragma warning( disable : 4351 )
506# pragma warning( disable : 5105 )
537#if defined(__cplusplus)
538# define EXTERNVARINIT extern
540# define EXTERNVARINIT
552# define CPP_STR(x) # x
564# define CPP_XSTR(x) CPP_STR(x)
580# define CPP_GLUE(a, b) a ## b
594# define CPP_XGLUE(a, b) CPP_GLUE(a, b)
607# define CPP_SCAN(sz) "%" CPP_XSTR(sz) "s"
615# define CPP_FILELINE __FILE__ ":" CPP_XSTR(__LINE__)
624# define COMPILER_DLLEXPORT __declspec(dllexport)
625# define COMPILER_DLLIMPORT __declspec(dllimport)
626#elif defined(__GNUC__) || defined(__clang__)
627# define COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
628# define COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
630# define COMPILER_DLLEXPORT
631# define COMPILER_DLLIMPORT
void float float int int int int float * size