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