mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/win32.h, win32/Makefile.sub, win32/win32.c
(clock_gettime): [experimental] emulates clock_gettime(2) of posix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3670ca436e
commit
866cee6162
4 changed files with 54 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Aug 15 14:30:23 2013 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* include/ruby/win32.h, win32/Makefile.sub, win32/win32.c
|
||||||
|
(clock_gettime): [experimental] emulates clock_gettime(2) of posix.
|
||||||
|
|
||||||
Thu Aug 15 02:32:40 2013 Zachary Scott <e@zzak.io>
|
Thu Aug 15 02:32:40 2013 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick
|
* hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick
|
||||||
|
|
|
@ -124,6 +124,10 @@ typedef unsigned int uintptr_t;
|
||||||
|
|
||||||
#define WNOHANG -1
|
#define WNOHANG -1
|
||||||
|
|
||||||
|
typedef int clockid_t;
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#define CLOCK_MONOTINIC 1
|
||||||
|
|
||||||
#undef getc
|
#undef getc
|
||||||
#undef putc
|
#undef putc
|
||||||
#undef fgetc
|
#undef fgetc
|
||||||
|
@ -312,6 +316,7 @@ extern int rb_w32_uchown(const char *, int, int);
|
||||||
extern int link(const char *, const char *);
|
extern int link(const char *, const char *);
|
||||||
extern int rb_w32_ulink(const char *, const char *);
|
extern int rb_w32_ulink(const char *, const char *);
|
||||||
extern int gettimeofday(struct timeval *, struct timezone *);
|
extern int gettimeofday(struct timeval *, struct timezone *);
|
||||||
|
extern int clock_gettime(clockid_t, struct timespec *);
|
||||||
extern rb_pid_t waitpid (rb_pid_t, int *, int);
|
extern rb_pid_t waitpid (rb_pid_t, int *, int);
|
||||||
extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
|
extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
|
||||||
extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
|
extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
|
||||||
|
|
|
@ -536,6 +536,8 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
||||||
#define TIMET2NUM(v) LONG2NUM(v)
|
#define TIMET2NUM(v) LONG2NUM(v)
|
||||||
#define NUM2TIMET(v) NUM2LONG(v)
|
#define NUM2TIMET(v) NUM2LONG(v)
|
||||||
!endif
|
!endif
|
||||||
|
#define CLOCKID2NUM(v) INT2NUM(v)
|
||||||
|
#define NUM2CLOCKID(v) NUM2INT(v)
|
||||||
#define SIZEOF_RLIM_T 0
|
#define SIZEOF_RLIM_T 0
|
||||||
!if "$(ARCH)" == "x64" || "$(ARCH)" == "ia64"
|
!if "$(ARCH)" == "x64" || "$(ARCH)" == "ia64"
|
||||||
#define SIZEOF_SIZE_T 8
|
#define SIZEOF_SIZE_T 8
|
||||||
|
@ -638,6 +640,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
||||||
#define HAVE_MEMCMP 1
|
#define HAVE_MEMCMP 1
|
||||||
#define HAVE_MEMMOVE 1
|
#define HAVE_MEMMOVE 1
|
||||||
#define HAVE_MKDIR 1
|
#define HAVE_MKDIR 1
|
||||||
|
#define HAVE_CLOCK_GETTIME 1
|
||||||
#define HAVE_SPAWNV 1
|
#define HAVE_SPAWNV 1
|
||||||
#define HAVE_STRCASECMP 1
|
#define HAVE_STRCASECMP 1
|
||||||
#define HAVE_STRNCASECMP 1
|
#define HAVE_STRNCASECMP 1
|
||||||
|
|
|
@ -4309,6 +4309,47 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* License: Ruby's */
|
||||||
|
typedef int clockid_t;
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#define CLOCK_MONOTONIC 1
|
||||||
|
int
|
||||||
|
clock_gettime(clockid_t clock_id, struct timespec *sp)
|
||||||
|
{
|
||||||
|
switch (clock_id) {
|
||||||
|
case CLOCK_REALTIME:
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
sp->tv_sec = tv.tv_sec;
|
||||||
|
sp->tv_nsec = tv.tv_usec * 1000;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case CLOCK_MONOTONIC:
|
||||||
|
{
|
||||||
|
LARGE_INTEGER freq;
|
||||||
|
LARGE_INTEGER count;
|
||||||
|
if (!QueryPerformanceFrequency(&freq)) {
|
||||||
|
errno = map_errno(GetLastError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!QueryPerformanceCounter(&count)) {
|
||||||
|
errno = map_errno(GetLastError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sp->tv_sec = count.QuadPart / freq.QuadPart;
|
||||||
|
if (freq.QuadPart < 1000000000)
|
||||||
|
sp->tv_nsec = (count.QuadPart % freq.QuadPart) * (1000000000 / freq.QuadPart);
|
||||||
|
else
|
||||||
|
sp->tv_nsec = (long)((count.QuadPart % freq.QuadPart) * (1000000000.0 / freq.QuadPart));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
char *
|
char *
|
||||||
rb_w32_getcwd(char *buffer, int size)
|
rb_w32_getcwd(char *buffer, int size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue