xref: /xnu-12377.41.6/libsyscall/wrappers/varargs_wrappers.s (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1*bbb1b6f9SApple OSS Distributions/*
2*bbb1b6f9SApple OSS Distributions * Copyright (c) 2011-2013 Apple Inc. All rights reserved.
3*bbb1b6f9SApple OSS Distributions *
4*bbb1b6f9SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@
5*bbb1b6f9SApple OSS Distributions *
6*bbb1b6f9SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*bbb1b6f9SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*bbb1b6f9SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*bbb1b6f9SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at
10*bbb1b6f9SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this
11*bbb1b6f9SApple OSS Distributions * file.
12*bbb1b6f9SApple OSS Distributions *
13*bbb1b6f9SApple OSS Distributions * The Original Code and all software distributed under the License are
14*bbb1b6f9SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15*bbb1b6f9SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16*bbb1b6f9SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17*bbb1b6f9SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18*bbb1b6f9SApple OSS Distributions * Please see the License for the specific language governing rights and
19*bbb1b6f9SApple OSS Distributions * limitations under the License.
20*bbb1b6f9SApple OSS Distributions *
21*bbb1b6f9SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@
22*bbb1b6f9SApple OSS Distributions */
23*bbb1b6f9SApple OSS Distributions
24*bbb1b6f9SApple OSS Distributions#ifdef __arm64__
25*bbb1b6f9SApple OSS Distributions
26*bbb1b6f9SApple OSS Distributions#include "../custom/SYS.h"
27*bbb1b6f9SApple OSS Distributions#include <mach/arm64/asm.h>
28*bbb1b6f9SApple OSS Distributions
29*bbb1b6f9SApple OSS Distributions/*
30*bbb1b6f9SApple OSS Distributions * Stubs are to handle the ARM64 ABI for variadic functions'
31*bbb1b6f9SApple OSS Distributions * not matching the ABI used by the system call handler.
32*bbb1b6f9SApple OSS Distributions */
33*bbb1b6f9SApple OSS Distributions
34*bbb1b6f9SApple OSS Distributions/*
35*bbb1b6f9SApple OSS Distributions *	sem_t* sem_open(const char *name, int oflag, ...);
36*bbb1b6f9SApple OSS Distributions *	sem_t* __sem_open(const char *name, int oflag, int mode, int value);
37*bbb1b6f9SApple OSS Distributions */
38*bbb1b6f9SApple OSS DistributionsMI_ENTRY_POINT(_sem_open)
39*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
40*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
41*bbb1b6f9SApple OSS Distributions#if __LP64__
42*bbb1b6f9SApple OSS Distributions	ldp	x2, x3, [fp, #16]
43*bbb1b6f9SApple OSS Distributions#else
44*bbb1b6f9SApple OSS Distributions	ldp	w2, w3, [fp, #16]
45*bbb1b6f9SApple OSS Distributions#endif
46*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___sem_open)
47*bbb1b6f9SApple OSS Distributions#if !__LP64__
48*bbb1b6f9SApple OSS Distributions	/* xnu returns a 64-bit '-1' on failure, but pointers must have the high
49*bbb1b6f9SApple OSS Distributions	 * 32-bits set to zero. The following instruction is equivalent to
50*bbb1b6f9SApple OSS Distributions	 * masking off the top 32-bits.
51*bbb1b6f9SApple OSS Distributions	 */
52*bbb1b6f9SApple OSS Distributions	mov w0, w0
53*bbb1b6f9SApple OSS Distributions#endif
54*bbb1b6f9SApple OSS Distributions	POP_FRAME
55*bbb1b6f9SApple OSS Distributions	ARM64_STACK_EPILOG
56*bbb1b6f9SApple OSS Distributions
57*bbb1b6f9SApple OSS Distributions/*
58*bbb1b6f9SApple OSS Distributions * int shm_open(const char *, int, ...);
59*bbb1b6f9SApple OSS Distributions * int __shm_open(const char*, int oflag, int mode);
60*bbb1b6f9SApple OSS Distributions */
61*bbb1b6f9SApple OSS DistributionsMI_ENTRY_POINT(_shm_open)
62*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
63*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
64*bbb1b6f9SApple OSS Distributions#if __LP64__
65*bbb1b6f9SApple OSS Distributions	ldr	x2, [fp, #16]
66*bbb1b6f9SApple OSS Distributions#else
67*bbb1b6f9SApple OSS Distributions	ldr	w2, [fp, #16]
68*bbb1b6f9SApple OSS Distributions#endif
69*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___shm_open)
70*bbb1b6f9SApple OSS Distributions	POP_FRAME
71*bbb1b6f9SApple OSS Distributions	ARM64_STACK_EPILOG
72*bbb1b6f9SApple OSS Distributions
73*bbb1b6f9SApple OSS Distributions/*
74*bbb1b6f9SApple OSS Distributions * int msgsys(int, ...);
75*bbb1b6f9SApple OSS Distributions * int __msgsys(int which, int a2, int a3, int a4, int a5);
76*bbb1b6f9SApple OSS Distributions */
77*bbb1b6f9SApple OSS DistributionsMI_ENTRY_POINT(_msgsys)
78*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
79*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
80*bbb1b6f9SApple OSS Distributions#if __LP64__
81*bbb1b6f9SApple OSS Distributions	ldp	x1, x2, [fp, #16]
82*bbb1b6f9SApple OSS Distributions	ldp	x3, x4, [fp, #32]
83*bbb1b6f9SApple OSS Distributions#else
84*bbb1b6f9SApple OSS Distributions	ldp	w1, w2, [fp, #16]
85*bbb1b6f9SApple OSS Distributions	ldp	w3, w4, [fp, #24]
86*bbb1b6f9SApple OSS Distributions#endif
87*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___msgsys)
88*bbb1b6f9SApple OSS Distributions	POP_FRAME
89*bbb1b6f9SApple OSS Distributions
90*bbb1b6f9SApple OSS Distributions/*
91*bbb1b6f9SApple OSS Distributions * int semsys(int, ...);
92*bbb1b6f9SApple OSS Distributions * int __semsys(int which, int a2, int a3, int a4, int a5);
93*bbb1b6f9SApple OSS Distributions */
94*bbb1b6f9SApple OSS DistributionsMI_ENTRY_POINT(_semsys)
95*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
96*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
97*bbb1b6f9SApple OSS Distributions#if __LP64__
98*bbb1b6f9SApple OSS Distributions	ldp	x1, x2, [fp, #16]
99*bbb1b6f9SApple OSS Distributions	ldp	x3, x4, [fp, #32]
100*bbb1b6f9SApple OSS Distributions#else
101*bbb1b6f9SApple OSS Distributions	ldp	w1, w2, [fp, #16]
102*bbb1b6f9SApple OSS Distributions	ldp	w3, w4, [fp, #24]
103*bbb1b6f9SApple OSS Distributions#endif
104*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___semsys)
105*bbb1b6f9SApple OSS Distributions	POP_FRAME
106*bbb1b6f9SApple OSS Distributions	ARM64_STACK_EPILOG
107*bbb1b6f9SApple OSS Distributions
108*bbb1b6f9SApple OSS Distributions/*
109*bbb1b6f9SApple OSS Distributions * int	semctl(int, int, int, ...);
110*bbb1b6f9SApple OSS Distributions * int __semctl(int semid, int semnum, int cmd, semun_t arg);
111*bbb1b6f9SApple OSS Distributions */
112*bbb1b6f9SApple OSS Distributions MI_ENTRY_POINT(_semctl)
113*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
114*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
115*bbb1b6f9SApple OSS Distributions#if __LP64__
116*bbb1b6f9SApple OSS Distributions	ldr	x3, [fp, #16]
117*bbb1b6f9SApple OSS Distributions#else
118*bbb1b6f9SApple OSS Distributions	ldr	w3, [fp, #16]
119*bbb1b6f9SApple OSS Distributions#endif
120*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___semctl)
121*bbb1b6f9SApple OSS Distributions	POP_FRAME
122*bbb1b6f9SApple OSS Distributions	ARM64_STACK_EPILOG
123*bbb1b6f9SApple OSS Distributions
124*bbb1b6f9SApple OSS Distributions/*
125*bbb1b6f9SApple OSS Distributions * int	shmsys(int, ...);
126*bbb1b6f9SApple OSS Distributions * int __shmsys(int which, int a2, int a3, int a4);
127*bbb1b6f9SApple OSS Distributions */
128*bbb1b6f9SApple OSS Distributions MI_ENTRY_POINT(_shmsys)
129*bbb1b6f9SApple OSS Distributions	ARM64_STACK_PROLOG
130*bbb1b6f9SApple OSS Distributions	PUSH_FRAME
131*bbb1b6f9SApple OSS Distributions#if __LP64__
132*bbb1b6f9SApple OSS Distributions	ldp	x1, x2, [fp, #16]
133*bbb1b6f9SApple OSS Distributions	ldr	x3, [fp, #32]
134*bbb1b6f9SApple OSS Distributions#else
135*bbb1b6f9SApple OSS Distributions	ldp	w1, w2, [fp, #16]
136*bbb1b6f9SApple OSS Distributions	ldr	w3, [fp, #24]
137*bbb1b6f9SApple OSS Distributions#endif
138*bbb1b6f9SApple OSS Distributions	MI_CALL_EXTERNAL(___shmsys)
139*bbb1b6f9SApple OSS Distributions	POP_FRAME
140*bbb1b6f9SApple OSS Distributions	ARM64_STACK_EPILOG
141*bbb1b6f9SApple OSS Distributions
142*bbb1b6f9SApple OSS Distributions#endif /* defined(__arm64__) */
143