From patchwork Mon Mar 6 19:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 659264 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1987899wrb; Mon, 6 Mar 2023 11:17:40 -0800 (PST) X-Google-Smtp-Source: AK7set+s67gVXTBkUDngxxsqX/J88Wmt7T6qIhi8q5hYXLKgMGYbExhokJEf7gxQSQICF+O21Qia X-Received: by 2002:a17:906:d296:b0:8b1:315f:6c10 with SMTP id ay22-20020a170906d29600b008b1315f6c10mr12094433ejb.56.1678130260811; Mon, 06 Mar 2023 11:17:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678130260; cv=none; d=google.com; s=arc-20160816; b=sjtSLeCd/6CNGp/wAJdRJD3It6RdNAxmJUO0wSF5ByUOcut7+8PYu4dV9Yky+3YGP1 4ScOel59/XbGXls/oGherqfOmVBY3lW+euh+LPFERpMocgjJMe4wD8qIJQKSIYCkLdoA JE6eUYsNp9wUtycWgwDkSqbRFVHOOIR0wgaKAsrRWkLJHhPr3z8Lx7nmMVX2anhTQyQF 0923nKphht5GRBjnQzAW4Lz18e1JdJvwcCExyicj3nUSjfrSacuH7oSqKarCmB21WK7l Wn6q4zcKW+OOZd+JfNxrgcTc7b6+GCFjnxE86FGaW5jrzynuIW64oc1kuGApXoSUnMLG VKIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=XcR5WZD4eKeabawv6N9xhRny9nAXaV8W99o7i38GdQs=; b=uahrIOojtx6kSspHD54McMyz7r2/CsmVgaqdO1RINfqpjxLkgyNRAeQS43ANVrOTGL J1BHdrVZap/jHWEPrnNMiOc3BKye4/qiTE71NV7n83dLfT4nnTubs/Mu78ZLQ9OJXm5K pvbW+2FFK3W952veInC7o2TjM6pZ+wVufreXRhAGKmsFA6iYguiJ/WiERB7I6H412EMU jn5IEeP6GiRPBP12FqvBDlQ6nUYlMP44ApBzGgeIAdM9t3Y5OBOZvNaNhm/LNMfZ4llK gVV0hVU/71HB5hfGWscsJ8H+pp6RspDnjut+CQD+shz4tPWKCk2eqUsrGQa6Bc+dnr6r BCYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="L/kZkIPc"; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id re26-20020a170906d8da00b008e48d70f31fsi8435535ejb.662.2023.03.06.11.17.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 11:17:40 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="L/kZkIPc"; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97C3B3854836 for ; Mon, 6 Mar 2023 19:17:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97C3B3854836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678130259; bh=XcR5WZD4eKeabawv6N9xhRny9nAXaV8W99o7i38GdQs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=L/kZkIPcrr+j1j0cKI5Du98gVbEogugu6PrnAhJfPfvuI4eORRPezxE5uGLMJgZBG noSSK+U8C8WlRST2nKCtnwV50QRDp7mLGZcBhVm5LM9nWO4V/FER0pFfsRxB35tkKI UVnWnn3Byz9BI48llDdAiTd/YVXcqKG6tEs0PklE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 45324385B52D for ; Mon, 6 Mar 2023 19:16:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45324385B52D Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1763e201bb4so12601194fac.1 for ; Mon, 06 Mar 2023 11:16:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678130214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XcR5WZD4eKeabawv6N9xhRny9nAXaV8W99o7i38GdQs=; b=PnW6e10w8TGXXoE2EtKa3pmUBDT5XNPhhuWyN9z4l4LQuWm3mBs3mw7lp09g6JToDs hv2xP0NCe/MrbXyX2chUcEj5Ha97aCXUyTmuiaffcuYoz4N31X8WBmxaIvYPuI5+liDd cr/bbytorJwSn+tpvrNnb8p4Za6rUWsSlQaxVtvZ2Gz8ToTC3y5F8GpLN0OM1Fj9H1FS Jp6uILeAMi0vf2YmpVANj8JSs2Oj5QvSBlAbx/79y2rab579dEg8oVb+LtsEW17j2Y81 OayL3bkVcG4p6lC5QPqopF0k89cH6PgQHt/XzhnLsjbf9LJdespAvOC2AVh6Punr6KHk pPnw== X-Gm-Message-State: AO0yUKVtHxRPiv5yNIHT0v3BN2OFz/i3crHMAQB/2cDGgSxF8hrD386r w81LI60urlWse2II/LtuAMhRACQOKQV9pdvzvxlBhQ== X-Received: by 2002:a05:6870:5703:b0:172:2d00:99f7 with SMTP id k3-20020a056870570300b001722d0099f7mr6888476oap.20.1678130213922; Mon, 06 Mar 2023 11:16:53 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:d849:8c2f:e58d:3e6:9de5]) by smtp.gmail.com with ESMTPSA id zf29-20020a0568716a9d00b00176598b79d3sm4280668oab.24.2023.03.06.11.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 11:16:53 -0800 (PST) To: libc-alpha@sourceware.org, Florian Weimer , Carlos O'Donell Cc: Adhemerval Zanella Netto Subject: [PATCH v5 2/5] libio: Do not autogenerate stdio_lim.h Date: Mon, 6 Mar 2023 16:16:39 -0300 Message-Id: <20230306191642.347001-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306191642.347001-1-adhemerval.zanella@linaro.org> References: <20230306191642.347001-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Adhemerval Zanella Netto Instead define the required fields in system dependend files. Thee only system dependent definition is FILENAME_MAX, which should match POSIX PATH_MAX, and it is obtained from either kernel UAPI or mach headers. Currently set pre-defined value from current kernels. It avoid a circular dependendy when including stdio.h in gen-as-const-headers files. Checked on x86_64-linux-gnu and i686-linux-gnu Reviewed-by: Carlos O'Donell --- Makerules | 40 ------------------- Rules | 3 -- libio/stdio.h | 19 +++++---- .../mach/hurd/bits/stdio_lim.h | 17 ++------ sysdeps/posix/Makefile | 5 --- sysdeps/unix/sysv/linux/bits/stdio_lim.h | 28 +++++++++++++ 6 files changed, 43 insertions(+), 69 deletions(-) rename stdio-common/stdio_lim.h.in => sysdeps/mach/hurd/bits/stdio_lim.h (72%) delete mode 100644 sysdeps/posix/Makefile create mode 100644 sysdeps/unix/sysv/linux/bits/stdio_lim.h diff --git a/Makerules b/Makerules index f6071eab50..57b3f093c4 100644 --- a/Makerules +++ b/Makerules @@ -1351,46 +1351,6 @@ endif endif -# These will have been set by sysdeps/posix/Makefile. -L_tmpnam ?= 1 -TMP_MAX ?= 0 -L_ctermid ?= 1 -L_cuserid ?= 1 - -stdio_lim = $(common-objpfx)bits/stdio_lim.h - -$(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @: -$(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \ - $(common-objpfx)config.make - $(make-target-directory) - { echo '#include "$(..)posix/bits/posix1_lim.h"'; \ - } | \ - $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \ - $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT) - sed $(sed-remove-objpfx) $(sed-remove-dotdot) \ - $(@:st=dT) > $(@:st=dt) - mv -f $(@:st=dt) $(@:st=d) - fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \ - filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \ - fopen_max=$${fopen_max:-16}; \ - filename_max=$${filename_max:-1024}; \ - sed -e "s/@FOPEN_MAX@/$$fopen_max/" \ - -e "s/@FILENAME_MAX@/$$filename_max/" \ - -e "s/@L_tmpnam@/$(L_tmpnam)/" \ - -e "s/@TMP_MAX@/$(TMP_MAX)/" \ - -e "s/@L_ctermid@/$(L_ctermid)/" \ - -e "s/@L_cuserid@/$(L_cuserid)/" \ - $< > $(@:st=h.new) - $(move-if-change) $(@:st=h.new) $(@:st=h) -# Remove these last so that they can be examined if something went wrong. - rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt) - touch $@ -# Get dependencies. -ifndef no_deps --include $(stdio_lim:h=d) -endif -common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st - FORCE: .PHONY: echo-headers diff --git a/Rules b/Rules index fdff415fdc..5e945d7347 100644 --- a/Rules +++ b/Rules @@ -60,9 +60,6 @@ ifneq "$(findstring env,$(origin common-generated))" "" common-generated := endif -# See below. This must be set before Makerules processes it. -before-compile += $(common-objpfx)bits/stdio_lim.h - include $(..)Makerules .PHONY: subdir_lib diff --git a/libio/stdio.h b/libio/stdio.h index 857f02888d..686c40f28d 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -120,18 +120,23 @@ typedef __fpos64_t fpos64_t; # define P_tmpdir "/tmp" #endif +#define L_tmpnam 20 +#define TMP_MAX 238328 /* Get the values: - L_tmpnam How long an array of chars must be to be passed to `tmpnam'. - TMP_MAX The minimum number of unique filenames generated by tmpnam - (and tempnam when it uses tmpnam's name space), - or tempnam (the two are separate). - L_ctermid How long an array to pass to `ctermid'. - L_cuserid How long an array to pass to `cuserid'. - FOPEN_MAX Minimum number of files that can be open at once. FILENAME_MAX Maximum length of a filename. */ #include +#ifdef __USE_POSIX +# define L_ctermid 9 +# if !defined __USE_XOPEN2K || defined __USE_GNU +# define L_cuserid 9 +# endif +#endif + +#undef FOPEN_MAX +#define FOPEN_MAX 16 + #if __GLIBC_USE (ISOC2X) /* Maximum length of printf output for a NaN. */ diff --git a/stdio-common/stdio_lim.h.in b/sysdeps/mach/hurd/bits/stdio_lim.h similarity index 72% rename from stdio-common/stdio_lim.h.in rename to sysdeps/mach/hurd/bits/stdio_lim.h index bc7aacc35e..f3ef0be96e 100644 --- a/stdio-common/stdio_lim.h.in +++ b/sysdeps/mach/hurd/bits/stdio_lim.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1994-2023 Free Software Foundation, Inc. +/* System specific stdio.h definitions. Hurd version. + Copyright (C) 2023 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 @@ -22,18 +23,6 @@ # error "Never include directly; use instead." #endif -#define L_tmpnam @L_tmpnam@ -#define TMP_MAX @TMP_MAX@ -#define FILENAME_MAX @FILENAME_MAX@ - -#ifdef __USE_POSIX -# define L_ctermid @L_ctermid@ -# if !defined __USE_XOPEN2K || defined __USE_GNU -# define L_cuserid @L_cuserid@ -# endif -#endif - -#undef FOPEN_MAX -#define FOPEN_MAX @FOPEN_MAX@ +#define FILENAME_MAX 1024 #endif /* bits/stdio_lim.h */ diff --git a/sysdeps/posix/Makefile b/sysdeps/posix/Makefile deleted file mode 100644 index b58aa6aadb..0000000000 --- a/sysdeps/posix/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# These affect the generated bits/stdio_lim.h file. -L_tmpnam = 20 -TMP_MAX = 238328 -L_ctermid = 9 -L_cuserid = 9 diff --git a/sysdeps/unix/sysv/linux/bits/stdio_lim.h b/sysdeps/unix/sysv/linux/bits/stdio_lim.h new file mode 100644 index 0000000000..4c3f36d7ce --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/stdio_lim.h @@ -0,0 +1,28 @@ +/* System specific stdio.h definitions. Linux version. + Copyright (C) 2023 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 + . */ + +#ifndef _BITS_STDIO_LIM_H +#define _BITS_STDIO_LIM_H 1 + +#ifndef _STDIO_H +# error "Never include directly; use instead." +#endif + +#define FILENAME_MAX 4096 + +#endif /* bits/stdio_lim.h */