]> git.saurik.com Git - apple/xnu.git/blame - libsyscall/wrappers/varargs_wrappers.s
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / libsyscall / wrappers / varargs_wrappers.s
CommitLineData
2d21ac55 1/*
fe8ab488 2 * Copyright (c) 2011-2013 Apple Inc. All rights reserved.
2d21ac55 3 *
fe8ab488 4 * @APPLE_LICENSE_HEADER_START@
2d21ac55
A
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
fe8ab488
A
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.
2d21ac55
A
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 *
fe8ab488 21 * @APPLE_LICENSE_HEADER_END@
2d21ac55
A
22 */
23
5ba3f43e
A
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 */
38MI_ENTRY_POINT(_sem_open)
d9a64523 39 ARM64_STACK_PROLOG
5ba3f43e 40 PUSH_FRAME
d9a64523 41#if __LP64__
5ba3f43e 42 ldp x2, x3, [fp, #16]
d9a64523
A
43#else
44 ldp w2, w3, [fp, #16]
45#endif
5ba3f43e 46 MI_CALL_EXTERNAL(___sem_open)
d9a64523
A
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
5ba3f43e 54 POP_FRAME
d9a64523 55 ARM64_STACK_EPILOG
5ba3f43e 56
5ba3f43e
A
57/*
58 * int shm_open(const char *, int, ...);
59 * int __shm_open(const char*, int oflag, int mode);
60 */
61MI_ENTRY_POINT(_shm_open)
d9a64523 62 ARM64_STACK_PROLOG
5ba3f43e 63 PUSH_FRAME
d9a64523
A
64#if __LP64__
65 ldr x2, [fp, #16]
66#else
67 ldr w2, [fp, #16]
68#endif
5ba3f43e
A
69 MI_CALL_EXTERNAL(___shm_open)
70 POP_FRAME
d9a64523 71 ARM64_STACK_EPILOG
5ba3f43e
A
72
73/*
74 * int msgsys(int, ...);
75 * int __msgsys(int which, int a2, int a3, int a4, int a5);
76 */
77MI_ENTRY_POINT(_msgsys)
d9a64523 78 ARM64_STACK_PROLOG
5ba3f43e 79 PUSH_FRAME
d9a64523
A
80#if __LP64__
81 ldp x1, x2, [fp, #16]
82 ldp x3, x4, [fp, #32]
83#else
84 ldp w1, w2, [fp, #16]
85 ldp w3, w4, [fp, #24]
86#endif
5ba3f43e
A
87 MI_CALL_EXTERNAL(___msgsys)
88 POP_FRAME
5ba3f43e
A
89
90/*
91 * int semsys(int, ...);
92 * int __semsys(int which, int a2, int a3, int a4, int a5);
93 */
94MI_ENTRY_POINT(_semsys)
d9a64523 95 ARM64_STACK_PROLOG
5ba3f43e 96 PUSH_FRAME
d9a64523
A
97#if __LP64__
98 ldp x1, x2, [fp, #16]
99 ldp x3, x4, [fp, #32]
100#else
101 ldp w1, w2, [fp, #16]
102 ldp w3, w4, [fp, #24]
103#endif
5ba3f43e
A
104 MI_CALL_EXTERNAL(___semsys)
105 POP_FRAME
d9a64523 106 ARM64_STACK_EPILOG
5ba3f43e
A
107
108/*
109 * int semctl(int, int, int, ...);
110 * int __semctl(int semid, int semnum, int cmd, semun_t arg);
111 */
112 MI_ENTRY_POINT(_semctl)
d9a64523 113 ARM64_STACK_PROLOG
5ba3f43e 114 PUSH_FRAME
d9a64523
A
115#if __LP64__
116 ldr x3, [fp, #16]
117#else
118 ldr w3, [fp, #16]
119#endif
5ba3f43e
A
120 MI_CALL_EXTERNAL(___semctl)
121 POP_FRAME
d9a64523 122 ARM64_STACK_EPILOG
5ba3f43e
A
123
124/*
125 * int shmsys(int, ...);
126 * int __shmsys(int which, int a2, int a3, int a4);
127 */
128 MI_ENTRY_POINT(_shmsys)
d9a64523 129 ARM64_STACK_PROLOG
5ba3f43e 130 PUSH_FRAME
d9a64523
A
131#if __LP64__
132 ldp x1, x2, [fp, #16]
133 ldr x3, [fp, #32]
134#else
135 ldp w1, w2, [fp, #16]
136 ldr w3, [fp, #24]
137#endif
5ba3f43e
A
138 MI_CALL_EXTERNAL(___shmsys)
139 POP_FRAME
d9a64523 140 ARM64_STACK_EPILOG
5ba3f43e
A
141
142#endif /* defined(__arm64__) */