summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@src.gnome.org>1998-07-14 06:42:25 +0000
committerRaja R Harinath <harinath@src.gnome.org>1998-07-14 06:42:25 +0000
commitccbb7b73ea66c6d2bfd91628badbc4468669581b (patch)
tree5288bb701a7379eac3dad0496e93bb634a5fb056
parentc387a59e68cab9275ac782aa513176c57a0ff12f (diff)
downloadgnome-common-ccbb7b73ea66c6d2bfd91628badbc4468669581b.tar.gz
Systems that don't have `mkstemp' probably don't have <stdint.h> either.
* mkstemp.c (<stdint.h>): Systems that don't have `mkstemp' probably don't have <stdint.h> either. Will fix it with a proper autoconf test later. svn path=/trunk/; revision=274
-rw-r--r--support/ChangeLog6
-rw-r--r--support/mkstemp.c23
2 files changed, 20 insertions, 9 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index 3668574..b479610 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,9 @@
+1998-07-14 Raja R Harinath <harinath@cs.umn.edu>
+
+ * mkstemp.c (<stdint.h>): Systems that don't have `mkstemp'
+ probably don't have <stdint.h> either. Will fix it with a proper
+ autoconf test later.
+
1998-07-13 Raja R Harinath <harinath@cs.umn.edu>
* argp.h (ARGP_EI): Define to `extern __inline__', rather that
diff --git a/support/mkstemp.c b/support/mkstemp.c
index 5744bc9..09c5a55 100644
--- a/support/mkstemp.c
+++ b/support/mkstemp.c
@@ -19,15 +19,20 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
-#ifndef _LIBC
-#define __gettimeofday gettimeofday
-#define __set_errno(e) errno = (e)
+#ifdef _LIBC
+#include <stdint.h>
+#define gettimeofday __gettimeofday
+#define set_errno(e) __set_errno(e)
+typedef uint64_t big_type;
+#else
+#define set_errno(e) errno = (e)
+/* FIXME: maybe check for long long. */
+typedef long big_type;
#endif
/* Generate a unique temporary file name from TEMPLATE.
@@ -40,7 +45,7 @@ mkstemp (template)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- static uint64_t value;
+ static big_type value;
struct timeval tv;
char *XXXXXX;
size_t len;
@@ -49,7 +54,7 @@ mkstemp (template)
len = strlen (template);
if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
{
- __set_errno (EINVAL);
+ set_errno (EINVAL);
return -1;
}
@@ -57,12 +62,12 @@ mkstemp (template)
XXXXXX = &template[len - 6];
/* Get some more or less random data. */
- __gettimeofday (&tv, NULL);
- value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
+ gettimeofday (&tv, NULL);
+ value += ((big_type) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
for (count = 0; count < TMP_MAX; ++count)
{
- uint64_t v = value;
+ big_type v = value;
int fd;
/* Fill in the random bits. */