mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
More tweaks on Linux and Solaris.
This commit is contained in:
parent
f7012583e9
commit
64bcfff3a1
14 changed files with 118 additions and 75 deletions
3
bin/9c
3
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 "$@"
|
||||
|
|
2
bin/9l
2
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"
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
static char *exname;
|
||||
|
||||
#define STACK 8192
|
||||
#define STACK 16384
|
||||
|
||||
void
|
||||
getscreen(int argc, char **argv)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 @@ 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <u.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
|
||||
|
|
|
@ -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",
|
||||
"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"},
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ DIRS=\
|
|||
libfmt\
|
||||
libframe\
|
||||
libhttpd\
|
||||
libip\
|
||||
# libip\
|
||||
libregexp\
|
||||
libsec\
|
||||
libthread\
|
||||
|
|
Loading…
Reference in a new issue