xref: /xnu-11417.140.69/libsyscall/wrappers/varargs_wrappers.s (revision 43a90889846e00bfb5cf1d255cdc0a701a1e05a4)
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 */
38MI_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 shm_open(const char *, int, ...);
59 * int __shm_open(const char*, int oflag, int mode);
60 */
61MI_ENTRY_POINT(_shm_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(___shm_open)
70	POP_FRAME
71	ARM64_STACK_EPILOG
72
73/*
74 * int msgsys(int, ...);
75 * int __msgsys(int which, int a2, int a3, int a4, int a5);
76 */
77MI_ENTRY_POINT(_msgsys)
78	ARM64_STACK_PROLOG
79	PUSH_FRAME
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
87	MI_CALL_EXTERNAL(___msgsys)
88	POP_FRAME
89
90/*
91 * int semsys(int, ...);
92 * int __semsys(int which, int a2, int a3, int a4, int a5);
93 */
94MI_ENTRY_POINT(_semsys)
95	ARM64_STACK_PROLOG
96	PUSH_FRAME
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
104	MI_CALL_EXTERNAL(___semsys)
105	POP_FRAME
106	ARM64_STACK_EPILOG
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)
113	ARM64_STACK_PROLOG
114	PUSH_FRAME
115#if __LP64__
116	ldr	x3, [fp, #16]
117#else
118	ldr	w3, [fp, #16]
119#endif
120	MI_CALL_EXTERNAL(___semctl)
121	POP_FRAME
122	ARM64_STACK_EPILOG
123
124/*
125 * int	shmsys(int, ...);
126 * int __shmsys(int which, int a2, int a3, int a4);
127 */
128 MI_ENTRY_POINT(_shmsys)
129	ARM64_STACK_PROLOG
130	PUSH_FRAME
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
138	MI_CALL_EXTERNAL(___shmsys)
139	POP_FRAME
140	ARM64_STACK_EPILOG
141
142#endif /* defined(__arm64__) */
143