From ebc2093847705c382b4d83ed5120e44b9afad3c0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Feb 2011 19:24:53 -0800 Subject: split out RSTRUCT* compat macros We might reuse that for other code... --- ext/raindrops/linux_inet_diag.c | 16 +--------------- ext/raindrops/rstruct_19.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 ext/raindrops/rstruct_19.h diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c index 78859cb..9e42c64 100644 --- a/ext/raindrops/linux_inet_diag.c +++ b/ext/raindrops/linux_inet_diag.c @@ -8,22 +8,8 @@ #ifndef RSTRING_LEN # define RSTRING_LEN(s) (RSTRING(s)->len) #endif -#ifdef RSTRUCT -# ifndef RSTRUCT_PTR -# define RSTRUCT_PTR(s) (RSTRUCT(s)->ptr) -# endif -# ifndef RSTRUCT_LEN -# define RSTRUCT_LEN(s) (RSTRUCT(s)->len) -# endif -#endif -#ifndef HAVE_RB_STRUCT_ALLOC_NOINIT -static ID id_new; -static VALUE rb_struct_alloc_noinit(VALUE class) -{ - return rb_funcall(class, id_new, 0, 0); -} -#endif /* !defined(HAVE_RB_STRUCT_ALLOC_NOINIT) */ +#include "rstruct_19.h" /* partial emulation of the 1.9 rb_thread_blocking_region under 1.8 */ #ifndef HAVE_RB_THREAD_BLOCKING_REGION diff --git a/ext/raindrops/rstruct_19.h b/ext/raindrops/rstruct_19.h new file mode 100644 index 0000000..f156206 --- /dev/null +++ b/ext/raindrops/rstruct_19.h @@ -0,0 +1,17 @@ +#ifdef RSTRUCT +# ifndef RSTRUCT_PTR +# define RSTRUCT_PTR(s) (RSTRUCT(s)->ptr) +# endif +# ifndef RSTRUCT_LEN +# define RSTRUCT_LEN(s) (RSTRUCT(s)->len) +# endif +#endif + + +#ifndef HAVE_RB_STRUCT_ALLOC_NOINIT +static ID id_new; +static VALUE rb_struct_alloc_noinit(VALUE class) +{ + return rb_funcall(class, id_new, 0, 0); +} +#endif /* !defined(HAVE_RB_STRUCT_ALLOC_NOINIT) */ -- cgit v1.2.3-24-ge0c7