Commit b3f538a4 authored by Devon H. O'Dell's avatar Devon H. O'Dell Committed by Russ Cox

FreeBSD/i386 work

This patchset gets Go to pretty much the same state that
FreeBSD/amd64 is in.

R=rsc
https://golang.org/cl/157055
parent 2115f514
......@@ -36,6 +36,7 @@
#define Dbufslop 100
char linuxdynld[] = "/lib/ld-linux.so.2";
char freebsddynld[] = "/usr/libexec/ld-elf.so.1";
uint32 symdatva = 0x99<<24;
int32
......@@ -273,7 +274,7 @@ doelf(void)
Sym *s, *shstrtab, *dynamic, *dynstr, *d;
int h, nsym, t;
if(HEADTYPE != 7 && HEADTYPE != 8)
if(HEADTYPE != 7 && HEADTYPE != 8 && HEADTYPE != 9)
return;
/* predefine strings we need for section headers */
......@@ -303,7 +304,14 @@ doelf(void)
s = lookup(".interp", 0);
s->reachable = 1;
s->type = SDATA; // TODO: rodata
addstring(lookup(".interp", 0), linuxdynld);
switch(HEADTYPE) {
case 7:
addstring(lookup(".interp", 0), linuxdynld);
break;
case 9:
addstring(lookup(".interp", 0), freebsddynld);
break;
}
/*
* hash table - empty for now.
......@@ -527,6 +535,7 @@ asmb(void)
break;
case 7:
case 8:
case 9:
v = rnd(HEADR+textsize, INITRND);
seek(cout, v, 0);
break;
......@@ -583,6 +592,7 @@ asmb(void)
break;
case 7:
case 8:
case 9:
symo = rnd(HEADR+textsize, INITRND)+datsize;
symo = rnd(symo, INITRND);
break;
......@@ -752,6 +762,7 @@ asmb(void)
case 7:
case 8:
case 9:
/* elf 386 */
if(HEADTYPE == 8)
debug['d'] = 1;
......@@ -975,10 +986,15 @@ asmb(void)
eh->ident[EI_CLASS] = ELFCLASS32;
eh->ident[EI_DATA] = ELFDATA2LSB;
eh->ident[EI_VERSION] = EV_CURRENT;
if(HEADTYPE == 8) {
switch(HEADTYPE) {
case 8:
eh->ident[EI_OSABI] = ELFOSABI_NACL;
eh->ident[EI_ABIVERSION] = 6;
eh->flags = 0x200000; // aligned mod 32
break;
case 9:
eh->ident[EI_OSABI] = 9;
break;
}
eh->type = ET_EXEC;
......
......@@ -49,6 +49,10 @@ char *thestring = "386";
* -H2 -T4128 -R4096 is plan9 format
* -H3 -Tx -Rx is MS-DOS .COM
* -H4 -Tx -Rx is fake MS-DOS .EXE
* -H6 -Tx -Rx is Apple Mach-O
* -H7 -Tx -Rx is Linux ELF32
* -H8 -Tx -Rx is Google Native Client
* -H9 -Tx -Rx is FreeBSD ELF32
*/
static int
......@@ -154,6 +158,10 @@ main(int argc, char *argv[])
if(strcmp(goos, "nacl") == 0)
HEADTYPE = 8;
else
if(strcmp(goos, "freebsd") == 0) {
debug['d'] = 1; /* no dynamic syms for now */
HEADTYPE = 9;
} else
print("goos is not known: %sn", goos);
}
......@@ -226,13 +234,17 @@ main(int argc, char *argv[])
INITRND = 4096;
break;
case 7: /* elf32 executable */
case 9:
/*
* Linux ELF uses TLS offsets negative from %gs.
* Translate 0(GS) and 4(GS) into -8(GS) and -4(GS).
* Also known to ../../pkg/runtime/linux/386/sys.s
* and ../../libcgo/linux_386.c.
*/
tlsoffset = -8;
if (HEADTYPE == 7)
tlsoffset = -8;
else
tlsoffset = 0;
elfinit();
HEADR = ELFRESERVE;
if(INITTEXT == -1)
......
File mode changed from 100644 to 100755
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <pthread.h>
#include "libcgo.h"
static void* threadentry(void*);
static pthread_key_t k1, k2;
/* gccism: arrange for inittls to be called at dynamic load time */
static void inittls(void) __attribute__((constructor));
static void
inittls(void)
{
/* unimplemented for now */
}
void
initcgo(void)
{
}
void
libcgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
pthread_t p;
size_t size;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
}
static void*
threadentry(void *v)
{
ThreadStart ts;
ts = *(ThreadStart*)v;
free(v);
ts.g->stackbase = (uintptr)&ts;
/*
* libcgo_sys_thread_start set stackguard to stack size;
* change to actual guard pointer.
*/
ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
pthread_setspecific(k1, (void*)ts.g);
pthread_setspecific(k2, (void*)ts.m);
crosscall_386(ts.fn);
return nil;
}
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proc
// godefs freebsd/defs.c
// MACHINE GENERATED - DO NOT EDIT.
// Constants
enum {
PROT_NONE = 0,
PROT_READ = 0x1,
PROT_WRITE = 0x2,
PROT_EXEC = 0x4,
MAP_ANON = 0x1000,
MAP_PRIVATE = 0x2,
SA_SIGINFO = 0x40,
SA_RESTART = 0x2,
SA_ONSTACK = 0x1,
UMTX_OP_WAIT = 0x2,
UMTX_OP_WAKE = 0x3,
EINTR = 0x4,
};
// Types
#pragma pack on
typedef struct Rtprio Rtprio;
struct Rtprio {
uint16 type;
uint16 prio;
};
typedef struct ThrParam ThrParam;
struct ThrParam {
void *start_func;
void *arg;
int8 *stack_base;
uint32 stack_size;
int8 *tls_base;
uint32 tls_size;
int32 *child_tid;
int32 *parent_tid;
int32 flags;
Rtprio *rtp;
void* spare[3];
};
typedef struct Sigaltstack Sigaltstack;
struct Sigaltstack {
int8 *ss_sp;
uint32 ss_size;
int32 ss_flags;
};
typedef struct Sigset Sigset;
struct Sigset {
uint32 __bits[4];
};
typedef union Sigval Sigval;
union Sigval {
int32 sival_int;
void *sival_ptr;
int32 sigval_int;
void *sigval_ptr;
};
typedef struct StackT StackT;
struct StackT {
int8 *ss_sp;
uint32 ss_size;
int32 ss_flags;
};
typedef struct Siginfo Siginfo;
struct Siginfo {
int32 si_signo;
int32 si_errno;
int32 si_code;
int32 si_pid;
uint32 si_uid;
int32 si_status;
void *si_addr;
Sigval si_value;
byte _reason[32];
};
typedef struct Mcontext Mcontext;
struct Mcontext {
int32 mc_onstack;
int32 mc_gs;
int32 mc_fs;
int32 mc_es;
int32 mc_ds;
int32 mc_edi;
int32 mc_esi;
int32 mc_ebp;
int32 mc_isp;
int32 mc_ebx;
int32 mc_edx;
int32 mc_ecx;
int32 mc_eax;
int32 mc_trapno;
int32 mc_err;
int32 mc_eip;
int32 mc_cs;
int32 mc_eflags;
int32 mc_esp;
int32 mc_ss;
int32 mc_len;
int32 mc_fpformat;
int32 mc_ownedfp;
int32 mc_spare1[1];
int32 mc_fpstate[128];
int32 mc_fsbase;
int32 mc_gsbase;
int32 mc_spare2[6];
};
typedef struct Ucontext Ucontext;
struct Ucontext {
Sigset uc_sigmask;
Mcontext uc_mcontext;
Ucontext *uc_link;
StackT uc_stack;
int32 uc_flags;
int32 __spare__[4];
byte pad0[12];
};
typedef struct Sigcontext Sigcontext;
struct Sigcontext {
Sigset sc_mask;
int32 sc_onstack;
int32 sc_gs;
int32 sc_fs;
int32 sc_es;
int32 sc_ds;
int32 sc_edi;
int32 sc_esi;
int32 sc_ebp;
int32 sc_isp;
int32 sc_ebx;
int32 sc_edx;
int32 sc_ecx;
int32 sc_eax;
int32 sc_trapno;
int32 sc_err;
int32 sc_eip;
int32 sc_cs;
int32 sc_efl;
int32 sc_esp;
int32 sc_ss;
int32 sc_len;
int32 sc_fpformat;
int32 sc_ownedfp;
int32 sc_spare1[1];
int32 sc_fpstate[128];
int32 sc_fsbase;
int32 sc_gsbase;
int32 sc_spare2[6];
};
#pragma pack off
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Darwin and Linux use the same linkage to main
TEXT _rt0_386_freebsd(SB),7,$0
JMP _rt0_386(SB)
#include "runtime.h"
#include "defs.h"
#include "signals.h"
#include "os.h"
extern void sigtramp(void);
typedef struct sigaction {
union {
void (*__sa_handler)(int32);
void (*__sa_sigaction)(int32, Siginfo*, void *);
} __sigaction_u; /* signal handler */
int32 sa_flags; /* see signal options below */
int64 sa_mask; /* signal mask to apply */
} Sigaction;
void
dumpregs(Sigcontext *r)
{
printf("eax %x\n", r->sc_eax);
printf("ebx %x\n", r->sc_ebx);
printf("ecx %x\n", r->sc_ecx);
printf("edx %x\n", r->sc_edx);
printf("edi %x\n", r->sc_edi);
printf("esi %x\n", r->sc_esi);
printf("ebp %x\n", r->sc_ebp);
printf("esp %x\n", r->sc_esp);
printf("eip %x\n", r->sc_eip);
printf("eflags %x\n", r->sc_efl);
printf("cs %x\n", r->sc_cs);
printf("fs %x\n", r->sc_fsbase);
printf("gs %x\n", r->sc_gsbase);
}
void
sighandler(int32 sig, Siginfo* info, void* context)
{
Ucontext *uc;
Mcontext *mc;
Sigcontext *sc;
if(panicking) // traceback already printed
exit(2);
panicking = 1;
uc = context;
mc = &uc->uc_mcontext;
sc = (Sigcontext*)mc; // same layout, more conveient names
if(sig < 0 || sig >= NSIG)
printf("Signal %d\n", sig);
else
printf("%s\n", sigtab[sig].name);
printf("Faulting address: %p\n", info->si_addr);
printf("PC=%X\n", sc->sc_eip);
printf("\n");
if(gotraceback()){
traceback((void*)sc->sc_eip, (void*)sc->sc_esp, m->curg);
tracebackothers(m->curg);
dumpregs(sc);
}
breakpoint();
exit(2);
}
void
sigignore(void)
{
}
void
signalstack(byte *p, int32 n)
{
Sigaltstack st;
st.ss_sp = (int8*)p;
st.ss_size = n;
st.ss_flags = 0;
sigaltstack(&st, nil);
}
void
initsig(void)
{
static Sigaction sa;
int32 i;
sa.sa_flags |= SA_ONSTACK | SA_SIGINFO;
sa.sa_mask = ~0x0ull;
for(i = 0; i < NSIG; i++) {
if(sigtab[i].flags) {
if(sigtab[i].flags & SigCatch)
sa.__sigaction_u.__sa_handler = (void*) sigtramp;
else
sa.__sigaction_u.__sa_handler = (void*) sigignore;
if(sigtab[i].flags & SigRestart)
sa.sa_flags |= SA_RESTART;
else
sa.sa_flags &= ~SA_RESTART;
sigaction(i, &sa, nil);
}
}
}
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// System calls and other sys.stuff for 386, FreeBSD
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "386/asm.h"
TEXT sys_umtx_op(SB),7,$-4
MOVL $454, AX
INT $0x80
RET
TEXT thr_new(SB),7,$-4
MOVL $455, AX
INT $0x80
RET
TEXT thr_start(SB),7,$0
MOVL mm+0(FP), AX
MOVL m_g0(AX), BX
LEAL m_tls(AX), BP
MOVL 0(BP), DI
ADDL $7, DI
PUSHAL
PUSHL $32
PUSHL BP
PUSHL DI
CALL setldt(SB)
POPL AX
POPL AX
POPL AX
POPAL
MOVL BX, g
MOVL AX, m
CALL mstart(SB)
MOVL 0, AX // crash (not reached)
// Exit the entire program (like C exit)
TEXT exit(SB),7,$-4
MOVL $1, AX
INT $0x80
CALL notok(SB)
RET
TEXT exit1(SB),7,$-4
MOVL $431, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
RET
TEXT write(SB),7,$-4
MOVL $4, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
RET
TEXT notok(SB),7,$0
MOVL $0xf1, 0xf1
RET
TEXT runtime·mmap(SB),7,$-4
MOVL $477, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
RET
TEXT sigaction(SB),7,$-4
MOVL $416, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
RET
TEXT sigtramp(SB),7,$40
// g = m->gsignal
MOVL m, BP
MOVL m_gsignal(BP), BP
MOVL BP, g
MOVL signo+0(FP), AX
MOVL siginfo+4(FP), BX
MOVL context+8(FP), CX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
MOVL CX, 8(SP)
CALL sighandler(SB)
// g = m->curg
MOVL m, BP
MOVL m_curg(BP), BP
MOVL BP, g
MOVL context+8(FP), AX
MOVL $0, 0(SP) // syscall gap
MOVL AX, 4(SP)
MOVL $417, AX // sigreturn(ucontext)
INT $0x80
CALL notok(SB)
RET
TEXT sigaltstack(SB),7,$0
MOVL $53, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
RET
/*
descriptor entry format for system call
is the native machine format, ugly as it is:
2-byte limit
3-byte base
1-byte: 0x80=present, 0x60=dpl<<5, 0x1F=type
1-byte: 0x80=limit is *4k, 0x40=32-bit operand size,
0x0F=4 more bits of limit
1 byte: 8 more bits of base
int i386_get_ldt(int, union ldt_entry *, int);
int i386_set_ldt(int, const union ldt_entry *, int);
*/
// setldt(int entry, int address, int limit)
TEXT setldt(SB),7,$32
MOVL address+4(FP), BX // aka base
MOVL limit+8(FP), CX
// set up data_desc
LEAL 16(SP), AX // struct data_desc
MOVL $0, 0(AX)
MOVL $0, 4(AX)
MOVW BX, 2(AX)
SHRL $16, BX
MOVB BX, 4(AX)
SHRL $8, BX
MOVB BX, 7(AX)
MOVW CX, 0(AX)
SHRL $16, CX
ANDL $0x0F, CX
ORL $0x40, CX // 32-bit operand size
MOVB CX, 6(AX)
MOVB $0xF2, 5(AX) // r/w data descriptor, dpl=3, present
// call i386_set_ldt(entry, desc, 1)
MOVL $0xffffffff, 0(SP) // auto-allocate entry and return in AX
MOVL AX, 4(SP)
MOVL $1, 8(SP)
CALL i386_set_ldt(SB)
// compute segment selector - (entry*8+7)
SHLL $3, AX
ADDL $7, AX
MOVW AX, GS
RET
TEXT i386_set_ldt(SB),7,$16
LEAL args+0(FP), AX // 0(FP) == 4(SP) before SP got moved
MOVL $0, 0(SP) // syscall gap
MOVL $1, 4(SP)
MOVL AX, 8(SP)
MOVL $165, AX
INT $0x80
CMPL AX, $0xfffff001
JLS 2(PC)
INT $3
RET
GLOBL tlsoffset(SB),$4
// godefs -f -m64 freebsd/defs.c
// godefs -f -m64 defs.c
// MACHINE GENERATED - DO NOT EDIT.
......@@ -21,6 +21,28 @@ enum {
// Types
#pragma pack on
typedef struct Rtprio Rtprio;
struct Rtprio {
uint16 type;
uint16 prio;
};
typedef struct ThrParam ThrParam;
struct ThrParam {
void *start_func;
void *arg;
int8 *stack_base;
uint64 stack_size;
int8 *tls_base;
uint64 tls_size;
int64 *child_tid;
int64 *parent_tid;
int32 flags;
byte pad0[4];
Rtprio *rtp;
void* spare[3];
};
typedef struct Sigaltstack Sigaltstack;
struct Sigaltstack {
int8 *ss_sp;
......
......@@ -16,6 +16,8 @@
#include <sys/mman.h>
#include <sys/ucontext.h>
#include <sys/umtx.h>
#include <sys/rtprio.h>
#include <sys/thr.h>
#include <sys/_sigset.h>
enum {
......@@ -37,6 +39,8 @@ enum {
$EINTR = EINTR,
};
typedef struct rtprio $Rtprio;
typedef struct thr_param $ThrParam;
typedef struct sigaltstack $Sigaltstack;
typedef struct __sigset $Sigset;
typedef union sigval $Sigval;
......
// FreeBSD-specific system calls
int32 ksem_init(uint64 *, uint32);
int32 ksem_wait(uint32);
int32 ksem_destroy(uint32);
int32 ksem_post(uint32);
struct thr_param {
void (*start_func)(void *); /* thread entry function. */
void *arg; /* argument for entry function. */
byte *stack_base; /* stack base address. */
int64 stack_size; /* stack size. */
byte *tls_base; /* tls base address. */
int64 tls_size; /* tls size. */
int64 *child_tid; /* address to store new TID. */
int64 *parent_tid; /* parent accesses the new TID here. */
int32 flags; /* thread flags. */
void *spare[4]; /* TODO: cpu affinity mask etc. */
};
int32 thr_new(struct thr_param*, uint64);
int32 thr_new(ThrParam*, int32);
......@@ -125,7 +125,7 @@ void thr_start(void*);
void
newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
struct thr_param param;
ThrParam param;
USED(fn); // thr_start assumes fn == mstart
USED(g); // thr_start assumes g == m->g0
......@@ -141,8 +141,12 @@ newosproc(M *m, G *g, void *stk, void (*fn)(void))
param.arg = m;
param.stack_base = stk;
param.stack_size = g->stackbase - g->stackguard + 256;
param.child_tid = (int64*)&m->procid;
param.child_tid = (int32*)&m->procid;
param.parent_tid = nil;
param.tls_base = (int8*)&m->tls[0];
param.tls_size = sizeof m->tls;
m->tls[0] = m->id; // so 386 asm can find it
thr_new(&param, sizeof param);
}
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// System call support for 386, FreeBSD
//
// func Syscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32);
// func Syscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32);
// Trap # in AX, args on stack above caller pc.
TEXT syscall·Syscall(SB),7,$0
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
INT $0x80
JAE ok
MOVL $-1, 20(SP) // r1
MOVL $-1, 24(SP) // r2
MOVL AX, 28(SP) // errno
CALL runtime·exitsyscall(SB)
RET
ok:
MOVL AX, 20(SP) // r1
MOVL DX, 24(SP) // r2
MOVL $0, 28(SP) // errno
CALL runtime·exitsyscall(SB)
RET
TEXT syscall·Syscall6(SB),7,$0
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
INT $0x80
JAE ok6
MOVL $-1, 32(SP) // r1
MOVL $-1, 36(SP) // r2
MOVL AX, 40(SP) // errno
CALL runtime·exitsyscall(SB)
RET
ok6:
MOVL AX, 32(SP) // r1
MOVL DX, 36(SP) // r2
MOVL $0, 40(SP) // errno
CALL runtime·exitsyscall(SB)
RET
TEXT syscall·RawSyscall(SB),7,$0
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
INT $0x80
JAE ok1
MOVL $-1, 20(SP) // r1
MOVL $-1, 24(SP) // r2
MOVL AX, 28(SP) // errno
RET
ok1:
MOVL AX, 20(SP) // r1
MOVL DX, 24(SP) // r2
MOVL $0, 28(SP) // errno
RET
......@@ -99,6 +99,11 @@ _* | *_ | _)
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
exit 1
;;
freebsd_386)
mksyscall="mksyscall.sh -l32"
mksysnum="mksysnum_freebsd.sh /usr/src/sys/kern/syscalls.master"
mktypes="godefs -gsyscall -f-m32"
;;
freebsd_amd64)
mksysnum="mksysnum_freebsd.sh /usr/src/sys/kern/syscalls.master"
mktypes="godefs -gsyscall -f-m64"
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
func Getpagesize() int { return 4096 }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9);
ts.Nsec = int32(nsec % 1e9);
return;
}
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
func NsecToTimeval(nsec int64) (tv Timeval) {
nsec += 999; // round up to microsecond
tv.Usec = int32(nsec % 1e9 / 1e3);
tv.Sec = int32(nsec / 1e9);
return;
}
func SetKevent(k *Kevent_t, fd, mode, flags int) {
k.Ident = uint32(fd);
k.Filter = int16(mode);
k.Flags = uint16(flags);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// godefs -gsyscall -f-m32 types_freebsd.c
// MACHINE GENERATED - DO NOT EDIT.
package syscall
// Constants
const (
sizeofPtr = 0x4;
sizeofShort = 0x2;
sizeofInt = 0x4;
sizeofLong = 0x4;
sizeofLongLong = 0x8;
O_CLOEXEC = 0;
S_IFMT = 0xf000;
S_IFIFO = 0x1000;
S_IFCHR = 0x2000;
S_IFDIR = 0x4000;
S_IFBLK = 0x6000;
S_IFREG = 0x8000;
S_IFLNK = 0xa000;
S_IFSOCK = 0xc000;
S_ISUID = 0x800;
S_ISGID = 0x400;
S_ISVTX = 0x200;
S_IRUSR = 0x100;
S_IWUSR = 0x80;
S_IXUSR = 0x40;
SizeofSockaddrInet4 = 0x10;
SizeofSockaddrInet6 = 0x1c;
SizeofSockaddrAny = 0x6c;
SizeofSockaddrUnix = 0x6a;
SizeofLinger = 0x8;
SizeofMsghdr = 0x1c;
SizeofCmsghdr = 0xc;
PTRACE_TRACEME = 0;
PTRACE_CONT = 0x7;
PTRACE_KILL = 0x8;
)
// Types
type _C_short int16
type _C_int int32
type _C_long int32
type _C_long_long int64
type Timespec struct {
Sec int32;
Nsec int32;
}
type Timeval struct {
Sec int32;
Usec int32;
}
type Rusage struct {
Utime Timeval;
Stime Timeval;
Maxrss int32;
Ixrss int32;
Idrss int32;
Isrss int32;
Minflt int32;
Majflt int32;
Nswap int32;
Inblock int32;
Oublock int32;
Msgsnd int32;
Msgrcv int32;
Nsignals int32;
Nvcsw int32;
Nivcsw int32;
}
type Rlimit struct {
Cur int64;
Max int64;
}
type _Gid_t uint32
type Stat_t struct {
Dev uint32;
Ino uint32;
Mode uint16;
Nlink uint16;
Uid uint32;
Gid uint32;
Rdev uint32;
Atimespec Timespec;
Mtimespec Timespec;
Ctimespec Timespec;
Size int64;
Blocks int64;
Blksize uint32;
Flags uint32;
Gen uint32;
Lspare int32;
Birthtimespec Timespec;
Pad0 uint32;
Pad1 uint32;
}
type Statfs_t struct {
Version uint32;
Type uint32;
Flags uint64;
Bsize uint64;
Iosize uint64;
Blocks uint64;
Bfree uint64;
Bavail int64;
Files uint64;
Ffree int64;
Syncwrites uint64;
Asyncwrites uint64;
Syncreads uint64;
Asyncreads uint64;
Spare [10]uint64;
Namemax uint32;
Owner uint32;
Fsid [8]byte; /* fsid */
Charspare [80]int8;
Fstypename [16]int8;
Mntfromname [88]int8;
Mntonname [88]int8;
}
type Flock_t struct {
Start int64;
Len int64;
Pid int32;
Type int16;
Whence int16;
Sysid int32;
}
type Dirent struct {
Fileno uint32;
Reclen uint16;
Type uint8;
Namlen uint8;
Name [256]int8;
}
type RawSockaddrInet4 struct {
Len uint8;
Family uint8;
Port uint16;
Addr [4]byte; /* in_addr */
Zero [8]int8;
}
type RawSockaddrInet6 struct {
Len uint8;
Family uint8;
Port uint16;
Flowinfo uint32;
Addr [16]byte; /* in6_addr */
Scope_id uint32;
}
type RawSockaddrUnix struct {
Len uint8;
Family uint8;
Path [104]int8;
}
type RawSockaddr struct {
Len uint8;
Family uint8;
Data [14]int8;
}
type RawSockaddrAny struct {
Addr RawSockaddr;
Pad [92]int8;
}
type _Socklen uint32
type Linger struct {
Onoff int32;
Linger int32;
}
type Iovec struct {
Base *byte;
Len uint32;
}
type Msghdr struct {
Name *byte;
Namelen uint32;
Iov *Iovec;
Iovlen int32;
Control *byte;
Controllen uint32;
Flags int32;
}
type Cmsghdr struct {
Len uint32;
Level int32;
Type int32;
}
type Kevent_t struct {
Ident uint32;
Filter int16;
Flags uint16;
Fflags uint32;
Data int32;
Udata *byte;
}
type FdSet struct {
X__fds_bits [32]uint32;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment