You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

135 lines
3.0 KiB

From 08617a8d29ee22831175697555558fec8f52772c Mon Sep 17 00:00:00 2001
From: Samuel Martin <s.martin49@gmail.com>
Date: Sun, 1 Jun 2014 16:05:04 +0200
Subject: [PATCH] auto/unix: make sys_nerr guessing cross-friendly
This patch replaces the default sys_nerr runtest with a test done at
buildtime.
The idea behind this buildtime test is finding the value of the ERR_MAX
macro if defined, or the EHWPOISON (which is currently the last errno)
otherwise.
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Refresh for 1.8.0.
Signed-off-by: Danomi Manchego <danomimanchego123@gmail.com>
[rebased against v1.20.1]
Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
auto/os/sys_nerr | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
auto/unix | 8 +++++
2 files changed, 86 insertions(+)
create mode 100644 auto/os/sys_nerr
diff --git a/auto/os/sys_nerr b/auto/os/sys_nerr
new file mode 100644
index 0000000..8970f5f
--- /dev/null
+++ b/auto/os/sys_nerr
@@ -0,0 +1,78 @@
+
+# Copyright (C) Samuel Martin <s.martin49@gmail.com>
+
+
+echo $ngx_n "checking for sys_nerr value...$ngx_c"
+
+# sys_nerr guessing is done using a (very) poor (but working)
+# heuristics, by checking for the value of ERR_MAX if defined, or
+# EHWPOISON otherwise.
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for sys_nerr value
+
+END
+
+ngx_sys_nerr=
+
+cat << _EOF > $NGX_AUTOTEST.c
+
+#include <stdio.h>
+#include <errno.h>
+
+static char sys_nerr_test[ERR_MAX];
+int main(void)
+{
+ return 0;
+}
+
+_EOF
+
+if $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+ $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
+ $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 ; then
+ _ngx_max_err_macro=ERR_MAX
+else
+ # the +2 has been empirically found!
+ _ngx_max_err_macro="EHWPOISON + 2"
+fi
+
+cat << _EOF > $NGX_AUTOTEST.c
+
+#include <stdio.h>
+#include <errno.h>
+
+static char sys_nerr_test[(TEST_ERR_MAX == $_ngx_max_err_macro) ? 1 : -1];
+int main(void)
+{
+ return 0;
+}
+
+_EOF
+
+
+ngx_sys_nerr=`for i in $(seq 0 2000) ; do \
+ $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+ -DTEST_ERR_MAX="$i" \
+ $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
+ $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 || continue ;\
+ echo $i ; break ; done`
+
+rm -rf $NGX_AUTOTEST*
+
+if test -z $ngx_sys_nerr ; then
+ ngx_size=0
+ ngx_sys_nerr=0
+fi
+
+cat << END >> $NGX_AUTO_CONFIG_H
+
+#ifndef $ngx_feature_name
+#define $ngx_feature_name $ngx_sys_nerr
+#endif
+
+END
+
+echo " $ngx_sys_nerr"
diff --git a/auto/unix b/auto/unix
index 7dbf9d1..00a7370 100755
--- a/auto/unix
+++ b/auto/unix
@@ -744,10 +744,18 @@ if [ $ngx_found = no ]; then
#include <stdio.h>'
ngx_feature_path=
ngx_feature_libs=
+ if false ; then
+ # Disabled because only valid for native build.
ngx_feature_test='printf("%d", _sys_nerr);'
. auto/feature
fi
+else
+ # Cross-compilation support
+ . auto/os/sys_nerr
+
+fi
+
ngx_feature="localtime_r()"
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
--
1.9.1