[njs] Detecting standard data types in configure script.
Dmitry Volyntsev
xeioex at nginx.com
Tue Nov 19 16:31:59 UTC 2019
details: https://hg.nginx.org/njs/rev/e4383fdfdc82
branches:
changeset: 1243:e4383fdfdc82
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Tue Nov 19 19:17:09 2019 +0300
description:
Detecting standard data types in configure script.
diffstat:
auto/time | 15 -------
auto/types | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
configure | 1 +
3 files changed, 121 insertions(+), 15 deletions(-)
diffs (160 lines):
diff -r 11850951c75c -r e4383fdfdc82 auto/time
--- a/auto/time Tue Nov 19 19:17:06 2019 +0300
+++ b/auto/time Tue Nov 19 19:17:09 2019 +0300
@@ -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 <time.h>
- #include <stdio.h>
-
- int main(void) {
- printf(\"%zu\", sizeof(time_t));
- return 0;
- }"
-. auto/feature
-
-
# Linux, FreeBSD, MacOSX.
njs_feature="struct tm.tm_gmtoff"
diff -r 11850951c75c -r e4383fdfdc82 auto/types
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/types Tue Nov 19 19:17:09 2019 +0300
@@ -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 <stdio.h>
+
+ 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 <sys/types.h>
+ #include <stdio.h>
+
+ 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 <stdio.h>
+
+ 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 <stdint.h>
+ #include <stdio.h>
+
+ 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 <stdio.h>
+
+ 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 <unistd.h>
+ #include <stdio.h>
+
+ 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 <time.h>
+ #include <stdio.h>
+
+ int main(void) {
+ printf(\"%d\", (int) sizeof(time_t));
+ return 0;
+ }"
+. auto/feature
diff -r 11850951c75c -r e4383fdfdc82 configure
--- a/configure Tue Nov 19 19:17:06 2019 +0300
+++ b/configure Tue Nov 19 19:17:09 2019 +0300
@@ -47,6 +47,7 @@ NJS_LIBRT=
. auto/os
. auto/options
. auto/cc
+. auto/types
. auto/clang
. auto/time
. auto/memalign
More information about the nginx-devel
mailing list