]> git.kaiwu.me - njs.git/commitdiff
Detecting standard data types in configure script.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 19 Nov 2019 16:17:09 +0000 (19:17 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 19 Nov 2019 16:17:09 +0000 (19:17 +0300)
auto/time
auto/types [new file with mode: 0644]
configure

index 353d244a1cad956eeb85bccf10b971162f436f08..0e4eda2a14e83180ef2516808b50006491d7df9c 100644 (file)
--- 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 <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 --git a/auto/types b/auto/types
new file mode 100644 (file)
index 0000000..7bb9c16
--- /dev/null
@@ -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
index 9276a29b05314b8ba247b329a06d3f15902c4614..7cfc042175eafd05142577dc291e65846a9245d8 100755 (executable)
--- a/configure
+++ b/configure
@@ -47,6 +47,7 @@ NJS_LIBRT=
 . auto/os
 . auto/options
 . auto/cc
+. auto/types
 . auto/clang
 . auto/time
 . auto/memalign