Commit Diff


commit - f7012583e9a7594cbb5ebe8e974bb69061189262
commit + 64bcfff3a12695f4e3f54b0590e896611da71c3b
blob - 9104a08c8dad87a99a0094185e825a191cc4aa24
blob + 8a7148e889912f9949263415211a5f1cd4b01a34
--- bin/9c
+++ 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 "$@"
blob - adc6603855dc3134bf31fe46baf7e8fd4efe182c
blob + 19be47ed7f77408d25c9233b6359266ffd4eba14
--- bin/9l
+++ 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"
 		;;
 *)
blob - 21490e6518f49c0e75f69beee64accae4af1e6b4
blob + ce5187cdb5a3f633f69dbf128f9404f342db3e8d
--- include/lib9.h
+++ 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;
@@ -105,6 +86,11 @@ typedef long long vlong;
 typedef uvlong u64int;
 typedef uchar u8int;
 typedef ushort u16int;
+
+#undef _NEEDUCHAR
+#undef _NEEDUSHORT
+#undef _NEEDUINT
+#undef _NEEDULONG
 
 /*
  * Begin usual libc.h 
blob - f12f08502625ebc5f69183752ced8a3e1332c4d7
blob + f49393e6d707357649445e5a48f6a07547e9d3fb
--- src/cmd/samterm/plan9.c
+++ src/cmd/samterm/plan9.c
@@ -15,7 +15,7 @@
 
 static char *exname;
 
-#define STACK 8192
+#define STACK 16384
 
 void
 getscreen(int argc, char **argv)
blob - d94208ccbb81a5f6859c74fd2d717504e4c4e9c7
blob + 4375222281322960243235122f2878bc6790b13d
--- src/lib9/_p9dir.c
+++ 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)
 {
blob - 22ec67213a3d4207861dd55a0aaa20baeb54fd52
blob + 8ece0c688819408c91609118d132a62759f967de
--- src/lib9/date.c
+++ src/lib9/date.c
@@ -1,19 +1,25 @@
 #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;
 
 static void
@@ -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
blob - c7cf64d662aa2746640661560354344ddbeb6004
blob + 7144e7cd543a88c9ff2ceb325d69d1d3220fab7e
--- src/lib9/dirfwstat.c
+++ 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;
blob - ab9ec7f598de288e9e0bb7fb30dec0dbe7772ee0
blob + 1e479fe438af9a85b4b1c493464e7285d5f65c3b
--- src/lib9/dirread.c
+++ 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)
blob - d003ac832e8aa9e1a4c7f49e739119378c31b82a
blob + 6f35196509cdce3c576710e9565ad6f14121f426
--- src/lib9/dirwstat.c
+++ src/lib9/dirwstat.c
@@ -1,7 +1,6 @@
 #include <u.h>
 #define NOPLAN9DEFINES
 #include <libc.h>
-
 #include <sys/time.h>
 #include <utime.h>
 
blob - 92da30c87df5b6f3c6a464d38c51d149748d37de
blob + c65ddaaeb935ebb9385d63913beeb9792ba6fd97
--- src/libhttpd/fail.c
+++ 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"},
 };
 
 /*
blob - ac1cac21244f0f71f11e8184a23073933a419094
blob + fce96fd3ef3bd4bd9022824edbc10a56e001dfce
--- src/libsec/port/aes.c
+++ 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]);
blob - b9e646e3c2e82dd7649b90f5d236892955fc4b98
blob + 293e330626d6eb6fdb0d8636a94a72cef04e30b3
--- src/libthread/sched.c
+++ 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)
blob - 5eb2135ece3661bfef35cc6ff2b0617f2d1e1142
blob + 0c298c627142333a22313f35156afda51e76464c
--- src/libthread/sun4u.c
+++ 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 *ar
 {
 	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);
 }
 
blob - 23e34efe36f7ce04feb453fc123033fcba2b71c9
blob + 790f0f608dfc8e59da9849a42bdc904a05c1dbaf
--- src/mkfile
+++ src/mkfile
@@ -7,7 +7,7 @@ DIRS=\
 	libfmt\
 	libframe\
 	libhttpd\
-	libip\
+#	libip\
 	libregexp\
 	libsec\
 	libthread\