00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _builtin_h
00026 #ifdef __GNUG__
00027 #if ! defined(TWINE)
00028 #pragma interface
00029 #endif
00030 #endif
00031 #define _builtin_h 1
00032
00033 #include <stddef.h>
00034 #include <math.h>
00035
00036 #ifdef __GNUG__
00037 #include <cmath>
00038 #endif
00039
00040 #ifdef __GNUG__
00041 #define _VOLATILE_VOID volatile void
00042 #else
00043 #define _VOLATILE_VOID void
00044 #endif
00045
00046 typedef void (*one_arg_error_handler_t)(const char*);
00047 typedef void (*two_arg_error_handler_t)(const char*, const char*);
00048
00049 long gcd(long, long);
00050 long lg(unsigned long);
00051 double pow(double, long);
00052 long pow(long, long);
00053
00054 #ifdef __GNUG__ // Otherwise, see myenv.h
00055 extern "C" double start_timer();
00056 extern "C" double return_elapsed_time(double last_time = 0.0);
00057 #endif
00058
00059 char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
00060
00061 unsigned int hashpjw(const char*);
00062 unsigned int multiplicativehash(int);
00063 unsigned int foldhash(double);
00064
00065 extern _VOLATILE_VOID default_one_arg_error_handler(const char*);
00066 extern _VOLATILE_VOID default_two_arg_error_handler(const char*, const char*);
00067
00068 extern two_arg_error_handler_t lib_error_handler;
00069
00070 extern two_arg_error_handler_t
00071 set_lib_error_handler(two_arg_error_handler_t f);
00072
00073
00074 #if !defined(IV)
00075
00076 #if !defined(__GNUG__) && !defined(__xlC__) // has been defined in <cmath>
00077 inline double abs(double arg)
00078 {
00079 return (arg < 0.0)? -arg : arg;
00080 }
00081
00082 inline float abs(float arg)
00083 {
00084 return (arg < 0.0)? -arg : arg;
00085 }
00086 #endif
00087
00088 inline short abs(short arg)
00089 {
00090 return (arg < 0)? -arg : arg;
00091 }
00092
00093 #ifndef __GNUG__ // has been defined in <cstdlib>
00094 inline long abs(long arg)
00095 {
00096 return (arg < 0)? -arg : arg;
00097 }
00098 #endif
00099
00100 inline int sign(long arg)
00101 {
00102 return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 );
00103 }
00104
00105 inline int sign(double arg)
00106 {
00107 return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 );
00108 }
00109
00110 inline long sqr(long arg)
00111 {
00112 return arg * arg;
00113 }
00114
00115 #if ! _G_MATH_H_INLINES
00116 inline double sqr(double arg)
00117 {
00118 return arg * arg;
00119 }
00120 #endif
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 inline long lcm(long x, long y)
00133 {
00134 return x / gcd(x, y) * y;
00135 }
00136
00137 inline void (setbit)(long& x, long b)
00138 {
00139 x |= (1 << b);
00140 }
00141
00142 inline void clearbit(long& x, long b)
00143 {
00144 x &= ~(1 << b);
00145 }
00146
00147 inline int testbit(long x, long b)
00148 {
00149 return ((x & (1 << b)) != 0);
00150 }
00151
00152 #endif
00153 #endif