diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-10 03:01:37 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-10 03:01:37 +0200 |
commit | 3238f124b81e53762e5c2e021630de20bdb7cbd9 (patch) | |
tree | ccc487619075a8cb8976ff38ccc9bcfc06b420a1 /sys/src/ape/lib/9 | |
parent | ea6910b70680cd8a0d77e413f116e758c07997a5 (diff) |
ape: move compatibility libc.h to lib9 directory and incooperate needed functions for ape/mp (wip)
Diffstat (limited to 'sys/src/ape/lib/9')
-rw-r--r-- | sys/src/ape/lib/9/argv0.c | 3 | ||||
-rw-r--r-- | sys/src/ape/lib/9/libc.h | 153 | ||||
-rw-r--r-- | sys/src/ape/lib/9/mkfile | 28 | ||||
-rw-r--r-- | sys/src/ape/lib/9/setmalloctag.c | 4 | ||||
-rw-r--r-- | sys/src/ape/lib/9/setrealloctag.c | 6 |
5 files changed, 192 insertions, 2 deletions
diff --git a/sys/src/ape/lib/9/argv0.c b/sys/src/ape/lib/9/argv0.c new file mode 100644 index 000000000..c2b466bbf --- /dev/null +++ b/sys/src/ape/lib/9/argv0.c @@ -0,0 +1,3 @@ +#include <lib9.h> + +char *argv0; diff --git a/sys/src/ape/lib/9/libc.h b/sys/src/ape/lib/9/libc.h new file mode 100644 index 000000000..6ec1580c2 --- /dev/null +++ b/sys/src/ape/lib/9/libc.h @@ -0,0 +1,153 @@ +#define _LOCK_EXTENSION +#define _QLOCK_EXTENSION +#define _BSD_EXTENSION +#include <stdint.h> +#include <sys/types.h> +#include <lock.h> +#include <qlock.h> +#include <lib9.h> +#include <stdlib.h> +#include <string.h> +#include <bsd.h> +#include <unistd.h> +#include <fcntl.h> +#include <assert.h> +#include <utf.h> +#include <fmt.h> +#include <signal.h> + +#define nelem(x) (sizeof(x)/sizeof((x)[0])) + +typedef +struct Qid +{ + uvlong path; + ulong vers; + uchar type; +} Qid; + +typedef +struct Dir { + /* system-modified data */ + ushort type; /* server type */ + uint dev; /* server subtype */ + /* file data */ + Qid qid; /* unique id from server */ + ulong mode; /* permissions */ + ulong atime; /* last read time */ + ulong mtime; /* last write time */ + vlong length; /* file length: see <u.h> */ + char *name; /* last element of path */ + char *uid; /* owner name */ + char *gid; /* group name */ + char *muid; /* last modifier name */ +} Dir; + +uint _convM2D(uchar*, uint, Dir*, char*); +uint _convD2M(Dir*, uchar*, uint); +Dir *_dirstat(char*); +int _dirwstat(char*, Dir*); +Dir *_dirfstat(int); +int _dirfwstat(int, Dir*); +long _dirread(int, Dir**); +long _dirreadall(int, Dir**); +void _nulldir(Dir*); +uint _sizeD2M(Dir*); + +typedef +struct Waitmsg +{ + int pid; /* of loved one */ + unsigned long time[3]; /* of loved one & descendants */ + char *msg; +} Waitmsg; + + +extern int _AWAIT(char*, int); +extern int _ALARM(unsigned long); +extern int _BIND(const char*, const char*, int); +extern int _CHDIR(const char*); +extern int _CLOSE(int); +extern int _CREATE(char*, int, unsigned long); +extern int _DUP(int, int); +extern int _ERRSTR(char*, unsigned int); +extern int _EXEC(char*, char*[]); +extern void _EXITS(char *); +extern int _FD2PATH(int, char*, int); +extern int _FAUTH(int, char*); +extern int _FSESSION(int, char*, int); +extern int _FSTAT(int, unsigned char*, int); +extern int _FWSTAT(int, unsigned char*, int); +extern int _MOUNT(int, int, const char*, int, const char*); +extern int _NOTED(int); +extern int _NOTIFY(int(*)(void*, char*)); +extern int _OPEN(const char*, int); +extern int _PIPE(int*); +extern long _PREAD(int, void*, long, long long); +extern long _PWRITE(int, void*, long, long long); +extern long _READ(int, void*, long); +extern int _REMOVE(const char*); +extern void* _RENDEZVOUS(void*, void*); +extern int _RFORK(int); +extern void* _SEGATTACH(int, char*, void*, unsigned long); +extern void* _SEGBRK(void*, void*); +extern int _SEGDETACH(void*); +extern int _SEGFLUSH(void*, unsigned long); +extern int _SEGFREE(void*, unsigned long); +extern long long _SEEK(int, long long, int); +extern int _SLEEP(long); +extern int _STAT(const char*, unsigned char*, int); +extern Waitmsg* _WAIT(void); +extern long _WRITE(int, const void*, long); +extern int _WSTAT(const char*, unsigned char*, int); +extern void* _MALLOCZ(int, int); +extern int _WERRSTR(char*, ...); +extern long _READN(int, void*, long); +extern int _IOUNIT(int); +extern vlong _NSEC(void); + +#define dirstat _dirstat +#define dirfstat _dirfstat + +#define OREAD 0 +#define OWRITE 1 +#define ORDWR 2 +#define OCEXEC 32 + +#define AREAD 4 +#define AWRITE 2 +#define AEXEC 1 +#define AEXIST 0 + +#define _exits(s) _exit(s && *(char*)s ? 1 : 0) +#define exits(s) exit(s && *(char*)s ? 1 : 0) + +#define create(file, omode, perm) open(file, (omode) |O_CREAT | O_TRUNC, perm) +#define seek(fd, off, dir) lseek(fd, off, dir) + +#define readn _READN +#define pread _PREAD +#define pwrite _PWRITE +#define mallocz _MALLOCZ +#define nsec _NSEC +#define iounit _IOUNIT + +#define postnote(who,pid,note) kill(pid,SIGTERM) +#define atnotify(func,in) + +#define ERRMAX 128 + +extern void setmalloctag(void*, uintptr_t); +extern void setrealloctag(void*, uintptr_t); +extern uintptr_t getcallerpc(void*); + +extern int dec16(uchar *, int, char *, int); +extern int enc16(char *, int, uchar *, int); +extern int dec32(uchar *, int, char *, int); +extern int enc32(char *, int, uchar *, int); +extern int dec64(uchar *, int, char *, int); +extern int enc64(char *, int, uchar *, int); + +extern int tokenize(char*, char**, int); +extern void sysfatal(char*, ...); +extern ulong truerand(void); /* uses /dev/random */ diff --git a/sys/src/ape/lib/9/mkfile b/sys/src/ape/lib/9/mkfile index c040695df..cc3e5b9b8 100644 --- a/sys/src/ape/lib/9/mkfile +++ b/sys/src/ape/lib/9/mkfile @@ -2,7 +2,8 @@ APE=/sys/src/ape <$APE/config LIB=/$objtype/lib/ape/lib9.a -OFILES=errstr.$O\ +OFILES=argv0.$O\ + errstr.$O\ bind.$O\ getcallerpc.$O\ getfcr.$O\ @@ -14,6 +15,13 @@ OFILES=errstr.$O\ segflush.$O\ segfree.$O\ setmalloctag.$O\ + setrealloctag.$O\ + sysfatal.$O\ + tokenize.$O\ + truerand.$O\ + u16.$O\ + u32.$O\ + u64.$O\ unmount.$O\ </sys/src/cmd/mksyslib @@ -28,3 +36,21 @@ CFLAGS=-c $CFLAGS -D_POSIX_SOURCE -D_PLAN9_SOURCE %.$O: $objtype/%.c $CC $CFLAGS $prereq + +sysfatal.$O: ../../../libc/9sys/sysfatal.c + $CC $CFLAGS -I. ../../../libc/9sys/sysfatal.c + +tokenize.$O: ../../../libc/port/tokenize.c + $CC $CFLAGS -I. ../../../libc/port/tokenize.c + +truerand.$O: ../../../libc/9sys/truerand.c + $CC $CFLAGS -I. ../../../libc/9sys/truerand.c + +u16.$O: ../../../libc/port/u16.c + $CC $CFLAGS -I. ../../../libc/port/u16.c + +u32.$O: ../../../libc/port/u32.c + $CC $CFLAGS -I. ../../../libc/port/u32.c + +u64.$O: ../../../libc/port/u64.c + $CC $CFLAGS -I. ../../../libc/port/u64.c diff --git a/sys/src/ape/lib/9/setmalloctag.c b/sys/src/ape/lib/9/setmalloctag.c index b5d159475..b83787036 100644 --- a/sys/src/ape/lib/9/setmalloctag.c +++ b/sys/src/ape/lib/9/setmalloctag.c @@ -1,4 +1,6 @@ +#include <stdint.h> + void -setmalloctag(void*, unsigned long) +setmalloctag(void*, uintptr_t) { } diff --git a/sys/src/ape/lib/9/setrealloctag.c b/sys/src/ape/lib/9/setrealloctag.c new file mode 100644 index 000000000..4574b739c --- /dev/null +++ b/sys/src/ape/lib/9/setrealloctag.c @@ -0,0 +1,6 @@ +#include <stdint.h> + +void +setrealloctag(void*, uintptr_t) +{ +} |