From d2c4ee9e488f6c94865cc2f4c874d025bc2ae0d2 Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 24 Nov 2003 00:43:41 +0000 Subject: Tweaks to build properly on Linux. --- src/cmd/idiff.c | 19 ++++--------------- src/lib9/await.c | 2 ++ src/lib9/date.c | 19 ++++++++++++++++--- src/lib9/dirfwstat.c | 7 +++++++ src/lib9/dirread.c | 15 +++++++++++++++ src/lib9/dirwstat.c | 11 +++++------ src/lib9/notify.c | 5 +++++ src/lib9/postnote.c | 4 ++-- 8 files changed, 56 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/cmd/idiff.c b/src/cmd/idiff.c index 47326782..c3f207fe 100644 --- a/src/cmd/idiff.c +++ b/src/cmd/idiff.c @@ -81,23 +81,12 @@ main(int argc, char **argv) int opentemp(char *template, int mode, long perm) { - int fd, i; - char *p; - - p = strdup(template); - if(p == nil) - sysfatal("strdup out of memory"); - fd = -1; - for(i=0; i<10; i++){ - mktemp(p); - if(access(p, 0) < 0 && (fd=create(p, mode, perm)) >= 0) - break; - strcpy(p, template); - } + int fd; + + fd = mkstemp(template); if(fd < 0) sysfatal("could not create temporary file"); - strcpy(template, p); - free(p); + fchmod(fd, perm); return fd; } diff --git a/src/lib9/await.c b/src/lib9/await.c index ba94c28a..56d79b79 100644 --- a/src/lib9/await.c +++ b/src/lib9/await.c @@ -18,7 +18,9 @@ static struct { SIGILL, "sys: trap: illegal instruction", SIGTRAP, "sys: trace trap", SIGABRT, "sys: abort", +#ifdef SIGEMT SIGEMT, "sys: emulate instruction executed", +#endif SIGFPE, "sys: fp: trap", SIGKILL, "sys: kill", SIGBUS, "sys: bus error", diff --git a/src/lib9/date.c b/src/lib9/date.c index 72860aa7..22ec6721 100644 --- a/src/lib9/date.c +++ b/src/lib9/date.c @@ -1,3 +1,5 @@ +#include /* setenv etc. */ + #include #include @@ -72,11 +74,22 @@ p9localtime(long t) return &bigtm; } -#if !defined(_HAVETIMEGM) && defined(_HAVETIMEZONEINT) -static long +#if !defined(_HAVETIMEGM) +static time_t timegm(struct tm *tm) { - return mktime(tm)-timezone; + time_t ret; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if(tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + return ret; } #endif diff --git a/src/lib9/dirfwstat.c b/src/lib9/dirfwstat.c index 7ca51251..9f0d485c 100644 --- a/src/lib9/dirfwstat.c +++ b/src/lib9/dirfwstat.c @@ -10,6 +10,13 @@ futimes(int fd, struct timeval *tv) { return futimesat(fd, 0, tv); } +#elif !defined(_HAVEFUTIMES) +static int +futimes(int fd, struct timeval *tv) +{ + werrstr("futimes not available"); + return -1; +} #endif int diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c index 5151b132..d19429e8 100644 --- a/src/lib9/dirread.c +++ b/src/lib9/dirread.c @@ -11,6 +11,21 @@ extern int _p9dir(struct stat*, char*, Dir*, char**, char*); +#if !defined(_HAVEGETDENTS) && defined(_HAVEGETDIRENTRIES) +static int +getdents(int fd, char *buf, int n) +{ + ssize_t nn; + off_t off; + + off = seek(fd, 0, 1); + nn = getdirentries(fd, buf, n, &off); + if(nn > 0) + seek(fd, off, 0); + return nn; +} +#endif + static int countde(char *p, int n) { diff --git a/src/lib9/dirwstat.c b/src/lib9/dirwstat.c index 573dd376..d003ac83 100644 --- a/src/lib9/dirwstat.c +++ b/src/lib9/dirwstat.c @@ -3,19 +3,18 @@ #include #include +#include int dirwstat(char *file, Dir *dir) { - struct timeval tv[2]; + struct utimbuf ub; /* BUG handle more */ if(dir->mtime == ~0ULL) return 0; - tv[0].tv_sec = dir->mtime; - tv[0].tv_usec = 0; - tv[1].tv_sec = dir->mtime; - tv[1].tv_usec = 0; - return utimes(file, tv); + ub.actime = dir->mtime; + ub.modtime = dir->mtime; + return utime(file, &ub); } diff --git a/src/lib9/notify.c b/src/lib9/notify.c index 095a3f54..7e3c04f7 100644 --- a/src/lib9/notify.c +++ b/src/lib9/notify.c @@ -14,7 +14,9 @@ static int sigs[] = { SIGILL, SIGTRAP, SIGABRT, +#ifdef SIGEMT SIGEMT, +#endif SIGFPE, SIGBUS, SIGSEGV, @@ -30,6 +32,9 @@ static int sigs[] = { SIGVTALRM, SIGUSR1, SIGUSR2, +#ifdef SIGINFO + SIGINFO, +#endif }; static void (*notifyf)(void*, char*); diff --git a/src/lib9/postnote.c b/src/lib9/postnote.c index 9124bd5c..a75305cf 100644 --- a/src/lib9/postnote.c +++ b/src/lib9/postnote.c @@ -1,9 +1,9 @@ -#include - #include #define _NO9DEFINES_ #include +#include + extern int _p9strsig(char*); -- cgit v1.2.3