# define longjmp PerlProc_longjmp
# define signal PerlProc_signal
# define getpid PerlProc_getpid
+# define gettimeofday PerlProc_gettimeofday
# define htonl PerlSock_htonl
# define htons PerlSock_htons
# define ntohl PerlSock_ntohl
return 0;
}
-#if !defined(HAS_GETTIMEOFDAY) && defined(WIN32)
-#define HAS_GETTIMEOFDAY
-
-/* shows up in winsock.h?
-struct timeval {
- long tv_sec;
- long tv_usec;
-}
-*/
-
-typedef union {
- unsigned __int64 ft_i64;
- FILETIME ft_val;
-} FT_t;
-
-/* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
-#ifdef __GNUC__
-#define Const64(x) x##LL
-#else
-#define Const64(x) x##i64
-#endif
-#define EPOCH_BIAS Const64(116444736000000000)
-
-/* NOTE: This does not compute the timezone info (doing so can be expensive,
- * and appears to be unsupported even by glibc) */
-int
-gettimeofday (struct timeval *tp, void *not_used)
-{
- FT_t ft;
-
- /* this returns time in 100-nanosecond units (i.e. tens of usecs) */
- GetSystemTimeAsFileTime(&ft.ft_val);
-
- /* seconds since epoch */
- tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
-
- /* microseconds remaining */
- tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
-
- return 0;
-}
-#endif
-
#if !defined(HAS_GETTIMEOFDAY) && defined(VMS)
#define HAS_GETTIMEOFDAY
{
struct timeval Tp;
int status;
- status = gettimeofday (&Tp, NULL);
+ status = PerlProc_gettimeofday(&Tp,NULL);
ret[0] = Tp.tv_sec;
ret[1] = Tp.tv_usec;
return status;
{
struct timeval Tp;
int status;
- status = gettimeofday (&Tp, NULL);
+ status = PerlProc_gettimeofday(&Tp,NULL);
return status == 0 ? Tp.tv_sec + (Tp.tv_usec / 1000000.) : -1.0;
}
PREINIT:
struct timeval Ta, Tb;
CODE:
- gettimeofday(&Ta, NULL);
+ PerlProc_gettimeofday(&Ta,NULL);
if (items > 0) {
if (useconds > 1E6) {
IV seconds = (IV) (useconds / 1E6);
usleep((UV)useconds);
} else
PerlProc_pause();
- gettimeofday(&Tb, NULL);
+ PerlProc_gettimeofday(&Tb,NULL);
#if 0
printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec);
#endif
PREINIT:
struct timeval Ta, Tb;
CODE:
- gettimeofday(&Ta, NULL);
+ PerlProc_gettimeofday(&Ta,NULL);
if (items > 0) {
NV seconds = SvNV(ST(0));
if (seconds >= 0.0) {
croak("Time::HiRes::sleep(%"NVgf"): negative time not invented yet", seconds);
} else
PerlProc_pause();
- gettimeofday(&Tb, NULL);
+ PerlProc_gettimeofday(&Tb,NULL);
#if 0
printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec);
#endif
struct timezone Tz;
PPCODE:
int status;
- status = gettimeofday (&Tp, &Tz);
+ status = PerlProc_gettimeofday(&Tp,&Tz);
Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
if (GIMME == G_ARRAY) {
struct timezone Tz;
CODE:
int status;
- status = gettimeofday (&Tp, &Tz);
+ status = PerlProc_gettimeofday(&Tp,&Tz);
Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0);
OUTPUT:
struct timeval Tp;
PPCODE:
int status;
- status = gettimeofday (&Tp, NULL);
+ status = PerlProc_gettimeofday(&Tp,NULL);
if (GIMME == G_ARRAY) {
EXTEND(sp, 2);
PUSHs(sv_2mortal(newSViv(Tp.tv_sec)));
struct timeval Tp;
CODE:
int status;
- status = gettimeofday (&Tp, NULL);
+ status = PerlProc_gettimeofday(&Tp,NULL);
RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.);
OUTPUT:
RETVAL
typedef int (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**);
#endif
typedef int (*LPProcLastHost)(struct IPerlProc*);
+typedef int (*LPProcGetTimeOfDay)(struct IPerlProc*,
+ struct timeval*, void*);
struct IPerlProc
{
#endif
LPProcLastHost pLastHost;
LPProcPopenList pPopenList;
+ LPProcGetTimeOfDay pGetTimeOfDay;
};
struct IPerlProcInfo
#endif
#define PerlProc_lasthost() \
(*PL_Proc->pLastHost)(PL_Proc)
+#define PerlProc_gettimeofday(t,z) \
+ (*PL_Proc->pGetTimeOfDay)(PL_Proc,(t),(z))
#else /* PERL_IMPLICIT_SYS */
#define PerlProc_signal(n, h) signal((n), (h))
#define PerlProc_fork() my_fork()
#define PerlProc_getpid() getpid()
+#define PerlProc_gettimeofday(t,z) gettimeofday((t),(z))
#ifdef WIN32
#define PerlProc_DynaLoad(f) \
win32_link
win32_unlink
win32_utime
+ win32_gettimeofday
win32_uname
win32_wait
win32_waitpid
u = (U32)SEED_C1 * when[0] + (U32)SEED_C2 * when[1];
#else
# ifdef HAS_GETTIMEOFDAY
- gettimeofday(&when,(struct timezone *) 0);
+ PerlProc_gettimeofday(&when,NULL);
u = (U32)SEED_C1 * when.tv_sec + (U32)SEED_C2 * when.tv_usec;
# else
(void)time(&when);
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
d_getsent='undef'
d_getservprotos='define'
d_getspnam='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gnulibc='undef'
d_grpasswd='undef'
d_hasmntopt='undef'
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
d_finitel='undef'
d_flexfnam='define'
d_flock='define'
-d_flockproto='undef'
+d_flockproto='define'
d_fork='undef'
d_fp_class='undef'
d_fpathconf='undef'
d_getservprotos='define'
d_getspnam='undef'
d_getspnam_r='undef'
-d_gettimeod='undef'
+d_gettimeod='define'
d_gmtime_r='undef'
d_gnulibc='undef'
d_grpasswd='undef'
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
* <sys/resource.h> needs to be included (see I_SYS_RESOURCE).
* The type "Timeval" should be used to refer to "struct timeval".
*/
-/*#define HAS_GETTIMEOFDAY /**/
+#define HAS_GETTIMEOFDAY /**/
#ifdef HAS_GETTIMEOFDAY
#define Timeval struct timeval /* Structure used by gettimeofday() */
#endif
* to the program to supply one. A good guess is
* extern int flock(int, int);
*/
-/*#define HAS_FLOCK_PROTO /**/
+#define HAS_FLOCK_PROTO /**/
/* HAS_FPCLASSL:
* This symbol, if defined, indicates that the fpclassl routine is
return win32_signal(sig, subcode);
}
+int
+PerlProcGetTimeOfDay(struct IPerlProc* piPerl, struct timeval *t, void *z)
+{
+ return win32_gettimeofday(t, z);
+}
+
#ifdef USE_ITHREADS
static THREAD_RET_TYPE
win32_start_child(LPVOID arg)
PerlProcSpawnvp,
PerlProcASpawn,
PerlProcLastHost,
- PerlProcPopenList
+ PerlProcPopenList,
+ PerlProcGetTimeOfDay
};
return rc;
}
+typedef union {
+ unsigned __int64 ft_i64;
+ FILETIME ft_val;
+} FT_t;
+
+#ifdef __GNUC__
+#define Const64(x) x##LL
+#else
+#define Const64(x) x##i64
+#endif
+/* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
+#define EPOCH_BIAS Const64(116444736000000000)
+
+/* NOTE: This does not compute the timezone info (doing so can be expensive,
+ * and appears to be unsupported even by glibc) */
+DllExport int
+win32_gettimeofday(struct timeval *tp, void *not_used)
+{
+ FT_t ft;
+
+ /* this returns time in 100-nanosecond units (i.e. tens of usecs) */
+ GetSystemTimeAsFileTime(&ft.ft_val);
+
+ /* seconds since epoch */
+ tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
+
+ /* microseconds remaining */
+ tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
+
+ return 0;
+}
+
DllExport int
win32_uname(struct utsname *name)
{
DllExport int win32_link(const char *oldname, const char *newname);
DllExport int win32_unlink(const char *f);
DllExport int win32_utime(const char *f, struct utimbuf *t);
+DllExport int win32_gettimeofday(struct timeval *tp, void *not_used);
DllExport int win32_uname(struct utsname *n);
DllExport int win32_wait(int *status);
DllExport int win32_waitpid(int pid, int *status, int flags);
#undef ioctl
#undef unlink
#undef utime
+#undef gettimeofday
#undef uname
#undef wait
#define link win32_link
#define unlink win32_unlink
#define utime win32_utime
+#define gettimeofday win32_gettimeofday
#define uname win32_uname
#define wait win32_wait
#define waitpid win32_waitpid