1/*	$OpenBSD: types.h,v 1.49 2022/08/06 13:31:13 semarie Exp $	*/
2/*	$NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $	*/
3
4/*-
5 * Copyright (c) 1982, 1986, 1991, 1993
6 *	The Regents of the University of California.  All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 *    may be used to endorse or promote products derived from this software
23 *    without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 *	@(#)types.h	8.4 (Berkeley) 1/21/94
38 */
39
40#ifndef _SYS_TYPES_H_
41#define	_SYS_TYPES_H_
42
43#include <sys/cdefs.h>
44#if __BSD_VISIBLE
45#include <sys/endian.h>
46#else
47#include <sys/_endian.h>
48#endif
49
50#if __BSD_VISIBLE
51typedef	unsigned char	u_char;
52typedef	unsigned short	u_short;
53typedef	unsigned int	u_int;
54typedef	unsigned long	u_long;
55
56typedef unsigned char	unchar;		/* Sys V compatibility */
57typedef	unsigned short	ushort;		/* Sys V compatibility */
58typedef	unsigned int	uint;		/* Sys V compatibility */
59typedef unsigned long	ulong;		/* Sys V compatibility */
60
61typedef	__cpuid_t	cpuid_t;	/* CPU id */
62typedef	__register_t	register_t;	/* register-sized type */
63#endif /* __BSD_VISIBLE */
64
65/*
66 * XXX The exact-width bit types should only be exposed if __BSD_VISIBLE
67 *     but the rest of the includes are not ready for that yet.
68 */
69#ifndef	__BIT_TYPES_DEFINED__
70#define	__BIT_TYPES_DEFINED__
71#endif
72
73#ifndef	_INT8_T_DEFINED_
74#define	_INT8_T_DEFINED_
75typedef	__int8_t		int8_t;
76#endif
77
78#ifndef	_UINT8_T_DEFINED_
79#define	_UINT8_T_DEFINED_
80typedef	__uint8_t		uint8_t;
81#endif
82
83#ifndef	_INT16_T_DEFINED_
84#define	_INT16_T_DEFINED_
85typedef	__int16_t		int16_t;
86#endif
87
88#ifndef	_UINT16_T_DEFINED_
89#define	_UINT16_T_DEFINED_
90typedef	__uint16_t		uint16_t;
91#endif
92
93#ifndef	_INT32_T_DEFINED_
94#define	_INT32_T_DEFINED_
95typedef	__int32_t		int32_t;
96#endif
97
98#ifndef	_UINT32_T_DEFINED_
99#define	_UINT32_T_DEFINED_
100typedef	__uint32_t		uint32_t;
101#endif
102
103#ifndef	_INT64_T_DEFINED_
104#define	_INT64_T_DEFINED_
105typedef	__int64_t		int64_t;
106#endif
107
108#ifndef	_UINT64_T_DEFINED_
109#define	_UINT64_T_DEFINED_
110typedef	__uint64_t		uint64_t;
111#endif
112
113/* BSD-style unsigned bits types */
114typedef	__uint8_t	u_int8_t;
115typedef	__uint16_t	u_int16_t;
116typedef	__uint32_t	u_int32_t;
117typedef	__uint64_t	u_int64_t;
118
119/* quads, deprecated in favor of 64 bit int types */
120typedef	__int64_t	quad_t;
121typedef	__uint64_t	u_quad_t;
122
123#if __BSD_VISIBLE
124/* VM system types */
125typedef __vaddr_t	vaddr_t;
126typedef __paddr_t	paddr_t;
127typedef __vsize_t	vsize_t;
128typedef __psize_t	psize_t;
129#endif /* __BSD_VISIBLE */
130
131/* Standard system types */
132typedef __blkcnt_t	blkcnt_t;	/* blocks allocated for file */
133typedef __blksize_t	blksize_t;	/* optimal blocksize for I/O */
134typedef	char *		caddr_t;	/* core address */
135typedef	__int32_t	daddr32_t;	/* 32-bit disk address */
136typedef	__int64_t	daddr_t;	/* 64-bit disk address */
137typedef	__dev_t		dev_t;		/* device number */
138typedef	__fixpt_t	fixpt_t;	/* fixed point number */
139typedef	__gid_t		gid_t;		/* group id */
140typedef	__id_t		id_t;		/* may contain pid, uid or gid */
141typedef	__ino_t		ino_t;		/* inode number */
142typedef	__key_t		key_t;		/* IPC key (for Sys V IPC) */
143typedef	__mode_t	mode_t;		/* permissions */
144typedef	__nlink_t	nlink_t;	/* link count */
145typedef	__rlim_t	rlim_t;		/* resource limit */
146typedef	__segsz_t	segsz_t;	/* segment size */
147typedef	__uid_t		uid_t;		/* user id */
148typedef	__useconds_t	useconds_t;	/* microseconds */
149typedef	__suseconds_t	suseconds_t;	/* microseconds (signed) */
150typedef	__fsblkcnt_t	fsblkcnt_t;	/* file system block count */
151typedef	__fsfilcnt_t	fsfilcnt_t;	/* file system file count */
152
153/*
154 * The following types may be defined in multiple header files.
155 */
156#ifndef	_CLOCK_T_DEFINED_
157#define	_CLOCK_T_DEFINED_
158typedef	__clock_t	clock_t;
159#endif
160
161#ifndef	_CLOCKID_T_DEFINED_
162#define	_CLOCKID_T_DEFINED_
163typedef	__clockid_t	clockid_t;
164#endif
165
166#ifndef	_PID_T_DEFINED_
167#define	_PID_T_DEFINED_
168typedef	__pid_t		pid_t;
169#endif
170
171#ifndef	_SIZE_T_DEFINED_
172#define	_SIZE_T_DEFINED_
173typedef	__size_t	size_t;
174#endif
175
176#ifndef	_SSIZE_T_DEFINED_
177#define	_SSIZE_T_DEFINED_
178typedef	__ssize_t	ssize_t;
179#endif
180
181#ifndef	_TIME_T_DEFINED_
182#define	_TIME_T_DEFINED_
183typedef	__time_t	time_t;
184#endif
185
186#ifndef	_TIMER_T_DEFINED_
187#define	_TIMER_T_DEFINED_
188typedef	__timer_t	timer_t;
189#endif
190
191#ifndef	_OFF_T_DEFINED_
192#define	_OFF_T_DEFINED_
193typedef	__off_t		off_t;
194#endif
195
196/*
197 * These belong in unistd.h, but are placed here too to ensure that
198 * long arguments will be promoted to off_t if the program fails to
199 * include that header or explicitly cast them to off_t.
200 */
201#if __BSD_VISIBLE && !defined(_KERNEL)
202__BEGIN_DECLS
203off_t	 lseek(int, off_t, int);
204int	 ftruncate(int, off_t);
205int	 truncate(const char *, off_t);
206__END_DECLS
207#endif /* __BSD_VISIBLE && !_KERNEL */
208
209#if __BSD_VISIBLE
210/* Major, minor numbers, dev_t's. */
211#define	major(x)	(((unsigned)(x) >> 8) & 0xff)
212#define	minor(x)	((unsigned)((x) & 0xff) | (((x) & 0xffff0000) >> 8))
213#define	makedev(x,y)	((dev_t)((((x) & 0xff) << 8) | ((y) & 0xff) | (((y) & 0xffff00) << 8)))
214#endif
215
216#if defined(__STDC__) && defined(_KERNEL)
217/*
218 * Forward structure declarations for function prototypes.  We include the
219 * common structures that cross subsystem boundaries here; others are mostly
220 * used in the same place that the structure is defined.
221 */
222struct	proc;
223struct	pgrp;
224struct	ucred;
225struct	rusage;
226struct	file;
227struct	buf;
228struct	tty;
229struct	uio;
230#endif
231
232#ifdef _KERNEL
233#if defined(__GNUC__) || \
234	(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
235/* Support for C99: type _Bool is already built-in. */
236#define false	0
237#define true	1
238
239#else
240/* `_Bool' type must promote to `int' or `unsigned int'. */
241typedef enum {
242	false = 0,
243	true = 1
244} _Bool;
245
246/* And those constants must also be available as macros. */
247#define	false	false
248#define	true	true
249
250#endif
251
252/* User visible type `bool' is provided as a macro which may be redefined */
253#define bool _Bool
254
255/* Inform that everything is fine */
256#define __bool_true_false_are_defined 1
257
258#endif /* _KERNEL */
259
260#endif /* !_SYS_TYPES_H_ */
261