4 /* not all Ruby implementations support frozen objects (Rubinius does not) */
5 #if defined(OBJ_FROZEN)
6 # define assert_frozen(f) assert(OBJ_FROZEN(f) && "unfrozen object")
8 # define assert_frozen(f) do {} while (0)
9 #endif /* !defined(OBJ_FROZEN) */
11 #if !defined(OFFT2NUM)
12 # if SIZEOF_OFF_T == SIZEOF_LONG
13 # define OFFT2NUM(n) LONG2NUM(n)
15 # define OFFT2NUM(n) LL2NUM(n)
17 #endif /* ! defined(OFFT2NUM) */
19 #if !defined(SIZET2NUM)
20 # if SIZEOF_SIZE_T == SIZEOF_LONG
21 # define SIZET2NUM(n) ULONG2NUM(n)
23 # define SIZET2NUM(n) ULL2NUM(n)
25 #endif /* ! defined(SIZET2NUM) */
27 #if !defined(NUM2SIZET)
28 # if SIZEOF_SIZE_T == SIZEOF_LONG
29 # define NUM2SIZET(n) ((size_t)NUM2ULONG(n))
31 # define NUM2SIZET(n) ((size_t)NUM2ULL(n))
33 #endif /* ! defined(NUM2SIZET) */
35 static inline int str_cstr_eq(VALUE val
, const char *ptr
, long len
)
37 return (RSTRING_LEN(val
) == len
&& !memcmp(ptr
, RSTRING_PTR(val
), len
));
40 #define STR_CSTR_EQ(val, const_str) \
41 str_cstr_eq(val, const_str, sizeof(const_str) - 1)
43 /* strcasecmp isn't locale independent */
44 static int str_cstr_case_eq(VALUE val
, const char *ptr
, long len
)
46 if (RSTRING_LEN(val
) == len
) {
47 const char *v
= RSTRING_PTR(val
);
49 for (; len
--; ++ptr
, ++v
) {
50 if ((*ptr
== *v
) || (*v
>= 'A' && *v
<= 'Z' && (*v
| 0x20) == *ptr
))
59 #define STR_CSTR_CASE_EQ(val, const_str) \
60 str_cstr_case_eq(val, const_str, sizeof(const_str) - 1)
62 #endif /* ext_help_h */