More tweaks on Linux and Solaris.
diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
index f12f085..f49393e 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 d94208c..4375222 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 22ec672..8ece0c6 100644
--- a/src/lib9/date.c
+++ b/src/lib9/date.c
@@ -1,19 +1,25 @@
 #include <stdlib.h> /* setenv etc. */
 
 #include <u.h>
+#define NOPLAN9DEFINES
 #include <libc.h>
-
-#undef gmtime
-#undef localtime
-#undef asctime
-#undef ctime
-#undef cputime
-#undef times
-#undef tm2sec
-#undef nsec
-
 #include <time.h>
 
+#define _HAVETIMEGM 1
+#define _HAVETMZONE 1
+#define _HAVETMTZOFF 1
+
+#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 @@
 {
 	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 c7cf64d..7144e7c 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 @@
 	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 ab9ec7f..1e479fe 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 d003ac8..6f35196 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 92da30c..c65ddaa 100644
--- a/src/libhttpd/fail.c
+++ b/src/libhttpd/fail.c
@@ -14,33 +14,33 @@
 
 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",
-		"The object %s does not support the search command."},
-	[HNoData]	{"403 Forbidden", "No data supplied",
-		"Search or forms data must be supplied to %s."},
-	[HExpectFail]	{"403 Expectation Failed", "Expectation Failed",
-		"This server does not support some of your request's expectations."},
-	[HUnauth]	{"403 Forbidden", "Forbidden",
+	/* HUnauth */	{"403 Forbidden", "Forbidden",
 		"You are not allowed to see the object %s."},
-	[HOK]		{"200 OK", "everything is fine"},
+	/* 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",
+		"Search or forms data must be supplied to %s."},
+	/* HExpectFail */	{"403 Expectation Failed", "Expectation Failed",
+		"This server does not support some of your request's expectations."},
+	/* 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 ac1cac2..fce96fd 100644
--- a/src/libsec/port/aes.c
+++ b/src/libsec/port/aes.c
@@ -43,7 +43,7 @@
 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 b9e646e..293e330 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -10,7 +10,6 @@
 	"Ready",
 	"Rendezvous",
 };
-#endif
 
 static char*
 psstate(int s)
@@ -19,6 +18,7 @@
 		return "unknown";
 	return _psstate[s];
 }
+#endif
 
 void
 _schedinit(void *arg)
diff --git a/src/libthread/sun4u.c b/src/libthread/sun4u.c
index 5eb2135..0c298c6 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 @@
 {
 	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 23e34ef..790f0f6 100644
--- a/src/mkfile
+++ b/src/mkfile
@@ -7,7 +7,7 @@
 	libfmt\
 	libframe\
 	libhttpd\
-	libip\
+#	libip\
 	libregexp\
 	libsec\
 	libthread\