]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
1 | /* |
2 | * Copyright (c) 1999-2007 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. | |
29 | */ | |
30 | ||
31 | #include "SYS.h" | |
32 | ||
6d2010ae | 33 | #if defined(__i386__) |
2d21ac55 A |
34 | |
35 | .globl _errno | |
36 | ||
37 | LABEL(cerror) | |
38 | REG_TO_EXTERN(%eax, _errno) | |
39 | mov %esp,%edx | |
40 | andl $0xfffffff0,%esp | |
41 | subl $16,%esp | |
42 | movl %edx,4(%esp) | |
43 | movl %eax,(%esp) | |
44 | CALL_EXTERN(_cthread_set_errno_self) | |
45 | movl 4(%esp),%esp | |
46 | movl $-1,%eax | |
47 | movl $-1,%edx /* in case a 64-bit value is returned */ | |
48 | ret | |
49 | ||
6d2010ae | 50 | LABEL(__sysenter_trap) |
2d21ac55 A |
51 | popl %edx |
52 | movl %esp, %ecx | |
53 | sysenter | |
54 | ||
55 | #elif defined(__x86_64__) | |
56 | ||
57 | .globl _errno | |
58 | ||
59 | LABEL(cerror) | |
6d2010ae A |
60 | PICIFY(_errno) /* address -> %r11 */ |
61 | movl %eax,(%r11) | |
62 | mov %rsp,%rdx | |
2d21ac55 A |
63 | andq $-16,%rsp |
64 | subq $16,%rsp | |
65 | // Preserve the original stack | |
66 | movq %rdx,(%rsp) | |
67 | movq %rax,%rdi | |
68 | CALL_EXTERN(_cthread_set_errno_self) | |
69 | // Restore the original stack | |
70 | movq (%rsp),%rsp | |
71 | movq $-1,%rax | |
72 | movq $-1,%rdx /* in case a 128-bit value is returned */ | |
73 | ret | |
74 | ||
2d21ac55 A |
75 | #else |
76 | #error Unsupported architecture | |
77 | #endif | |
78 | ||
79 | #if defined(__i386__) || defined(__x86_64__) | |
80 | ||
81 | .globl _i386_get_ldt | |
82 | ALIGN | |
83 | _i386_get_ldt: | |
84 | movl $6,%eax | |
85 | MACHDEP_SYSCALL_TRAP | |
86 | jnb 2f | |
87 | jmp cerror | |
88 | 2: ret | |
89 | ||
90 | ||
91 | .globl _i386_set_ldt | |
92 | ALIGN | |
93 | _i386_set_ldt: | |
94 | movl $5,%eax | |
95 | MACHDEP_SYSCALL_TRAP | |
96 | jnb 2f | |
97 | jmp cerror | |
98 | 2: ret | |
99 | ||
100 | #endif |