about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/configure.in24
-rw-r--r--sysdeps/unix/sysv/linux/mk-stdiolim.c4
-rw-r--r--sysdeps/unix/sysv/linux/stdio_lim.h.in8
3 files changed, 36 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/configure.in b/sysdeps/unix/sysv/linux/configure.in
index 18bb6dc469..f24af67f1e 100644
--- a/sysdeps/unix/sysv/linux/configure.in
+++ b/sysdeps/unix/sysv/linux/configure.in
@@ -83,3 +83,27 @@ fi
 if test -f $srcdir/elf/ldconfig.c; then
   has_ldconfig=yes
 fi
+
+# Generate stdio_lim.h
+default_fopen_max="`${CC-gcc} -E $srcdir/sysdeps/unix/sysv/linux/mk-stdiolim.c | grep DEFAULT_FOPEN_MAX | cut -f2 -d':'`"
+default_filename_max="`${CC-gcc} -E $srcdir/sysdeps/unix/sysv/linux/mk-stdiolim.c | grep DEFAULT_FILENAME_MAX | cut -f2 -d':'`"
+# We double check if "default_fopen_max" and "default_filename_max" are
+# ok or not.
+if test "x$default_fopen_max" != "xOPEN_MAX" \
+	-a "x$default_filename_max" != "xPATH_MAX"
+then
+  sed -e "s/DEFAULT_FOPEN_MAX/$default_fopen_max/" \
+	-e "s/DEFAULT_FILENAME_MAX/$default_filename_max/" \
+	$srcdir/sysdeps/unix/sysv/linux/stdio_lim.h.in > stdio_lim.h.new
+  if test -r stdio_lim.h.new && cmp -s stdio_lim.h.new stdio_lim.h
+  then
+    echo stdio_lim.h unchanged
+    rm -f stdio_lim.h.new
+  else
+    mv -f stdio_lim.h.new stdio_lim.h
+  fi
+else
+  # We remove the old one if we cannot generate the new one during
+  # configure.
+  rm -f stdio_lim.h
+fi
diff --git a/sysdeps/unix/sysv/linux/mk-stdiolim.c b/sysdeps/unix/sysv/linux/mk-stdiolim.c
new file mode 100644
index 0000000000..23295f007d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mk-stdiolim.c
@@ -0,0 +1,4 @@
+#include <linux/limits.h>
+
+DEFAULT_FOPEN_MAX:OPEN_MAX
+DEFAULT_FILENAME_MAX:PATH_MAX
diff --git a/sysdeps/unix/sysv/linux/stdio_lim.h.in b/sysdeps/unix/sysv/linux/stdio_lim.h.in
new file mode 100644
index 0000000000..9d6a957028
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/stdio_lim.h.in
@@ -0,0 +1,8 @@
+#define L_tmpnam 19
+#define TMP_MAX 238328
+#ifdef __USE_POSIX
+#define L_ctermid 9
+#define L_cuserid 9
+#endif
+#define FOPEN_MAX DEFAULT_FOPEN_MAX
+#define FILENAME_MAX DEFAULT_FILENAME_MAX