#ifdef __cplusplus
extern "C" {
#endif
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef WIN32
#include <time.h>
#else
#endif
#ifdef HAS_SELECT
# ifdef I_SYS_SELECT
# endif
#endif
#ifdef __cplusplus
}
#endif
#ifndef NOOP
# define NOOP (void)0
#endif
#ifndef dNOOP
# define dNOOP extern int Perl___notused
#endif
#ifndef aTHX_
# define aTHX_
# define pTHX_
#endif
#ifdef START_MY_CXT
# ifndef MY_CXT_CLONE
# define MY_CXT_CLONE \
dMY_CXT_SV; \
# endif
#else
# define MY_CXT_INIT NOOP
# define MY_CXT_CLONE NOOP
#endif
#ifndef NVTYPE
# if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
# define NVTYPE long double
# else
# define NVTYPE double
# endif
#endif
#ifndef IVdf
# ifdef IVSIZE
# define IVdf "ld"
# define UVuf "lu"
# else
# define IVdf "d"
# define UVuf "u"
# endif
# endif
# else
# define IVdf "ld"
# define UVuf "lu"
# endif
#endif
#ifndef NVef
# if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
defined(PERL_PRIgldbl) /* Not very likely, but let's try anyway. */
# define NVgf PERL_PRIgldbl
# else
# define NVgf "g"
# endif
#endif
#ifndef INT2PTR
#else
# define PTRV unsigned long
# else
# define PTRV unsigned
# endif
#endif
#endif /* !INT2PTR */
#ifndef SvPV_nolen
static char *
{
}
# define SvPV_nolen(sv) \
#endif
#ifndef PerlProc_pause
# define PerlProc_pause() Pause()
#endif
/* Though the cpp define ITIMER_VIRTUAL is available the functionality
* is not supported in Cygwin as of August 2002, ditto for Win32.
* Neither are ITIMER_PROF or ITIMER_REALPROF implemented. --jhi
*/
#if defined(__CYGWIN__) || defined(WIN32)
#endif
/* 5.004 doesn't define PL_sv_undef */
#ifndef ATLEASTFIVEOHOHFIVE
#ifndef PL_sv_undef
#define PL_sv_undef sv_undef
#endif
#endif
#include "const-c.inc"
#ifdef WIN32
#ifndef HAS_GETTIMEOFDAY
# define HAS_GETTIMEOFDAY
#endif
/* shows up in winsock.h?
struct timeval {
long tv_sec;
long tv_usec;
}
*/
typedef union {
} FT_t;
typedef struct {
unsigned long run_count;
unsigned __int64 base_ticks;
unsigned __int64 tick_frequency;
} my_cxt_t;
/* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
#ifdef __GNUC__
#else
#endif
/* NOTE: This does not compute the timezone info (doing so can be expensive,
* and appears to be unsupported even by glibc) */
/* dMY_CXT needs a Perl context and we don't want to call PERL_GET_CONTEXT
for performance reasons */
/* If the performance counter delta drifts more than 0.5 seconds from the
* system time then we recalibrate to the system time. This means we may
* move *backwards* in time! */
static int
{
}
}
else {
}
/* seconds since epoch */
/* microseconds remaining */
return 0;
}
#endif
#if defined(WIN32) && !defined(ATLEASTFIVEOHOHFIVE)
static unsigned int
sleep(unsigned int t)
{
Sleep(t*1000);
return 0;
}
#endif
#if !defined(HAS_GETTIMEOFDAY) && defined(VMS)
#define HAS_GETTIMEOFDAY
#include <lnmdef.h>
#include <time.h> /* gettimeofday */
#include <stdlib.h> /* qdiv */
#include <starlet.h> /* sys$gettim */
#include <descrip.h>
#ifdef __VAX
#endif
/*
VMS binary time is expressed in 100 nano-seconds since
system base time which is 17-NOV-1858 00:00:00.00
*/
#define DIV_100NS_TO_SECS 10000000L
#define DIV_100NS_TO_USECS 10L
/*
gettimeofday is supposed to return times since the epoch
so need to determine this in terms of VMS base time
*/
#ifdef __VAX
static long base_adjust[2]={0L,0L};
#else
static __int64 base_adjust=0;
#endif
/*
If we don't have gettimeofday, then likely we are on a VMS machine that
operates on local time rather than UTC...so we have to zone-adjust.
This code gleefully swiped from VMS.C
*/
/* method used to handle UTC conversions:
* 1 == CRTL gmtime(); 2 == SYS$TIMEZONE_DIFFERENTIAL; 3 == no correction
*/
static int gmtime_emulation_type;
/* number of secs to add to UTC POSIX-style time to get local time */
static long int utc_offset_secs;
loc -= utc_offset_secs;
return loc;
}
utc += utc_offset_secs;
return utc;
}
((gmtime_emulation_type || timezone_setup()), \
((secs) - utc_offset_secs))))
((gmtime_emulation_type || timezone_setup()), \
((secs) + utc_offset_secs))))
static int
timezone_setup(void)
{
if (gmtime_emulation_type == 0) {
int dstnow;
/* results of calls to gmtime() and localtime() */
/* for same &base */
utc_offset_secs = 0;
}
}
else { /* We've got a working gmtime() */
}
}
return 1;
}
int
{
long ret;
#ifdef __VAX
long quad[2];
long quad1[2];
long div_100ns_to_secs;
long div_100ns_to_usecs;
#else
#endif
/*
In case of error, tv_usec = 0 and tv_sec = VMS condition code.
The return from function is also set to -1.
This is not exactly as per the manual page.
*/
#ifdef __VAX
#else
if (base_adjust==0) { /* Need to determine epoch adjustment */
#endif
return -1;
}
}
#ifdef __VAX
quad1[1] = 0L;
#else
#endif
} else {
return -1;
}
# ifdef VMSISH_TIME
# ifdef RTL_USES_UTC
# else
# endif
# endif
return 0;
}
#endif
/* Do not use H A S _ N A N O S L E E P
* so that Perl Configure doesn't scan for it.
* The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */
#if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP)
#define HAS_USLEEP
void
hrt_nanosleep(unsigned long usec)
{
}
#endif
#if !defined(HAS_USLEEP) && defined(HAS_SELECT)
#ifndef SELECT_IS_BROKEN
#define HAS_USLEEP
void
hrt_usleep(unsigned long usec)
{
}
#endif
#endif
#if !defined(HAS_USLEEP) && defined(WIN32)
#define HAS_USLEEP
void
hrt_usleep(unsigned long usec)
{
long msec;
}
#endif
#if !defined(HAS_UALARM) && defined(HAS_SETITIMER)
#define HAS_UALARM
int
{
}
#endif
#if !defined(HAS_UALARM) && defined(VMS)
#define HAS_UALARM
#define ualarm vms_ualarm
#include <ssdef.h>
#include <starlet.h>
#include <descrip.h>
#include <signal.h>
#include <jpidef.h>
#include <psldef.h>
#define VMSERR(s) (!((s)&1))
static void
{
int iss;
unsigned long qq[2];
qq[1] = 0;
v[0] = v[1] = 0;
}
static int
VMS_to_us(unsigned long v[])
{
int iss;
return quot;
}
typedef unsigned short word;
typedef struct _ualarm {
int function;
int repeat;
unsigned long delay[2];
unsigned long interval[2];
unsigned long remain[2];
} Alarm;
static int alarm_ef;
#define UAL_NULL 0
#define UAL_SET 1
#define UAL_CLEAR 2
#define UAL_ACTIVE 4
static void ualarm_AST(Alarm *a);
static int
{
struct item_list3 {
void *bufaddr;
void *retlenaddr;
} ;
static int first = 1;
unsigned long asten;
if (first) {
first = 0;
a0 = &alarm_base;
}
a = &abase;
if (mseconds) {
} else {
}
if (interval) {
a->repeat = 1;
} else
a->repeat = 0;
if (a->function == UAL_ACTIVE)
else
return 0;
}
static void
ualarm_AST(Alarm *a)
{
int iss;
unsigned long now[2];
}
}
} else {
}
} else if (a->function == UAL_ACTIVE) {
if (a->repeat) {
} else {
}
} else {
}
}
#endif /* !HAS_UALARM && VMS */
#ifdef HAS_GETTIMEOFDAY
static int
{
int status;
return status;
}
static NV
myNVtime()
{
#ifdef WIN32
dTHX;
#endif
int status;
}
#endif
BOOT:
{
#ifdef MY_CXT_KEY
#endif
#ifdef ATLEASTFIVEOHOHFIVE
#ifdef HAS_GETTIMEOFDAY
{
}
#endif
#endif
}
#if defined(USE_ITHREADS) && defined(MY_CXT_KEY)
void
CLONE(...)
CODE:
#endif
#if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY)
CODE:
if (items > 0) {
if (useconds > 1E6) {
/* If usleep() has been implemented using setitimer()
* then this contortion is unnecessary-- but usleep()
* may be implemented in some other way, so let's contort. */
if (seconds) {
}
} else if (useconds < 0.0)
} else
#if 0
#endif
sleep(...)
CODE:
if (items > 0) {
if (seconds >= 0.0) {
if (seconds >= 1.0)
#if defined(__sparc64__) && defined(__GNUC__)
/* Sparc64 gcc 2.95.3 (e.g. on NetBSD) has a bug
* where (0.5 - (UV)(0.5)) will under certain
* circumstances (if the double is cast to UV more
* than once?) evaluate to -0.5, instead of 0.5. */
#endif
croak("Time::HiRes::sleep(%"NVgf"): internal error: useconds < 0 (unsigned %"UVuf" signed %"IVdf")", seconds, useconds, (IV)useconds);
}
} else
} else
#if 0
#endif
#endif
#ifdef HAS_UALARM
int
int useconds
int interval
CODE:
CODE:
#endif
#ifdef HAS_GETTIMEOFDAY
# ifdef MACOS_TRADITIONAL /* fix epoch TZ and use unsigned time_t */
void
int status;
/* Mac OS (Classic) has unsigned time_t */
} else {
}
time()
CODE:
int status;
# else /* MACOS_TRADITIONAL */
void
int status;
} else {
}
time()
CODE:
int status;
# endif /* MACOS_TRADITIONAL */
#endif
#if defined(HAS_GETITIMER) && defined(HAS_SETITIMER)
void
int which
croak("Time::HiRes::setitimer(%"IVdf", %"NVgf", %"NVgf"): negative time not invented yet", (IV)which, seconds, interval);
}
}
void
int which
}
}
#endif