2 * Copyright (c) 1999-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
33 #if defined(__ppc__) || defined(__ppc64__)
35 /* We use mode-independent "g" opcodes such as "srgi", and/or
36 * mode-independent macros such as MI_GET_ADDRESS. These expand
37 * into word operations when targeting __ppc__, and into doubleword
38 * operations when targeting __ppc64__.
40 #include <architecture/ppc/mode_independent_asm.h>
44 MI_ENTRY_POINT(cerror)
46 MI_GET_ADDRESS(r12,_errno)
47 stw r3,0(r12) /* save syscall return code in global */
48 MI_CALL_EXTERNAL(_cthread_set_errno_self)
49 li r3,-1 /* then bug return value */
50 li r4,-1 /* in case we're returning a long-long in 32-bit mode, etc */
51 MI_POP_STACK_FRAME_AND_RETURN
54 .globl _processor_facilities_used
56 _processor_facilities_used:
61 #elif defined(__i386__)
66 REG_TO_EXTERN(%eax, _errno)
72 CALL_EXTERN(_cthread_set_errno_self)
75 movl $-1,%edx /* in case a 64-bit value is returned */
78 .private_extern __sysenter_trap
85 #elif defined(__x86_64__)
90 REG_TO_EXTERN(%rax, _errno)
94 // Preserve the original stack
97 CALL_EXTERN(_cthread_set_errno_self)
98 // Restore the original stack
101 movq $-1,%rdx /* in case a 128-bit value is returned */
105 #error Unsupported architecture
108 #if defined(__i386__) || defined(__x86_64__)