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