From patchwork Mon Mar 11 14:59:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 1054504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-100537-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=panix.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Sbunwtxw"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44J1Vg6nRDz9s4V for ; Tue, 12 Mar 2019 02:00:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=i5Zy2OD/L3WRIcudzKA03EpVIlCOjRh21W5MhqeBkCA EbQGKy8/UDLgxCDM5HD0djKw0IFPBttiTUjLPgGpX8nl47lo8UBjT+uohRjWIcxG +NyVRvMOnE6jvuW7K7OAon+3alWj4jtEAORFrnaMEALpgUELW4LKCrfi+Z/o69iY = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=rpa1DQl7kBQYKi2sKgp/79Mvt2E=; b=SbunwtxwB9FIJ9fBN WsSBQXef+RLq+yrMjEzbJ32Rk01BufRycR0ssbRxjnXnnOtQoNhcBvlTgXqARrYV QGZLA0K9As+eeXPx8RXWxcPFpuudlezvysIMdttXjZRnzX4IT7IVtYCKf3FxFozc p4tppfzK3PLNomMq4vz6Ombfcw= Received: (qmail 29297 invoked by alias); 11 Mar 2019 14:59:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 29208 invoked by uid 89); 11 Mar 2019 14:59:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:cover.1, historically, unconditionally, 2614 X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Subject: [PATCH 3/8] =?utf-8?q?sys/types=2Eh=3A_Don=E2=80=99t_define_u=5Fi?= =?utf-8?q?ntN=5Ft_or_register=5Ft_unless_=5F=5FUSE=5FMISC=2E?= Date: Mon, 11 Mar 2019 10:59:47 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t. These are not part of any standard. The u_intXX_t types are superseded by C99’s uintXX_t types (defined in stdint.h). I’m not aware of a standardized exact equivalent of register_t, but also I’ve never seen anyone use it for anything. I could be persuaded to leave that one alone. sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and int64_t, which are the same as the C99 exact-width signed types in stdint.h. POSIX doesn’t require these to appear in sys/types.h, so in principle they ought to be brought under __USE_MISC also. But, when I tried that it broke about two dozen files just in our own source tree, and POSIX doesn’t *forbid* sys/types.h to define these types, so I think we should leave them alone. * posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t) (register_t): Move under #ifdef __USE_MISC. Consolidate adjacent #ifdef __USE_MISC blocks. * scripts/check_obsolete_constructs.py: Add register_t to the set of obsolete typedefs that our headers should not use (but sys/types.h may still define). --- NEWS | 8 ++++++++ posix/sys/types.h | 16 ++++++++-------- scripts/check-obsolete-constructs.py | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 0d9236c38d..a4d34213b4 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,14 @@ Deprecated and removed features, and other changes affecting compatibility: definitions in libc will be used automatically, which have been available since glibc 2.17. +* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t + are no longer defined by in strict conformance modes. + These types were historically provided by on BSD systems, + but are not part of the POSIX specification for that header. Applications + requiring fixed-width unsigned integer types should use the similarly + named uint8_t, uint16_t, etc. from . There is no standardized + replacement for register_t. + Changes to build and runtime requirements: * GCC 6.2 or later is required to build the GNU C Library. diff --git a/posix/sys/types.h b/posix/sys/types.h index 1bbd896ad4..7327904346 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -143,18 +143,20 @@ typedef __suseconds_t suseconds_t; #define __need_size_t #include +/* POSIX does not require intN_t to be defined in this header, so + technically this ought to be under __USE_MISC, but it doesn't + forbid them to be defined here either, and much existing code + expects them to be defined here. */ +#include + #ifdef __USE_MISC /* Old compatibility names for C types. */ typedef unsigned long int ulong; typedef unsigned short int ushort; typedef unsigned int uint; -#endif -/* These size-specific names are used by some of the inet code. */ - -#include - -/* These were defined by ISO C without the first `_'. */ +/* These size-specific names are used by some of the inet code. + They were defined by ISO C without the first `_'. */ typedef __uint8_t u_int8_t; typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; @@ -167,8 +169,6 @@ typedef __register_t register_t; defined. */ #define __BIT_TYPES_DEFINED__ 1 - -#ifdef __USE_MISC /* In BSD is expected to define BYTE_ORDER. */ # include diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index 46535afcac..4317aa320d 100755 --- a/scripts/check-obsolete-constructs.py +++ b/scripts/check-obsolete-constructs.py @@ -254,6 +254,7 @@ class NoCheck(ConstructChecker): OBSOLETE_TYPE_RE_ = re.compile(r"""\A (__)? ( quad_t + | register_t | u(?: short | int | long | _(?: char | short | int(?:[0-9]+_t)? | long | quad_t ))) \Z""", re.VERBOSE)