Commit c354f93b authored by Dave Cheney's avatar Dave Cheney Committed by Russ Cox

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
parent 8bbe5ccb
......@@ -34,6 +34,9 @@ const (
MAP_PRIVATE = C.MAP_PRIVATE
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_SEND = C.MACH_MSG_TYPE_MOVE_SEND
MACH_MSG_TYPE_MOVE_SEND_ONCE = C.MACH_MSG_TYPE_MOVE_SEND_ONCE
......
......@@ -12,6 +12,9 @@ enum {
MAP_PRIVATE = 0x2,
MAP_FIXED = 0x10,
MADV_DONTNEED = 0x4,
MADV_FREE = 0x5,
MACH_MSG_TYPE_MOVE_RECEIVE = 0x10,
MACH_MSG_TYPE_MOVE_SEND = 0x11,
MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12,
......
......@@ -12,6 +12,9 @@ enum {
MAP_PRIVATE = 0x2,
MAP_FIXED = 0x10,
MADV_DONTNEED = 0x4,
MADV_FREE = 0x5,
MACH_MSG_TYPE_MOVE_RECEIVE = 0x10,
MACH_MSG_TYPE_MOVE_SEND = 0x11,
MACH_MSG_TYPE_MOVE_SEND_ONCE = 0x12,
......
......@@ -23,9 +23,8 @@ runtime·SysAlloc(uintptr n)
void
runtime·SysUnused(void *v, uintptr n)
{
USED(v);
USED(n);
// TODO(rsc): call madvise MADV_DONTNEED
// Linux's MADV_DONTNEED is like BSD's MADV_FREE.
runtime·madvise(v, n, MADV_FREE);
}
void
......
......@@ -48,6 +48,13 @@ TEXT runtime·mmap(SB),7,$0
INT $0x80
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
MOVL $73, AX
INT $0x80
......
......@@ -55,6 +55,16 @@ TEXT runtime·setitimer(SB), 7, $0
SYSCALL
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)
TEXT time·now(SB), 7, $32
MOVQ SP, DI // must be non-nil, unused
......
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