1 /************************************************ 2 3 missing.h - prototype for *.c in ./missing, and 4 for missing timeval struct 5 6 $Author: ngoto $ 7 created at: Sat May 11 23:46:03 JST 2002 8 9 ************************************************/ 10 11 #ifndef RUBY_MISSING_H 12 #define RUBY_MISSING_H 1 13 14 #if defined(__cplusplus) 15 extern "C" { 16 #if 0 17 } /* satisfy cc-mode */ 18 #endif 19 #endif 20 21 #include "ruby/config.h" 22 #include <stddef.h> 23 #include <math.h> /* for INFINITY and NAN */ 24 #ifdef RUBY_ALTERNATIVE_MALLOC_HEADER 25 # include RUBY_ALTERNATIVE_MALLOC_HEADER 26 #endif 27 #ifdef RUBY_EXTCONF_H 28 #include RUBY_EXTCONF_H 29 #endif 30 31 #if !defined(HAVE_STRUCT_TIMEVAL) || !defined(HAVE_STRUCT_TIMESPEC) 32 #if defined(HAVE_TIME_H) 33 # include <time.h> 34 #endif 35 #if defined(HAVE_SYS_TIME_H) 36 # include <sys/time.h> 37 #endif 38 #endif 39 40 #ifndef M_PI 41 # define M_PI 3.14159265358979323846 42 #endif 43 #ifndef M_PI_2 44 # define M_PI_2 (M_PI/2) 45 #endif 46 47 #ifndef RUBY_SYMBOL_EXPORT_BEGIN 48 # define RUBY_SYMBOL_EXPORT_BEGIN /* begin */ 49 # define RUBY_SYMBOL_EXPORT_END /* end */ 50 #endif 51 52 #if !defined(HAVE_STRUCT_TIMEVAL) 53 struct timeval { 54 time_t tv_sec; /* seconds */ 55 long tv_usec; /* microseconds */ 56 }; 57 #endif /* HAVE_STRUCT_TIMEVAL */ 58 59 #if !defined(HAVE_STRUCT_TIMESPEC) 60 struct timespec { 61 time_t tv_sec; /* seconds */ 62 long tv_nsec; /* nanoseconds */ 63 }; 64 #endif 65 66 #if !defined(HAVE_STRUCT_TIMEZONE) 67 struct timezone { 68 int tz_minuteswest; 69 int tz_dsttime; 70 }; 71 #endif 72 73 #ifdef RUBY_EXPORT 74 #undef RUBY_EXTERN 75 #endif 76 #ifndef RUBY_EXTERN 77 #define RUBY_EXTERN extern 78 #endif 79 80 RUBY_SYMBOL_EXPORT_BEGIN 81 82 #ifndef HAVE_ACOSH 83 RUBY_EXTERN double acosh(double); 84 RUBY_EXTERN double asinh(double); 85 RUBY_EXTERN double atanh(double); 86 #endif 87 88 #ifndef HAVE_CRYPT 89 RUBY_EXTERN char *crypt(const char *, const char *); 90 #endif 91 92 #ifndef HAVE_DUP2 93 RUBY_EXTERN int dup2(int, int); 94 #endif 95 96 #ifndef HAVE_EACCESS 97 RUBY_EXTERN int eaccess(const char*, int); 98 #endif 99 100 #ifndef HAVE_ROUND 101 RUBY_EXTERN double round(double); /* numeric.c */ 102 #endif 103 104 #ifndef HAVE_FINITE 105 RUBY_EXTERN int finite(double); 106 #endif 107 108 #ifndef HAVE_FLOCK 109 RUBY_EXTERN int flock(int, int); 110 #endif 111 112 /* 113 #ifndef HAVE_FREXP 114 RUBY_EXTERN double frexp(double, int *); 115 #endif 116 */ 117 118 #ifndef HAVE_HYPOT 119 RUBY_EXTERN double hypot(double, double); 120 #endif 121 122 #ifndef HAVE_ERF 123 RUBY_EXTERN double erf(double); 124 RUBY_EXTERN double erfc(double); 125 #endif 126 127 #ifndef HAVE_TGAMMA 128 RUBY_EXTERN double tgamma(double); 129 #endif 130 131 #ifndef HAVE_LGAMMA_R 132 RUBY_EXTERN double lgamma_r(double, int *); 133 #endif 134 135 #ifndef HAVE_CBRT 136 RUBY_EXTERN double cbrt(double); 137 #endif 138 139 #if !defined(INFINITY) || !defined(NAN) 140 union bytesequence4_or_float { 141 unsigned char bytesequence[4]; 142 float float_value; 143 }; 144 #endif 145 146 #ifndef INFINITY 147 /** @internal */ 148 RUBY_EXTERN const union bytesequence4_or_float rb_infinity; 149 # define INFINITY (rb_infinity.float_value) 150 # define USE_RB_INFINITY 1 151 #endif 152 153 #ifndef NAN 154 /** @internal */ 155 RUBY_EXTERN const union bytesequence4_or_float rb_nan; 156 # define NAN (rb_nan.float_value) 157 # define USE_RB_NAN 1 158 #endif 159 160 #ifndef HUGE_VAL 161 # define HUGE_VAL ((double)INFINITY) 162 #endif 163 164 #ifndef isinf 165 # ifndef HAVE_ISINF 166 # if defined(HAVE_FINITE) && defined(HAVE_ISNAN) 167 # ifdef HAVE_IEEEFP_H 168 # include <ieeefp.h> 169 # endif 170 # define isinf(x) (!finite(x) && !isnan(x)) 171 # elif defined(__cplusplus) && __cplusplus >= 201103L 172 # include <cmath> // it must include constexpr bool isinf(double); 173 # else 174 RUBY_EXTERN int isinf(double); 175 # endif 176 # endif 177 #endif 178 179 #ifndef isnan 180 # ifndef HAVE_ISNAN 181 # if defined(__cplusplus) && __cplusplus >= 201103L 182 # include <cmath> // it must include constexpr bool isnan(double); 183 # else 184 RUBY_EXTERN int isnan(double); 185 # endif 186 # endif 187 #endif 188 189 #ifndef isfinite 190 # ifndef HAVE_ISFINITE 191 # define HAVE_ISFINITE 1 192 # define isfinite(x) finite(x) 193 # endif 194 #endif 195 196 #ifndef HAVE_NAN 197 RUBY_EXTERN double nan(const char *); 198 #endif 199 200 #ifndef HAVE_NEXTAFTER 201 RUBY_EXTERN double nextafter(double x, double y); 202 #endif 203 204 /* 205 #ifndef HAVE_MEMCMP 206 RUBY_EXTERN int memcmp(const void *, const void *, size_t); 207 #endif 208 */ 209 210 #ifndef HAVE_MEMMOVE 211 RUBY_EXTERN void *memmove(void *, const void *, size_t); 212 #endif 213 214 /* 215 #ifndef HAVE_MODF 216 RUBY_EXTERN double modf(double, double *); 217 #endif 218 */ 219 220 #ifndef HAVE_STRCHR 221 RUBY_EXTERN char *strchr(const char *, int); 222 RUBY_EXTERN char *strrchr(const char *, int); 223 #endif 224 225 #ifndef HAVE_STRERROR 226 RUBY_EXTERN char *strerror(int); 227 #endif 228 229 #ifndef HAVE_STRSTR 230 RUBY_EXTERN char *strstr(const char *, const char *); 231 #endif 232 233 #ifndef HAVE_STRLCPY 234 RUBY_EXTERN size_t strlcpy(char *, const char*, size_t); 235 #endif 236 237 #ifndef HAVE_STRLCAT 238 RUBY_EXTERN size_t strlcat(char *, const char*, size_t); 239 #endif 240 241 #ifndef HAVE_SIGNBIT 242 RUBY_EXTERN int signbit(double x); 243 #endif 244 245 #ifndef HAVE_FFS 246 RUBY_EXTERN int ffs(int); 247 #endif 248 249 #ifdef BROKEN_CLOSE 250 #include <sys/types.h> 251 #include <sys/socket.h> 252 RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *); 253 RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *); 254 RUBY_EXTERN int ruby_shutdown(int, int); 255 RUBY_EXTERN int ruby_close(int); 256 #endif 257 258 #ifndef HAVE_SETPROCTITLE 259 RUBY_EXTERN void setproctitle(const char *fmt, ...); 260 #endif 261 262 #ifndef HAVE_EXPLICIT_BZERO 263 RUBY_EXTERN void explicit_bzero(void *b, size_t len); 264 # if defined SecureZeroMemory 265 # define explicit_bzero(b, len) SecureZeroMemory(b, len) 266 # endif 267 #endif 268 269 RUBY_SYMBOL_EXPORT_END 270 271 #if defined(__cplusplus) 272 #if 0 273 { /* satisfy cc-mode */ 274 #endif 275 } /* extern "C" { */ 276 #endif 277 278 #endif /* RUBY_MISSING_H */ 279