]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/wrappers/varargs_wrappers.s
xnu-6153.101.6.tar.gz
[apple/xnu.git] / libsyscall / wrappers / varargs_wrappers.s
1 /*
2 * Copyright (c) 2011-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifdef __arm64__
25
26 #include "../custom/SYS.h"
27 #include <mach/arm64/asm.h>
28
29 /*
30 * Stubs are to handle the ARM64 ABI for variadic functions'
31 * not matching the ABI used by the system call handler.
32 */
33
34 /*
35 * sem_t* sem_open(const char *name, int oflag, ...);
36 * sem_t* __sem_open(const char *name, int oflag, int mode, int value);
37 */
38 MI_ENTRY_POINT(_sem_open)
39 ARM64_STACK_PROLOG
40 PUSH_FRAME
41 #if __LP64__
42 ldp x2, x3, [fp, #16]
43 #else
44 ldp w2, w3, [fp, #16]
45 #endif
46 MI_CALL_EXTERNAL(___sem_open)
47 #if !__LP64__
48 /* xnu returns a 64-bit '-1' on failure, but pointers must have the high
49 * 32-bits set to zero. The following instruction is equivalent to
50 * masking off the top 32-bits.
51 */
52 mov w0, w0
53 #endif
54 POP_FRAME
55 ARM64_STACK_EPILOG
56
57 /*
58 * int open(const char *name, int oflag, ...);
59 * int __open(const char *name, int oflag, int mode, int value);
60 */
61 MI_ENTRY_POINT(_open)
62 ARM64_STACK_PROLOG
63 PUSH_FRAME
64 #if __LP64__
65 ldr x2, [fp, #16]
66 #else
67 ldr w2, [fp, #16]
68 #endif
69 MI_CALL_EXTERNAL(___open)
70 POP_FRAME
71 ARM64_STACK_EPILOG
72
73 /*
74 * int open_nocancel(const char *name, int oflag, ...);
75 * int __open_nocancel(const char *name, int oflag, int mode);
76 */
77 MI_ENTRY_POINT(_open$NOCANCEL)
78 ARM64_STACK_PROLOG
79 PUSH_FRAME
80 #if __LP64__
81 ldr x2, [fp, #16]
82 #else
83 ldr w2, [fp, #16]
84 #endif
85 MI_CALL_EXTERNAL(___open_nocancel)
86 POP_FRAME
87 ARM64_STACK_EPILOG
88
89 /*
90 * int openat(int fd,const char *name, int oflag, ...);
91 * int __openat(int fd, const char *name, int oflag, int mode, int value);
92 */
93 MI_ENTRY_POINT(_openat)
94 ARM64_STACK_PROLOG
95 PUSH_FRAME
96 #if __LP64__
97 ldr x3, [fp, #16]
98 #else
99 ldr w3, [fp, #16]
100 #endif
101 MI_CALL_EXTERNAL(___openat)
102 POP_FRAME
103 ARM64_STACK_EPILOG
104
105 /*
106 * int openat_nocancel(int fd, const char *name, int oflag, ...);
107 * int __openat_nocancel(int fd, const char *name, int oflag, int mode);
108 */
109 MI_ENTRY_POINT(_openat$NOCANCEL)
110 ARM64_STACK_PROLOG
111 PUSH_FRAME
112 #if __LP64__
113 ldr x3, [fp, #16]
114 #else
115 ldr w3, [fp, #16]
116 #endif
117 MI_CALL_EXTERNAL(___openat_nocancel)
118 POP_FRAME
119 ARM64_STACK_EPILOG
120
121 /*
122 * int shm_open(const char *, int, ...);
123 * int __shm_open(const char*, int oflag, int mode);
124 */
125 MI_ENTRY_POINT(_shm_open)
126 ARM64_STACK_PROLOG
127 PUSH_FRAME
128 #if __LP64__
129 ldr x2, [fp, #16]
130 #else
131 ldr w2, [fp, #16]
132 #endif
133 MI_CALL_EXTERNAL(___shm_open)
134 POP_FRAME
135 ARM64_STACK_EPILOG
136
137 /*
138 * int msgsys(int, ...);
139 * int __msgsys(int which, int a2, int a3, int a4, int a5);
140 */
141 MI_ENTRY_POINT(_msgsys)
142 ARM64_STACK_PROLOG
143 PUSH_FRAME
144 #if __LP64__
145 ldp x1, x2, [fp, #16]
146 ldp x3, x4, [fp, #32]
147 #else
148 ldp w1, w2, [fp, #16]
149 ldp w3, w4, [fp, #24]
150 #endif
151 MI_CALL_EXTERNAL(___msgsys)
152 POP_FRAME
153
154 /*
155 * int semsys(int, ...);
156 * int __semsys(int which, int a2, int a3, int a4, int a5);
157 */
158 MI_ENTRY_POINT(_semsys)
159 ARM64_STACK_PROLOG
160 PUSH_FRAME
161 #if __LP64__
162 ldp x1, x2, [fp, #16]
163 ldp x3, x4, [fp, #32]
164 #else
165 ldp w1, w2, [fp, #16]
166 ldp w3, w4, [fp, #24]
167 #endif
168 MI_CALL_EXTERNAL(___semsys)
169 POP_FRAME
170 ARM64_STACK_EPILOG
171
172 /*
173 * int semctl(int, int, int, ...);
174 * int __semctl(int semid, int semnum, int cmd, semun_t arg);
175 */
176 MI_ENTRY_POINT(_semctl)
177 ARM64_STACK_PROLOG
178 PUSH_FRAME
179 #if __LP64__
180 ldr x3, [fp, #16]
181 #else
182 ldr w3, [fp, #16]
183 #endif
184 MI_CALL_EXTERNAL(___semctl)
185 POP_FRAME
186 ARM64_STACK_EPILOG
187
188 /*
189 * int shmsys(int, ...);
190 * int __shmsys(int which, int a2, int a3, int a4);
191 */
192 MI_ENTRY_POINT(_shmsys)
193 ARM64_STACK_PROLOG
194 PUSH_FRAME
195 #if __LP64__
196 ldp x1, x2, [fp, #16]
197 ldr x3, [fp, #32]
198 #else
199 ldp w1, w2, [fp, #16]
200 ldr w3, [fp, #24]
201 #endif
202 MI_CALL_EXTERNAL(___shmsys)
203 POP_FRAME
204 ARM64_STACK_EPILOG
205
206 #endif /* defined(__arm64__) */