1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

(scm_current_time, scm_gettimeofday, scm_strptime): Don't

throw error before unlocking mutex with SCM_ALLOW_INTS.
This commit is contained in:
Kevin Ryde 2004-09-07 00:15:48 +00:00
parent 8bddb01ebb
commit 763313a219

View file

@ -218,9 +218,10 @@ SCM_DEFINE (scm_current_time, "current-time", 0, 0, 0,
timet timv; timet timv;
SCM_DEFER_INTS; SCM_DEFER_INTS;
if ((timv = time (0)) == -1) timv = time (NULL);
SCM_MISC_ERROR ("current time not available", SCM_EOL);
SCM_ALLOW_INTS; SCM_ALLOW_INTS;
if (timv == -1)
SCM_MISC_ERROR ("current time not available", SCM_EOL);
return scm_from_long (timv); return scm_from_long (timv);
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -235,11 +236,17 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
{ {
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
struct timeval time; struct timeval time;
int ret, err;
SCM_DEFER_INTS; SCM_DEFER_INTS;
if (gettimeofday (&time, NULL) == -1) ret = gettimeofday (&time, NULL);
SCM_SYSERROR; err = errno;
SCM_ALLOW_INTS; SCM_ALLOW_INTS;
if (ret == -1)
{
errno = err;
SCM_SYSERROR;
}
return scm_cons (scm_from_long (time.tv_sec), return scm_cons (scm_from_long (time.tv_sec),
scm_from_long (time.tv_usec)); scm_from_long (time.tv_usec));
#else #else
@ -251,11 +258,17 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
scm_from_int (time.millitm * 1000)); scm_from_int (time.millitm * 1000));
# else # else
timet timv; timet timv;
int err;
SCM_DEFER_INTS; SCM_DEFER_INTS;
if ((timv = time (0)) == -1) timv = time (NULL);
SCM_SYSERROR; err = errno;
SCM_ALLOW_INTS; SCM_ALLOW_INTS;
if (timv == -1)
{
errno = err;
SCM_SYSERROR;
}
return scm_cons (scm_from_long (timv), scm_from_int (0)); return scm_cons (scm_from_long (timv), scm_from_int (0));
# endif # endif
#endif #endif
@ -726,7 +739,9 @@ SCM_DEFINE (scm_strptime, "strptime", 2, 0, 0,
fields, hence the use of SCM_DEFER_INTS. */ fields, hence the use of SCM_DEFER_INTS. */
t.tm_isdst = -1; t.tm_isdst = -1;
SCM_DEFER_INTS; SCM_DEFER_INTS;
if ((rest = strptime (str, fmt, &t)) == NULL) rest = strptime (str, fmt, &t);
SCM_ALLOW_INTS;
if (rest == NULL)
{ {
/* POSIX doesn't say strptime sets errno, and on glibc 2.3.2 for /* POSIX doesn't say strptime sets errno, and on glibc 2.3.2 for
instance it doesn't. Force a sensible value for our error instance it doesn't. Force a sensible value for our error
@ -735,7 +750,6 @@ SCM_DEFINE (scm_strptime, "strptime", 2, 0, 0,
SCM_SYSERROR; SCM_SYSERROR;
} }
SCM_ALLOW_INTS;
return scm_cons (filltime (&t, 0, NULL), return scm_cons (filltime (&t, 0, NULL),
scm_from_signed_integer (rest - str)); scm_from_signed_integer (rest - str));
} }