diff options
| author | Russ Cox <rsc@golang.org> | 2011-03-23 11:31:42 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-03-23 11:31:42 -0400 |
| commit | 8dee872963ca0260c3b941b54cf5ac2cd583fd02 (patch) | |
| tree | 0d79b4079dff73bc5e4eec1f88f6a0a7d55c9e14 /src/pkg/runtime/linux | |
| parent | ccdbb8a6c2bf8a058d5cd8dd94374d02e584e39a (diff) | |
| download | go-8dee872963ca0260c3b941b54cf5ac2cd583fd02.tar.xz | |
runtime: os-specific types and code for setitimer
R=r
CC=golang-dev
https://golang.org/cl/4273097
Diffstat (limited to 'src/pkg/runtime/linux')
| -rw-r--r-- | src/pkg/runtime/linux/386/defs.h | 12 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/386/sys.s | 9 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/amd64/defs.h | 13 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/amd64/sys.s | 8 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/arm/sys.s | 9 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/defs.c | 7 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/defs2.c | 8 | ||||
| -rw-r--r-- | src/pkg/runtime/linux/os.h | 4 |
8 files changed, 65 insertions, 5 deletions
diff --git a/src/pkg/runtime/linux/386/defs.h b/src/pkg/runtime/linux/386/defs.h index c1f58b2a08..6ae1c4e139 100644 --- a/src/pkg/runtime/linux/386/defs.h +++ b/src/pkg/runtime/linux/386/defs.h @@ -58,6 +58,9 @@ enum { BUS_OBJERR = 0x3, SEGV_MAPERR = 0x1, SEGV_ACCERR = 0x2, + ITIMER_REAL = 0, + ITIMER_VIRTUAL = 0x1, + ITIMER_PROF = 0x2, }; // Types @@ -98,7 +101,8 @@ struct Fpstate { uint32 reserved; Fpxreg _fxsr_st[8]; Xmmreg _xmm[8]; - uint32 padding[56]; + uint32 padding1[44]; + byte Pad_godefs_0[48]; }; typedef struct Timespec Timespec; @@ -176,4 +180,10 @@ struct Ucontext { Sigcontext uc_mcontext; uint32 uc_sigmask; }; + +typedef struct Itimerval Itimerval; +struct Itimerval { + Timeval it_interval; + Timeval it_value; +}; #pragma pack off diff --git a/src/pkg/runtime/linux/386/sys.s b/src/pkg/runtime/linux/386/sys.s index a684371bea..c39ce253f0 100644 --- a/src/pkg/runtime/linux/386/sys.s +++ b/src/pkg/runtime/linux/386/sys.s @@ -30,6 +30,15 @@ TEXT runtime·write(SB),7,$0 INT $0x80 RET + +TEXT runtime·setitimer(SB),7,$0-24 + MOVL $104, AX // syscall - setitimer + MOVL 4(SP), BX + MOVL 8(SP), CX + MOVL 12(SP), DX + INT $0x80 + RET + TEXT runtime·gettime(SB), 7, $32 MOVL $78, AX // syscall - gettimeofday LEAL 8(SP), BX diff --git a/src/pkg/runtime/linux/amd64/defs.h b/src/pkg/runtime/linux/amd64/defs.h index 3e3d32f0d4..70d63145c6 100644 --- a/src/pkg/runtime/linux/amd64/defs.h +++ b/src/pkg/runtime/linux/amd64/defs.h @@ -58,6 +58,9 @@ enum { BUS_OBJERR = 0x3, SEGV_MAPERR = 0x1, SEGV_ACCERR = 0x2, + ITIMER_REAL = 0, + ITIMER_VIRTUAL = 0x1, + ITIMER_PROF = 0x2, }; // Types @@ -88,9 +91,15 @@ struct Siginfo { int32 si_signo; int32 si_errno; int32 si_code; - byte pad0[4]; + byte pad_godefs_0[4]; byte _sifields[112]; }; + +typedef struct Itimerval Itimerval; +struct Itimerval { + Timeval it_interval; + Timeval it_value; +}; #pragma pack off // godefs -f -m64 defs1.c @@ -170,7 +179,7 @@ typedef struct Sigaltstack Sigaltstack; struct Sigaltstack { void *ss_sp; int32 ss_flags; - byte pad0[4]; + byte pad_godefs_0[4]; uint64 ss_size; }; diff --git a/src/pkg/runtime/linux/amd64/sys.s b/src/pkg/runtime/linux/amd64/sys.s index 1bf734dc06..11df1f894b 100644 --- a/src/pkg/runtime/linux/amd64/sys.s +++ b/src/pkg/runtime/linux/amd64/sys.s @@ -36,6 +36,14 @@ TEXT runtime·write(SB),7,$0-24 SYSCALL RET +TEXT runtime·setitimer(SB),7,$0-24 + MOVL 8(SP), DI + MOVQ 16(SP), SI + MOVQ 24(SP), DX + MOVL $38, AX // syscall entry + SYSCALL + RET + TEXT runtime·gettime(SB), 7, $32 LEAQ 8(SP), DI MOVQ $0, SI diff --git a/src/pkg/runtime/linux/arm/sys.s b/src/pkg/runtime/linux/arm/sys.s index 9daf9c2e4d..2b01f0cbb3 100644 --- a/src/pkg/runtime/linux/arm/sys.s +++ b/src/pkg/runtime/linux/arm/sys.s @@ -26,6 +26,7 @@ #define SYS_futex (SYS_BASE + 240) #define SYS_exit_group (SYS_BASE + 248) #define SYS_munmap (SYS_BASE + 91) +#define SYS_setitimer (SYS_BASE + 104) #define ARM_BASE (SYS_BASE + 0x0f0000) #define SYS_ARM_cacheflush (ARM_BASE + 2) @@ -72,6 +73,14 @@ TEXT runtime·munmap(SB),7,$0 SWI $0 RET +TEXT runtime·getitimer(SB),7,$0 + MOVW 0(FP), R0 + MOVW 4(FP), R1 + MOWW 8(FP), R2 + MOVW $SYS_setitimer, R7 + SWI $0 + RET + TEXT runtime·gettime(SB),7,$32 /* dummy version - return 0,0 */ MOVW $0, R1 diff --git a/src/pkg/runtime/linux/defs.c b/src/pkg/runtime/linux/defs.c index 2044fd60c9..5dda787891 100644 --- a/src/pkg/runtime/linux/defs.c +++ b/src/pkg/runtime/linux/defs.c @@ -15,6 +15,8 @@ // headers for things like ucontext_t, so that happens in // a separate file, defs1.c. +#include <asm/posix_types.h> +#define size_t __kernel_size_t #include <asm/signal.h> #include <asm/siginfo.h> #include <asm/mman.h> @@ -80,9 +82,14 @@ enum { $SEGV_MAPERR = SEGV_MAPERR, $SEGV_ACCERR = SEGV_ACCERR, + + $ITIMER_REAL = ITIMER_REAL, + $ITIMER_VIRTUAL = ITIMER_VIRTUAL, + $ITIMER_PROF = ITIMER_PROF, }; typedef struct timespec $Timespec; typedef struct timeval $Timeval; typedef struct sigaction $Sigaction; typedef siginfo_t $Siginfo; +typedef struct itimerval $Itimerval; diff --git a/src/pkg/runtime/linux/defs2.c b/src/pkg/runtime/linux/defs2.c index 3c0b110fc9..ff641fff2b 100644 --- a/src/pkg/runtime/linux/defs2.c +++ b/src/pkg/runtime/linux/defs2.c @@ -8,7 +8,7 @@ -f -I/home/rsc/pub/linux-2.6/arch/x86/include \ -f -I/home/rsc/pub/linux-2.6/include \ -f -D_LOOSE_KERNEL_NAMES \ - -f -D__ARCH_SI_UID_T=__kernel_uid32_t \ + -f -D__ARCH_SI_UID_T'='__kernel_uid32_t \ defs2.c >386/defs.h * The asm header tricks we have to use for Linux on amd64 @@ -100,6 +100,10 @@ enum { $SEGV_MAPERR = SEGV_MAPERR, $SEGV_ACCERR = SEGV_ACCERR, + + $ITIMER_REAL = ITIMER_REAL, + $ITIMER_VIRTUAL = ITIMER_VIRTUAL, + $ITIMER_PROF = ITIMER_PROF, }; typedef struct _fpreg $Fpreg; @@ -113,4 +117,4 @@ typedef siginfo_t $Siginfo; typedef struct sigaltstack $Sigaltstack; typedef struct sigcontext $Sigcontext; typedef struct ucontext $Ucontext; - +typedef struct itimerval $Itimerval; diff --git a/src/pkg/runtime/linux/os.h b/src/pkg/runtime/linux/os.h index 772ade7da9..6ae0889777 100644 --- a/src/pkg/runtime/linux/os.h +++ b/src/pkg/runtime/linux/os.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#define SIG_DFL ((void*)0) +#define SIG_IGN ((void*)1) + // Linux-specific system calls int32 runtime·futex(uint32*, int32, uint32, Timespec*, uint32*, uint32); int32 runtime·clone(int32, void*, M*, G*, void(*)(void)); @@ -11,3 +14,4 @@ void runtime·rt_sigaction(uintptr, struct Sigaction*, void*, uintptr); void runtime·sigaltstack(Sigaltstack*, Sigaltstack*); void runtime·sigpanic(void); +void runtime·setitimer(int32, Itimerval*, Itimerval*); |
