2002-05-11 15:31:18 -04:00
|
|
|
/************************************************
|
|
|
|
|
2002-09-17 09:52:45 -04:00
|
|
|
missing.h - prototype for *.c in ./missing, and
|
|
|
|
for missing timeval struct
|
2002-05-11 15:31:18 -04:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sat May 11 23:46:03 JST 2002
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#ifndef RUBY_MISSING_H
|
|
|
|
#define RUBY_MISSING_H 1
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#if 0
|
|
|
|
} /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
#endif
|
2002-05-11 15:31:18 -04:00
|
|
|
|
2010-07-27 05:33:55 -04:00
|
|
|
#include "ruby/config.h"
|
2011-02-03 02:37:22 -05:00
|
|
|
#include <stddef.h>
|
2012-06-19 17:24:31 -04:00
|
|
|
#include <math.h> /* for INFINITY and NAN */
|
2014-06-05 01:16:46 -04:00
|
|
|
#ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
|
|
|
|
# include RUBY_ALTERNATIVE_MALLOC_HEADER
|
|
|
|
#endif
|
2010-07-27 05:33:55 -04:00
|
|
|
#ifdef RUBY_EXTCONF_H
|
|
|
|
#include RUBY_EXTCONF_H
|
|
|
|
#endif
|
|
|
|
|
2013-03-16 11:16:32 -04:00
|
|
|
#if !defined(HAVE_STRUCT_TIMEVAL) || !defined(HAVE_STRUCT_TIMESPEC)
|
2013-03-16 03:28:32 -04:00
|
|
|
#if defined(HAVE_TIME_H)
|
|
|
|
# include <time.h>
|
|
|
|
#endif
|
2013-03-16 11:58:25 -04:00
|
|
|
#if defined(HAVE_SYS_TIME_H)
|
2013-03-16 03:28:32 -04:00
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2013-03-16 11:16:32 -04:00
|
|
|
#endif
|
2013-03-16 03:28:32 -04:00
|
|
|
|
2015-07-21 06:51:40 -04:00
|
|
|
#ifndef M_PI
|
|
|
|
# define M_PI 3.14159265358979323846
|
|
|
|
#endif
|
|
|
|
#ifndef M_PI_2
|
|
|
|
# define M_PI_2 (M_PI/2)
|
|
|
|
#endif
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
#ifndef RUBY_SYMBOL_EXPORT_BEGIN
|
|
|
|
# define RUBY_SYMBOL_EXPORT_BEGIN /* begin */
|
|
|
|
# define RUBY_SYMBOL_EXPORT_END /* end */
|
|
|
|
#endif
|
|
|
|
|
2013-03-16 01:06:47 -04:00
|
|
|
#if !defined(HAVE_STRUCT_TIMEVAL)
|
2002-09-17 09:52:45 -04:00
|
|
|
struct timeval {
|
|
|
|
time_t tv_sec; /* seconds */
|
* configure.in: check struct timespec, clock_gettime, utimensat,
struct stat.st_atim,
struct stat.st_atimespec,
struct stat.st_atimensec,
struct stat.st_mtim,
struct stat.st_mtimespec,
struct stat.st_mtimensec,
struct stat.st_ctim,
struct stat.st_ctimespec,
struct stat.st_ctimensec.
* include/ruby/missing.h: provide struct timespec if not available.
* time.c: support nanosecond-resolution using struct timespec.
* include/ruby/intern.h: provide rb_time_nano_new.
* file.c (utime_internal): use utimensat if available.
(rb_file_s_utime): refactored.
(rb_f_test): use stat_atime, stat_mtime, stat_ctime.
(rb_stat_cmp): check tv_nsec.
(stat_atimespec): new function.
(stat_atime): ditto.
(stat_mtimespec): ditto.
(stat_mtime): ditto.
(stat_ctimespec): ditto.
(stat_ctime): ditto.
(rb_stat_atime): use stat_atime.
(rb_file_s_atime): ditto.
(rb_file_atime): ditto.
(rb_stat_mtime): use stat_mtime.
(rb_file_s_mtime): ditto.
(rb_file_mtime): ditto.
(rb_file_ctime): use stat_ctime.
(rb_file_s_ctime): ditto.
(rb_stat_ctime): ditto.
* variable.c (rb_copy_generic_ivar): clear clone's instance variables
if obj has no instance variable.
* marshal.c (w_object): dump instance variables of generated string
for TYPE_USERDEF, even if original object has instance variables.
* lib/time.rb (Time#xmlschema): use nsec instead of usec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-19 04:09:38 -05:00
|
|
|
long tv_usec; /* microseconds */
|
2002-09-17 09:52:45 -04:00
|
|
|
};
|
2013-03-16 01:06:47 -04:00
|
|
|
#endif /* HAVE_STRUCT_TIMEVAL */
|
|
|
|
|
* configure.in: check struct timespec, clock_gettime, utimensat,
struct stat.st_atim,
struct stat.st_atimespec,
struct stat.st_atimensec,
struct stat.st_mtim,
struct stat.st_mtimespec,
struct stat.st_mtimensec,
struct stat.st_ctim,
struct stat.st_ctimespec,
struct stat.st_ctimensec.
* include/ruby/missing.h: provide struct timespec if not available.
* time.c: support nanosecond-resolution using struct timespec.
* include/ruby/intern.h: provide rb_time_nano_new.
* file.c (utime_internal): use utimensat if available.
(rb_file_s_utime): refactored.
(rb_f_test): use stat_atime, stat_mtime, stat_ctime.
(rb_stat_cmp): check tv_nsec.
(stat_atimespec): new function.
(stat_atime): ditto.
(stat_mtimespec): ditto.
(stat_mtime): ditto.
(stat_ctimespec): ditto.
(stat_ctime): ditto.
(rb_stat_atime): use stat_atime.
(rb_file_s_atime): ditto.
(rb_file_atime): ditto.
(rb_stat_mtime): use stat_mtime.
(rb_file_s_mtime): ditto.
(rb_file_mtime): ditto.
(rb_file_ctime): use stat_ctime.
(rb_file_s_ctime): ditto.
(rb_stat_ctime): ditto.
* variable.c (rb_copy_generic_ivar): clear clone's instance variables
if obj has no instance variable.
* marshal.c (w_object): dump instance variables of generated string
for TYPE_USERDEF, even if original object has instance variables.
* lib/time.rb (Time#xmlschema): use nsec instead of usec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-19 04:09:38 -05:00
|
|
|
#if !defined(HAVE_STRUCT_TIMESPEC)
|
|
|
|
struct timespec {
|
|
|
|
time_t tv_sec; /* seconds */
|
|
|
|
long tv_nsec; /* nanoseconds */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2010-01-12 16:54:47 -05:00
|
|
|
#if !defined(HAVE_STRUCT_TIMEZONE)
|
|
|
|
struct timezone {
|
|
|
|
int tz_minuteswest;
|
|
|
|
int tz_dsttime;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2010-07-28 06:39:33 -04:00
|
|
|
#ifdef RUBY_EXPORT
|
|
|
|
#undef RUBY_EXTERN
|
|
|
|
#endif
|
2008-11-03 02:32:57 -05:00
|
|
|
#ifndef RUBY_EXTERN
|
|
|
|
#define RUBY_EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2002-05-11 15:31:18 -04:00
|
|
|
#ifndef HAVE_ACOSH
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double acosh(double);
|
|
|
|
RUBY_EXTERN double asinh(double);
|
|
|
|
RUBY_EXTERN double atanh(double);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_CRYPT
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN char *crypt(const char *, const char *);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_DUP2
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int dup2(int, int);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
2006-01-25 08:30:11 -05:00
|
|
|
#ifndef HAVE_EACCESS
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int eaccess(const char*, int);
|
2006-01-25 08:30:11 -05:00
|
|
|
#endif
|
|
|
|
|
2011-06-03 07:58:11 -04:00
|
|
|
#ifndef HAVE_ROUND
|
|
|
|
RUBY_EXTERN double round(double); /* numeric.c */
|
|
|
|
#endif
|
|
|
|
|
2002-05-11 15:31:18 -04:00
|
|
|
#ifndef HAVE_FINITE
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int finite(double);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_FLOCK
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int flock(int, int);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
#ifndef HAVE_FREXP
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double frexp(double, int *);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HAVE_HYPOT
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double hypot(double, double);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
2003-06-05 02:40:42 -04:00
|
|
|
#ifndef HAVE_ERF
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double erf(double);
|
|
|
|
RUBY_EXTERN double erfc(double);
|
2003-06-05 02:40:42 -04:00
|
|
|
#endif
|
|
|
|
|
2008-02-06 20:43:43 -05:00
|
|
|
#ifndef HAVE_TGAMMA
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double tgamma(double);
|
2008-02-06 20:43:43 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_LGAMMA_R
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double lgamma_r(double, int *);
|
2008-02-06 20:43:43 -05:00
|
|
|
#endif
|
|
|
|
|
2008-03-06 00:06:30 -05:00
|
|
|
#ifndef HAVE_CBRT
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double cbrt(double);
|
2008-03-06 00:06:30 -05:00
|
|
|
#endif
|
|
|
|
|
2015-10-20 03:15:16 -04:00
|
|
|
#if !defined(HAVE_INFINITY) || !defined(HAVE_NAN)
|
2011-10-21 13:34:58 -04:00
|
|
|
union bytesequence4_or_float {
|
|
|
|
unsigned char bytesequence[4];
|
|
|
|
float float_value;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-10-19 12:29:31 -04:00
|
|
|
#ifndef INFINITY
|
2011-06-06 02:11:37 -04:00
|
|
|
/** @internal */
|
2011-10-21 13:34:58 -04:00
|
|
|
RUBY_EXTERN const union bytesequence4_or_float rb_infinity;
|
|
|
|
# define INFINITY (rb_infinity.float_value)
|
2011-06-06 02:11:37 -04:00
|
|
|
#endif
|
|
|
|
|
2015-10-19 12:29:31 -04:00
|
|
|
#ifndef NAN
|
2011-06-06 02:11:37 -04:00
|
|
|
/** @internal */
|
2011-10-21 13:34:58 -04:00
|
|
|
RUBY_EXTERN const union bytesequence4_or_float rb_nan;
|
|
|
|
# define NAN (rb_nan.float_value)
|
2011-06-06 02:11:37 -04:00
|
|
|
#endif
|
2018-01-18 20:45:36 -05:00
|
|
|
|
|
|
|
#ifndef HUGE_VAL
|
|
|
|
# define HUGE_VAL ((double)INFINITY)
|
|
|
|
#endif
|
2011-06-06 02:11:37 -04:00
|
|
|
|
2006-01-01 01:34:48 -05:00
|
|
|
#ifndef isinf
|
|
|
|
# ifndef HAVE_ISINF
|
|
|
|
# if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
|
2011-06-15 20:12:55 -04:00
|
|
|
# ifdef HAVE_IEEEFP_H
|
|
|
|
# include <ieeefp.h>
|
|
|
|
# endif
|
2006-01-01 01:34:48 -05:00
|
|
|
# define isinf(x) (!finite(x) && !isnan(x))
|
|
|
|
# else
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int isinf(double);
|
2006-01-01 01:34:48 -05:00
|
|
|
# endif
|
2003-12-22 03:23:55 -05:00
|
|
|
# endif
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
2010-06-11 10:00:35 -04:00
|
|
|
#ifndef isnan
|
|
|
|
# ifndef HAVE_ISNAN
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int isnan(double);
|
2010-06-11 10:00:35 -04:00
|
|
|
# endif
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
2016-05-23 08:33:39 -04:00
|
|
|
#ifndef isfinite
|
|
|
|
# ifndef HAVE_ISFINITE
|
|
|
|
# define HAVE_ISFINITE 1
|
|
|
|
# define isfinite(x) finite(x)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 20:37:10 -04:00
|
|
|
#ifndef HAVE_NEXTAFTER
|
|
|
|
RUBY_EXTERN double nextafter(double x, double y);
|
|
|
|
#endif
|
|
|
|
|
2002-05-11 15:31:18 -04:00
|
|
|
/*
|
|
|
|
#ifndef HAVE_MEMCMP
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN int memcmp(const void *, const void *, size_t);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HAVE_MEMMOVE
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN void *memmove(void *, const void *, size_t);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
#ifndef HAVE_MODF
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN double modf(double, double *);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HAVE_STRCHR
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN char *strchr(const char *, int);
|
|
|
|
RUBY_EXTERN char *strrchr(const char *, int);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRERROR
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN char *strerror(int);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRSTR
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN char *strstr(const char *, const char *);
|
2002-05-11 15:31:18 -04:00
|
|
|
#endif
|
|
|
|
|
2007-03-19 04:01:40 -04:00
|
|
|
#ifndef HAVE_STRLCPY
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
|
2007-03-19 04:01:40 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRLCAT
|
2008-11-03 02:32:57 -05:00
|
|
|
RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
|
2007-03-19 04:01:40 -04:00
|
|
|
#endif
|
|
|
|
|
2010-05-15 22:39:18 -04:00
|
|
|
#ifndef HAVE_SIGNBIT
|
|
|
|
RUBY_EXTERN int signbit(double x);
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 09:23:20 -04:00
|
|
|
#ifndef HAVE_FFS
|
|
|
|
RUBY_EXTERN int ffs(int);
|
|
|
|
#endif
|
|
|
|
|
2010-07-25 23:05:25 -04:00
|
|
|
#ifdef BROKEN_CLOSE
|
2010-07-22 01:41:54 -04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *);
|
|
|
|
RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *);
|
|
|
|
RUBY_EXTERN int ruby_shutdown(int, int);
|
|
|
|
RUBY_EXTERN int ruby_close(int);
|
|
|
|
#endif
|
|
|
|
|
2011-05-14 06:49:47 -04:00
|
|
|
#ifndef HAVE_SETPROCTITLE
|
|
|
|
RUBY_EXTERN void setproctitle(const char *fmt, ...);
|
|
|
|
#endif
|
|
|
|
|
2015-11-30 15:26:13 -05:00
|
|
|
#ifndef HAVE_EXPLICIT_BZERO
|
|
|
|
RUBY_EXTERN void explicit_bzero(void *b, size_t len);
|
2016-01-10 01:45:36 -05:00
|
|
|
# if defined SecureZeroMemory
|
2015-11-30 20:39:24 -05:00
|
|
|
# define explicit_bzero(b, len) SecureZeroMemory(b, len)
|
2015-11-30 20:24:23 -05:00
|
|
|
# endif
|
2015-11-30 15:26:13 -05:00
|
|
|
#endif
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if 0
|
|
|
|
{ /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
} /* extern "C" { */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RUBY_MISSING_H */
|