o Implement <sys/_types.h>, a new header for storing types that are

MI, not required to be a fixed size, and used in multiple headers.
  This will grow in time, as more things move here from <sys/types.h>
  and <machine/ansi.h>.
o Add missing type definitions (uint16_t and uint32_t) to
  <arpa/inet.h> and <netinet/in.h>.
o Reduce pollution in <sys/types.h> by using `#if _FOO_T_DECLARED'
  widgets to avoid including <sys/stdint.h>.
o Add some missing type definitions to <unistd.h> and note the ones
  that still need to be added.
o Make use of <sys/_types.h> primitives in <grp.h> and <sys/types.h>.

Reviewed by:	bde
This commit is contained in:
Mike Barcroft 2002-04-01 08:12:25 +00:00
parent 41156c80b5
commit 8822d3fb83
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=93514
7 changed files with 215 additions and 36 deletions

View file

@ -72,14 +72,24 @@
#define INET6_ADDRSTRLEN 46
#endif
#ifndef _IN_ADDR_T_DECLARED_
typedef __uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED_
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t;
#define _UINT16_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED_
typedef __uint16_t in_port_t;
#define _IN_PORT_T_DECLARED_
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t;
#define _UINT32_T_DECLARED
#endif
#ifndef _IN_ADDR_T_DECLARED
typedef uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef uint16_t in_port_t;
#define _IN_PORT_T_DECLARED
#endif
#ifndef _POSIX_SOURCE
@ -105,10 +115,6 @@ struct in_addr {
#define _STRUCT_IN_ADDR_DECLARED
#endif
/*
* XXX missing typedefs for uint16_t and uint32_t.
*/
/* XXX all new diversions!! argh!! */
#ifndef _POSIX_SOURCE
#define inet_addr __inet_addr
@ -130,10 +136,10 @@ struct in_addr {
__BEGIN_DECLS
#ifndef _BYTEORDER_PROTOTYPED
#define _BYTEORDER_PROTOTYPED
__uint32_t htonl(__uint32_t);
__uint16_t htons(__uint16_t);
__uint32_t ntohl(__uint32_t);
__uint16_t ntohs(__uint16_t);
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
#endif
in_addr_t inet_addr(const char *);

View file

@ -49,9 +49,9 @@
#define _PATH_GROUP "/etc/group"
#endif
#ifndef _GID_T_DECLARED
#define _GID_T_DECLARED
typedef __uint32_t gid_t;
#ifdef _BSD_GID_T_
typedef _BSD_GID_T_ gid_t;
#undef _BSD_GID_T_
#endif
struct group {

View file

@ -38,8 +38,33 @@
#define _UNISTD_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/types.h> /* XXX adds too much pollution. */
#include <sys/unistd.h>
#include <sys/_types.h>
#ifdef _BSD_GID_T_
typedef _BSD_GID_T_ gid_t;
#undef _BSD_GID_T_
#endif
#ifdef _BSD_SIZE_T_
typedef _BSD_SIZE_T_ size_t;
#undef _BSD_SIZE_T_
#endif
#ifdef _BSD_SSIZE_T_
typedef _BSD_SSIZE_T_ ssize_t;
#undef _BSD_SSIZE_T_
#endif
#ifdef _BSD_UID_T_
typedef _BSD_UID_T_ uid_t;
#undef _BSD_UID_T_
#endif
/*
* XXX missing type definitions for off_t, pid_t and useconds_t.
*/
#define STDIN_FILENO 0 /* standard input file descriptor */
#define STDOUT_FILENO 1 /* standard output file descriptor */

View file

@ -37,6 +37,8 @@
#ifndef _NETINET_IN_H_
#define _NETINET_IN_H_
#include <sys/_types.h>
/*
* Constants and structures defined by the internet system,
* Per RFC 790, September 1981, and numerous additions.
@ -230,14 +232,29 @@
#define IPPORT_MAX 65535
#ifndef _IN_ADDR_T_DECLARED_
typedef __uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED_
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t;
#define _UINT8_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED_
typedef __uint16_t in_port_t;
#define _IN_PORT_T_DECLARED_
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t;
#define _UINT16_T_DECLARED
#endif
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t;
#define _UINT32_T_DECLARED
#endif
#ifndef _IN_ADDR_T_DECLARED
typedef uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef uint16_t in_port_t;
#define _IN_PORT_T_DECLARED
#endif
/*
@ -503,10 +520,10 @@ char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
#ifndef _BYTEORDER_PROTOTYPED
#define _BYTEORDER_PROTOTYPED
__BEGIN_DECLS
__uint32_t htonl(__uint32_t);
__uint16_t htons(__uint16_t);
__uint32_t ntohl(__uint32_t);
__uint16_t ntohs(__uint16_t);
uint32_t htonl(uint32_t);
uint16_t htons(uint16_t);
uint32_t ntohl(uint32_t);
uint16_t ntohs(uint16_t);
__END_DECLS
#endif

38
sys/sys/_types.h Normal file
View file

@ -0,0 +1,38 @@
/*-
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* All rights reserved.
*
* 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 AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
#ifndef _SYS__TYPES_H_
#define _SYS__TYPES_H_
#include <sys/cdefs.h>
#include <machine/ansi.h>
#define _BSD_GID_T_ __uint32_t
#define _BSD_UID_T_ __uint32_t
#endif /* !_SYS__TYPES_H_ */

View file

@ -34,15 +34,45 @@
#include <machine/ansi.h>
#include <machine/limits.h>
#ifndef _INT8_T_DECLARED
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
#define _INT8_T_DECLARED
#endif
#ifndef _INT16_T_DECLARED
typedef __int16_t int16_t;
#define _INT16_T_DECLARED
#endif
#ifndef _INT32_T_DECLARED
typedef __int32_t int32_t;
#define _INT32_T_DECLARED
#endif
#ifndef _INT64_T_DECLARED
typedef __int64_t int64_t;
#define _INT64_T_DECLARED
#endif
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t;
#define _UINT8_T_DECLARED
#endif
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t;
#define _UINT16_T_DECLARED
#endif
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t;
#define _UINT32_T_DECLARED
#endif
#ifndef _UINT64_T_DECLARED
typedef __uint64_t uint64_t;
#define _UINT64_T_DECLARED
#endif
typedef __int_least8_t int_least8_t;
typedef __int_least16_t int_least16_t;
@ -67,8 +97,11 @@ typedef __uint_fast64_t uint_fast64_t;
typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
#ifndef _INTPTR_T_DECLARED
typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
#define _INTPTR_T_DECLARED
#endif
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
#define INT8_C(c) __INT8_C(c)

View file

@ -45,9 +45,10 @@
#include <sys/cdefs.h>
/* Machine type dependent parameters. */
#include <sys/stdint.h> /* includes <machine/ansi.h> */
#include <machine/ansi.h>
#include <machine/endian.h>
#include <machine/types.h>
#include <sys/_types.h>
#ifndef _POSIX_SOURCE
typedef unsigned char u_char;
@ -58,11 +59,66 @@ typedef unsigned short ushort; /* Sys V compatibility */
typedef unsigned int uint; /* Sys V compatibility */
#endif
/*
* XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
*/
#ifndef _INT8_T_DECLARED
typedef __int8_t int8_t;
#define _INT8_T_DECLARED
#endif
#ifndef _INT16_T_DECLARED
typedef __int16_t int16_t;
#define _INT16_T_DECLARED
#endif
#ifndef _INT32_T_DECLARED
typedef __int32_t int32_t;
#define _INT32_T_DECLARED
#endif
#ifndef _INT64_T_DECLARED
typedef __int64_t int64_t;
#define _INT64_T_DECLARED
#endif
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t;
#define _UINT8_T_DECLARED
#endif
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t;
#define _UINT16_T_DECLARED
#endif
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t;
#define _UINT32_T_DECLARED
#endif
#ifndef _UINT64_T_DECLARED
typedef __uint64_t uint64_t;
#define _UINT64_T_DECLARED
#endif
#ifndef _INTPTR_T_DECLARED
typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
#define _INTPTR_T_DECLARED
#endif
/*
* Deprecated BSD unsigned integrals.
*/
typedef __uint8_t u_int8_t;
typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;
/*
* Deprecated BSD 64-bit integrals.
*/
typedef u_int64_t u_quad_t; /* quads */
typedef int64_t quad_t;
typedef quad_t * qaddr_t;
@ -75,9 +131,9 @@ typedef int64_t daddr64_t; /* 64-bit disk address */
typedef u_int32_t u_daddr_t; /* unsigned disk address */
typedef u_int32_t fixpt_t; /* fixed point number */
#ifndef _GID_T_DECLARED
#define _GID_T_DECLARED
typedef u_int32_t gid_t; /* group id */
#ifdef _BSD_GID_T_
typedef _BSD_GID_T_ gid_t; /* group id */
#undef _BSD_GID_T_
#endif
typedef u_int32_t ino_t; /* inode number */
@ -95,7 +151,11 @@ typedef int32_t segsz_t; /* segment size */
typedef int32_t swblk_t; /* swap offset */
typedef int32_t ufs_daddr_t;
typedef int32_t ufs_time_t;
typedef u_int32_t uid_t; /* user id */
#ifdef _BSD_UID_T_
typedef _BSD_UID_T_ uid_t; /* user id */
#undef _BSD_UID_T_
#endif
#ifdef _KERNEL
typedef int boolean_t;