]>
Commit | Line | Data |
---|---|---|
2d21ac55 | 1 | /* |
316670eb | 2 | * Copyright (c) 1999-2011 Apple Inc. All rights reserved. |
2d21ac55 A |
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) | |
316670eb A |
38 | movl $0,%ecx |
39 | jmp 1f | |
40 | LABEL(cerror_nocancel) | |
41 | movl $1,%ecx | |
42 | 1: REG_TO_EXTERN(%eax, _errno) | |
2d21ac55 A |
43 | mov %esp,%edx |
44 | andl $0xfffffff0,%esp | |
45 | subl $16,%esp | |
316670eb A |
46 | movl %edx,8(%esp) |
47 | movl %ecx,4(%esp) | |
2d21ac55 A |
48 | movl %eax,(%esp) |
49 | CALL_EXTERN(_cthread_set_errno_self) | |
316670eb | 50 | movl 8(%esp),%esp |
2d21ac55 A |
51 | movl $-1,%eax |
52 | movl $-1,%edx /* in case a 64-bit value is returned */ | |
53 | ret | |
54 | ||
6d2010ae | 55 | LABEL(__sysenter_trap) |
2d21ac55 A |
56 | popl %edx |
57 | movl %esp, %ecx | |
58 | sysenter | |
59 | ||
60 | #elif defined(__x86_64__) | |
61 | ||
62 | .globl _errno | |
63 | ||
64 | LABEL(cerror) | |
316670eb A |
65 | /* cancelable syscall, for arg1 to _cthread_set_errno_self */ |
66 | movq $0,%rsi | |
67 | jmp 1f | |
68 | LABEL(cerror_nocancel) | |
69 | /* non-cancelable, see above. */ | |
70 | movq $1,%rsi | |
71 | 1: PICIFY(_errno) /* address -> %r11 */ | |
6d2010ae A |
72 | movl %eax,(%r11) |
73 | mov %rsp,%rdx | |
2d21ac55 A |
74 | andq $-16,%rsp |
75 | subq $16,%rsp | |
76 | // Preserve the original stack | |
77 | movq %rdx,(%rsp) | |
78 | movq %rax,%rdi | |
79 | CALL_EXTERN(_cthread_set_errno_self) | |
80 | // Restore the original stack | |
81 | movq (%rsp),%rsp | |
82 | movq $-1,%rax | |
83 | movq $-1,%rdx /* in case a 128-bit value is returned */ | |
84 | ret | |
85 | ||
2d21ac55 A |
86 | #else |
87 | #error Unsupported architecture | |
88 | #endif | |
89 | ||
90 | #if defined(__i386__) || defined(__x86_64__) | |
91 | ||
92 | .globl _i386_get_ldt | |
93 | ALIGN | |
94 | _i386_get_ldt: | |
95 | movl $6,%eax | |
96 | MACHDEP_SYSCALL_TRAP | |
97 | jnb 2f | |
98 | jmp cerror | |
99 | 2: ret | |
100 | ||
101 | ||
102 | .globl _i386_set_ldt | |
103 | ALIGN | |
104 | _i386_set_ldt: | |
105 | movl $5,%eax | |
106 | MACHDEP_SYSCALL_TRAP | |
107 | jnb 2f | |
108 | jmp cerror | |
109 | 2: ret | |
110 | ||
111 | #endif |