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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _builtin_h
00048 #ifdef __GNUG__
00049 #pragma interface
00050 #endif
00051 #define _builtin_h 1
00052
00053 #include <stddef.h>
00054
00055
00056 #include <stdio.h>
00057
00058 #ifndef __GNUC__
00059 #define __attribute__(x)
00060 #endif
00061
00062 typedef void (*one_arg_error_handler_t)(const char*);
00063 typedef void (*two_arg_error_handler_t)(const char*, const char*);
00064
00065 long gcd(long, long);
00066 long lg(unsigned long);
00067 double pow(double, long);
00068 long pow(long, long);
00069
00070 extern "C" double start_timer();
00071 extern "C" double return_elapsed_time(double last_time = 0.0);
00072
00073 char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
00074
00075 unsigned int hashpjw(const char*);
00076 unsigned int multiplicativehash(int);
00077 unsigned int foldhash(double);
00078
00079 extern void default_one_arg_error_handler(const char*) __attribute__ ((noreturn));
00080 extern void default_two_arg_error_handler(const char*, const char*) __attribute__ ((noreturn));
00081
00082 extern two_arg_error_handler_t lib_error_handler;
00083
00084 extern two_arg_error_handler_t
00085 set_lib_error_handler(two_arg_error_handler_t f);
00086
00087
00088 #if !defined(IV)
00089
00090 inline short abs(short arg)
00091 {
00092 return (arg < 0)? -arg : arg;
00093 }
00094
00095 inline int sign(long arg)
00096 {
00097 return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 );
00098 }
00099
00100 inline int sign(double arg)
00101 {
00102 return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 );
00103 }
00104
00105 inline long sqr(long arg)
00106 {
00107 return arg * arg;
00108 }
00109
00110 #if ! _G_MATH_H_INLINES
00111 inline double sqr(double arg)
00112 {
00113 return arg * arg;
00114 }
00115 #endif
00116
00117 inline int even(long arg)
00118 {
00119 return !(arg & 1);
00120 }
00121
00122 inline int odd(long arg)
00123 {
00124 return (arg & 1);
00125 }
00126
00127 inline long lcm(long x, long y)
00128 {
00129 return x / gcd(x, y) * y;
00130 }
00131
00132 inline void (setbit)(long& x, long b)
00133 {
00134 x |= (1 << b);
00135 }
00136
00137 inline void clearbit(long& x, long b)
00138 {
00139 x &= ~(1 << b);
00140 }
00141
00142 inline int testbit(long x, long b)
00143 {
00144 return ((x & (1 << b)) != 0);
00145 }
00146
00147 #endif
00148 #endif