Merge branch 'master' of git://factorcode.org/git/factor

Slava Pestov 2008-03-20 21:12:09 -05:00
commit bc8d7e7cd0
12 changed files with 311 additions and 31 deletions

View File

@ -0,0 +1,30 @@
USING: kernel alien.syntax math ;
IN: unix.stat
! FreeBSD 8.0-CURRENT
C-STRUCT: stat
{ "__dev_t" "st_dev" }
{ "ino_t" "st_ino" }
{ "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" }
{ "gid_t" "st_gid" }
{ "__dev_t" "st_rdev" }
{ "timespec" "st_atim" }
{ "timespec" "st_mtim" }
{ "timespec" "st_ctim" }
{ "off_t" "st_size" }
{ "blkcnt_t" "st_blocks" }
{ "blksize_t" "st_blksize" }
{ "fflags_t" "st_flags" }
{ "__uint32_t" "st_gen" }
{ "__int32_t" "st_lspare" }
{ "timespec" "st_birthtimespec" }
! not sure about the padding here.
{ "__uint32_t" "pad0" }
{ "__uint32_t" "pad1" } ;
FUNCTION: int stat ( char* pathname, stat* buf ) ;
FUNCTION: int lstat ( char* pathname, stat* buf ) ;

View File

@ -0,0 +1,30 @@
USING: kernel alien.syntax math ;
IN: unix.stat
! FreeBSD 8.0-CURRENT
! untested
C-STRUCT: stat
{ "__dev_t" "st_dev" }
{ "ino_t" "st_ino" }
{ "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" }
{ "gid_t" "st_gid" }
{ "__dev_t" "st_rdev" }
{ "timespec" "st_atim" }
{ "timespec" "st_mtim" }
{ "timespec" "st_ctim" }
{ "off_t" "st_size" }
{ "blkcnt_t" "st_blocks" }
{ "blksize_t" "st_blksize" }
{ "fflags_t" "st_flags" }
{ "__uint32_t" "st_gen" }
{ "__int32_t" "st_lspare" }
{ "timespec" "st_birthtimespec" }
! not sure about the padding here.
{ "__uint32_t" "pad0" }
{ "__uint32_t" "pad1" } ;
FUNCTION: int stat ( char* pathname, stat* buf ) ;
FUNCTION: int lstat ( char* pathname, stat* buf ) ;

View File

@ -1,30 +1,7 @@
USING: kernel alien.syntax math ;
USING: layouts combinators vocabs.loader ;
IN: unix.stat
! FreeBSD 8.0-CURRENT
C-STRUCT: stat
{ "__dev_t" "st_dev" }
{ "ino_t" "st_ino" }
{ "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" }
{ "gid_t" "st_gid" }
{ "__dev_t" "st_rdev" }
{ "timespec" "st_atim" }
{ "timespec" "st_mtim" }
{ "timespec" "st_ctim" }
{ "off_t" "st_size" }
{ "blkcnt_t" "st_blocks" }
{ "blksize_t" "st_blksize" }
{ "fflags_t" "st_flags" }
{ "__uint32_t" "st_gen" }
{ "__int32_t" "st_lspare" }
{ "timespec" "st_birthtimespec" }
! not sure about the padding here.
{ "__uint32_t" "pad0" }
{ "__uint32_t" "pad1" } ;
FUNCTION: int stat ( char* pathname, stat* buf ) ;
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
cell-bits {
{ 32 [ "unix.stat.freebsd.32" require ] }
{ 64 [ "unix.stat.freebsd.64" require ] }
} case

View File

@ -0,0 +1,29 @@
USING: kernel alien.syntax math ;
IN: unix.stat
! OpenBSD 4.2
C-STRUCT: stat
{ "dev_t" "st_dev" }
{ "ino_t" "st_ino" }
{ "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" }
{ "gid_t" "st_gid" }
{ "dev_t" "st_rdev" }
{ "int32_t" "st_lspare0" }
{ "timespec*" "st_atimespec" }
{ "timespec*" "st_mtimespec" }
{ "timespec*" "st_ctimespec" }
{ "off_t" "st_size" }
{ "int64_t" "st_blocks" }
{ "u_int32_t" "st_blksize" }
{ "u_int32_t" "st_flags" }
{ "u_int32_t" "st_gen" }
{ "int32_t" "st_lspare1" }
{ "timespec*" "st_birthtimespec" }
{ "int64_t" "st_qspare1" }
{ "int64_t" "st_qspare2" } ;
! FUNCTION: int stat ( char* pathname, stat* buf ) ;
FUNCTION: int lstat ( char* pathname, stat* buf ) ;

View File

@ -0,0 +1,29 @@
USING: kernel alien.syntax math ;
IN: unix.stat
! OpenBSD 4.2
C-STRUCT: stat
{ "dev_t" "st_dev" }
{ "ino_t" "st_ino" }
{ "mode_t" "st_mode" }
{ "nlink_t" "st_nlink" }
{ "uid_t" "st_uid" }
{ "gid_t" "st_gid" }
{ "dev_t" "st_rdev" }
{ "int32_t" "st_lspare0" }
{ "timespec*" "st_atimespec" }
{ "timespec*" "st_mtimespec" }
{ "timespec*" "st_ctimespec" }
{ "off_t" "st_size" }
{ "int64_t" "st_blocks" }
{ "u_int32_t" "st_blksize" }
{ "u_int32_t" "st_flags" }
{ "u_int32_t" "st_gen" }
{ "int32_t" "st_lspare1" }
{ "timespec*" "st_birthtimespec" }
{ "int64_t" "st_qspare1" }
{ "int64_t" "st_qspare2" } ;
! FUNCTION: int stat ( char* pathname, stat* buf ) ;
FUNCTION: int lstat ( char* pathname, stat* buf ) ;

View File

@ -0,0 +1,7 @@
USING: layouts combinators vocabs.loader ;
IN: unix.stat
cell-bits {
{ 32 [ "unix.stat.openbsd.32" require ] }
{ 64 [ "unix.stat.openbsd.64" require ] }
} case

View File

@ -0,0 +1,29 @@
USING: alien.syntax ;
IN: unix.types
! OpenBSD 4.2
TYPEDEF: ushort __uint16_t
TYPEDEF: uint __uint32_t
TYPEDEF: int __int32_t
TYPEDEF: longlong __int64_t
TYPEDEF: int int32_t
TYPEDEF: int u_int32_t
TYPEDEF: longlong int64_t
TYPEDEF: ulonglong u_int64_t
TYPEDEF: __uint32_t __dev_t
TYPEDEF: __uint32_t dev_t
TYPEDEF: __uint32_t ino_t
TYPEDEF: __uint16_t mode_t
TYPEDEF: __uint16_t nlink_t
TYPEDEF: __uint32_t uid_t
TYPEDEF: __uint32_t gid_t
TYPEDEF: __int64_t off_t
TYPEDEF: __int64_t blkcnt_t
TYPEDEF: __uint32_t blksize_t
TYPEDEF: __uint32_t fflags_t
TYPEDEF: int ssize_t
TYPEDEF: int pid_t
TYPEDEF: int time_t

View File

@ -10,6 +10,8 @@ os
{ "linux" [ "unix.types.linux" require ] }
{ "macosx" [ "unix.types.macosx" require ] }
{ "freebsd" [ "unix.types.freebsd" require ] }
{ "openbsd" [ "unix.types.openbsd" require ] }
{ "netbsd" [ "unix.types.netbsd" require ] }
[ drop ]
}
case
case

139
misc/grovel.c Normal file
View File

@ -0,0 +1,139 @@
#include <stdio.h>
#if defined(__FreeBSD__)
#define BSD
#define FREEBSD
#define UNIX
#endif
#if defined(__NetBSD__)
#define BSD
#define NETBSD
#define UNIX
#endif
#if (__OpenBSD__)
#define BSD
#define OPENBSD
#define UNIX
#endif
#if defined(linux)
#define LINUX
#define UNIX
#endif
#if defined(__amd64__) || defined(__x86_64__)
#define BIT64
#else
#define BIT32
#endif
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
#endif
#define BL printf(" ");
#define QUOT printf("\"");
#define NL printf("\n");
#define LB printf("{"); BL
#define RB BL printf("}");
#define SEMI printf(";");
#define grovel(t) printf("TYPEDEF: "); printf("%d", sizeof(t)); BL printf(#t); NL
#define grovel2impl(t,n) BL BL BL BL LB QUOT printf(#t); QUOT BL QUOT printf((n)); QUOT RB
#define grovel2(t,n) grovel2impl(t,n) NL
#define grovel2end(t,n) grovel2impl(t,n) BL SEMI NL
#define header(os) printf("vvv %s vvv", (os)); NL
#define footer(os) printf("^^^ %s ^^^", (os)); NL
#define header2(os,struct) printf("vvv %s %s vvv", (os), (struct)); NL
#define footer2(os,struct) printf("^^^ %s %s ^^^", (os), (struct)); NL
#define struct(n) printf("C-STRUCT: %s\n", (n));
void openbsd_types()
{
header2("openbsd", "types");
grovel(dev_t);
grovel(gid_t);
grovel(ino_t);
grovel(int32_t);
grovel(int64_t);
grovel(mode_t);
grovel(nlink_t);
grovel(off_t);
grovel(struct timespec);
grovel(uid_t);
footer2("openbsd", "types");
}
void openbsd_stat()
{
header2("openbsd", "stat");
struct("stat");
grovel2(dev_t, "st_dev");
grovel2(ino_t, "st_ino");
grovel2(mode_t, "st_mode");
grovel2(nlink_t, "st_nlink");
grovel2(uid_t, "st_uid");
grovel2(gid_t, "st_gid");
grovel2(dev_t, "st_rdev");
grovel2(int32_t, "st_lspare0");
grovel2(struct timespec, "st_atimespec");
grovel2(struct timespec, "st_mtimespec");
grovel2(struct timespec, "st_ctimespec");
grovel2(off_t, "st_size");
grovel2(int64_t, "st_blocks");
grovel2(u_int32_t, "st_blksize");
grovel2(u_int32_t, "st_flags");
grovel2(u_int32_t, "st_gen");
grovel2(int32_t, "st_lspare1");
grovel2(struct timespec, "st_birthtimespec");
grovel2(int64_t, "st_qspare1");
grovel2end(int64_t, "st_qspare2");
footer2("openbsd", "stat");
}
void unix_types()
{
grovel(dev_t);
grovel(gid_t);
grovel(ino_t);
grovel(int32_t);
grovel(int64_t);
grovel(mode_t);
grovel(nlink_t);
grovel(off_t);
grovel(struct timespec);
grovel(struct stat);
grovel(time_t);
grovel(uid_t);
}
int main() {
//grovel(char);
//grovel(int);
//grovel(uint);
//grovel(long);
//grovel(ulong);
//grovel(long long);
//grovel(unsigned long long);
//grovel(void*);
//grovel(char*);
#ifdef FREEBSD
grovel(blkcnt_t);
grovel(blksize_t);
grovel(fflags_t);
#endif
#ifdef OPENBSD
openbsd_stat();
openbsd_types();
#endif
#ifdef UNIX
#endif
return 0;
}

View File

@ -1,4 +1,5 @@
include vm/Config.unix
PLAF_DLL_OBJS += vm/os-genunix.o vm/os-openbsd.o
CC = egcc
CFLAGS += -export-dynamic
LIBS = -L/usr/local/lib/ -lm $(X11_UI_LIBS)

View File

@ -1,7 +1,10 @@
#include <i386/signal.h>
INLINE void *openbsd_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
return (void *)ucontext->sc_esp;
struct sigcontext *sc = (struct sigcontext*) uap;
return (void *)sc->sc_esp;
}
#define ucontext_stack_pointer openbsd_stack_pointer
#define UAP_PROGRAM_COUNTER(uap) (((struct sigcontext*)(uap))->sc_eip)

View File

@ -1,2 +1,6 @@
#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
#ifndef environ
extern char **environ;
#endif