Annoying changes to work on Sun boxes.

This commit is contained in:
rsc 2003-11-23 19:49:17 +00:00
parent 50e628cb8f
commit 1c253ceb58
19 changed files with 95 additions and 54 deletions

5
bin/9c
View file

@ -15,8 +15,7 @@ usegcc()
"
}
cc=none
tag="`uname`-`uname -m`-${CC:-cc}"
tag="`uname`-`uname -m`-${CC9:-cc}"
case "$tag" in
*BSD*) usegcc ;;
*Darwin*) usegcc ;;
@ -30,4 +29,4 @@ case "$tag" in
exit 1
esac
exec cc $cflags "$@"
exec $cc $cflags "$@"

18
bin/9l
View file

@ -1,26 +1,18 @@
#!/bin/sh
ld=none
extralibs=-lm
tag="`uname`-`uname -m`-${CC:-cc}"
tag="`uname`-`uname -m`"
case "$tag" in
*FreeBSD*) ld=gcc ;;
*BSD*) ld=gcc ;;
*Linux*) ld=gcc ;;
*Darwin*) ld=gcc ;;
*SunOS*-cc) ld=cc; extralibs="$extralibs -lrt -lpthread" ;;
*SunOS*-gcc) ld=gcc ;;
*SunOS*) ld=${CC9:-cc}
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
;;
*)
echo do not know how to link on "$tag" 1>&2
exit 1
esac
case $ld in
gcc)
exec gcc \
-ggdb \
-L$PLAN9/lib \
"$@" \
$extralibs
;;
esac
exec $ld -L$PLAN9/lib "$@" $extralibs

View file

@ -30,6 +30,15 @@ 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 _HAVETIMEZONEINT 1
#define _HAVEFUTIMESAT 1
#define _HAVEFUTIMES 1
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#if defined(__linux__)
@ -45,6 +54,12 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
# 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>
@ -52,6 +67,7 @@ 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>
@ -412,7 +428,7 @@ extern double atof(char*); <stdlib.h>
extern int atoi(char*);
extern long atol(char*);
*/
extern vlong atoll(char*);
extern vlong atoll(const char*);
extern double charstod(int(*)(void*), void*);
extern char* cleanname(char*);
extern int p9decrypt(void*, void*, int);
@ -723,7 +739,7 @@ extern int p9dup(int, int);
extern int errstr(char*, uint);
extern int p9exec(char*, char*[]);
/* extern int execl(char*, ...); <unistd.h> */
extern int fork(void);
/* extern int fork(void); <unistd.h> */
extern int p9rfork(int);
/* not implemented
extern int fauth(int, char*);
@ -788,8 +804,8 @@ extern int dirfwstat(int, Dir*);
extern long dirread(int, Dir**);
extern void nulldir(Dir*);
extern long dirreadall(int, Dir**);
extern int getpid(void);
extern int getppid(void);
/* extern int getpid(void); <unistd.h> */
/* extern int getppid(void); */
extern void rerrstr(char*, uint);
extern char* sysname(void);
extern void werrstr(char*, ...);

View file

@ -1,5 +1,6 @@
../bin/mk: mkmk.sh
PATH=`pwd`/../bin:$PATH export PATH
PATH=`pwd`/../bin:$$PATH export PATH; \
PLAN9=`pwd`/.. export PLAN9; \
sh -x mkmk.sh
all clean install nuke: ../bin/mk

View file

@ -6,7 +6,7 @@ LDFLAGS=$LDFLAGS -lsec -lregexp9 -l9 -lbio -lfmt -lutf
<$PLAN9/src/mkmany
BUGGERED='CVS|oplumb|plumb|plumb2|mk|vac'
BUGGERED='CVS|oplumb|plumb|plumb2|mk|vac|9term'
DIRS=`ls -l |sed -n 's/^d.* //p' |egrep -v "$BUGGERED"`
<$PLAN9/src/mkdirs

View file

@ -7,7 +7,7 @@
%left BANG SUBSHELL
%left PIPE
%left '^'
%right '$' COUNT '"'
%right '$' COUNT '\"'
%left SUB
%{
#include "rc.h"

View file

@ -71,16 +71,12 @@ it:V: all
<$PLAN9/src/mkmany
$SLIB: $LIBOFILES
ar rvc $SLIB $LIBOFILES
# xml.c:D: mkxml dat.h
# ./mkxml dat.h > xml.c
$SLIB(%.$O):N: %.$O
$SLIB: ${LIBOFILES:%=$SLIB(%)}
names=`echo $newprereq | sed -E 's/'$SLIB'\(([^)]+)\)/\1/g'`
# names = `{echo $newprereq |sed 's/ /\n/g' |sed -n 's/'$SLIB'\(([^)]+)\)/\1/gp'}
ar rvc $SLIB $names
# rm $names
ainstall:V: ${TARG:%=%.ainstall}
%.ainstall:V: $O.%

View file

@ -1,9 +1,9 @@
#include <u.h>
#include <libc.h>
#include <netdb.h>
#include <sys/un.h>
#include <u.h>
#include <libc.h>
static char *nets[] = { "tcp", "udp", nil };
#define CLASS(p) ((*(uchar*)(p))>>6)
@ -59,7 +59,7 @@ _p9dialparse(char *addr, char **pnet, char **punix, u32int *phost, int *pport)
int i;
struct servent *se;
struct hostent *he;
struct sockaddr_un *sun;
struct sockaddr_un *sockun;
if(strncmp(addr, "/net/", 5) == 0)
addr += 5;
@ -73,7 +73,7 @@ _p9dialparse(char *addr, char **pnet, char **punix, u32int *phost, int *pport)
if((port = strchr(host, '!')) == nil){
if(strcmp(net, "unix")==0 || strcmp(net, "net")==0){
Unix:
if(strlen(host)+1 > sizeof sun->sun_path){
if(strlen(host)+1 > sizeof sockun->sun_path){
werrstr("unix socket name too long");
return -1;
}

View file

@ -1,13 +1,15 @@
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
#include <sys/stat.h>
#ifdef _HAVEDISKLABEL
#include <sys/disklabel.h>
#endif
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
int
_p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
{
@ -83,7 +85,9 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
d->muid = "";
d->qid.path = ((uvlong)st->st_dev<<32) | st->st_ino;
#ifdef _HAVESTGEN
d->qid.vers = st->st_gen;
#endif
d->mode = st->st_mode&0777;
d->atime = st->st_atime;
d->mtime = st->st_mtime;
@ -96,6 +100,7 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
}
/* fetch real size for disks */
#ifdef _HAVEDISKLABEL
if(S_ISCHR(st->st_mode)){
int fd, n;
struct disklabel lab;
@ -114,6 +119,7 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
if(fd >= 0)
close(fd);
}
#endif
}
return sz;

View file

@ -6,6 +6,8 @@
#include <netinet/in.h>
#include <sys/un.h>
#undef sun
#define sun sockun
extern int _p9dialparse(char*, char**, char**, u32int*, int*);
static int
@ -88,7 +90,6 @@ print("announce dir: %s\n", dir);
Unix:
memset(&sun, 0, sizeof sun);
sun.sun_family = AF_UNIX;
sun.sun_len = sizeof sun;
strcpy(sun.sun_path, unix);
if((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
return -1;

View file

@ -38,7 +38,9 @@ static struct {
SIGVTALRM, "sys: virtual time alarm",
SIGPROF, "sys: profiling timer alarm",
SIGWINCH, "sys: window size change",
#ifdef SIGINFO
SIGINFO, "sys: status request",
#endif
SIGUSR1, "sys: usr1",
SIGUSR2, "sys: usr2",
};

View file

@ -25,8 +25,12 @@ tm2Tm(struct tm *tm, Tm *bigtm)
bigtm->mon = tm->tm_mon;
bigtm->year = tm->tm_year;
bigtm->wday = tm->tm_wday;
#ifdef _HAVETMZONE
strecpy(bigtm->zone, bigtm->zone+4, tm->tm_zone);
#endif
#ifdef _HAVETZOFF
bigtm->tzoff = tm->tm_gmtoff;
#endif
}
static void
@ -40,8 +44,12 @@ Tm2tm(Tm *bigtm, struct tm *tm)
tm->tm_mon = bigtm->mon;
tm->tm_year = bigtm->year;
tm->tm_wday = bigtm->wday;
#ifdef _HAVETMZONE
tm->tm_zone = bigtm->zone;
#endif
#ifdef _HAVETZOFF
tm->tm_gmtoff = bigtm->tzoff;
#endif
}
Tm*
@ -64,6 +72,14 @@ p9localtime(long t)
return &bigtm;
}
#if !defined(_HAVETIMEGM) && defined(_HAVETIMEZONEINT)
static long
timegm(struct tm *tm)
{
return mktime(tm)-timezone;
}
#endif
long
p9tm2sec(Tm *bigtm)
{

View file

@ -72,7 +72,6 @@ p9dial(char *addr, char *dummy1, char *dummy2, int *dummy3)
Unix:
memset(&su, 0, sizeof su);
su.sun_len = sizeof su;
su.sun_family = AF_UNIX;
if(strlen(unix)+1 > sizeof su.sun_path){
werrstr("unix socket name too long");

View file

@ -4,6 +4,14 @@
#include <sys/time.h>
#if !defined(_HAVEFUTIMES) && defined(_HAVEFUTIMESAT)
static int
futimes(int fd, struct timeval *tv)
{
return futimesat(fd, 0, tv);
}
#endif
int
dirfwstat(int fd, Dir *dir)
{
@ -19,3 +27,4 @@ dirfwstat(int fd, Dir *dir)
tv[1].tv_usec = 0;
return futimes(fd, tv);
}

View file

@ -24,10 +24,10 @@ countde(char *p, int n)
de = (struct dirent*)p;
if(de->d_reclen <= 4+2+2+1 || p+de->d_reclen > e)
break;
if(de->d_namlen == 1 && de->d_name[0]=='.')
de->d_namlen = 0;
else if(de->d_namlen == 2 && de->d_name[0]=='.' && de->d_name[1]=='.')
de->d_namlen = 0;
if(de->d_name[0]=='.' && de->d_name[1]==0)
de->d_name[0] = 0;
else if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0)
de->d_name[0] = 0;
else
m++;
p += de->d_reclen;
@ -59,7 +59,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
for(i=0; i<n; i++){
de = (struct dirent*)p;
if(stat(de->d_name, &st) < 0)
de->d_namlen = 0;
de->d_name[0] = 0;
else
nstr += _p9dir(&st, de->d_name, nil, nil, nil);
p += de->d_reclen;
@ -78,7 +78,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
m = 0;
for(i=0; i<n; i++){
de = (struct dirent*)p;
if(de->d_namlen != 0 && stat(de->d_name, &st) >= 0)
if(de->d_name[0] != 0 && stat(de->d_name, &st) >= 0)
_p9dir(&st, de->d_name, &d[m++], &str, estr);
p += de->d_reclen;
}
@ -108,7 +108,7 @@ dirread(int fd, Dir **dp)
if(buf == nil)
return -1;
n = getdents(fd, buf, st.st_blksize);
n = getdents(fd, (struct dirent*)buf, st.st_blksize);
if(n < 0){
free(buf);
return -1;
@ -141,7 +141,7 @@ dirreadall(int fd, Dir **d)
return -1;
}
buf = nbuf;
n = getdents(fd, buf+ts, st.st_blksize);
n = getdents(fd, (struct dirent*)(buf+ts), st.st_blksize);
if(n <= 0)
break;
ts += n;

View file

@ -38,7 +38,7 @@ OFILES=\
getuser.$O\
getwd.$O\
jmp.$O\
jmp-FreeBSD.$O\
jmp-$SYSNAME.$O\
lock.$O\
main.$O\
malloctag.$O\

View file

@ -9,7 +9,7 @@ p9rfork(int flags)
return -1;
}
if(flags&RFNOTEG){
setpgrp(0, 0);
setpgid(0, getpid());
flags &= ~RFNOTEG;
}
if(flags){

View file

@ -42,7 +42,7 @@ testmkmk:V:
ls -l ../bin/mk
testcvs:V:
cvs up -dAP
(cd ..; cvs up -dAP)
cp ../bin/_mk ../bin/mk
mk clean
rm ../lib/*.a

View file

@ -2,14 +2,18 @@ SYSNAME=`uname`
OBJTYPE=`uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'`
X11=/usr/X11R6
LDFLAGS=
CC=9c
LD=9l
AS=9a
CFLAGS=
LDFLAGS=
AFLAGS=
O=o
BIN=$PLAN9/bin
LIBDIR=$PLAN9/lib
<|sed -E '"s/(.*)\+=/\1=$\1 /g"' $PLAN9/src/Make.$SYSNAME-$OBJTYPE
<$PLAN9/src/mk.$SYSNAME-$OBJTYPE
OS=$O
LD=9l