* Makefile: use cp -r to install the library

* ceval.c: use #ifdef COMPAT_HACKS instead of #if 0
* Makefile: fix to make clmodule.c compile;
  make config.o dependent on libpython.a (so date is always correct)
* timemodule.c: now sleep() also takes a float argument.
* posixmodule.c: added nice().
This commit is contained in:
Guido van Rossum 1993-01-09 17:18:52 +00:00
parent d513f0bcb6
commit 775f4dacbc
3 changed files with 45 additions and 33 deletions

View File

@ -1,6 +1,6 @@
/*********************************************************** /***********************************************************
Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
Netherlands. Amsterdam, The Netherlands.
All Rights Reserved All Rights Reserved
@ -358,6 +358,23 @@ posix_mkdir(self, args)
return posix_strint(args, mkdir); return posix_strint(args, mkdir);
} }
#ifndef MSDOS
static object *
posix_nice(self, args)
object *self;
object *args;
{
int increment, value;
if (!getargs(args, "i", &increment))
return NULL;
value = nice(increment);
if (value == -1)
return posix_error();
return newintobject((long) value);
}
#endif
#ifdef i386 #ifdef i386
int int
rename(from, to) rename(from, to)
@ -919,6 +936,9 @@ static struct methodlist posix_methods[] = {
{"listdir", posix_listdir}, {"listdir", posix_listdir},
{"lstat", posix_lstat}, {"lstat", posix_lstat},
{"mkdir", posix_mkdir}, {"mkdir", posix_mkdir},
#ifndef MSDOS
{"nice", posix_nice},
#endif
{"readlink", posix_readlink}, {"readlink", posix_readlink},
{"rename", posix_rename}, {"rename", posix_rename},
{"rmdir", posix_rmdir}, {"rmdir", posix_rmdir},

View File

@ -1,6 +1,6 @@
/*********************************************************** /***********************************************************
Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
Netherlands. Amsterdam, The Netherlands.
All Rights Reserved All Rights Reserved
@ -124,9 +124,9 @@ time_sleep(self, args)
object *self; object *self;
object *args; object *args;
{ {
long secs; double secs;
SIGTYPE (*sigsave)() = 0; /* Initialized to shut lint up */ SIGTYPE (*sigsave)() = 0; /* Initialized to shut lint up */
if (!getargs(args, "l", &secs)) if (!getargs(args, "d", &secs))
return NULL; return NULL;
BGN_SAVE BGN_SAVE
if (setjmp(sleep_intr)) { if (setjmp(sleep_intr)) {
@ -138,11 +138,7 @@ time_sleep(self, args)
sigsave = signal(SIGINT, SIG_IGN); sigsave = signal(SIGINT, SIG_IGN);
if (sigsave != (SIGTYPE (*)()) SIG_IGN) if (sigsave != (SIGTYPE (*)()) SIG_IGN)
signal(SIGINT, sleep_catcher); signal(SIGINT, sleep_catcher);
#ifdef BSD_TIME floatsleep(secs);
longsleep(secs);
#else
sleep((int)secs);
#endif
END_SAVE END_SAVE
signal(SIGINT, sigsave); signal(SIGINT, sigsave);
INCREF(None); INCREF(None);
@ -188,7 +184,7 @@ time_millisleep(self, args)
sigsave = signal(SIGINT, SIG_IGN); sigsave = signal(SIGINT, SIG_IGN);
if (sigsave != (SIGTYPE (*)()) SIG_IGN) if (sigsave != (SIGTYPE (*)()) SIG_IGN)
signal(SIGINT, sleep_catcher); signal(SIGINT, sleep_catcher);
millisleep(msecs); floatsleep(msecs / 1000.0);
END_SAVE END_SAVE
signal(SIGINT, sigsave); signal(SIGINT, sigsave);
INCREF(None); INCREF(None);
@ -284,12 +280,12 @@ sleep(secs)
} }
#endif #endif
millisleep(msecs) floatsleep(secs)
long msecs; double secs;
{ {
register long deadline; register long deadline;
deadline = MacTicks + msecs * 3 / 50; /* msecs * 60 / 1000 */ deadline = MacTicks + long(secs * 60.0);
while (MacTicks < deadline) { while (MacTicks < deadline) {
if (intrcheck()) if (intrcheck())
sleep_catcher(SIGINT); sleep_catcher(SIGINT);
@ -319,21 +315,17 @@ millitimer()
return t.tv_sec*1000 + t.tv_usec/1000; return t.tv_sec*1000 + t.tv_usec/1000;
} }
millisleep(msecs) floatsleep(secs)
long msecs; double secs;
{ {
struct timeval t; struct timeval t;
t.tv_sec = msecs/1000; double frac;
t.tv_usec = (msecs%1000)*1000; extern double fmod PROTO((double, double));
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); extern double floor PROTO((double));
} frac = fmod(secs, 1.0);
secs = floor(secs);
longsleep(secs) t.tv_sec = (long)secs;
long secs; t.tv_usec = (long)(frac*1000000.0);
{
struct timeval t;
t.tv_sec = secs;
t.tv_usec = 0;
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
} }
@ -347,10 +339,10 @@ longsleep(secs)
#endif #endif
static static
millisleep(msecs) floatsleep(secs)
long msecs; double secs;
{ {
delay(msecs); delay(long(secs/1000.0));
} }
static long static long
@ -359,7 +351,7 @@ millitimer()
clock_t ticks; clock_t ticks;
ticks = clock(); /* ticks since program start */ ticks = clock(); /* ticks since program start */
return ticks * CLOCKS_PER_SEC; return ticks * CLOCKS_PER_SEC;/* XXX shouldn't this be different? */
} }
#endif /* TURBO_C */ #endif /* TURBO_C */

View File

@ -819,7 +819,7 @@ eval_code(co, globals, locals, arg)
n = gettuplesize(v); n = gettuplesize(v);
} }
} }
#if 0 /* Compatibility hacks no longer needed (I think) */ #ifdef COMPAT_HACKS /* Compatibility hacks no longer needed (I think) */
else if (n != 1 && oparg == 1) { else if (n != 1 && oparg == 1) {
/* Rule (b) */ /* Rule (b) */
PUSH(v); PUSH(v);