about summary refs log tree commit homepage
path: root/ext/unicorn_http/c_util.h
diff options
context:
space:
mode:
authorEric Wong <bofh@yhbt.net>2021-10-01 03:09:18 +0000
committerEric Wong <bofh@yhbt.net>2021-10-04 17:39:55 -0900
commit8296cd0fff593364698e3a8ca3905103eee131ee (patch)
treec9d8a092ac3a57f2d4c108d60ec9b427e636720a /ext/unicorn_http/c_util.h
parentfc7c85fc446d4c3e33ea1694426a574c7c695566 (diff)
downloadunicorn-8296cd0fff593364698e3a8ca3905103eee131ee.tar.gz
SIZEOF_*, *2NUM and NUM2* should all be defined by ruby.h and
dependencies it pulls in since Ruby 2.0 and possibly earlier.

INT_MAX and LLONG_MAX are in limits.h which is POSIX.

HAVE_GMTIME_R is already defined by ruby/config.h, so we
shouldn't have to check for it, either.

Combined, these changes speed up extconf.rb by several seconds.
Diffstat (limited to 'ext/unicorn_http/c_util.h')
-rw-r--r--ext/unicorn_http/c_util.h18
1 files changed, 5 insertions, 13 deletions
diff --git a/ext/unicorn_http/c_util.h b/ext/unicorn_http/c_util.h
index ab1fc0e..5774615 100644
--- a/ext/unicorn_http/c_util.h
+++ b/ext/unicorn_http/c_util.h
@@ -8,23 +8,15 @@
 
 #include <unistd.h>
 #include <assert.h>
+#include <limits.h>
 
 #define MIN(a,b) (a < b ? a : b)
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
-#ifndef SIZEOF_OFF_T
-#  define SIZEOF_OFF_T 4
-#  warning SIZEOF_OFF_T not defined, guessing 4.  Did you run extconf.rb?
-#endif
-
-#if SIZEOF_OFF_T == 4
-#  define UH_OFF_T_MAX 0x7fffffff
-#elif SIZEOF_OFF_T == 8
-#  if SIZEOF_LONG == 4
-#    define UH_OFF_T_MAX 0x7fffffffffffffffLL
-#  else
-#    define UH_OFF_T_MAX 0x7fffffffffffffff
-#  endif
+#if SIZEOF_OFF_T == SIZEOF_INT
+#  define UH_OFF_T_MAX INT_MAX
+#elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
+#  define UH_OFF_T_MAX LLONG_MAX
 #else
 #  error off_t size unknown for this platform!
 #endif /* SIZEOF_OFF_T check */