Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 4 v2] auto/type/sizeof: rework autotest to be cross-compilation friendly

Samuel Martin
June 01, 2014 11:20AM
# HG changeset patch
# User Samuel Martin <s.martin49@gmail.com>
# Date 1401633266 -7200
# Sun Jun 01 16:34:26 2014 +0200
# Branch sma/cross-compilation
# Node ID e52b6d1510a8ce2570d29c56738189485e9c9a1e
# Parent b9553b4b8e670a0231afc0484f23953c0d8b5f22
auto/type/sizeof: rework autotest to be cross-compilation friendly
Rework the sizeof test to do the checks at compile time instead of at
runtime. This way, it does not break when cross-compiling for a
different CPU architecture.

diff -r b9553b4b8e67 -r e52b6d1510a8 auto/types/sizeof
--- a/auto/types/sizeof Tue Apr 29 22:22:38 2014 +0200
+++ b/auto/types/sizeof Sun Jun 01 16:34:26 2014 +0200
@@ -14,7 +14,7 @@

ngx_size=

-cat << END > $NGX_AUTOTEST.c
+cat << _EOF > $NGX_AUTOTEST.c

#include <sys/types.h>
#include <sys/time.h>
@@ -25,28 +25,42 @@
$NGX_INCLUDE_INTTYPES_H
$NGX_INCLUDE_AUTO_CONFIG_H

-int main() {
- printf("%d", (int) sizeof($ngx_type));
+#if !defined( PASTE)
+#define PASTE2( x, y) x##y
+#define PASTE( x, y) PASTE2( x, y)
+#endif /* PASTE */
+
+#define SAY_IF_SIZEOF( typename, type, size) \\
+ static char PASTE( PASTE( PASTE( sizeof_, typename), _is_), size) \\
+ [(sizeof(type) == (size)) ? 1 : -1]
+
+SAY_IF_SIZEOF(TEST_TYPENAME, TEST_TYPE, TEST_SIZE);
+
+int main(void)
+{
return 0;
}

-END
+_EOF

-
-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
- -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
-
-eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
-
-
-if [ -x $NGX_AUTOTEST ]; then
- ngx_size=`$NGX_AUTOTEST`
- echo " $ngx_size bytes"
-fi
-
+_ngx_typename=`echo "$ngx_type" | sed 's/ /_/g;s/\*/p/'`
+ngx_size="-1"
+ngx_size=`for i in 1 2 4 8 16 ; do \
+ $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+ -DTEST_TYPENAME="$_ngx_typename" -DTEST_TYPE="$ngx_type" -DTEST_SIZE="$i" \
+ $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
+ $NGX_LD_OPT $ngx_feature_libs &>/dev/null || continue ;\
+ echo $i ; break ; done`

rm -rf $NGX_AUTOTEST*

+if test -z $ngx_size ; then
+ ngx_size=-1
+fi
+
+if [ $ngx_size -gt 0 ]; then
+ echo " $ngx_size bytes"
+fi

case $ngx_size in
4)

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 4 v2] Cross-compilation support improvement

Samuel Martin 724 June 01, 2014 11:20AM

[PATCH 1 of 4 v2] auto/type/sizeof: rework autotest to be cross-compilation friendly

Samuel Martin 349 June 01, 2014 11:20AM

[PATCH 2 of 4 v2] auto/feature: add mechanism allowing to force feature run test result

Samuel Martin 317 June 01, 2014 11:20AM

[PATCH 4 of 4 v2] auto/lib/libxslt/conf: allow to override ngx_feature_path and ngx_feature_libs

Samuel Martin 338 June 01, 2014 11:20AM

[PATCH 3 of 4 v2] auto/*: set ngx_feature_run_force_result for each feature requiring run test

Samuel Martin 376 June 01, 2014 11:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready