1/* $OpenBSD: _types.h,v 1.4 2023/07/02 19:02:28 cheloha Exp $ */
2/*-
3 * Copyright (c) 1990, 1993
4 *	The Regents of the University of California.  All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 *    may be used to endorse or promote products derived from this software
16 *    without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 *	@(#)types.h	8.3 (Berkeley) 1/5/94
31 *	@(#)ansi.h	8.2 (Berkeley) 1/4/94
32 */
33
34#ifndef _MACHINE__TYPES_H_
35#define _MACHINE__TYPES_H_
36
37#if defined(_KERNEL)
38typedef struct label_t {
39	long val[22];
40} label_t;
41#endif
42
43/*
44 * _ALIGN(p) rounds p (pointer or byte index) up to a correctly-aligned
45 * value for all data types (int, long, ...).   The result is an
46 * unsigned long and must be cast to any desired pointer type.
47 *
48 * _ALIGNED_POINTER is a boolean macro that checks whether an address
49 * is valid to fetch data elements of type t from on this architecture.
50 * This does not reflect the optimal alignment, just the possibility
51 * (within reasonable limits).
52 */
53#define	_ALIGNBYTES		(sizeof(long) - 1)
54#define	_STACKALIGNBYTES	15
55#define	_ALIGN(p)		(((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
56#define	_ALIGNED_POINTER(p,t)	((((unsigned long)(p)) & (sizeof(t) - 1)) == 0)
57#define	_MAX_PAGE_SHIFT		12	/* same as PAGE_SHIFT */
58
59/* 7.18.1.1 Exact-width integer types */
60typedef	signed char		__int8_t;
61typedef	unsigned char		__uint8_t;
62typedef	short			__int16_t;
63typedef	unsigned short		__uint16_t;
64typedef	int			__int32_t;
65typedef	unsigned int		__uint32_t;
66/* LONGLONG */
67typedef	long long		__int64_t;
68/* LONGLONG */
69typedef	unsigned long long	__uint64_t;
70
71/* 7.18.1.2 Minimum-width integer types */
72typedef	__int8_t		__int_least8_t;
73typedef	__uint8_t		__uint_least8_t;
74typedef	__int16_t		__int_least16_t;
75typedef	__uint16_t		__uint_least16_t;
76typedef	__int32_t		__int_least32_t;
77typedef	__uint32_t		__uint_least32_t;
78typedef	__int64_t		__int_least64_t;
79typedef	__uint64_t		__uint_least64_t;
80
81/* 7.18.1.3 Fastest minimum-width integer types */
82typedef	__int32_t		__int_fast8_t;
83typedef	__uint32_t		__uint_fast8_t;
84typedef	__int32_t		__int_fast16_t;
85typedef	__uint32_t		__uint_fast16_t;
86typedef	__int32_t		__int_fast32_t;
87typedef	__uint32_t		__uint_fast32_t;
88typedef	__int64_t		__int_fast64_t;
89typedef	__uint64_t		__uint_fast64_t;
90#define	__INT_FAST8_MIN		INT32_MIN
91#define	__INT_FAST16_MIN	INT32_MIN
92#define	__INT_FAST32_MIN	INT32_MIN
93#define	__INT_FAST64_MIN	INT64_MIN
94#define	__INT_FAST8_MAX		INT32_MAX
95#define	__INT_FAST16_MAX	INT32_MAX
96#define	__INT_FAST32_MAX	INT32_MAX
97#define	__INT_FAST64_MAX	INT64_MAX
98#define	__UINT_FAST8_MAX	UINT32_MAX
99#define	__UINT_FAST16_MAX	UINT32_MAX
100#define	__UINT_FAST32_MAX	UINT32_MAX
101#define	__UINT_FAST64_MAX	UINT64_MAX
102
103/* 7.18.1.4 Integer types capable of holding object pointers */
104typedef	long			__intptr_t;
105typedef	unsigned long		__uintptr_t;
106
107/* 7.18.1.5 Greatest-width integer types */
108typedef	__int64_t		__intmax_t;
109typedef	__uint64_t		__uintmax_t;
110
111/* Register size */
112typedef long			__register_t;
113
114/* VM system types */
115typedef unsigned long		__vaddr_t;
116typedef unsigned long		__paddr_t;
117typedef unsigned long		__vsize_t;
118typedef unsigned long		__psize_t;
119
120/* Standard system types */
121typedef	double			__double_t;
122typedef	float			__float_t;
123typedef	long			__ptrdiff_t;
124typedef	unsigned long		__size_t;
125typedef	long			__ssize_t;
126#if defined(__GNUC__) && __GNUC__ >= 3
127typedef	__builtin_va_list	__va_list;
128#else
129typedef	char *			__va_list;
130#endif
131
132/* Wide character support types */
133#ifndef __cplusplus
134#ifdef __WCHAR_UNSIGNED__
135typedef	unsigned int		__wchar_t;
136#else
137typedef	int			__wchar_t;
138#endif
139#endif
140typedef	int			__wint_t;
141typedef	int			__rune_t;
142typedef	void *			__wctrans_t;
143typedef	void *			__wctype_t;
144
145#endif	/* _MACHINE__TYPES_H_ */
146