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