Skip to content

Commit

Permalink
* configure.in: check struct timeval exist or not.
Browse files Browse the repository at this point in the history
* include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL
  properly. and don't include sys/time.h if struct timeval exist.

* file.c: include sys/time.h explicitly.
* random.c: ditto.
* thread_pthread.c: ditto.
* time.c: ditto.
* ext/date/date_strftime.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
kosaki committed Mar 16, 2013
1 parent 2e54447 commit 798ff85
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 3 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Wed Mar 13 13:54:45 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>

* configure.in: check struct timeval exist or not.
* include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL
properly. and don't include sys/time.h if struct timeval exist.

* file.c: include sys/time.h explicitly.
* random.c: ditto.
* thread_pthread.c: ditto.
* time.c: ditto.
* ext/date/date_strftime.c: ditto.

Fri Mar 15 14:45:02 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>

* configure.in (_FORTIFY_SOURCE): added a few comments.
Expand Down
7 changes: 7 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,13 @@ AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])

AC_CHECK_TYPES([struct timeval], [], [], [@%:@ifdef HAVE_TIME_H
@%:@include <time.h>
@%:@endif
@%:@ifdef HAVE_SYS_TIME_H
@%:@include <sys/time.h>
@%:@endif])

AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
@%:@include <time.h>
@%:@endif
Expand Down
4 changes: 4 additions & 0 deletions ext/date/date_strftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <ctype.h>
#include <errno.h>

#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

#undef strchr /* avoid AIX weirdness */

#define range(low, item, hi) (item)
Expand Down
4 changes: 4 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ int flock(int, int);
#include <fcntl.h>
#endif

#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

#if !defined HAVE_LSTAT && !defined lstat
#define lstat stat
#endif
Expand Down
9 changes: 6 additions & 3 deletions include/ruby/missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ extern "C" {
#include RUBY_EXTCONF_H
#endif

#if defined(HAVE_SYS_TIME_H)
#if !defined(HAVE_STRUCT_TIMEVAL)
# if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
#elif !defined(_WIN32)
# elif !defined(_WIN32)
# define time_t long
struct timeval {
time_t tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
#endif
# endif
#endif /* HAVE_STRUCT_TIMEVAL */

#if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h>
#endif
Expand Down
3 changes: 3 additions & 0 deletions random.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ The original copyright notice follows.
#endif
#include <math.h>
#include <errno.h>
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

#ifdef _WIN32
# if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400
Expand Down
3 changes: 3 additions & 0 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#if HAVE_POLL
#include <poll.h>
#endif
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

static void native_mutex_lock(pthread_mutex_t *lock);
static void native_mutex_unlock(pthread_mutex_t *lock);
Expand Down
4 changes: 4 additions & 0 deletions time.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <strings.h>
#endif

#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

#include "timev.h"

static ID id_divmod, id_mul, id_submicro, id_nano_num, id_nano_den, id_offset, id_zone;
Expand Down

0 comments on commit 798ff85

Please sign in to comment.