1199767fToomas Soome/*-
2199767fToomas Soome * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
3199767fToomas Soome * All rights reserved.
4199767fToomas Soome *
5199767fToomas Soome * Redistribution and use in source and binary forms, with or without
6199767fToomas Soome * modification, are permitted provided that the following conditions
7199767fToomas Soome * are met:
8199767fToomas Soome * 1. Redistributions of source code must retain the above copyright
9199767fToomas Soome *    notice, this list of conditions and the following disclaimer.
10199767fToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
11199767fToomas Soome *    notice, this list of conditions and the following disclaimer in the
12199767fToomas Soome *    documentation and/or other materials provided with the distribution.
13199767fToomas Soome *
14199767fToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15199767fToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16199767fToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17199767fToomas Soome * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18199767fToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19199767fToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20199767fToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21199767fToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22199767fToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23199767fToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24199767fToomas Soome * SUCH DAMAGE.
25199767fToomas Soome *
26199767fToomas Soome * $FreeBSD$
27199767fToomas Soome */
28199767fToomas Soome
29199767fToomas Soome#ifndef _SYS__TYPES_H_
30199767fToomas Soome#define _SYS__TYPES_H_
31199767fToomas Soome
32199767fToomas Soome#include <sys/cdefs.h>
33199767fToomas Soome#include <machine/_types.h>
34199767fToomas Soome
35199767fToomas Soome/*
36199767fToomas Soome * Standard type definitions.
37199767fToomas Soome */
38199767fToomas Soometypedef	__int32_t	__blksize_t;	/* file block size */
39199767fToomas Soometypedef	__int64_t	__blkcnt_t;	/* file block count */
40199767fToomas Soometypedef	__int32_t	__clockid_t;	/* clock_gettime()... */
41199767fToomas Soometypedef	__uint32_t	__fflags_t;	/* file flags */
42199767fToomas Soometypedef	__uint64_t	__fsblkcnt_t;
43199767fToomas Soometypedef	__uint64_t	__fsfilcnt_t;
44199767fToomas Soometypedef	__uint32_t	__gid_t;
45199767fToomas Soometypedef	__int64_t	__id_t;		/* can hold a gid_t, pid_t, or uid_t */
46199767fToomas Soometypedef	__uint32_t	__ino_t;	/* inode number */
47199767fToomas Soometypedef	long		__key_t;	/* IPC key (for Sys V IPC) */
48199767fToomas Soometypedef	__int32_t	__lwpid_t;	/* Thread ID (a.k.a. LWP) */
49199767fToomas Soometypedef	__uint16_t	__mode_t;	/* permissions */
50199767fToomas Soometypedef	int		__accmode_t;	/* access permissions */
51199767fToomas Soometypedef	int		__nl_item;
52199767fToomas Soometypedef	__uint16_t	__nlink_t;	/* link count */
53199767fToomas Soometypedef	__int64_t	__off_t;	/* file offset */
54199767fToomas Soometypedef	__int32_t	__pid_t;	/* process [group] */
55199767fToomas Soometypedef	__int64_t	__rlim_t;	/* resource limit - intentionally */
56199767fToomas Soome					/* signed, because of legacy code */
57199767fToomas Soome					/* that uses -1 for RLIM_INFINITY */
58199767fToomas Soometypedef	__uint8_t	__sa_family_t;
59199767fToomas Soometypedef	__uint32_t	__socklen_t;
60199767fToomas Soometypedef	long		__suseconds_t;	/* microseconds (signed) */
61199767fToomas Soometypedef	struct __timer	*__timer_t;	/* timer_gettime()... */
62199767fToomas Soometypedef	struct __mq	*__mqd_t;	/* mq_open()... */
63199767fToomas Soometypedef	__uint32_t	__uid_t;
64199767fToomas Soometypedef	unsigned int	__useconds_t;	/* microseconds (unsigned) */
65199767fToomas Soometypedef	int		__cpuwhich_t;	/* which parameter for cpuset. */
66199767fToomas Soometypedef	int		__cpulevel_t;	/* level parameter for cpuset. */
67199767fToomas Soometypedef int		__cpusetid_t;	/* cpuset identifier. */
68199767fToomas Soome
69199767fToomas Soome/*
70199767fToomas Soome * Unusual type definitions.
71199767fToomas Soome */
72199767fToomas Soome/*
73199767fToomas Soome * rune_t is declared to be an ``int'' instead of the more natural
74199767fToomas Soome * ``unsigned long'' or ``long''.  Two things are happening here.  It is not
75199767fToomas Soome * unsigned so that EOF (-1) can be naturally assigned to it and used.  Also,
76199767fToomas Soome * it looks like 10646 will be a 31 bit standard.  This means that if your
77199767fToomas Soome * ints cannot hold 32 bits, you will be in trouble.  The reason an int was
78199767fToomas Soome * chosen over a long is that the is*() and to*() routines take ints (says
79199767fToomas Soome * ANSI C), but they use __ct_rune_t instead of int.
80199767fToomas Soome *
81199767fToomas Soome * NOTE: rune_t is not covered by ANSI nor other standards, and should not
82199767fToomas Soome * be instantiated outside of lib/libc/locale.  Use wchar_t.  wint_t and
83199767fToomas Soome * rune_t must be the same type.  Also, wint_t should be able to hold all
84199767fToomas Soome * members of the largest character set plus one extra value (WEOF), and
85199767fToomas Soome * must be at least 16 bits.
86199767fToomas Soome */
87199767fToomas Soometypedef	int		__ct_rune_t;	/* arg type for ctype funcs */
88199767fToomas Soometypedef	__ct_rune_t	__rune_t;	/* rune_t (see above) */
89199767fToomas Soometypedef	__ct_rune_t	__wint_t;	/* wint_t (see above) */
90199767fToomas Soome
91199767fToomas Soome/* Clang already provides these types as built-ins, but only in C++ mode. */
92199767fToomas Soome#if !defined(__clang__) || !defined(__cplusplus)
93199767fToomas Soometypedef	__uint_least16_t __char16_t;
94199767fToomas Soometypedef	__uint_least32_t __char32_t;
95199767fToomas Soome#endif
96199767fToomas Soome/* In C++11, char16_t and char32_t are built-in types. */
97199767fToomas Soome#if defined(__cplusplus) && __cplusplus >= 201103L
98199767fToomas Soome#define	_CHAR16_T_DECLARED
99199767fToomas Soome#define	_CHAR32_T_DECLARED
100199767fToomas Soome#endif
101199767fToomas Soome
102199767fToomas Soometypedef	__uint32_t	__dev_t;	/* device number */
103199767fToomas Soome
104199767fToomas Soometypedef	__uint32_t	__fixpt_t;	/* fixed point number */
105199767fToomas Soome
106199767fToomas Soome/*
107199767fToomas Soome * mbstate_t is an opaque object to keep conversion state during multibyte
108199767fToomas Soome * stream conversions.
109199767fToomas Soome */
110199767fToomas Soometypedef union {
111199767fToomas Soome	char		__mbstate8[128];
112199767fToomas Soome	__int64_t	_mbstateL;	/* for alignment */
113199767fToomas Soome} __mbstate_t;
114199767fToomas Soome
115199767fToomas Soometypedef unsigned long	__rman_res_t;
116199767fToomas Soome
117199767fToomas Soome#endif /* !_SYS__TYPES_H_ */
118