From patchwork Mon Mar 11 14:59:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 1054505 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-100538-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="mz9SRJD+"; 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 44J1Vr56gqz9s4Y for ; Tue, 12 Mar 2019 02:00:20 +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=u+jcFzz+8L83a9VoSDdSZINvsvdIuquWLypSYASXSnL P21wG/sFgoZ5aGbMAmDJi+6R5tQDTVMoskEWOt3/+l293ar4WK47AG1F2PFuEMp+ 4yYeb3a2fHGfw+jr4u0qSzoqwbh+zSquzdVTZNkJBvNtrFclQhLIKWZa1tVOolgc = 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=4LfsPJH+6bPDQ/G4XGtadsSODSw=; b=mz9SRJD+ACAGclKWr fSWlCiK5/4k1WIzEUpqWUA/209wuILJFj1JFfi2go6B0u5DKbxKa27vBmG4qJmnV nx/TenMXRuNM+WLVACLdUc/EyYplyyRr6yY4/x4cvYAVSxOqpxGbXJpqGQi1R19W mlPsL44i9OVUBcJOe19DUcYv0A= Received: (qmail 29377 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 29286 invoked by uid 89); 11 Mar 2019 14:59:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.8 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=Tell, metcalf, Metcalf, H*f:sk:cover.1 X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Subject: [PATCH 2/8] Define register_t using bits/typesizes.h macros. Date: Mon, 11 Mar 2019 10:59:46 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Currently register_t is, unlike all other types in sys/types.h, defined using a GCC extension (__attribute__((mode(word)))), falling back to ‘int’ if the extension is unavailable. This is a potential ABI compatibility hazard for people using non-GNU compilers with glibc. It’s also unnecessary; the bits/typesizes.h mechanism can handle all of the existing variation in the definition. In most cases, defining __REGISTER_T_TYPE as __SWORD_TYPE is sufficient. Special handling is necessary for MIPS n32 and x86-64 x32, where __SWORD_TYPE is ‘int’ and the appropriate type for register_t is ‘long long’. Unfortunately, this means we need to create a new bits/typesizes.h variant for linux/mips. This variant is based on the top-level bits/typesizes.h, not linux/generic/bits/typesizes.h, to match the existing MIPS ABIs. Tested using build-many-glibcs. The c++-types test confirms that the physical type of register_t does not change on any supported platform. * posix/sys/types.h: Typedef register_t as __register_t. * posix/bits/types.h: Typedef __register_t using __REGISTER_T_TYPE. * bits/typesizes.h * sysdeps/mach/hurd/bits/typesizes.h * sysdeps/unix/sysv/linux/alpha/bits/typesizes.h * sysdeps/unix/sysv/linux/generic/bits/typesizes.h * sysdeps/unix/sysv/linux/s390/bits/typesizes.h * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Define __REGISTER_T_TYPE as __SWORD_TYPE. * sysdeps/unix/sysv/linux/mips/bits/typesizes.h: New file (copied from bits/typesizes.h). Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and n64 ABIs. Define __REGISTER_T_TYPE as __SQUAD_TYPE for n32. * sysdeps/unix/sysv/linux/x86/bits/typesizes.h: Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and 64-bit ABIs. Define __REGISTER_T_TYPE as __SQUAD_TYPE for x32. --- bits/typesizes.h | 1 + posix/bits/types.h | 3 +++ posix/sys/types.h | 7 ++----- sysdeps/mach/hurd/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 1 + .../sysv/linux/{generic => mips}/bits/typesizes.h | 13 +++++++++---- sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 2 ++ 10 files changed, 22 insertions(+), 9 deletions(-) copy sysdeps/unix/sysv/linux/{generic => mips}/bits/typesizes.h (90%) diff --git a/bits/typesizes.h b/bits/typesizes.h index 41c8924336..4541013361 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -60,6 +60,7 @@ #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE #ifdef __LP64__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/posix/bits/types.h b/posix/bits/types.h index 0de6c59bb4..4521d9d06e 100644 --- a/posix/bits/types.h +++ b/posix/bits/types.h @@ -219,6 +219,9 @@ typedef int __sig_atomic_t; __STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */ #endif +/* BSD: Size of a general-purpose integer register. */ +__STD_TYPE __REGISTER_T_TYPE __register_t; + #undef __STD_TYPE #endif /* bits/types.h */ diff --git a/posix/sys/types.h b/posix/sys/types.h index 0e37b1ce6a..1bbd896ad4 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -160,11 +160,8 @@ typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; typedef __uint64_t u_int64_t; -#if __GNUC_PREREQ (2, 7) -typedef int register_t __attribute__ ((__mode__ (__word__))); -#else -typedef int register_t; -#endif +/* Type of a general-purpose integer register (BSD). */ +typedef __register_t register_t; /* Some code from BIND tests this macro to see if the types above are defined. */ diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index 6bd9b43599..94b0afcdaf 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -60,6 +60,7 @@ #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 256 diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index cde275defd..0485dd1eb7 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -60,6 +60,7 @@ #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE #define __FSWORD_T_TYPE __S32_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE /* Tell the libc code that off_t and off64_t are actually the same type for all ABI purposes, even if possibly expressed as different base types diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index 3ef1281c8a..c738ff50a5 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -61,6 +61,7 @@ #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE #ifdef __LP64__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/mips/bits/typesizes.h similarity index 90% copy from sysdeps/unix/sysv/linux/generic/bits/typesizes.h copy to sysdeps/unix/sysv/linux/mips/bits/typesizes.h index 3ef1281c8a..1132670b1c 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/mips/bits/typesizes.h @@ -1,7 +1,6 @@ -/* bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +/* bits/typesizes.h -- underlying types for *_t. For the MIPS Linux ABI. Copyright (C) 2011-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -33,7 +32,7 @@ #define __INO_T_TYPE __ULONGWORD_TYPE #define __INO64_T_TYPE __UQUAD_TYPE #define __MODE_T_TYPE __U32_TYPE -#define __NLINK_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __UWORD_TYPE #define __OFF_T_TYPE __SLONGWORD_TYPE #define __OFF64_T_TYPE __SQUAD_TYPE #define __PID_T_TYPE __S32_TYPE @@ -55,13 +54,19 @@ #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE #define __TIMER_T_TYPE void * -#define __BLKSIZE_T_TYPE __S32_TYPE +#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE #define __FSID_T_TYPE struct { int __val[2]; } #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#if defined _ABIN32 && _MIPS_SIM == _ABIN32 +#define __REGISTER_T_TYPE __SQUAD_TYPE +#else +#define __REGISTER_T_TYPE __SWORD_TYPE +#endif + #ifdef __LP64__ /* Tell the libc code that off_t and off64_t are actually the same type for all ABI purposes, even if possibly expressed as different base types diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index e42105700a..c578237817 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -66,6 +66,7 @@ #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE #ifdef __s390x__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index 115cc1995b..0db18f4913 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -60,6 +60,7 @@ #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE #define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __REGISTER_T_TYPE __SWORD_TYPE #if defined __arch64__ || defined __sparcv9 /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index 18d2c63b0a..0a71e30681 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -30,9 +30,11 @@ #if defined __x86_64__ && defined __ILP32__ # define __SYSCALL_SLONG_TYPE __SQUAD_TYPE # define __SYSCALL_ULONG_TYPE __UQUAD_TYPE +# define __REGISTER_T_TYPE __SQUAD_TYPE #else # define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE # define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +# define __REGISTER_T_TYPE __SWORD_TYPE #endif #define __DEV_T_TYPE __UQUAD_TYPE