Module Name: src Committed By: matt Date: Tue Aug 19 07:27:31 UTC 2014
Modified Files: src/sys/sys: Makefile Added Files: src/sys/sys: common_ansi.h common_limits.h Log Message: More "common" includes which use the preprocessor defined macros. To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/sys/sys/Makefile cvs rdiff -u -r0 -r1.1 src/sys/sys/common_ansi.h src/sys/sys/common_limits.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/sys/Makefile diff -u src/sys/sys/Makefile:1.150 src/sys/sys/Makefile:1.151 --- src/sys/sys/Makefile:1.150 Mon Aug 18 22:33:25 2014 +++ src/sys/sys/Makefile Tue Aug 19 07:27:31 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.150 2014/08/18 22:33:25 matt Exp $ +# $NetBSD: Makefile,v 1.151 2014/08/19 07:27:31 matt Exp $ .include <bsd.own.mk> @@ -8,8 +8,9 @@ INCS= acct.h agpio.h aio.h ansi.h aout_m bitops.h bootblock.h bswap.h buf.h \ callback.h callout.h cdbr.h cdefs.h cdefs_aout.h \ cdefs_elf.h cdio.h chio.h clockctl.h \ - common_int_const.h common_int_fmtio.h common_int_limits.h \ - common_int_mwgwtypes.h common_int_types.h common_wchar_limits.h \ + common_ansi.h common_int_const.h common_int_fmtio.h \ + common_int_limits.h common_int_mwgwtypes.h common_int_types.h \ + common_limits.h common_wchar_limits.h \ condvar.h conf.h core.h \ cpufreq.h cpuio.h ctype_bits.h ctype_inline.h \ device.h device_if.h \ Added files: Index: src/sys/sys/common_ansi.h diff -u /dev/null src/sys/sys/common_ansi.h:1.1 --- /dev/null Tue Aug 19 07:27:31 2014 +++ src/sys/sys/common_ansi.h Tue Aug 19 07:27:31 2014 @@ -0,0 +1,76 @@ +/* $NetBSD: common_ansi.h,v 1.1 2014/08/19 07:27:31 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_COMMON_ANSI_H_ +#define _SYS_COMMON_ANSI_H_ + +#include <sys/cdefs.h> + +#include <machine/int_types.h> + +#if !defined(__PTRDIFF_TYPE__) +#error __PTRDIFF_TYPE__ not present +#endif + +#if !defined(__SIZE_TYPE__) +#error __SIZE_TYPE__ not present +#endif + +#if !defined(__WCHAR_TYPE__) +#error __WCHAR_TYPE__ not present +#endif + +#if !defined(__WINT_TYPE__) +#error __WINT_TYPE__ not present +#endif + +/* + * Types which are fundamental to the implementation and may appear in + * more than one standard header are defined here. Standard headers + * then use: + * #ifdef _BSD_SIZE_T_ + * typedef _BSD_SIZE_T_ size_t; + * #undef _BSD_SIZE_T_ + * #endif + */ +#define _BSD_CLOCK_T_ unsigned int /* clock() */ +#define _BSD_PTRDIFF_T_ __PTRDIFF_TYPE__ /* ptr1 - ptr2 */ +#define _BSD_SSIZE_T_ __PTRDIFF_TYPE__ /* byte count or error */ +#define _BSD_SIZE_T_ __SIZE_TYPE__ /* sizeof() */ +#define _BSD_TIME_T_ __int64_t /* time() */ +#define _BSD_CLOCKID_T_ int /* clockid_t */ +#define _BSD_TIMER_T_ int /* timer_t */ +#define _BSD_SUSECONDS_T_ int /* suseconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ +#define _BSD_WCHAR_T_ __WCHAR_TYPE__ /* wchar_t */ +#define _BSD_WINT_T_ __WINT_TYPE__ /* wint_t */ + +#endif /* _SYS_COMMON_ANSI_H_ */ Index: src/sys/sys/common_limits.h diff -u /dev/null src/sys/sys/common_limits.h:1.1 --- /dev/null Tue Aug 19 07:27:31 2014 +++ src/sys/sys/common_limits.h Tue Aug 19 07:27:31 2014 @@ -0,0 +1,109 @@ +/* $NetBSD: common_limits.h,v 1.1 2014/08/19 07:27:31 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_COMMON_LIMITS_H_ +#define _SYS_COMMON_LIMITS_H_ + +#define CHAR_BIT __CHAR_BIT__ /* number of bits in a char */ + +#define UCHAR_MAX (2*__SCHAR_MAX__+1) /* max value for an unsigned char */ +#define SCHAR_MAX __SCHAR_MAX__ /* max value for a signed char */ +#define SCHAR_MIN (-__SCHAR_MAX__-1) /* min value for a signed char */ + +#define USHRT_MAX (2*__SHRT_MAX__+1) /* max value for an unsigned short */ +#define SHRT_MAX __SHRT_MAX__ /* max value for a short */ +#define SHRT_MIN (-__SHRT_MAX__-1) /* min value for a short */ + +#if defined(__UINT_MAX__) +#define UINT_MAX __UINT_MAX__ /* max value for an unsigned int */ +#else +#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ +#endif +#define INT_MAX __INT_MAX__ /* max value for an int */ +#define INT_MIN (-__INT_MAX__-1) /* min value for an int */ + +#if defined(__ULONG_MAX__) +#define ULONG_MAX __ULONG_MAX__ /* max value for an unsigned long */ +#elif __SIZEOF_LONG__ == __SIZEOF_LONG_LONG__ +#define ULONG_MAX 0xffffffffffffffffUL /* max unsigned long */ +#else +#define ULONG_MAX 0xffffffffUL /* max unsigned long */ +#endif +#define LONG_MAX __LONG_MAX__ /* max value for a long */ +#define LONG_MIN (-__LONG_MAX__-1) /* min value for a long */ + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#if defined(__ULONG_LONG_MAX__) +#define ULLONG_MAX __ULONG_LONG_MAX__ /* max unsigned long long */ +#else +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#endif +#define LLONG_MAX __LONG_LONG_MAX__ /* max signed long long */ +#define LLONG_MIN (-__LONG_LONG_MAX__-1) /* min signed long long */ +#endif + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX ULLONG_MAX /* max unsigned quad */ +#define QUAD_MAX LLONG_MAX /* max signed quad */ +#define QUAD_MIN LLONG_MIN /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT (__SIZEOF_LONG__ * 8) +#define WORD_BIT (__SIZEOF_INT__ * 8) + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ + +#ifdef __LDBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MIN __LDBL_MIN__ +#endif + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* _SYS_COMMON_LIMITS_H_ */