_types.h revision 250985
193514Smike/*-
293514Smike * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
393514Smike * All rights reserved.
493514Smike *
593514Smike * Redistribution and use in source and binary forms, with or without
693514Smike * modification, are permitted provided that the following conditions
793514Smike * are met:
893514Smike * 1. Redistributions of source code must retain the above copyright
993514Smike *    notice, this list of conditions and the following disclaimer.
1093514Smike * 2. Redistributions in binary form must reproduce the above copyright
1193514Smike *    notice, this list of conditions and the following disclaimer in the
1293514Smike *    documentation and/or other materials provided with the distribution.
1393514Smike *
1493514Smike * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1593514Smike * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1693514Smike * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1793514Smike * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1893514Smike * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1993514Smike * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2093514Smike * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2193514Smike * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2293514Smike * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2393514Smike * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2493514Smike * SUCH DAMAGE.
2593514Smike *
2693514Smike * $FreeBSD: head/sys/sys/_types.h 250985 2013-05-25 16:58:12Z ed $
2793514Smike */
2893514Smike
2993514Smike#ifndef _SYS__TYPES_H_
3093514Smike#define _SYS__TYPES_H_
3193514Smike
3293514Smike#include <sys/cdefs.h>
33102227Smike#include <machine/_types.h>
3493514Smike
35102315Smike/*
36102315Smike * Standard type definitions.
37102315Smike */
38143952Sdastypedef	__uint32_t	__blksize_t;	/* file block size */
39143952Sdastypedef	__int64_t	__blkcnt_t;	/* file block count */
40105690Smiketypedef	__int32_t	__clockid_t;	/* clock_gettime()... */
41223710Sjonathantypedef	__uint64_t	__cap_rights_t;	/* capability rights */
42105690Smiketypedef	__uint32_t	__fflags_t;	/* file flags */
43102227Smiketypedef	__uint64_t	__fsblkcnt_t;
44102227Smiketypedef	__uint64_t	__fsfilcnt_t;
45102227Smiketypedef	__uint32_t	__gid_t;
46105690Smiketypedef	__int64_t	__id_t;		/* can hold a gid_t, pid_t, or uid_t */
47111705Smiketypedef	__uint32_t	__ino_t;	/* inode number */
48105690Smiketypedef	long		__key_t;	/* IPC key (for Sys V IPC) */
49130735Smarceltypedef	__int32_t	__lwpid_t;	/* Thread ID (a.k.a. LWP) */
50105690Smiketypedef	__uint16_t	__mode_t;	/* permissions */
51184413Strasztypedef	int		__accmode_t;	/* access permissions */
52103521Smiketypedef	int		__nl_item;
53111705Smiketypedef	__uint16_t	__nlink_t;	/* link count */
54105690Smiketypedef	__int64_t	__off_t;	/* file offset */
55105690Smiketypedef	__int32_t	__pid_t;	/* process [group] */
56137390Sdestypedef	__int64_t	__rlim_t;	/* resource limit - intentionally */
57137390Sdes					/* signed, because of legacy code */
58137390Sdes					/* that uses -1 for RLIM_INFINITY */
59102227Smiketypedef	__uint8_t	__sa_family_t;
60102315Smiketypedef	__uint32_t	__socklen_t;
61108190Smiketypedef	long		__suseconds_t;	/* microseconds (signed) */
62156134Sdavidxutypedef	struct __timer	*__timer_t;	/* timer_gettime()... */
63156134Sdavidxutypedef	struct __mq	*__mqd_t;	/* mq_open()... */
64102227Smiketypedef	__uint32_t	__uid_t;
65108190Smiketypedef	unsigned int	__useconds_t;	/* microseconds (unsigned) */
66176730Sjefftypedef	int		__cpuwhich_t;	/* which parameter for cpuset. */
67176730Sjefftypedef	int		__cpulevel_t;	/* level parameter for cpuset. */
68176730Sjefftypedef int		__cpusetid_t;	/* cpuset identifier. */
6993514Smike
70102315Smike/*
71102315Smike * Unusual type definitions.
72102315Smike */
73102315Smike/*
74102315Smike * rune_t is declared to be an ``int'' instead of the more natural
75102315Smike * ``unsigned long'' or ``long''.  Two things are happening here.  It is not
76102315Smike * unsigned so that EOF (-1) can be naturally assigned to it and used.  Also,
77102315Smike * it looks like 10646 will be a 31 bit standard.  This means that if your
78102315Smike * ints cannot hold 32 bits, you will be in trouble.  The reason an int was
79102315Smike * chosen over a long is that the is*() and to*() routines take ints (says
80102315Smike * ANSI C), but they use __ct_rune_t instead of int.
81102315Smike *
82102315Smike * NOTE: rune_t is not covered by ANSI nor other standards, and should not
83237517Sandrew * be instantiated outside of lib/libc/locale.  Use wchar_t.  wint_t and
84237517Sandrew * rune_t must be the same type.  Also, wint_t should be able to hold all
85237517Sandrew * members of the largest character set plus one extra value (WEOF), and
86237517Sandrew * must be at least 16 bits.
87102315Smike */
88130473Sbdetypedef	int		__ct_rune_t;	/* arg type for ctype funcs */
89130473Sbdetypedef	__ct_rune_t	__rune_t;	/* rune_t (see above) */
90130473Sbdetypedef	__ct_rune_t	__wint_t;	/* wint_t (see above) */
91102315Smike
92250883Sed/* Clang already provides these types as built-ins, but only in C++ mode. */
93250883Sed#if !defined(__clang__) || !defined(__cplusplus)
94250883Sedtypedef	__uint_least16_t __char16_t;
95250883Sedtypedef	__uint_least32_t __char32_t;
96250883Sed#endif
97250985Sed/* In C++11, char16_t and char32_t are built-in types. */
98250985Sed#if defined(__cplusplus) && __cplusplus >= 201103L
99250985Sed#define	_CHAR16_T_DECLARED
100250985Sed#define	_CHAR32_T_DECLARED
101250985Sed#endif
102250883Sed
103130640Sphktypedef	__uint32_t	__dev_t;	/* device number */
104112745Smike
105130473Sbdetypedef	__uint32_t	__fixpt_t;	/* fixed point number */
106130434Sdas
107112745Smike/*
108102315Smike * mbstate_t is an opaque object to keep conversion state during multibyte
109102315Smike * stream conversions.
110102315Smike */
111102315Smiketypedef union {
112102315Smike	char		__mbstate8[128];
113130473Sbde	__int64_t	_mbstateL;	/* for alignment */
114102315Smike} __mbstate_t;
115102315Smike
11693514Smike#endif /* !_SYS__TYPES_H_ */
117