From a2943b2cb2431ac94a86f34a4a8c2c656f271fc2 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Tue, 19 Nov 2019 19:17:09 +0300 Subject: [PATCH] Detecting standard data types in configure script. --- auto/time | 15 ------- auto/types | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 1 + 3 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 auto/types diff --git a/auto/time b/auto/time index 353d244a..0e4eda2a 100644 --- a/auto/time +++ b/auto/time @@ -34,21 +34,6 @@ if [ $njs_found = no ]; then fi -njs_feature="sizeof(time_t)" -njs_feature_name=NJS_TIME_T_SIZE -njs_feature_run=value -njs_feature_incs= -njs_feature_libs= -njs_feature_test="#include - #include - - int main(void) { - printf(\"%zu\", sizeof(time_t)); - return 0; - }" -. auto/feature - - # Linux, FreeBSD, MacOSX. njs_feature="struct tm.tm_gmtoff" diff --git a/auto/types b/auto/types new file mode 100644 index 00000000..7bb9c16a --- /dev/null +++ b/auto/types @@ -0,0 +1,120 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Sizes of C types. + +# "-Wall -Werror" or similar constraints in default CFLAGS may require +# to use "%zu" format to printf() result of sizeof(). But "%zu" may +# be unavailable, so the "(int)" cast is a simple and portable solution: +# printf("%d", (int) sizeof(TYPE)); + + +njs_feature="sizeof(int)" +njs_feature_name=NJS_INT_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + + int main() { + printf(\"%d\", (int) sizeof(int)); + return 0; + }" +. auto/feature + + +njs_feature="sizeof(u_int)" +njs_feature_name=NJS_UINT_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + #include + + int main() { + printf(\"%d\", (int) sizeof(u_int)); + return 0; + }" +. auto/feature + + +njs_feature="sizeof(void *)" +njs_feature_name=NJS_PTR_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + + int main() { + printf(\"%d\", (int) sizeof(void *)); + return 0; + }" +. auto/feature + + +njs_feature="sizeof(uintptr_t)" +njs_feature_name=NJS_UINTPTR_T_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + #include + + int main() { + printf(\"%d\", (int) sizeof(uintptr_t)); + return 0; + }" +. auto/feature + + +case "$njs_feature_value" in + 8) NJS_64BIT=1 ;; + *) NJS_64BIT=0 ;; +esac + + +njs_feature="sizeof(size_t)" +njs_feature_name=NJS_SIZE_T_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + + int main() { + printf(\"%d\", (int) sizeof(size_t)); + return 0; + }" +. auto/feature + + +njs_feature="sizeof(off_t)" +njs_feature_name=NJS_OFF_T_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#define _FILE_OFFSET_BITS 64 + #include + #include + + int main() { + printf(\"%d\", (int) sizeof(off_t)); + return 0; + }" +. auto/feature + + +njs_feature="sizeof(time_t)" +njs_feature_name=NJS_TIME_T_SIZE +njs_feature_run=value +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + #include + + int main(void) { + printf(\"%d\", (int) sizeof(time_t)); + return 0; + }" +. auto/feature diff --git a/configure b/configure index 9276a29b..7cfc0421 100755 --- a/configure +++ b/configure @@ -47,6 +47,7 @@ NJS_LIBRT= . auto/os . auto/options . auto/cc +. auto/types . auto/clang . auto/time . auto/memalign -- 2.47.3