From 718d5e9b6c863e388984e641d36b6e6cbacd99c7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 12:30:34 -0700 Subject: unicorn_http: add helpful macros We'll be needing the UH_OFF_T_MAX define for the chunked body handling and rb_str_set_len may be needed as well. --- ext/unicorn_http/ext_help.h | 23 +++++++++++++++++++++++ ext/unicorn_http/extconf.rb | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h index 8220600..8ccb2b9 100644 --- a/ext/unicorn_http/ext_help.h +++ b/ext/unicorn_http/ext_help.h @@ -10,4 +10,27 @@ #define RSTRING_LEN(s) (RSTRING(s)->len) #endif +#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 +# define UH_OFF_T_MAX 0x7fffffffffffffff +#else +# error off_t size unknown for this platform! +#endif + +#ifndef HAVE_RB_STR_SET_LEN +/* this is taken from Ruby 1.8.7, 1.8.6 may not have it */ +static void rb_18_str_set_len(VALUE str, long len) +{ + RSTRING(str)->len = len; + RSTRING(str)->ptr[len] = '\0'; +} +# define rb_str_set_len(str,len) rb_18_str_set_len(str,len) +#endif + #endif diff --git a/ext/unicorn_http/extconf.rb b/ext/unicorn_http/extconf.rb index 29d9334..39bd510 100644 --- a/ext/unicorn_http/extconf.rb +++ b/ext/unicorn_http/extconf.rb @@ -1,5 +1,6 @@ require 'mkmf' dir_config("unicorn_http") -have_library("c", "main") +check_sizeof("off_t", "sys/types.h") +have_func("rb_str_set_len", "ruby.h") create_makefile("unicorn_http") -- cgit v1.2.3-24-ge0c7