5b9e913a03197ac53abf39c875e7ec5a2d6b4941
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / nginx / 0001-auto-type-sizeof-rework-autotest-to-be-cross-compila.patch
1 From 81289d1d1adaf5a767a4b4d1309c286468cfd37f Mon Sep 17 00:00:00 2001
2 From: Samuel Martin <s.martin49@gmail.com>
3 Date: Thu, 24 Apr 2014 23:27:32 +0200
4 Subject: [PATCH 1/5] auto/type/sizeof: rework autotest to be cross-compilation
5  friendly
6
7 Rework the sizeof test to do the checks at compile time instead of at
8 runtime. This way, it does not break when cross-compiling for a
9 different CPU architecture.
10
11 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
12 ---
13  auto/types/sizeof | 42 ++++++++++++++++++++++++++++--------------
14  1 file changed, 28 insertions(+), 14 deletions(-)
15
16 diff --git a/auto/types/sizeof b/auto/types/sizeof
17 index 9215a54..c2c3ede 100644
18 --- a/auto/types/sizeof
19 +++ b/auto/types/sizeof
20 @@ -14,7 +14,7 @@ END
21  
22  ngx_size=
23  
24 -cat << END > $NGX_AUTOTEST.c
25 +cat << _EOF > $NGX_AUTOTEST.c
26  
27  #include <sys/types.h>
28  #include <sys/time.h>
29 @@ -25,29 +25,43 @@ $NGX_INCLUDE_UNISTD_H
30  $NGX_INCLUDE_INTTYPES_H
31  $NGX_INCLUDE_AUTO_CONFIG_H
32  
33 -int main() {
34 -    printf("%d", (int) sizeof($ngx_type));
35 +#if !defined( PASTE)
36 +#define PASTE2( x, y) x##y
37 +#define PASTE( x, y)  PASTE2( x, y)
38 +#endif /* PASTE */
39 +
40 +#define SAY_IF_SIZEOF( typename, type, size)   \\
41 +    static char PASTE( PASTE( PASTE( sizeof_, typename), _is_), size) \\
42 +    [(sizeof(type) == (size)) ? 1 : -1]
43 +
44 +SAY_IF_SIZEOF(TEST_TYPENAME, TEST_TYPE, TEST_SIZE);
45 +
46 +int main(void)
47 +{
48      return 0;
49  }
50  
51 -END
52 -
53 +_EOF
54  
55 -ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
56 -          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
57 +_ngx_typename=`echo "$ngx_type" | sed 's/ /_/g;s/\*/p/'`
58 +ngx_size="-1"
59 +ngx_size=`for i in 1 2 4 8 16 ; do \
60 +    $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
61 +    -DTEST_TYPENAME="$_ngx_typename" -DTEST_TYPE="$ngx_type" -DTEST_SIZE="$i" \
62 +    $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
63 +    $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 || continue ;\
64 +    echo $i ; break ; done`
65  
66 -eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
67 +rm -rf $NGX_AUTOTEST*
68  
69 +if test -z $ngx_size ; then
70 +    ngx_size=-1
71 +fi
72  
73 -if [ -x $NGX_AUTOTEST ]; then
74 -    ngx_size=`$NGX_AUTOTEST`
75 +if [ $ngx_size -gt 0 ]; then
76      echo " $ngx_size bytes"
77  fi
78  
79 -
80 -rm -rf $NGX_AUTOTEST*
81 -
82 -
83  case $ngx_size in
84      4)
85          if [ "$ngx_type"="long" ]; then
86 -- 
87 1.9.2
88