libio: Do not autogenerate stdio_lim.h
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Mon, 6 Mar 2023 18:53:55 +0000 (15:53 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 27 Mar 2023 16:57:55 +0000 (13:57 -0300)
Instead define the required fields in system dependend files.  The 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 avoids 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 <carlos@redhat.com>
Makerules
Rules
libio/stdio.h
sysdeps/mach/hurd/bits/stdio_lim.h [moved from stdio-common/stdio_lim.h.in with 72% similarity]
sysdeps/posix/Makefile [deleted file]
sysdeps/unix/sysv/linux/bits/stdio_lim.h [new file with mode: 0644]

index f6071ea..57b3f09 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1351,46 +1351,6 @@ endif
 
 endif
 \f
-# 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
-\f
 FORCE:
 
 .PHONY: echo-headers
diff --git a/Rules b/Rules
index fdff415..5e945d7 100644 (file)
--- 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
index 857f028..686c40f 100644 (file)
@@ -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 <bits/stdio_lim.h>
 
+#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.  */
similarity index 72%
rename from stdio-common/stdio_lim.h.in
rename to sysdeps/mach/hurd/bits/stdio_lim.h
index bc7aacc..f3ef0be 100644 (file)
@@ -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
 # error "Never include <bits/stdio_lim.h> directly; use <stdio.h> 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 (file)
index b58aa6a..0000000
+++ /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 (file)
index 0000000..4c3f36d
--- /dev/null
@@ -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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _BITS_STDIO_LIM_H
+#define _BITS_STDIO_LIM_H 1
+
+#ifndef _STDIO_H
+# error "Never include <bits/stdio_lim.h> directly; use <stdio.h> instead."
+#endif
+
+#define FILENAME_MAX 4096
+
+#endif /* bits/stdio_lim.h */