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 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ext/unicorn_http/ext_help.h') 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 -- cgit v1.2.3-24-ge0c7