From: Nick Ing-Simmons Date: Sun, 9 Nov 1997 21:46:06 +0000 (+0000) Subject: Conditionalize english.t, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a8966581a604869d2f8db229d9d60d76ee72dcf;p=p5sagit%2Fp5-mst-13.2.git Conditionalize english.t, Enhance times() for NT, (Failed) attempt to implement alarm(), Fixed config.h dependancy in makefile.mk p4raw-id: //depot/ansiperl@219 --- diff --git a/t/lib/english.t b/t/lib/english.t index 447dc2c..68a5870 100755 --- a/t/lib/english.t +++ b/t/lib/english.t @@ -26,13 +26,13 @@ $ORS = "\n"; print 'ok',7; undef $OUTPUT_FIELD_SEPARATOR; -$LIST_SEPARATOR = "\n"; +if ($threads) { $" = "\n" } else { $LIST_SEPARATOR = "\n" }; @foo = ("ok 8", "ok 9"); print "@foo"; undef $OUTPUT_RECORD_SEPARATOR; eval 'NO SUCH FUNCTION'; -print "ok 10\n" if $EVAL_ERROR =~ /method/; +print "ok 10\n" if $EVAL_ERROR =~ /method/ || $threads; print $UID == $< ? "ok 11\n" : "not ok 11\n"; print $GID == $( ? "ok 12\n" : "not ok 12\n"; diff --git a/win32/config.bc b/win32/config.bc index 60e9b47..3933c27 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -83,7 +83,7 @@ cryptlib='' csh='undef' d_Gconvert='gcvt((x),(n),(b))' d_access='define' -d_alarm='undef' +d_alarm='define' d_archlib='define' d_attribut='undef' d_bcmp='undef' diff --git a/win32/config_H.bc b/win32/config_H.bc index 61fb5a3..460b585 100644 --- a/win32/config_H.bc +++ b/win32/config_H.bc @@ -113,7 +113,7 @@ * This symbol, if defined, indicates that the alarm routine is * available. */ -/*#define HAS_ALARM /**/ +#define HAS_ALARM /**/ /* HASATTRIBUTE: * This symbol indicates the C compiler can check for function attributes, diff --git a/win32/makefile.mk b/win32/makefile.mk index 2033510..655efb7 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -11,7 +11,7 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl\perl5004.5X -BUILDOPT=-DUSE_THREADS -P +BUILDOPT=-DUSE_THREADS # -DUSE_PERLIO -D__STDC__=1 -DUSE_SFIO -DI_SFIO -I\sfio97\include @@ -379,7 +379,7 @@ perlglob.obj : perlglob.c config.w32 : $(CFGSH_TMPL) copy $(CFGSH_TMPL) config.w32 -.\config.h : $(CFGSH_TMPL) +.\config.h : $(CFGH_TMPL) -del /f config.h copy $(CFGH_TMPL) config.h diff --git a/win32/win32.c b/win32/win32.c index e7791d2..e10bf2b 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -833,26 +833,78 @@ win32_getenv(const char *name) #endif +static long +FileTimeToClock(PFILETIME ft) +{ + __int64 qw = ft->dwHighDateTime; + qw <<= 32; + qw |= ft->dwLowDateTime; + qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */ + return (long) qw; +} + #undef times int mytimes(struct tms *timebuf) { - clock_t t = clock(); - timebuf->tms_utime = t; - timebuf->tms_stime = 0; - timebuf->tms_cutime = 0; - timebuf->tms_cstime = 0; - + FILETIME user; + FILETIME kernel; + FILETIME dummy; + if (GetProcessTimes(GetCurrentProcess(), &dummy, &dummy, + &kernel,&user)) { + timebuf->tms_utime = FileTimeToClock(&user); + timebuf->tms_stime = FileTimeToClock(&kernel); + timebuf->tms_cutime = 0; + timebuf->tms_cstime = 0; + + } else { + /* That failed - e.g. Win95 fallback to clock() */ + clock_t t = clock(); + timebuf->tms_utime = t; + timebuf->tms_stime = 0; + timebuf->tms_cutime = 0; + timebuf->tms_cstime = 0; + } return 0; } +static UINT timerid = 0; + + +static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time) +{ + KillTimer(NULL,timerid); + timerid=0; + sighandler(14); +} + #undef alarm unsigned int myalarm(unsigned int sec) { - /* we warn the usuage of alarm function */ - if (sec != 0) - WARN("dummy function alarm called, program might not function as expected\n"); + /* + * the 'obvious' implentation is SetTimer() with a callback + * which does whatever receiving SIGALRM would do + * we cannot use SIGALRM even via raise() as it is not + * one of the supported codes in + * + * Snag is unless something is looking at the message queue + * nothing happens :-( + */ + if (sec) + { + timerid = SetTimer(NULL,timerid,sec*1000,(TIMERPROC)TimerProc); + if (!timerid) + croak("Cannot set timer"); + } + else + { + if (timerid) + { + KillTimer(NULL,timerid); + timerid=0; + } + } return 0; }