xref: /f-stack/freebsd/sys/_types.h (revision 22ce4aff)
1a9643ea8Slogwang /*-
2*22ce4affSfengbojiang  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*22ce4affSfengbojiang  *
4a9643ea8Slogwang  * Copyright (c) 2002 Mike Barcroft <[email protected]>
5a9643ea8Slogwang  * All rights reserved.
6a9643ea8Slogwang  *
7a9643ea8Slogwang  * Redistribution and use in source and binary forms, with or without
8a9643ea8Slogwang  * modification, are permitted provided that the following conditions
9a9643ea8Slogwang  * are met:
10a9643ea8Slogwang  * 1. Redistributions of source code must retain the above copyright
11a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer.
12a9643ea8Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
13a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer in the
14a9643ea8Slogwang  *    documentation and/or other materials provided with the distribution.
15a9643ea8Slogwang  *
16a9643ea8Slogwang  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17a9643ea8Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18a9643ea8Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19a9643ea8Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20a9643ea8Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21a9643ea8Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22a9643ea8Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23a9643ea8Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24a9643ea8Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25a9643ea8Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26a9643ea8Slogwang  * SUCH DAMAGE.
27a9643ea8Slogwang  *
28a9643ea8Slogwang  * $FreeBSD$
29a9643ea8Slogwang  */
30a9643ea8Slogwang 
31a9643ea8Slogwang #ifndef _SYS__TYPES_H_
32a9643ea8Slogwang #define _SYS__TYPES_H_
33a9643ea8Slogwang 
34a9643ea8Slogwang #include <sys/cdefs.h>
35a9643ea8Slogwang #include <machine/_types.h>
36a9643ea8Slogwang 
37a9643ea8Slogwang /*
38a9643ea8Slogwang  * Standard type definitions.
39a9643ea8Slogwang  */
40a9643ea8Slogwang typedef	__int32_t	__blksize_t;	/* file block size */
41a9643ea8Slogwang typedef	__int64_t	__blkcnt_t;	/* file block count */
42a9643ea8Slogwang typedef	__int32_t	__clockid_t;	/* clock_gettime()... */
43a9643ea8Slogwang typedef	__uint32_t	__fflags_t;	/* file flags */
44a9643ea8Slogwang typedef	__uint64_t	__fsblkcnt_t;
45a9643ea8Slogwang typedef	__uint64_t	__fsfilcnt_t;
46a9643ea8Slogwang typedef	__uint32_t	__gid_t;
47a9643ea8Slogwang typedef	__int64_t	__id_t;		/* can hold a gid_t, pid_t, or uid_t */
48*22ce4affSfengbojiang typedef	__uint64_t	__ino_t;	/* inode number */
49a9643ea8Slogwang typedef	long		__key_t;	/* IPC key (for Sys V IPC) */
50a9643ea8Slogwang typedef	__int32_t	__lwpid_t;	/* Thread ID (a.k.a. LWP) */
51a9643ea8Slogwang typedef	__uint16_t	__mode_t;	/* permissions */
52a9643ea8Slogwang typedef	int		__accmode_t;	/* access permissions */
53a9643ea8Slogwang typedef	int		__nl_item;
54*22ce4affSfengbojiang typedef	__uint64_t	__nlink_t;	/* link count */
55a9643ea8Slogwang typedef	__int64_t	__off_t;	/* file offset */
56a9643ea8Slogwang typedef	__int64_t	__off64_t;	/* file offset (alias) */
57a9643ea8Slogwang typedef	__int32_t	__pid_t;	/* process [group] */
58a9643ea8Slogwang typedef	__int64_t	__rlim_t;	/* resource limit - intentionally */
59a9643ea8Slogwang 					/* signed, because of legacy code */
60a9643ea8Slogwang 					/* that uses -1 for RLIM_INFINITY */
61a9643ea8Slogwang typedef	__uint8_t	__sa_family_t;
62a9643ea8Slogwang typedef	__uint32_t	__socklen_t;
63a9643ea8Slogwang typedef	long		__suseconds_t;	/* microseconds (signed) */
64a9643ea8Slogwang typedef	struct __timer	*__timer_t;	/* timer_gettime()... */
65a9643ea8Slogwang typedef	struct __mq	*__mqd_t;	/* mq_open()... */
66a9643ea8Slogwang typedef	__uint32_t	__uid_t;
67a9643ea8Slogwang typedef	unsigned int	__useconds_t;	/* microseconds (unsigned) */
68a9643ea8Slogwang typedef	int		__cpuwhich_t;	/* which parameter for cpuset. */
69a9643ea8Slogwang typedef	int		__cpulevel_t;	/* level parameter for cpuset. */
70a9643ea8Slogwang typedef int		__cpusetid_t;	/* cpuset identifier. */
71*22ce4affSfengbojiang typedef __int64_t	__daddr_t;	/* bwrite(3), FIOBMAP2, etc */
72a9643ea8Slogwang 
73a9643ea8Slogwang /*
74a9643ea8Slogwang  * Unusual type definitions.
75a9643ea8Slogwang  */
76a9643ea8Slogwang /*
77a9643ea8Slogwang  * rune_t is declared to be an ``int'' instead of the more natural
78a9643ea8Slogwang  * ``unsigned long'' or ``long''.  Two things are happening here.  It is not
79a9643ea8Slogwang  * unsigned so that EOF (-1) can be naturally assigned to it and used.  Also,
80a9643ea8Slogwang  * it looks like 10646 will be a 31 bit standard.  This means that if your
81a9643ea8Slogwang  * ints cannot hold 32 bits, you will be in trouble.  The reason an int was
82a9643ea8Slogwang  * chosen over a long is that the is*() and to*() routines take ints (says
83a9643ea8Slogwang  * ANSI C), but they use __ct_rune_t instead of int.
84a9643ea8Slogwang  *
85a9643ea8Slogwang  * NOTE: rune_t is not covered by ANSI nor other standards, and should not
86a9643ea8Slogwang  * be instantiated outside of lib/libc/locale.  Use wchar_t.  wint_t and
87a9643ea8Slogwang  * rune_t must be the same type.  Also, wint_t should be able to hold all
88a9643ea8Slogwang  * members of the largest character set plus one extra value (WEOF), and
89a9643ea8Slogwang  * must be at least 16 bits.
90a9643ea8Slogwang  */
91a9643ea8Slogwang typedef	int		__ct_rune_t;	/* arg type for ctype funcs */
92a9643ea8Slogwang typedef	__ct_rune_t	__rune_t;	/* rune_t (see above) */
93a9643ea8Slogwang typedef	__ct_rune_t	__wint_t;	/* wint_t (see above) */
94a9643ea8Slogwang 
95a9643ea8Slogwang /* Clang already provides these types as built-ins, but only in C++ mode. */
96a9643ea8Slogwang #if !defined(__clang__) || !defined(__cplusplus)
97a9643ea8Slogwang typedef	__uint_least16_t __char16_t;
98a9643ea8Slogwang typedef	__uint_least32_t __char32_t;
99a9643ea8Slogwang #endif
100a9643ea8Slogwang /* In C++11, char16_t and char32_t are built-in types. */
101a9643ea8Slogwang #if defined(__cplusplus) && __cplusplus >= 201103L
102a9643ea8Slogwang #define	_CHAR16_T_DECLARED
103a9643ea8Slogwang #define	_CHAR32_T_DECLARED
104a9643ea8Slogwang #endif
105a9643ea8Slogwang 
106*22ce4affSfengbojiang typedef struct {
107*22ce4affSfengbojiang 	long long __max_align1 __aligned(_Alignof(long long));
108*22ce4affSfengbojiang #ifndef _STANDALONE
109*22ce4affSfengbojiang 	long double __max_align2 __aligned(_Alignof(long double));
110*22ce4affSfengbojiang #endif
111*22ce4affSfengbojiang } __max_align_t;
112*22ce4affSfengbojiang 
113*22ce4affSfengbojiang typedef	__uint64_t	__dev_t;	/* device number */
114a9643ea8Slogwang 
115a9643ea8Slogwang typedef	__uint32_t	__fixpt_t;	/* fixed point number */
116a9643ea8Slogwang 
117a9643ea8Slogwang /*
118a9643ea8Slogwang  * mbstate_t is an opaque object to keep conversion state during multibyte
119a9643ea8Slogwang  * stream conversions.
120a9643ea8Slogwang  */
121a9643ea8Slogwang typedef union {
122a9643ea8Slogwang 	char		__mbstate8[128];
123a9643ea8Slogwang 	__int64_t	_mbstateL;	/* for alignment */
124a9643ea8Slogwang } __mbstate_t;
125a9643ea8Slogwang 
126a9643ea8Slogwang typedef __uintmax_t     __rman_res_t;
127a9643ea8Slogwang 
128*22ce4affSfengbojiang /*
129*22ce4affSfengbojiang  * Types for varargs. These are all provided by builtin types these
130*22ce4affSfengbojiang  * days, so centralize their definition.
131*22ce4affSfengbojiang  */
132*22ce4affSfengbojiang #ifdef __GNUCLIKE_BUILTIN_VARARGS
133*22ce4affSfengbojiang typedef	__builtin_va_list	__va_list;	/* internally known to gcc */
134*22ce4affSfengbojiang #else
135*22ce4affSfengbojiang #error "No support for your compiler for stdargs"
136*22ce4affSfengbojiang #endif
137*22ce4affSfengbojiang #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
138*22ce4affSfengbojiang     && !defined(__NO_GNUC_VA_LIST)
139*22ce4affSfengbojiang #define __GNUC_VA_LIST
140*22ce4affSfengbojiang typedef __va_list		__gnuc_va_list;	/* compatibility w/GNU headers*/
141*22ce4affSfengbojiang #endif
142*22ce4affSfengbojiang 
143*22ce4affSfengbojiang /*
144*22ce4affSfengbojiang  * When the following macro is defined, the system uses 64-bit inode numbers.
145*22ce4affSfengbojiang  * Programs can use this to avoid including <sys/param.h>, with its associated
146*22ce4affSfengbojiang  * namespace pollution.
147*22ce4affSfengbojiang  */
148*22ce4affSfengbojiang #define	__INO64
149*22ce4affSfengbojiang 
150a9643ea8Slogwang #endif /* !_SYS__TYPES_H_ */
151