types.h revision 199767f8919635c4928607450d9e0abb932109ce
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1982, 1986, 1991, 1993, 1994
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (c) UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All or some portions of this file are derived from material licensed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to the University of California by American Telephone and Telegraph
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the permission of UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)types.h 8.6 (Berkeley) 2/19/95
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Machine type dependent parameters. */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned char u_char;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned short u_short;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned int u_int;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned long u_long;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned short ushort; /* Sys V compatibility */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned int uint; /* Sys V compatibility */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __uint64_t u_quad_t; /* quads (deprecated) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef const char * c_caddr_t; /* core address, pointer to const */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __critical_t critical_t; /* Critical section value */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __dev_t dev_t; /* device number or struct cdev */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __fixpt_t fixpt_t; /* fixed point number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __uint32_t in_addr_t; /* base type for internet address */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __id_t id_t; /* can hold a uid_t or pid_t */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __key_t key_t; /* IPC key (for Sys V IPC) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __accmode_t accmode_t; /* access permissions */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __segsz_t segsz_t; /* segment size (in pages) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __suseconds_t suseconds_t; /* microseconds (signed) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __useconds_t useconds_t; /* microseconds (unsigned) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned long cap_ioctl_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * XXX this is fixed width for historical reasons. It should have had type
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __int_fast32_t. Fixed-width types should not be used unless binary
199767f8919635c4928607450d9e0abb932109ceToomas Soome * compatibility is essential. Least-width types should be used even less
199767f8919635c4928607450d9e0abb932109ceToomas Soome * since they provide smaller benefits.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * XXX should be MD.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * XXX this is bogus in -current, but still used for spl*().
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef char vm_memattr_t; /* memory attribute codes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define false 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define true 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int _Bool;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef _Bool bool;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !__bool_true_false_are_defined && !__cplusplus */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define offsetof(type, field) __offsetof(type, field)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The following are all things that really shouldn't exist in this header,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * since its purpose is to provide typedefs, not miscellaneous doodads.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcount32(x) __builtin_popcount((__uint32_t)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcount16(x) __builtin_popcount((__uint16_t)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcountl(x) __builtin_popcountl((unsigned long)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcount(x) __builtin_popcount((unsigned int)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Population count algorithm using SWAR approach
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - "SIMD Within A Register".
199767f8919635c4928607450d9e0abb932109ceToomas Soome _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
199767f8919635c4928607450d9e0abb932109ceToomas Soome _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcountl(x) __bitcount64((unsigned long)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (__bitcount32(_x >> 32) + __bitcount32(_x));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcountl(x) __bitcount32((unsigned long)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __bitcount(x) __bitcount32((unsigned int)(x))
199767f8919635c4928607450d9e0abb932109ceToomas Soome * minor() gives a cookie instead of an index since we don't want to
199767f8919635c4928607450d9e0abb932109ceToomas Soome * change the meanings of bits 0-15 or waste time and space shifting
199767f8919635c4928607450d9e0abb932109ceToomas Soome * bits 16-31 for devices that don't use them.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * These declarations belong elsewhere, but are repeated here and in
199767f8919635c4928607450d9e0abb932109ceToomas Soome * <stdio.h> to give broken programs a better chance of working with
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 64-bit off_t's.
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid * mmap(void *, size_t, int, int, int, off_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __BSD_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_SYS_TYPES_H_ */