summaryrefslogtreecommitdiff
path: root/libguile/stime.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2004-09-07 00:15:48 +0000
committerKevin Ryde <user42@zip.com.au>2004-09-07 00:15:48 +0000
commit763313a2194830fcaadd2ae90b15af1a383e8ca6 (patch)
tree27230ce9da545d5515e0ac170b73ea0e470036b4 /libguile/stime.c
parent8bddb01ebba8bd1b0c60fd7fc820705259f16b44 (diff)
downloadguile-763313a2194830fcaadd2ae90b15af1a383e8ca6.tar.gz
(scm_current_time, scm_gettimeofday, scm_strptime): Don't
throw error before unlocking mutex with SCM_ALLOW_INTS.
Diffstat (limited to 'libguile/stime.c')
-rw-r--r--libguile/stime.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/libguile/stime.c b/libguile/stime.c
index cf24e6668..32b58f4d4 100644
--- a/libguile/stime.c
+++ b/libguile/stime.c
@@ -218,9 +218,10 @@ SCM_DEFINE (scm_current_time, "current-time", 0, 0, 0,
timet timv;
SCM_DEFER_INTS;
- if ((timv = time (0)) == -1)
- SCM_MISC_ERROR ("current time not available", SCM_EOL);
+ timv = time (NULL);
SCM_ALLOW_INTS;
+ if (timv == -1)
+ SCM_MISC_ERROR ("current time not available", SCM_EOL);
return scm_from_long (timv);
}
#undef FUNC_NAME
@@ -235,11 +236,17 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
{
#ifdef HAVE_GETTIMEOFDAY
struct timeval time;
+ int ret, err;
SCM_DEFER_INTS;
- if (gettimeofday (&time, NULL) == -1)
- SCM_SYSERROR;
+ ret = gettimeofday (&time, NULL);
+ err = errno;
SCM_ALLOW_INTS;
+ if (ret == -1)
+ {
+ errno = err;
+ SCM_SYSERROR;
+ }
return scm_cons (scm_from_long (time.tv_sec),
scm_from_long (time.tv_usec));
#else
@@ -251,11 +258,17 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
scm_from_int (time.millitm * 1000));
# else
timet timv;
+ int err;
SCM_DEFER_INTS;
- if ((timv = time (0)) == -1)
- SCM_SYSERROR;
+ timv = time (NULL);
+ err = errno;
SCM_ALLOW_INTS;
+ if (timv == -1)
+ {
+ errno = err;
+ SCM_SYSERROR;
+ }
return scm_cons (scm_from_long (timv), scm_from_int (0));
# endif
#endif
@@ -726,7 +739,9 @@ SCM_DEFINE (scm_strptime, "strptime", 2, 0, 0,
fields, hence the use of SCM_DEFER_INTS. */
t.tm_isdst = -1;
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
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_ALLOW_INTS;
return scm_cons (filltime (&t, 0, NULL),
scm_from_signed_integer (rest - str));
}