From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 387911F4B4 for ; Thu, 22 Oct 2020 08:16:04 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3247238618F9; Thu, 22 Oct 2020 08:16:03 +0000 (GMT) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 2FD5438618F9 for ; Thu, 22 Oct 2020 08:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2FD5438618F9 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CH0YV6p84z1rwb1; Thu, 22 Oct 2020 10:15:58 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CH0YV5l35z1qv5g; Thu, 22 Oct 2020 10:15:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rKgMASy0vGDc; Thu, 22 Oct 2020 10:15:55 +0200 (CEST) X-Auth-Info: OL+xYZdARR1DINikI8GVCx3NiM8fQo2TMDZIv/WStJ4= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 22 Oct 2020 10:15:55 +0200 (CEST) Date: Thu, 22 Oct 2020 10:15:10 +0200 From: Lukasz Majewski To: Adhemerval Zanella Subject: Re: [PATCH 2/5] login: Move gnu utmpx to default implementaion Message-ID: <20201022101510.076bbf41@jawa> In-Reply-To: <20200729205117.2925113-2-adhemerval.zanella@linaro.org> References: <20200729205117.2925113-1-adhemerval.zanella@linaro.org> <20200729205117.2925113-2-adhemerval.zanella@linaro.org> Organization: denx.de X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/VftMnQwa0=AwlLDag0/I1s="; protocol="application/pgp-signature" 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: , Cc: Alistair Francis , libc-alpha@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --Sig_/VftMnQwa0=AwlLDag0/I1s= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Adhemerval, > It removes one indirection where generic implementation assumes that > utmp and utmpx might differ and allows the optimize the symbol alias > where getutmp is the same as getumpx. >=20 > Checked on all afftected ABIs. > --- > {sysdeps/gnu/bits =3D> bits}/struct_utmpx.h | 0 > {sysdeps/gnu/bits =3D> bits}/utmpx.h | 0 > include/utmpx.h | 1 + > login/getutmp.c | 34 ++++++++++++++++-- > login/getutmpx.c | 35 > +------------------ login/updwtmp.c | > 11 +++++- {sysdeps/gnu =3D> login}/utmpx.h | 0 > sysdeps/gnu/getutmp.c | 34 ------------------ > sysdeps/gnu/getutmpx.c | 1 - > sysdeps/gnu/updwtmp.c | 31 ---------------- > .../unix/sysv/linux/s390/s390-32/getutmp.c | 21 ++++------- > .../unix/sysv/linux/s390/s390-32/updwtmp.c | 2 +- > 12 files changed, 52 insertions(+), 118 deletions(-) > rename {sysdeps/gnu/bits =3D> bits}/struct_utmpx.h (100%) > rename {sysdeps/gnu/bits =3D> bits}/utmpx.h (100%) > create mode 100644 include/utmpx.h > rename {sysdeps/gnu =3D> login}/utmpx.h (100%) > delete mode 100644 sysdeps/gnu/getutmp.c > delete mode 100644 sysdeps/gnu/getutmpx.c > delete mode 100644 sysdeps/gnu/updwtmp.c Nice that we would have the getutmp.c in one place. Reviewed-by: Lukasz Majewski >=20 > diff --git a/sysdeps/gnu/bits/struct_utmpx.h b/bits/struct_utmpx.h > similarity index 100% > rename from sysdeps/gnu/bits/struct_utmpx.h > rename to bits/struct_utmpx.h > diff --git a/sysdeps/gnu/bits/utmpx.h b/bits/utmpx.h > similarity index 100% > rename from sysdeps/gnu/bits/utmpx.h > rename to bits/utmpx.h > diff --git a/include/utmpx.h b/include/utmpx.h > new file mode 100644 > index 0000000000..cfe9b7c054 > --- /dev/null > +++ b/include/utmpx.h > @@ -0,0 +1 @@ > +#include > diff --git a/login/getutmp.c b/login/getutmp.c > index e9a5fe69a5..3058a93d1b 100644 > --- a/login/getutmp.c > +++ b/login/getutmp.c > @@ -17,17 +17,47 @@ > =20 > #include > #include > +#include > +#define getutmpx __redirect_getutmpx > #include > +#undef getutmpx > + > +#define CHECK_SIZE_AND_OFFSET(field) \ > + _Static_assert (sizeof ((struct utmp){0}.field) \ > + =3D=3D sizeof ((struct utmpx){0}.field), > \ > + "sizeof ((struct utmp){0}." #field " !=3D " \ > + "sizeof ((struct utmpx){0}" #field); \ > + _Static_assert (offsetof (struct utmp, field) > \ > + =3D=3D offsetof (struct utmpx, field), \ > + "offsetof (struct utmp, " #field ") !=3D " \ > + "offsetof (struct utmpx, " #field ")"); > + > +/* This ensure the getutmp to getutmpx alias is valid. */ > +_Static_assert (sizeof (struct utmp) =3D=3D sizeof (struct utmpx), > + "sizeof (struct utmp) !=3D sizeof (struct utmpx)"); > +CHECK_SIZE_AND_OFFSET (ut_type) > +CHECK_SIZE_AND_OFFSET (ut_pid) > +CHECK_SIZE_AND_OFFSET (ut_line) > +CHECK_SIZE_AND_OFFSET (ut_user) > +CHECK_SIZE_AND_OFFSET (ut_id) > +CHECK_SIZE_AND_OFFSET (ut_host) > +CHECK_SIZE_AND_OFFSET (ut_tv) > + > =20 > /* Copy the information in UTMPX to UTMP. */ > void > -getutmp (const struct utmpx *utmpx, struct utmp *utmp) > +__getutmp (const struct utmpx *utmpx, struct utmp *utmp) > { > + memset (utmp, 0, sizeof (struct utmpx)); > utmp->ut_type =3D utmpx->ut_type; > utmp->ut_pid =3D utmpx->ut_pid; > memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line)); > memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user)); > memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id)); > memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host)); > - utmp->ut_tv =3D utmpx->ut_tv; > + utmp->ut_tv.tv_sec =3D utmpx->ut_tv.tv_sec; > + utmp->ut_tv.tv_usec =3D utmpx->ut_tv.tv_usec; > } > + > +weak_alias (__getutmp, getutmp) > +strong_alias (__getutmp, getutmpx) > diff --git a/login/getutmpx.c b/login/getutmpx.c > index 250a355235..839eb6826e 100644 > --- a/login/getutmpx.c > +++ b/login/getutmpx.c > @@ -1,34 +1 @@ > -/* Copyright (C) 1999-2020 Free Software Foundation, Inc. > - This file is part of the GNU C Library. > - > - The GNU C Library is free software; you can redistribute it and/or > - modify it under the terms of the GNU Lesser General Public > - License as published by the Free Software Foundation; either > - version 2.1 of the License, or (at your option) any later version. > - > - The GNU C Library is distributed in the hope that it will be > useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - Lesser General Public License for more details. > - > - You should have received a copy of the GNU Lesser General Public > - License along with the GNU C Library; if not, see > - . */ > - > -#include > -#include > -#include > - > -/* Copy the information in UTMP to UTMPX. */ > -void > -getutmpx (const struct utmp *utmp, struct utmpx *utmpx) > -{ > - memset (utmpx, 0, sizeof (struct utmpx)); > - utmpx->ut_type =3D utmp->ut_type; > - utmpx->ut_pid =3D utmp->ut_pid; > - memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line)); > - memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user)); > - memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id)); > - memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host)); > - utmpx->ut_tv =3D utmp->ut_tv; > -} > +/* Implemented by getutmp.c. */ > diff --git a/login/updwtmp.c b/login/updwtmp.c > index f6cd515ac4..489c28b553 100644 > --- a/login/updwtmp.c > +++ b/login/updwtmp.c > @@ -17,11 +17,20 @@ > . */ > =20 > #include > +#include > +#include > =20 > #include "utmp-private.h" > =20 > #ifndef TRANSFORM_UTMP_FILE_NAME > -# define TRANSFORM_UTMP_FILE_NAME(file_name) (file_name) > +# define TRANSFORM_UTMP_FILE_NAME(file_name) \ > + ((strcmp (file_name, _PATH_UTMP "x") =3D=3D 0 \ > + && __access (_PATH_UTMP "x", F_OK) !=3D 0) \ > + ? _PATH_UTMP \ > + : ((strcmp (file_name, _PATH_WTMP "x") =3D=3D 0 \ > + && __access (_PATH_WTMP "x", F_OK) !=3D 0) \ > + ? _PATH_WTMP \ > + : file_name)) > #endif > =20 > void > diff --git a/sysdeps/gnu/utmpx.h b/login/utmpx.h > similarity index 100% > rename from sysdeps/gnu/utmpx.h > rename to login/utmpx.h > diff --git a/sysdeps/gnu/getutmp.c b/sysdeps/gnu/getutmp.c > deleted file mode 100644 > index 95a9a4b354..0000000000 > --- a/sysdeps/gnu/getutmp.c > +++ /dev/null > @@ -1,34 +0,0 @@ > -/* Copyright (C) 1999-2020 Free Software Foundation, Inc. > - This file is part of the GNU C Library. > - > - The GNU C Library is free software; you can redistribute it and/or > - modify it under the terms of the GNU Lesser General Public > - License as published by the Free Software Foundation; either > - version 2.1 of the License, or (at your option) any later version. > - > - The GNU C Library is distributed in the hope that it will be > useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - Lesser General Public License for more details. > - > - You should have received a copy of the GNU Lesser General Public > - License along with the GNU C Library; if not, see > - . */ > - > -#include > -#include > -#include > -#ifndef _UTMPX_H > -/* This is an ugly hack but we must not see the getutmpx > declaration. */ -# define getutmpx XXXgetutmpx > -# include > -# undef getutmpx > -#endif > - > -void > -getutmp (const struct utmpx *utmpx, struct utmp *utmp) > -{ > - assert (sizeof (struct utmp) =3D=3D sizeof (struct utmpx)); > - memcpy (utmp, utmpx, sizeof (struct utmp)); > -} > -strong_alias (getutmp, getutmpx) > diff --git a/sysdeps/gnu/getutmpx.c b/sysdeps/gnu/getutmpx.c > deleted file mode 100644 > index f393734a63..0000000000 > --- a/sysdeps/gnu/getutmpx.c > +++ /dev/null > @@ -1 +0,0 @@ > -/* We don't need a separate version. it is the same as getutmp(). > */ diff --git a/sysdeps/gnu/updwtmp.c b/sysdeps/gnu/updwtmp.c > deleted file mode 100644 > index 044091b77c..0000000000 > --- a/sysdeps/gnu/updwtmp.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/* Copyright (C) 1998-2020 Free Software Foundation, Inc. > - This file is part of the GNU C Library. > - Contributed by Mark Kettenis , 1998. > - > - The GNU C Library is free software; you can redistribute it and/or > - modify it under the terms of the GNU Lesser General Public > - License as published by the Free Software Foundation; either > - version 2.1 of the License, or (at your option) any later version. > - > - The GNU C Library is distributed in the hope that it will be > useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - Lesser General Public License for more details. > - > - You should have received a copy of the GNU Lesser General Public > - License along with the GNU C Library; if not, see > - . */ > - > -#include > -#include > - > -#define TRANSFORM_UTMP_FILE_NAME(file_name) \ > - ((strcmp (file_name, _PATH_UTMP "x") =3D=3D 0 \ > - && __access (_PATH_UTMP "x", F_OK) !=3D 0) \ > - ? _PATH_UTMP \ > - : ((strcmp (file_name, _PATH_WTMP "x") =3D=3D 0 \ > - && __access (_PATH_WTMP "x", F_OK) !=3D 0) \ > - ? _PATH_WTMP \ > - : file_name)) > - > -#include > diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/getutmp.c > b/sysdeps/unix/sysv/linux/s390/s390-32/getutmp.c index > 6380ae2a82..50ce8c4f5c 100644 --- > a/sysdeps/unix/sysv/linux/s390/s390-32/getutmp.c +++ > b/sysdeps/unix/sysv/linux/s390/s390-32/getutmp.c @@ -16,22 +16,15 @@ > License along with the GNU C Library; if not, see > . */ > =20 > -#include > -#include > -/* This is an ugly hack but we must not see the getutmpx > declaration. */ -#define getutmpx XXXgetutmpx > -#include > -#undef getutmpx > +#undef weak_alias > +#define weak_alias(a, b) > +#undef strong_alias > +#define strong_alias(a, b) > =20 > -#include "utmp-compat.h" > +#include > =20 > -#undef weak_alias > -#define weak_alias(n,a) > -#define getutmp __getutmp > -#define getutmpx __getutmpx > -#include "sysdeps/gnu/getutmp.c" > -#undef getutmp > -#undef getutmpx > +#include "utmp-compat.h" > =20 > default_symbol_version (__getutmp, getutmp, UTMP_COMPAT_BASE); > +_strong_alias (__getutmp, __getutmpx) > default_symbol_version (__getutmpx, getutmpx, UTMP_COMPAT_BASE); > diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/updwtmp.c > b/sysdeps/unix/sysv/linux/s390/s390-32/updwtmp.c index > dcd334e5a9..2079571cc1 100644 --- > a/sysdeps/unix/sysv/linux/s390/s390-32/updwtmp.c +++ > b/sysdeps/unix/sysv/linux/s390/s390-32/updwtmp.c @@ -25,7 +25,7 @@ > # undef weak_alias > # define weak_alias(n,a) > #endif > -#include "sysdeps/gnu/updwtmp.c" > +#include > =20 > #if defined SHARED > default_symbol_version (__updwtmp, updwtmp, UTMP_COMPAT_BASE); Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/VftMnQwa0=AwlLDag0/I1s= Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl+RP44ACgkQAR8vZIA0 zr0BOQf/WKCyuKOfpi8fYYLvWosPEvpr7I2uGKk5PFsGGJncqUwTBOoKQv4iYe4s JDpVmRazwOYZK/cmBECxz/TGmflW5ZBkajXBfK1nlay4uXwLJ4PN/C1StB4QE19T HMECG3uDVksXYzq1h0InvkJiCNNo07sRPHYlvAVHE3BdXnQ4VGHbfR9wXFouyRoh oADNLDAjQ94OQLkgIr1SYxA1OdaatAlqIxSYo0quECOug4TrBqUsEZb0GJ5zArUv M6vijFWfQEyUf+T257EeSAvj6+EiWxC1WWLWpJWVKpthxpz5rERVL6LXZGA9teu/ 3itJrPO07mSF5+P1tGoWqILOjDPTnw== =TgYm -----END PGP SIGNATURE----- --Sig_/VftMnQwa0=AwlLDag0/I1s=--