12 #define MOAB_POLY_EPS ( 128 * DBL_EPSILON )
13 #define MOAB_POLY_PI 3.1415926535897932384626433832795028841971693993751058209749445923
31 #if defined( USE_LONG )
33 #elif defined( USE_LONG_LONG )
34 #define INTEGER long long
35 #elif defined( USE_SHORT )
42 #if defined( USE_GLOBAL_LONG_LONG )
43 #define GLOBAL_INT long long
44 #elif defined( USE_GLOBAL_LONG )
45 #define GLOBAL_INT long
47 #define GLOBAL_INT long
51 #if defined( USE_FLOAT )
53 #elif defined( USE_LONG_DOUBLE )
63 #pragma diag_suppress duplicate_typedef
92 #pragma diag_default duplicate_typedef
610 void fail(
const char* fmt, ... ) __attribute__( ( noreturn ) );
611 #define MAYBE_UNUSED __attribute__( ( unused ) )
613 void fail(
const char* fmt, ... );
622 static void*
smalloc(
size_t size,
const char* file )
624 void* res = malloc( size );
625 if( !res && size )
fail(
"%s: allocation of %d bytes failed\n", file, (
int)size );
630 static void*
scalloc(
size_t nmemb,
size_t size,
const char* file )
632 void* res = calloc( nmemb, size );
633 if( !res && nmemb )
fail(
"%s: allocation of %d bytes failed\n", file, (
int)size * nmemb );
638 static void*
srealloc(
void* ptr,
size_t size,
const char* file )
640 void* res = realloc( ptr, size );
641 if( !res && size )
fail(
"%s: allocation of %d bytes failed\n", file, (
int)size );
645 #define tmalloc( type, count ) ( (type*)smalloc( ( count ) * sizeof( type ), __FILE__ ) )
646 #define tcalloc( type, count ) ( (type*)scalloc( ( count ), sizeof( type ), __FILE__ ) )
647 #define trealloc( type, ptr, count ) ( (type*)srealloc( ( ptr ), ( count ) * sizeof( type ), __FILE__ ) )
684 #define MAYBE_UNUSED __attribute__( ( unused ) )
689 #define DECLMINMAX( type, prefix ) \
690 static type prefix##min_2( type a, type b ) MAYBE_UNUSED; \
691 static type prefix##min_2( type a, type b ) \
693 return b < a ? b : a; \
695 static type prefix##max_2( type a, type b ) MAYBE_UNUSED; \
696 static type prefix##max_2( type a, type b ) \
698 return a > b ? a : b; \
700 static void prefix##minmax_2( type* min, type* max, type a, type b ) MAYBE_UNUSED; \
701 static void prefix##minmax_2( type* min, type* max, type a, type b ) \
704 *min = b, *max = a; \
706 *min = a, *max = b; \
708 static type prefix##min_3( type a, type b, type c ) MAYBE_UNUSED; \
709 static type prefix##min_3( type a, type b, type c ) \
711 return b < a ? ( c < b ? c : b ) : ( c < a ? c : a ); \
713 static type prefix##max_3( type a, type b, type c ) MAYBE_UNUSED; \
714 static type prefix##max_3( type a, type b, type c ) \
716 return a > b ? ( a > c ? a : c ) : ( b > c ? b : c ); \
718 static void prefix##minmax_3( type* min, type* max, type a, type b, type c ) MAYBE_UNUSED; \
719 static void prefix##minmax_3( type* min, type* max, type a, type b, type c ) \
722 *min = prefix##min_2( b, c ), *max = prefix##max_2( a, c ); \
724 *min = prefix##min_2( a, c ), *max = prefix##max_2( b, c ); \
755 return mbsqrt( a * a + b * b );
760 return mbsqrt( a * a + b * b + c * c );