1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:14:47 -07:00

runtime: madvise and SysUnused for Darwin

SysUnused is a direct call to madvise MADV_FREE.

R=sebastien.paolacci, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/5531073
This commit is contained in:
Dave Cheney 2012-01-19 15:51:29 -05:00 committed by Russ Cox
parent 8bbe5ccb71
commit c354f93b93
6 changed files with 28 additions and 3 deletions

View File

@ -34,6 +34,9 @@ const (
MAP_PRIVATE = C.MAP_PRIVATE MAP_PRIVATE = C.MAP_PRIVATE
MAP_FIXED = C.MAP_FIXED MAP_FIXED = C.MAP_FIXED
MADV_DONTNEED = C.MADV_DONTNEED
MADV_FREE = C.MADV_FREE
MACH_MSG_TYPE_MOVE_RECEIVE = C.MACH_MSG_TYPE_MOVE_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE = C.MACH_MSG_TYPE_MOVE_RECEIVE
MACH_MSG_TYPE_MOVE_SEND = C.MACH_MSG_TYPE_MOVE_SEND MACH_MSG_TYPE_MOVE_SEND = C.MACH_MSG_TYPE_MOVE_SEND
MACH_MSG_TYPE_MOVE_SEND_ONCE = C.MACH_MSG_TYPE_MOVE_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE = C.MACH_MSG_TYPE_MOVE_SEND_ONCE

View File

@ -12,6 +12,9 @@ enum {
MAP_PRIVATE = 0x2, MAP_PRIVATE = 0x2,
MAP_FIXED = 0x10, MAP_FIXED = 0x10,
MADV_DONTNEED = 0x4,
MADV_FREE = 0x5,
MACH_MSG_TYPE_MOVE_RECEIVE = 0x10, MACH_MSG_TYPE_MOVE_RECEIVE = 0x10,
MACH_MSG_TYPE_MOVE_SEND = 0x11, MACH_MSG_TYPE_MOVE_SEND = 0x11,
MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12, MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12,

View File

@ -12,6 +12,9 @@ enum {
MAP_PRIVATE = 0x2, MAP_PRIVATE = 0x2,
MAP_FIXED = 0x10, MAP_FIXED = 0x10,
MADV_DONTNEED = 0x4,
MADV_FREE = 0x5,
MACH_MSG_TYPE_MOVE_RECEIVE = 0x10, MACH_MSG_TYPE_MOVE_RECEIVE = 0x10,
MACH_MSG_TYPE_MOVE_SEND = 0x11, MACH_MSG_TYPE_MOVE_SEND = 0x11,
MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12, MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12,

View File

@ -23,9 +23,8 @@ runtime·SysAlloc(uintptr n)
void void
runtime·SysUnused(void *v, uintptr n) runtime·SysUnused(void *v, uintptr n)
{ {
USED(v); // Linux's MADV_DONTNEED is like BSD's MADV_FREE.
USED(n); runtime·madvise(v, n, MADV_FREE);
// TODO(rsc): call madvise MADV_DONTNEED
} }
void void

View File

@ -48,6 +48,13 @@ TEXT runtime·mmap(SB),7,$0
INT $0x80 INT $0x80
RET RET
TEXT runtime·madvise(SB),7,$0
MOVL $75, AX
INT $0x80
JAE 2(PC)
CALL runtime·notok(SB)
RET
TEXT runtime·munmap(SB),7,$0 TEXT runtime·munmap(SB),7,$0
MOVL $73, AX MOVL $73, AX
INT $0x80 INT $0x80

View File

@ -55,6 +55,16 @@ TEXT runtime·setitimer(SB), 7, $0
SYSCALL SYSCALL
RET RET
TEXT runtime·madvise(SB), 7, $0
MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 advice
MOVL $(0x2000000+75), AX // syscall entry madvise
SYSCALL
JCC 2(PC)
CALL runtime·notok(SB)
RET
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
TEXT time·now(SB), 7, $32 TEXT time·now(SB), 7, $32
MOVQ SP, DI // must be non-nil, unused MOVQ SP, DI // must be non-nil, unused