aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/9c3
-rwxr-xr-xbin/9l2
-rw-r--r--include/lib9.h26
-rw-r--r--src/cmd/samterm/plan9.c2
-rw-r--r--src/lib9/_p9dir.c12
-rw-r--r--src/lib9/date.c36
-rw-r--r--src/lib9/dirfwstat.c17
-rw-r--r--src/lib9/dirread.c26
-rw-r--r--src/lib9/dirwstat.c1
-rw-r--r--src/libhttpd/fail.c36
-rw-r--r--src/libsec/port/aes.c2
-rw-r--r--src/libthread/sched.c2
-rw-r--r--src/libthread/sun4u.c20
-rw-r--r--src/mkfile2
14 files changed, 115 insertions, 72 deletions
diff --git a/bin/9c b/bin/9c
index 9104a08c..8a7148e8 100755
--- a/bin/9c
+++ b/bin/9c
@@ -5,7 +5,6 @@ usegcc()
cc=gcc
cflags=" \
-O2 \
- -I$PLAN9/include \
-c \
-ggdb \
-Wall \
@@ -29,4 +28,4 @@ case "$tag" in
exit 1
esac
-exec $cc $cflags "$@"
+exec $cc -I$PLAN9/include $cflags "$@"
diff --git a/bin/9l b/bin/9l
index adc66038..19be47ed 100755
--- a/bin/9l
+++ b/bin/9l
@@ -7,7 +7,7 @@ case "$tag" in
*BSD*) ld=gcc ;;
*Linux*) ld=gcc ;;
*Darwin*) ld=gcc ;;
-*SunOS*) ld=${CC9:-cc}
+*SunOS*) ld="${CC9:-cc} -g"
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
;;
*)
diff --git a/include/lib9.h b/include/lib9.h
index 21490e65..ce5187cd 100644
--- a/include/lib9.h
+++ b/include/lib9.h
@@ -15,6 +15,7 @@ extern "C" {
#define _XOPEN_SOURCE_EXTENDED 1
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64
+#define __EXTENSIONS__ 1 /* SunOS */
#include <unistd.h>
#include <string.h>
@@ -36,14 +37,6 @@ extern "C" {
#define _NEEDUINT 1
#define _NEEDULONG 1
-/* better to assume we have these and then be proved wrong */
-#define _HAVESTGEN 1
-#define _HAVETIMEGM 1
-#define _HAVETMZONE 1
-#define _HAVETMTZOFF 1
-#define _HAVEFUTIMESAT 1
-#define _HAVEFUTIMES 1
-
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#if defined(__linux__)
@@ -53,22 +46,12 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
# undef _NEEDUINT
# undef _NEEDULONG
# endif
-# undef _HAVESTGEN
-# undef _HAVETMZONE
-# undef _HAVETMTZOFF
-# undef _HAVEFUTIMESAT
#endif
#if defined(__sun__)
# include <sys/types.h>
# undef _NEEDUSHORT
# undef _NEEDUINT
# undef _NEEDULONG
-# undef _HAVESTGEN
-# undef _HAVETIMEGM
-# undef _HAVETMZONE
-# undef _HAVETMTZOFF
-# undef _HAVEFUTIMES
-# undef _HAVEUTIMES
#endif
#if defined(__FreeBSD__)
# include <sys/types.h>
@@ -76,14 +59,12 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
# undef _NEEDUSHORT
# undef _NEEDUINT
# endif
-# define _HAVEDISKLABEL 1
#endif
#if defined(__APPLE__)
# include <sys/types.h>
# undef _NEEDUSHORT
# undef _NEEDUINT
# define _NEEDLL 1
-# define _GETDIRENTRIES_TAKES_LONG 1
#endif
typedef signed char schar;
@@ -106,6 +87,11 @@ typedef uvlong u64int;
typedef uchar u8int;
typedef ushort u16int;
+#undef _NEEDUCHAR
+#undef _NEEDUSHORT
+#undef _NEEDUINT
+#undef _NEEDULONG
+
/*
* Begin usual libc.h
*/
diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
index f12f0850..f49393e6 100644
--- a/src/cmd/samterm/plan9.c
+++ b/src/cmd/samterm/plan9.c
@@ -15,7 +15,7 @@
static char *exname;
-#define STACK 8192
+#define STACK 16384
void
getscreen(int argc, char **argv)
diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c
index d94208cc..43752222 100644
--- a/src/lib9/_p9dir.c
+++ b/src/lib9/_p9dir.c
@@ -4,13 +4,19 @@
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef _HAVEDISKLABEL
-#include <sys/disklabel.h>
-#endif
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
+#if defined(__FreeBSD__)
+#include <sys/disklabel.h>
+#define _HAVEDISKLABEL
+#endif
+
+#if !defined(__linux__) && !defined(__sun__)
+#define _HAVESTGEN
+#endif
+
int
_p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
{
diff --git a/src/lib9/date.c b/src/lib9/date.c
index 22ec6721..8ece0c68 100644
--- a/src/lib9/date.c
+++ b/src/lib9/date.c
@@ -1,18 +1,24 @@
#include <stdlib.h> /* setenv etc. */
#include <u.h>
+#define NOPLAN9DEFINES
#include <libc.h>
+#include <time.h>
-#undef gmtime
-#undef localtime
-#undef asctime
-#undef ctime
-#undef cputime
-#undef times
-#undef tm2sec
-#undef nsec
+#define _HAVETIMEGM 1
+#define _HAVETMZONE 1
+#define _HAVETMTZOFF 1
-#include <time.h>
+#if defined(__linux__)
+# undef _HAVETMZONE
+# undef _HAVETMTZOFF
+
+#elif defined(__sun__)
+# undef _HAVETIMEGM
+# undef _HAVETMZONE
+# undef _HAVETMTZOFF
+
+#endif
static Tm bigtm;
@@ -80,15 +86,17 @@ timegm(struct tm *tm)
{
time_t ret;
char *tz;
+ char *s;
tz = getenv("TZ");
- setenv("TZ", "", 1);
+ putenv("TZ=");
tzset();
ret = mktime(tm);
- if(tz)
- setenv("TZ", tz, 1);
- else
- unsetenv("TZ");
+ if(tz){
+ s = smprint("TZ=%s", tz);
+ if(s)
+ putenv(s);
+ }
return ret;
}
#endif
diff --git a/src/lib9/dirfwstat.c b/src/lib9/dirfwstat.c
index c7cf64d6..7144e7cd 100644
--- a/src/lib9/dirfwstat.c
+++ b/src/lib9/dirfwstat.c
@@ -1,22 +1,30 @@
#include <u.h>
-#define NOPLAN9DEFINES
#include <libc.h>
-
#include <sys/time.h>
-#if !defined(_HAVEFUTIMES) && defined(_HAVEFUTIMESAT)
+#if defined(__FreeBSD__) || defined(__APPLE__)
+/* do nothing -- futimes exists and is fine */
+
+#elif defined(__sun__)
+/* use futimesat */
static int
futimes(int fd, struct timeval *tv)
{
return futimesat(fd, 0, tv);
}
-#elif !defined(_HAVEFUTIMES)
+
+#else
+/* provide dummy */
+/* rename just in case -- linux provides an unusable one */
+#undef futimes
+#define futimes myfutimes
static int
futimes(int fd, struct timeval *tv)
{
werrstr("futimes not available");
return -1;
}
+
#endif
int
@@ -25,6 +33,7 @@ dirfwstat(int fd, Dir *dir)
int ret;
struct timeval tv[2];
+ ret = 0;
if(~dir->mode != 0){
if(fchmod(fd, dir->mode) < 0)
ret = -1;
diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c
index ab9ec7f5..1e479fe4 100644
--- a/src/lib9/dirread.c
+++ b/src/lib9/dirread.c
@@ -6,19 +6,39 @@
extern int _p9dir(struct stat*, char*, Dir*, char**, char*);
-/* almost everyone has getdirentries, just use that */
+#if defined(__linux__)
static int
-mygetdents(int fd, char *buf, int n)
+mygetdents(int fd, struct dirent *buf, int n)
+{
+ ssize_t nn;
+ off_t off;
+
+ off = p9seek(fd, 0, 1);
+ nn = getdirentries(fd, (void*)buf, n, &off);
+ if(nn > 0)
+ p9seek(fd, off, 0);
+ return nn;
+}
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+static int
+mygetdents(int fd, struct dirent *buf, int n)
{
ssize_t nn;
long off;
off = p9seek(fd, 0, 1);
- nn = getdirentries(fd, buf, n, &off);
+ nn = getdirentries(fd, (void*)buf, n, &off);
if(nn > 0)
p9seek(fd, off, 0);
return nn;
}
+#elif defined(__sun__)
+static int
+mygetdents(int fd, struct dirent *buf, int n)
+{
+ return getdents(fd, (void*)buf, n);
+}
+#endif
static int
countde(char *p, int n)
diff --git a/src/lib9/dirwstat.c b/src/lib9/dirwstat.c
index d003ac83..6f351965 100644
--- a/src/lib9/dirwstat.c
+++ b/src/lib9/dirwstat.c
@@ -1,7 +1,6 @@
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
-
#include <sys/time.h>
#include <utime.h>
diff --git a/src/libhttpd/fail.c b/src/libhttpd/fail.c
index 92da30c8..c65ddaae 100644
--- a/src/libhttpd/fail.c
+++ b/src/libhttpd/fail.c
@@ -14,33 +14,33 @@ struct Error
Error errormsg[] =
{
- [HInternal] {"500 Internal Error", "Internal Error",
+ /* HInternal */ {"500 Internal Error", "Internal Error",
"This server could not process your request due to an internal error."},
- [HTempFail] {"500 Internal Error", "Temporary Failure",
+ /* HTempFail */ {"500 Internal Error", "Temporary Failure",
"The object %s is currently inaccessible.<p>Please try again later."},
- [HUnimp] {"501 Not implemented", "Command not implemented",
+ /* HUnimp */ {"501 Not implemented", "Command not implemented",
"This server does not implement the %s command."},
- [HUnkVers] {"501 Not Implemented", "Unknown http version",
- "This server does not know how to respond to http version %s."},
- [HBadCont] {"501 Not Implemented", "Impossible format",
- "This server cannot produce %s in any of the formats your client accepts."},
- [HBadReq] {"400 Bad Request", "Strange Request",
+ /* HBadReq */ {"400 Bad Request", "Strange Request",
"Your client sent a query that this server could not understand."},
- [HSyntax] {"400 Bad Request", "Garbled Syntax",
- "Your client sent a query with incoherent syntax."},
- [HBadSearch] {"400 Bad Request", "Inapplicable Search",
+ /* HBadSearch */ {"400 Bad Request", "Inapplicable Search",
"Your client sent a search that cannot be applied to %s."},
- [HNotFound] {"404 Not Found", "Object not found",
+ /* HNotFound */ {"404 Not Found", "Object not found",
"The object %s does not exist on this server."},
- [HNoSearch] {"403 Forbidden", "Search not supported",
+ /* HUnauth */ {"403 Forbidden", "Forbidden",
+ "You are not allowed to see the object %s."},
+ /* HSyntax */ {"400 Bad Request", "Garbled Syntax",
+ "Your client sent a query with incoherent syntax."},
+ /* HNoSearch */ {"403 Forbidden", "Search not supported",
"The object %s does not support the search command."},
- [HNoData] {"403 Forbidden", "No data supplied",
+ /* HNoData */ {"403 Forbidden", "No data supplied",
"Search or forms data must be supplied to %s."},
- [HExpectFail] {"403 Expectation Failed", "Expectation Failed",
+ /* HExpectFail */ {"403 Expectation Failed", "Expectation Failed",
"This server does not support some of your request's expectations."},
- [HUnauth] {"403 Forbidden", "Forbidden",
- "You are not allowed to see the object %s."},
- [HOK] {"200 OK", "everything is fine"},
+ /* HUnkVers */ {"501 Not Implemented", "Unknown http version",
+ "This server does not know how to respond to http version %s."},
+ /* HBadCont */ {"501 Not Implemented", "Impossible format",
+ "This server cannot produce %s in any of the formats your client accepts."},
+ /* HOK */ {"200 OK", "everything is fine"},
};
/*
diff --git a/src/libsec/port/aes.c b/src/libsec/port/aes.c
index ac1cac21..fce96fd3 100644
--- a/src/libsec/port/aes.c
+++ b/src/libsec/port/aes.c
@@ -43,7 +43,7 @@ static const u32 Td3[256];
static const u8 Te4[256];
static int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
-static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
+// static int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
static int rijndaelKeySetup(u32 erk[/*4*(Nr + 1)*/], u32 drk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
static void rijndaelEncrypt(const u32int rk[], int Nr, const uchar pt[16], uchar ct[16]);
static void rijndaelDecrypt(const u32int rk[], int Nr, const uchar ct[16], uchar pt[16]);
diff --git a/src/libthread/sched.c b/src/libthread/sched.c
index b9e646e3..293e3306 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -10,7 +10,6 @@ static char *_psstate[] = {
"Ready",
"Rendezvous",
};
-#endif
static char*
psstate(int s)
@@ -19,6 +18,7 @@ psstate(int s)
return "unknown";
return _psstate[s];
}
+#endif
void
_schedinit(void *arg)
diff --git a/src/libthread/sun4u.c b/src/libthread/sun4u.c
index 5eb2135e..0c298c62 100644
--- a/src/libthread/sun4u.c
+++ b/src/libthread/sun4u.c
@@ -1,9 +1,12 @@
#include "threadimpl.h"
static void
-launchersparc(int o0, int o1, int o2, int o3, int o4,
+launchersparc(uint o0, uint o1, uint o2, uint o3,
+ uint o4, uint o5, uint o6, uint o7,
void (*f)(void *arg), void *arg)
{
+ if(0) print("ls %x %x %x %x %x %x %x %x %x %x at %x\n",
+ o0, o1, o2, o3, o4, o5, o6, o7, f, arg, &o0);
(*f)(arg);
threadexits(nil);
}
@@ -13,13 +16,26 @@ _threadinitstack(Thread *t, void (*f)(void*), void *arg)
{
ulong *tos, *stk;
+ /*
+ * This is a bit more complicated than it should be,
+ * because we need to set things up so that gotolabel
+ * (which executes a return) gets us into launchersparc.
+ * So all the registers are going to be renamed before
+ * we get there. The input registers here become the
+ * output registers there, which is useless.
+ * The input registers there are inaccessible, so we
+ * have to give launchersparc enough arguments that
+ * everything ends up in the stack.
+ */
tos = (ulong*)&t->stk[t->stksize&~7];
stk = tos;
--stk;
*--stk = (ulong)arg;
*--stk = (ulong)f;
+ stk -= 25; /* would love to understand this */
t->sched.link = (ulong)launchersparc - 8;
t->sched.input[6] = 0;
- t->sched.sp = (ulong)stk - 0x5c;
+ t->sched.sp = (ulong)stk;
+ if(0) print("tis %x %x at %x\n", f, arg, t->sched.sp);
}
diff --git a/src/mkfile b/src/mkfile
index 23e34efe..790f0f60 100644
--- a/src/mkfile
+++ b/src/mkfile
@@ -7,7 +7,7 @@ DIRS=\
libfmt\
libframe\
libhttpd\
- libip\
+# libip\
libregexp\
libsec\
libthread\