Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
missing.h
1#ifndef RUBY_MISSING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_MISSING_H 1
12#include "ruby/internal/config.h"
13
14#ifdef STDC_HEADERS
15# include <stddef.h>
16#endif
17
18#if defined(__cplusplus)
19# include <cmath>
20#else
21# include <math.h> /* for INFINITY and NAN */
22#endif
23
24#ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
25# include RUBY_ALTERNATIVE_MALLOC_HEADER
26#endif
27
28#if defined(HAVE_TIME_H)
29# include <time.h>
30#endif
31
32#if defined(HAVE_SYS_TIME_H)
33# include <sys/time.h>
34#endif
35
36#ifdef HAVE_IEEEFP_H
37# include <ieeefp.h>
38#endif
39
42
43#ifndef M_PI
44# define M_PI 3.14159265358979323846
45#endif
46#ifndef M_PI_2
47# define M_PI_2 (M_PI/2)
48#endif
49
50#if !defined(HAVE_STRUCT_TIMEVAL)
51struct timeval {
52 time_t tv_sec; /* seconds */
53 long tv_usec; /* microseconds */
54};
55#endif /* HAVE_STRUCT_TIMEVAL */
56
57#if !defined(HAVE_STRUCT_TIMESPEC)
58/* :BEWARE: @shyouhei warns that IT IS A WRONG IDEA to define our own version
59 * of struct timespec here. `clock_gettime` is a system call, and your kernel
60 * could expect something other than just `long` (results stack smashing if
61 * that happens). See also https://ewontfix.com/19/ */
62struct timespec {
63 time_t tv_sec; /* seconds */
64 long tv_nsec; /* nanoseconds */
65};
66#endif
67
68#if !defined(HAVE_STRUCT_TIMEZONE)
69struct timezone {
70 int tz_minuteswest;
71 int tz_dsttime;
72};
73#endif
74
76
77#ifndef HAVE_ACOSH
78RUBY_EXTERN double acosh(double);
79RUBY_EXTERN double asinh(double);
80RUBY_EXTERN double atanh(double);
81#endif
82
83#ifndef HAVE_CRYPT
84RUBY_EXTERN char *crypt(const char *, const char *);
85#endif
86
87#ifndef HAVE_EACCESS
88RUBY_EXTERN int eaccess(const char*, int);
89#endif
90
91#ifndef HAVE_ROUND
92RUBY_EXTERN double round(double); /* numeric.c */
93#endif
94
95#ifndef HAVE_FLOCK
96RUBY_EXTERN int flock(int, int);
97#endif
98
99/*
100#ifndef HAVE_FREXP
101RUBY_EXTERN double frexp(double, int *);
102#endif
103*/
104
105#ifndef HAVE_HYPOT
106RUBY_EXTERN double hypot(double, double);
107#endif
108
109#ifndef HAVE_ERF
110RUBY_EXTERN double erf(double);
111RUBY_EXTERN double erfc(double);
112#endif
113
114#ifndef HAVE_TGAMMA
115RUBY_EXTERN double tgamma(double);
116#endif
117
118#ifndef HAVE_LGAMMA_R
119RUBY_EXTERN double lgamma_r(double, int *);
120#endif
121
122#ifndef HAVE_CBRT
123RUBY_EXTERN double cbrt(double);
124#endif
125
126#if !defined(INFINITY) || !defined(NAN)
128 unsigned char bytesequence[4];
129 float float_value;
130};
131#endif
132
133#ifndef INFINITY
135RUBY_EXTERN const union bytesequence4_or_float rb_infinity;
136# define INFINITY (rb_infinity.float_value)
137# define USE_RB_INFINITY 1
138#endif
139
140#ifndef NAN
142RUBY_EXTERN const union bytesequence4_or_float rb_nan;
143# define NAN (rb_nan.float_value)
144# define USE_RB_NAN 1
145#endif
146
147#ifndef HUGE_VAL
148# define HUGE_VAL ((double)INFINITY)
149#endif
150
151#ifndef HAVE_FINITE
152# define HAVE_FINITE 1
153# define finite(x) isfinite(x)
154#endif
155
156#ifndef HAVE_NAN
157RUBY_EXTERN double nan(const char *);
158#endif
159
160#ifndef HAVE_NEXTAFTER
161RUBY_EXTERN double nextafter(double x, double y);
162#endif
163
164/*
165#ifndef HAVE_MEMCMP
166RUBY_EXTERN int memcmp(const void *, const void *, size_t);
167#endif
168*/
169
170#ifndef HAVE_MEMMOVE
171RUBY_EXTERN void *memmove(void *, const void *, size_t);
172#endif
173
174/*
175#ifndef HAVE_MODF
176RUBY_EXTERN double modf(double, double *);
177#endif
178*/
179
180#ifndef HAVE_STRCHR
181RUBY_EXTERN char *strchr(const char *, int);
182RUBY_EXTERN char *strrchr(const char *, int);
183#endif
184
185#ifndef HAVE_STRERROR
186RUBY_EXTERN char *strerror(int);
187#endif
188
189#ifndef HAVE_STRSTR
190RUBY_EXTERN char *strstr(const char *, const char *);
191#endif
192
193#ifndef HAVE_STRLCPY
194RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
195#endif
196
197#ifndef HAVE_STRLCAT
198RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
199#endif
200
201#ifndef HAVE_FFS
202RUBY_EXTERN int ffs(int);
203#endif
204
205#ifdef BROKEN_CLOSE
206# include <sys/types.h>
207# include <sys/socket.h>
208RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *);
209RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *);
210RUBY_EXTERN int ruby_shutdown(int, int);
211RUBY_EXTERN int ruby_close(int);
212#endif
213
214#ifndef HAVE_SETPROCTITLE
215RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
216RUBY_EXTERN void setproctitle(const char *fmt, ...);
217#endif
218
219#ifdef HAVE_EXPLICIT_BZERO
220# /* Take that. */
221#elif defined(SecureZeroMemory)
222# define explicit_bzero(b, len) SecureZeroMemory(b, len)
223#else
224RUBY_EXTERN void explicit_bzero(void *b, size_t len);
225#endif
226
228
229#endif /* RUBY_MISSING_H */
Tweaking visibility of C variables/functions.
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition: dllexport.h:47
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
Defines RBIMPL_ATTR_FORMAT.
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format))
Definition: format.h:27