xref: /xnu-8796.121.2/bsd/arm/types.h (revision c54f35ca767986246321eb901baf8f5ff7923f6a)
1*c54f35caSApple OSS Distributions /*
2*c54f35caSApple OSS Distributions  * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
3*c54f35caSApple OSS Distributions  */
4*c54f35caSApple OSS Distributions /*
5*c54f35caSApple OSS Distributions  * Copyright 1995 NeXT Computer, Inc. All rights reserved.
6*c54f35caSApple OSS Distributions  */
7*c54f35caSApple OSS Distributions /*
8*c54f35caSApple OSS Distributions  * Copyright (c) 1990, 1993
9*c54f35caSApple OSS Distributions  *	The Regents of the University of California.  All rights reserved.
10*c54f35caSApple OSS Distributions  *
11*c54f35caSApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
12*c54f35caSApple OSS Distributions  * modification, are permitted provided that the following conditions
13*c54f35caSApple OSS Distributions  * are met:
14*c54f35caSApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
15*c54f35caSApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
16*c54f35caSApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
17*c54f35caSApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
18*c54f35caSApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
19*c54f35caSApple OSS Distributions  * 3. All advertising materials mentioning features or use of this software
20*c54f35caSApple OSS Distributions  *    must display the following acknowledgement:
21*c54f35caSApple OSS Distributions  *	This product includes software developed by the University of
22*c54f35caSApple OSS Distributions  *	California, Berkeley and its contributors.
23*c54f35caSApple OSS Distributions  * 4. Neither the name of the University nor the names of its contributors
24*c54f35caSApple OSS Distributions  *    may be used to endorse or promote products derived from this software
25*c54f35caSApple OSS Distributions  *    without specific prior written permission.
26*c54f35caSApple OSS Distributions  *
27*c54f35caSApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28*c54f35caSApple OSS Distributions  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29*c54f35caSApple OSS Distributions  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30*c54f35caSApple OSS Distributions  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31*c54f35caSApple OSS Distributions  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32*c54f35caSApple OSS Distributions  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33*c54f35caSApple OSS Distributions  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34*c54f35caSApple OSS Distributions  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35*c54f35caSApple OSS Distributions  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36*c54f35caSApple OSS Distributions  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37*c54f35caSApple OSS Distributions  * SUCH DAMAGE.
38*c54f35caSApple OSS Distributions  *
39*c54f35caSApple OSS Distributions  *	@(#)types.h	8.3 (Berkeley) 1/5/94
40*c54f35caSApple OSS Distributions  */
41*c54f35caSApple OSS Distributions 
42*c54f35caSApple OSS Distributions #ifndef _ARM_MACHTYPES_H_
43*c54f35caSApple OSS Distributions #define _ARM_MACHTYPES_H_
44*c54f35caSApple OSS Distributions #define _MACHTYPES_H_
45*c54f35caSApple OSS Distributions 
46*c54f35caSApple OSS Distributions #if defined (__arm__) || defined (__arm64__)
47*c54f35caSApple OSS Distributions 
48*c54f35caSApple OSS Distributions #ifndef __ASSEMBLER__
49*c54f35caSApple OSS Distributions #include <arm/_types.h>
50*c54f35caSApple OSS Distributions #include <sys/cdefs.h>
51*c54f35caSApple OSS Distributions /*
52*c54f35caSApple OSS Distributions  * Basic integral types.  Omit the typedef if
53*c54f35caSApple OSS Distributions  * not possible for a machine/compiler combination.
54*c54f35caSApple OSS Distributions  */
55*c54f35caSApple OSS Distributions #include <sys/_types/_int8_t.h>
56*c54f35caSApple OSS Distributions #include <sys/_types/_int16_t.h>
57*c54f35caSApple OSS Distributions #include <sys/_types/_int32_t.h>
58*c54f35caSApple OSS Distributions #include <sys/_types/_int64_t.h>
59*c54f35caSApple OSS Distributions 
60*c54f35caSApple OSS Distributions #include <sys/_types/_u_int8_t.h>
61*c54f35caSApple OSS Distributions #include <sys/_types/_u_int16_t.h>
62*c54f35caSApple OSS Distributions #include <sys/_types/_u_int32_t.h>
63*c54f35caSApple OSS Distributions #include <sys/_types/_u_int64_t.h>
64*c54f35caSApple OSS Distributions 
65*c54f35caSApple OSS Distributions #if __LP64__
66*c54f35caSApple OSS Distributions typedef int64_t                 register_t;
67*c54f35caSApple OSS Distributions #else
68*c54f35caSApple OSS Distributions typedef int32_t                 register_t;
69*c54f35caSApple OSS Distributions #endif
70*c54f35caSApple OSS Distributions 
71*c54f35caSApple OSS Distributions #include <sys/_types/_intptr_t.h>
72*c54f35caSApple OSS Distributions #include <sys/_types/_uintptr_t.h>
73*c54f35caSApple OSS Distributions 
74*c54f35caSApple OSS Distributions #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
75*c54f35caSApple OSS Distributions /* These types are used for reserving the largest possible size. */
76*c54f35caSApple OSS Distributions #ifdef __arm64__
77*c54f35caSApple OSS Distributions typedef u_int64_t               user_addr_t;
78*c54f35caSApple OSS Distributions typedef u_int64_t               user_size_t;
79*c54f35caSApple OSS Distributions typedef int64_t                 user_ssize_t;
80*c54f35caSApple OSS Distributions typedef int64_t                 user_long_t;
81*c54f35caSApple OSS Distributions typedef u_int64_t               user_ulong_t;
82*c54f35caSApple OSS Distributions typedef int64_t                 user_time_t;
83*c54f35caSApple OSS Distributions typedef int64_t                 user_off_t;
84*c54f35caSApple OSS Distributions #else
85*c54f35caSApple OSS Distributions typedef u_int32_t               user_addr_t;
86*c54f35caSApple OSS Distributions typedef u_int32_t               user_size_t;
87*c54f35caSApple OSS Distributions typedef int32_t                 user_ssize_t;
88*c54f35caSApple OSS Distributions typedef int32_t                 user_long_t;
89*c54f35caSApple OSS Distributions typedef u_int32_t               user_ulong_t;
90*c54f35caSApple OSS Distributions typedef int32_t                 user_time_t;
91*c54f35caSApple OSS Distributions typedef int64_t                 user_off_t;
92*c54f35caSApple OSS Distributions #endif
93*c54f35caSApple OSS Distributions 
94*c54f35caSApple OSS Distributions #define USER_ADDR_NULL  ((user_addr_t) 0)
95*c54f35caSApple OSS Distributions #define CAST_USER_ADDR_T(a_ptr)   ((user_addr_t)((uintptr_t)(a_ptr)))
96*c54f35caSApple OSS Distributions 
97*c54f35caSApple OSS Distributions #ifdef KERNEL
98*c54f35caSApple OSS Distributions 
99*c54f35caSApple OSS Distributions /*
100*c54f35caSApple OSS Distributions  * These types are used when you know the word size of the target
101*c54f35caSApple OSS Distributions  * user process. They can be used to create struct layouts independent
102*c54f35caSApple OSS Distributions  * of the types and alignment requirements of the current running
103*c54f35caSApple OSS Distributions  * kernel.
104*c54f35caSApple OSS Distributions  */
105*c54f35caSApple OSS Distributions 
106*c54f35caSApple OSS Distributions /*
107*c54f35caSApple OSS Distributions  * The user64_ types are not used on the ARM platform, but exist
108*c54f35caSApple OSS Distributions  * so that APIs that conditionalize their behavior based on the
109*c54f35caSApple OSS Distributions  * size of an input structure (like many ioctl(2) implementations)
110*c54f35caSApple OSS Distributions  * can differentiate those structures without a duplicate case
111*c54f35caSApple OSS Distributions  * value.
112*c54f35caSApple OSS Distributions  */
113*c54f35caSApple OSS Distributions 
114*c54f35caSApple OSS Distributions /*
115*c54f35caSApple OSS Distributions  * The default ABI for the ARM platform aligns fundamental integral
116*c54f35caSApple OSS Distributions  * data types to their natural boundaries, with a maximum alignment
117*c54f35caSApple OSS Distributions  * of 4, even for 8-byte quantites.
118*c54f35caSApple OSS Distributions  */
119*c54f35caSApple OSS Distributions 
120*c54f35caSApple OSS Distributions typedef __uint64_t              user64_addr_t;
121*c54f35caSApple OSS Distributions typedef __uint64_t              user64_size_t;
122*c54f35caSApple OSS Distributions typedef __int64_t               user64_ssize_t;
123*c54f35caSApple OSS Distributions typedef __int64_t               user64_long_t;
124*c54f35caSApple OSS Distributions typedef __uint64_t              user64_ulong_t;
125*c54f35caSApple OSS Distributions typedef __int64_t               user64_time_t;
126*c54f35caSApple OSS Distributions typedef __int64_t               user64_off_t;
127*c54f35caSApple OSS Distributions 
128*c54f35caSApple OSS Distributions typedef __uint32_t              user32_addr_t;
129*c54f35caSApple OSS Distributions typedef __uint32_t              user32_size_t;
130*c54f35caSApple OSS Distributions typedef __int32_t               user32_ssize_t;
131*c54f35caSApple OSS Distributions typedef __int32_t               user32_long_t;
132*c54f35caSApple OSS Distributions typedef __uint32_t              user32_ulong_t;
133*c54f35caSApple OSS Distributions typedef __int32_t               user32_time_t;
134*c54f35caSApple OSS Distributions 
135*c54f35caSApple OSS Distributions /*
136*c54f35caSApple OSS Distributions  * This alignment is required to ensure symmetry between userspace and kernelspace
137*c54f35caSApple OSS Distributions  * when the kernel is 64-bit and the user application is 32-bit. All currently
138*c54f35caSApple OSS Distributions  * supported ARM slices (arm64/armv7k/arm64_32) contain the same type alignment
139*c54f35caSApple OSS Distributions  * ABI so this alignment isn't needed for ARM.
140*c54f35caSApple OSS Distributions  */
141*c54f35caSApple OSS Distributions #if defined(__x86_64__)
142*c54f35caSApple OSS Distributions typedef __int64_t               user32_off_t __attribute__((aligned(4)));
143*c54f35caSApple OSS Distributions #else
144*c54f35caSApple OSS Distributions typedef __int64_t               user32_off_t;
145*c54f35caSApple OSS Distributions #endif
146*c54f35caSApple OSS Distributions 
147*c54f35caSApple OSS Distributions #endif /* KERNEL */
148*c54f35caSApple OSS Distributions 
149*c54f35caSApple OSS Distributions #endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
150*c54f35caSApple OSS Distributions 
151*c54f35caSApple OSS Distributions /* This defines the size of syscall arguments after copying into the kernel: */
152*c54f35caSApple OSS Distributions #if defined(__arm__)
153*c54f35caSApple OSS Distributions typedef u_int32_t               syscall_arg_t;
154*c54f35caSApple OSS Distributions #elif defined(__arm64__)
155*c54f35caSApple OSS Distributions typedef u_int64_t               syscall_arg_t;
156*c54f35caSApple OSS Distributions #else
157*c54f35caSApple OSS Distributions #error Unknown architecture.
158*c54f35caSApple OSS Distributions #endif
159*c54f35caSApple OSS Distributions 
160*c54f35caSApple OSS Distributions #endif /* __ASSEMBLER__ */
161*c54f35caSApple OSS Distributions #endif /* defined (__arm__) || defined (__arm64__) */
162*c54f35caSApple OSS Distributions #endif  /* _ARM_MACHTYPES_H_ */
163