From patchwork Thu Dec 10 01:19:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 41351 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C595B385781D; Thu, 10 Dec 2020 01:19:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C595B385781D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607563197; bh=dXb0CTxrBQbXoqnkLOsRKtg0Xe6/QbOVM992ePxbhJQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=seCmkn2sbJ5GCvA1rppYoTLcreyHoFQNbhTDQVnw0Q4phc3OeSEjuwgG+WKIUYMZK bEMDsUmuQbdClOcuHejeWUlJ70PkPhq8Sbu27SW0p1MBsLYbceIc9TP4EfB7NUUkIK 5dsR++TMJFcORZcdz+YfKihAq0/uaDP/8tOkDf5c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id 433173857816 for ; Thu, 10 Dec 2020 01:19:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 433173857816 Received: by mail-qv1-xf41.google.com with SMTP id n9so1670308qvp.5 for ; Wed, 09 Dec 2020 17:19:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dXb0CTxrBQbXoqnkLOsRKtg0Xe6/QbOVM992ePxbhJQ=; b=R5t/6Jh8Sl/8Ym+dPuwC95cOoHNyATYp8YTGIW1LWipWcQug057TMvT5tXivT3T+m0 /aEp+cDnAt8KekI9y7VO4mg8NdCrl1jUO3Kia5Mn8crRFqM35g1iwt5tpeTgXdyTtItj 9GVAjT0n+tcZQQo/6hsDyJPJBHB3icbtr32ZsBef8XAj/33Kt9kvad4rNnOeZReX3x9a qAv7oAeJCEFoWqIhKk672EGrd88ei3j8nCT/6z30kOzu10YHhmdmOtoHBpRPs0QOPvQM YEQK9c9XRyuLOBMX066jGYjBuIq1X2OlZfemNltYG0fXX3H17uQsPSTNd6/ldzBzsjPW zD6w== X-Gm-Message-State: AOAM531PR1R4/8AChtSHQFDuHDhzJqUKnUhgXsQKgnyVe3b9wLb2jg2A 4i/4EImbNeCnwUFlq8n+A85iOrRQUkfnDg== X-Google-Smtp-Source: ABdhPJwUUdd1UL65NcT32+0GYbtlhdjT8VTId35OyUujM821CKJAY04/ERa1xyk85Xpry1QTfMM+FA== X-Received: by 2002:ad4:4f0c:: with SMTP id fb12mr6159649qvb.16.1607563193178; Wed, 09 Dec 2020 17:19:53 -0800 (PST) Received: from localhost ([208.104.103.123]) by smtp.gmail.com with ESMTPSA id 76sm2537984qkg.134.2020.12.09.17.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 17:19:52 -0800 (PST) To: libc-alpha Subject: [PATCHv2] alpha: Remove anonymous union in struct stat [BZ #27042] Date: Wed, 9 Dec 2020 20:19:45 -0500 Message-Id: <20201210011945.2076794-1-mattst88@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209162008.2064091-1-mattst88@gmail.com> References: <20201209162008.2064091-1-mattst88@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matt Turner via Libc-alpha From: Matt Turner Reply-To: Matt Turner Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is clever, but it confuses downstream detection in at least zstd and GNOME's glib. zstd has preprocessor tests for the 'st_mtime' macro, which is not provided by the path using the anonymous union; glib checks for the presence of 'st_mtimensec' in struct stat but then tries to access that field in struct statx (which might be a bug on its own). Reviewed-by: Adhemerval Zanella --- The macros affect the definitions in kernel_stat.h, so rename them. Not thrilled. .../unix/sysv/linux/alpha/bits/struct_stat.h | 81 ++++++++++--------- sysdeps/unix/sysv/linux/alpha/kernel_stat.h | 24 +++--- sysdeps/unix/sysv/linux/alpha/xstatconv.c | 24 +++--- 3 files changed, 66 insertions(+), 63 deletions(-) diff --git a/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h index 1c9b4248b8..d2aae9fdd7 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h @@ -23,37 +23,6 @@ #ifndef _BITS_STRUCT_STAT_H #define _BITS_STRUCT_STAT_H 1 -/* Nanosecond resolution timestamps are stored in a format equivalent to - 'struct timespec'. This is the type used whenever possible but the - Unix namespace rules do not allow the identifier 'timespec' to appear - in the header. Therefore we have to handle the use of - this header in strictly standard-compliant sources special. - - Use neat tidy anonymous unions and structures when possible. */ - -#ifdef __USE_XOPEN2K8 -# if __GNUC_PREREQ(3,3) -# define __ST_TIME(X) \ - __extension__ union { \ - struct timespec st_##X##tim; \ - struct { \ - __time_t st_##X##time; \ - unsigned long st_##X##timensec; \ - }; \ - } -# else -# define __ST_TIME(X) struct timespec st_##X##tim -# define st_atime st_atim.tv_sec -# define st_mtime st_mtim.tv_sec -# define st_ctime st_ctim.tv_sec -# endif -#else -# define __ST_TIME(X) \ - __time_t st_##X##time; \ - unsigned long st_##X##timensec -#endif - - struct stat { __dev_t st_dev; /* Device. */ @@ -77,9 +46,27 @@ struct stat __blksize_t st_blksize; /* Optimal block size for I/O. */ __nlink_t st_nlink; /* Link count. */ int __pad2; /* Real padding. */ - __ST_TIME(a); /* Time of last access. */ - __ST_TIME(m); /* Time of last modification. */ - __ST_TIME(c); /* Time of last status change. */ +#ifdef __USE_XOPEN2K8 + /* Nanosecond resolution timestamps are stored in a format + equivalent to 'struct timespec'. This is the type used + whenever possible but the Unix namespace rules do not allow the + identifier 'timespec' to appear in the header. + Therefore we have to handle the use of this header in strictly + standard-compliant sources special. */ + struct timespec st_atim; /* Time of last access. */ + struct timespec st_mtim; /* Time of last modification. */ + struct timespec st_ctim; /* Time of last status change. */ +# define st_atime st_atim.tv_sec /* Backward compatibility. */ +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec +#else + __time_t st_atime; /* Time of last access. */ + unsigned long int st_atimensec; /* Nscecs of last access. */ + __time_t st_mtime; /* Time of last modification. */ + unsigned long int st_mtimensec; /* Nsecs of last modification. */ + __time_t st_ctime; /* Time of last status change. */ + unsigned long int st_ctimensec; /* Nsecs of last status change. */ +#endif long __glibc_reserved[3]; }; @@ -98,15 +85,31 @@ struct stat64 __blksize_t st_blksize; /* Optimal block size for I/O. */ __nlink_t st_nlink; /* Link count. */ int __pad0; /* Real padding. */ - __ST_TIME(a); /* Time of last access. */ - __ST_TIME(m); /* Time of last modification. */ - __ST_TIME(c); /* Time of last status change. */ +#ifdef __USE_XOPEN2K8 + /* Nanosecond resolution timestamps are stored in a format + equivalent to 'struct timespec'. This is the type used + whenever possible but the Unix namespace rules do not allow the + identifier 'timespec' to appear in the header. + Therefore we have to handle the use of this header in strictly + standard-compliant sources special. */ + struct timespec st_atim; /* Time of last access. */ + struct timespec st_mtim; /* Time of last modification. */ + struct timespec st_ctim; /* Time of last status change. */ +# define st_atime st_atim.tv_sec /* Backward compatibility. */ +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec +#else + __time_t st_atime; /* Time of last access. */ + unsigned long int st_atimensec; /* Nscecs of last access. */ + __time_t st_mtime; /* Time of last modification. */ + unsigned long int st_mtimensec; /* Nsecs of last modification. */ + __time_t st_ctime; /* Time of last status change. */ + unsigned long int st_ctimensec; /* Nsecs of last status change. */ +#endif long __glibc_reserved[3]; }; #endif -#undef __ST_TIME - /* Tell code we have these members. */ #define _STATBUF_ST_BLKSIZE #define _STATBUF_ST_RDEV diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h index ff69045f8f..a292920969 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h @@ -9,9 +9,9 @@ struct kernel_stat unsigned int st_gid; unsigned int st_rdev; long int st_size; - unsigned long int st_atime; - unsigned long int st_mtime; - unsigned long int st_ctime; + unsigned long int st_atime_sec; + unsigned long int st_mtime_sec; + unsigned long int st_ctime_sec; unsigned int st_blksize; int st_blocks; unsigned int st_flags; @@ -34,11 +34,11 @@ struct kernel_stat64 unsigned int st_nlink; unsigned int __pad0; - unsigned long st_atime; + unsigned long st_atime_sec; unsigned long st_atimensec; - unsigned long st_mtime; + unsigned long st_mtime_sec; unsigned long st_mtimensec; - unsigned long st_ctime; + unsigned long st_ctime_sec; unsigned long st_ctimensec; long __glibc_reserved[3]; }; @@ -54,9 +54,9 @@ struct glibc2_stat __gid_t st_gid; __dev_t st_rdev; __off_t st_size; - __time_t st_atime; - __time_t st_mtime; - __time_t st_ctime; + __time_t st_atime_sec; + __time_t st_mtime_sec; + __time_t st_ctime_sec; unsigned int st_blksize; int st_blocks; unsigned int st_flags; @@ -74,9 +74,9 @@ struct glibc21_stat __gid_t st_gid; __dev_t st_rdev; __off_t st_size; - __time_t st_atime; - __time_t st_mtime; - __time_t st_ctime; + __time_t st_atime_sec; + __time_t st_mtime_sec; + __time_t st_ctime_sec; __blkcnt64_t st_blocks; __blksize_t st_blksize; unsigned int st_flags; diff --git a/sysdeps/unix/sysv/linux/alpha/xstatconv.c b/sysdeps/unix/sysv/linux/alpha/xstatconv.c index f716a10f34..43224a7f25 100644 --- a/sysdeps/unix/sysv/linux/alpha/xstatconv.c +++ b/sysdeps/unix/sysv/linux/alpha/xstatconv.c @@ -44,9 +44,9 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) buf->st_gid = kbuf->st_gid; buf->st_rdev = kbuf->st_rdev; buf->st_size = kbuf->st_size; - buf->st_atime = kbuf->st_atime; - buf->st_mtime = kbuf->st_mtime; - buf->st_ctime = kbuf->st_ctime; + buf->st_atime_sec = kbuf->st_atime_sec; + buf->st_mtime_sec = kbuf->st_mtime_sec; + buf->st_ctime_sec = kbuf->st_ctime_sec; buf->st_blksize = kbuf->st_blksize; buf->st_blocks = kbuf->st_blocks; buf->st_flags = kbuf->st_flags; @@ -66,9 +66,9 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) buf->st_gid = kbuf->st_gid; buf->st_rdev = kbuf->st_rdev; buf->st_size = kbuf->st_size; - buf->st_atime = kbuf->st_atime; - buf->st_mtime = kbuf->st_mtime; - buf->st_ctime = kbuf->st_ctime; + buf->st_atime_sec = kbuf->st_atime_sec; + buf->st_mtime_sec = kbuf->st_mtime_sec; + buf->st_ctime_sec = kbuf->st_ctime_sec; buf->st_blocks = kbuf->st_blocks; buf->st_blksize = kbuf->st_blksize; buf->st_flags = kbuf->st_flags; @@ -98,12 +98,12 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) buf->st_nlink = kbuf->st_nlink; buf->__pad0 = 0; - buf->st_atime = kbuf->st_atime; - buf->st_atimensec = 0; - buf->st_mtime = kbuf->st_mtime; - buf->st_mtimensec = 0; - buf->st_ctime = kbuf->st_ctime; - buf->st_ctimensec = 0; + buf->st_atim.tv_sec = kbuf->st_atime_sec; + buf->st_atim.tv_nsec = 0; + buf->st_mtim.tv_sec = kbuf->st_mtime_sec; + buf->st_mtim.tv_nsec = 0; + buf->st_ctim.tv_sec = kbuf->st_ctime_sec; + buf->st_ctim.tv_nsec = 0; buf->__glibc_reserved[0] = 0; buf->__glibc_reserved[1] = 0;