shithub: mc

Download patch

ref: ed7bb0cde9b714159d8cdb56d2d6aa832674622c
parent: 2550b676852c8bbea1c4f22984991000fe6fc855
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 29 07:26:57 EST 2014

Add __osx_lseek

    I wonder if this is right..

--- a/libstd/syscall+osx-x64.s
+++ b/libstd/syscall+osx-x64.s
@@ -1,14 +1,14 @@
 .globl _sys$syscall
 _sys$syscall:
-	pushq %rbp 
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
+	pushq %rbp
+	pushq %rdi
+	pushq %rsi
+	pushq %rdx
+	pushq %r10
 	pushq %r8
 	pushq %r9
-	pushq %rcx 
-	pushq %r11 
+	pushq %rcx
+	pushq %r11
 	/*
 	hack: We load 6 args regardless of
 	how many we actually have. This may
@@ -51,14 +51,14 @@
 .globl _sys$__osx_fork
 _sys$__osx_fork:
 	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
+	pushq %rdi
+	pushq %rsi
+	pushq %rdx
+	pushq %r10
 	pushq %r8
 	pushq %r9
-	pushq %rcx 
-	pushq %r11 
+	pushq %rcx
+	pushq %r11
 
 	movq $0x2000002,%rax
 	syscall
@@ -72,14 +72,14 @@
 	xorq %rax,%rax
 .isparent:
 
-	popq %r11 
-	popq %rcx 
+	popq %r11
+	popq %rcx
 	popq %r9
 	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
 	popq %rbp
 	ret
 
@@ -91,14 +91,14 @@
 .globl _sys$__osx_pipe
 _sys$__osx_pipe:
 	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
+	pushq %rdi
+	pushq %rsi
+	pushq %rdx
+	pushq %r10
 	pushq %r8
 	pushq %r9
-	pushq %rcx 
-	pushq %r11 
+	pushq %rcx
+	pushq %r11
 
 	movq $0x200002a,%rax
 	syscall
@@ -112,28 +112,63 @@
 	movl %edx,4(%rdi)
 	xorq %rax,%rax
 
-	popq %r11 
-	popq %rcx 
+	popq %r11
+	popq %rcx
 	popq %r9
 	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
 	popq %rbp
 	ret
 
+.globl _sys$__osx_lseek
+_sys$__osx_lseek:
+	pushq %rbp
+	pushq %rdi
+	pushq %rsi
+	pushq %rdx
+	pushq %r10
+	pushq %r8
+	pushq %r9
+	pushq %rcx
+	pushq %r11
+
+	movq $0x20000C7,%rax
+	syscall
+
+	jae .lseeksuccess
+	negq %rax
+
+.lseeksuccess:
+	movq 80(%rsp),%rdi
+        shlq $32,%rdx
+        orq  %rdx,%rax
+
+	popq %r11
+	popq %rcx
+	popq %r9
+	popq %r8
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
+	popq %rbp
+	ret
+
+
 .globl _sys$__osx_gettimeofday
 _sys$__osx_gettimeofday:
 	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
+	pushq %rdi
+	pushq %rsi
+	pushq %rdx
+	pushq %r10
 	pushq %r8
 	pushq %r9
-	pushq %rcx 
-	pushq %r11 
+	pushq %rcx
+	pushq %r11
 
 	movq $0x2000074,%rax
 	syscall
@@ -147,14 +182,14 @@
 	movl %edx,8(%rdi)
 	xorq %rax,%rax
 
-	popq %r11 
-	popq %rcx 
+	popq %r11
+	popq %rcx
 	popq %r9
 	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
 	popq %rbp
 	ret