debianutils: bump to version 4.8.1
[buildroot-gz.git] / package / nginx / 0005-auto-unix-make-sys_nerr-guessing-cross-friendly.patch
blob2242d133636e2fa365fbb85dd016bce170b41219
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
7 buildtime.
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)
11 otherwise.
13 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
15 Refresh for 1.8.0.
17 Signed-off-by: Danomi Manchego <danomimanchego123@gmail.com>
18 ---
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
25 new file mode 100644
26 index 0000000..8970f5f
27 --- /dev/null
28 +++ b/auto/os/sys_nerr
29 @@ -0,0 +1,78 @@
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
45 +END
47 +ngx_sys_nerr=
49 +cat << _EOF > $NGX_AUTOTEST.c
51 +#include <stdio.h>
52 +#include <errno.h>
54 +static char sys_nerr_test[ERR_MAX];
55 +int main(void)
57 + return 0;
60 +_EOF
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
66 +else
67 + # the +2 has been empirically found!
68 + _ngx_max_err_macro="EHWPOISON + 2"
69 +fi
71 +cat << _EOF > $NGX_AUTOTEST.c
73 +#include <stdio.h>
74 +#include <errno.h>
76 +static char sys_nerr_test[(TEST_ERR_MAX == $_ngx_max_err_macro) ? 1 : -1];
77 +int main(void)
79 + return 0;
82 +_EOF
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
95 + ngx_size=0
96 + ngx_sys_nerr=0
97 +fi
99 +cat << END >> $NGX_AUTO_CONFIG_H
101 +#ifndef $ngx_feature_name
102 +#define $ngx_feature_name $ngx_sys_nerr
103 +#endif
105 +END
107 +echo " $ngx_sys_nerr"
108 diff --git a/auto/unix b/auto/unix
109 index 7dbf9d1..00a7370 100755
110 --- a/auto/unix
111 +++ b/auto/unix
112 @@ -595,6 +595,10 @@ ngx_feature_incs='#include <errno.h>
113 #include <stdio.h>'
114 ngx_feature_path=
115 ngx_feature_libs=
117 +if false ; then
118 +# Disabled because only valid for native build.
120 ngx_feature_test='printf("%d", sys_nerr);'
121 . auto/feature
123 @@ -643,6 +647,12 @@ if [ $ngx_found = no ]; then
124 . auto/feature
127 +else
128 + # Cross-compilation support
129 + . auto/os/sys_nerr
134 ngx_feature="localtime_r()"
135 ngx_feature_name="NGX_HAVE_LOCALTIME_R"
137 1.9.1