1 From 08617a8d29ee22831175697555558fec8f52772c Mon Sep 17 00:00:00 2001
2 From: Samuel Martin <s.martin49@gmail.com>
3 Date: Sun, 1 Jun 2014 16:05:04 +0200
4 Subject: [PATCH] auto/unix: make sys_nerr guessing cross-friendly
6 This patch replaces the default sys_nerr runtest with a test done at
9 The idea behind this buildtime test is finding the value of the ERR_MAX
10 macro if defined, or the EHWPOISON (which is currently the last errno)
13 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
17 Signed-off-by: Danomi Manchego <danomimanchego123@gmail.com>
19 auto/os/sys_nerr | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 auto/unix | 10 ++++++++
21 2 files changed, 88 insertions(+)
22 create mode 100644 auto/os/sys_nerr
24 diff --git a/auto/os/sys_nerr b/auto/os/sys_nerr
26 index 0000000..8970f5f
28 +++ b/auto/os/sys_nerr
31 +# Copyright (C) Samuel Martin <s.martin49@gmail.com>
34 +echo $ngx_n "checking for sys_nerr value...$ngx_c"
36 +# sys_nerr guessing is done using a (very) poor (but working)
37 +# heuristics, by checking for the value of ERR_MAX if defined, or
38 +# EHWPOISON otherwise.
40 +cat << END >> $NGX_AUTOCONF_ERR
42 +----------------------------------------
43 +checking for sys_nerr value
49 +cat << _EOF > $NGX_AUTOTEST.c
54 +static char sys_nerr_test[ERR_MAX];
62 +if $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
63 + $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
64 + $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 ; then
65 + _ngx_max_err_macro=ERR_MAX
67 + # the +2 has been empirically found!
68 + _ngx_max_err_macro="EHWPOISON + 2"
71 +cat << _EOF > $NGX_AUTOTEST.c
76 +static char sys_nerr_test[(TEST_ERR_MAX == $_ngx_max_err_macro) ? 1 : -1];
85 +ngx_sys_nerr=`for i in $(seq 0 2000) ; do \
86 + $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
87 + -DTEST_ERR_MAX="$i" \
88 + $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
89 + $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 || continue ;\
90 + echo $i ; break ; done`
92 +rm -rf $NGX_AUTOTEST*
94 +if test -z $ngx_sys_nerr ; then
99 +cat << END >> $NGX_AUTO_CONFIG_H
101 +#ifndef $ngx_feature_name
102 +#define $ngx_feature_name $ngx_sys_nerr
107 +echo " $ngx_sys_nerr"
108 diff --git a/auto/unix b/auto/unix
109 index 7dbf9d1..00a7370 100755
112 @@ -595,6 +595,10 @@ ngx_feature_incs='#include <errno.h>
118 +# Disabled because only valid for native build.
120 ngx_feature_test='printf("%d", sys_nerr);'
123 @@ -643,6 +647,12 @@ if [ $ngx_found = no ]; then
128 + # Cross-compilation support
134 ngx_feature="localtime_r()"
135 ngx_feature_name="NGX_HAVE_LOCALTIME_R"