ISO C99 doesn't support unnamed unions; fix
MODIFY
include/mruby/boxing_word.h
include/mruby/boxing_word.h
@@ -84,9 +84,9 @@ union mrb_value_ {
struct {
MRB_ENDIAN_LOHI(
mrb_sym sym;
- ,uint32_t sym_flag;
+ ,uint32_t flag;
)
- };
+ } sym;
#endif
struct RBasic *bp;
#ifndef MRB_NO_FLOAT
@@ -129,7 +129,7 @@ mrb_integer_func(mrb_value o) {
}
#define mrb_integer(o) mrb_integer_func(o)
#ifdef MRB_64BIT
-#define mrb_symbol(o) mrb_val_union(o).sym
+#define mrb_symbol(o) mrb_val_union(o).sym.sym
#else
#define mrb_symbol(o) (mrb_sym)(((o).w) >> BOXWORD_SYMBOL_SHIFT)
#endif
@@ -138,7 +138,7 @@ mrb_integer_func(mrb_value o) {
#define mrb_fixnum_p(o) BOXWORD_SHIFT_VALUE_P(o, FIXNUM)
#define mrb_integer_p(o) (BOXWORD_SHIFT_VALUE_P(o, FIXNUM)||BOXWORD_OBJ_TYPE_P(o, INTEGER))
#ifdef MRB_64BIT
-#define mrb_symbol_p(o) (mrb_val_union(o).sym_flag == BOXWORD_SYMBOL_FLAG)
+#define mrb_symbol_p(o) (mrb_val_union(o).sym.flag == BOXWORD_SYMBOL_FLAG)
#else
#define mrb_symbol_p(o) BOXWORD_SHIFT_VALUE_P(o, SYMBOL)
#endif
@@ -182,8 +182,8 @@ mrb_integer_func(mrb_value o) {
#ifdef MRB_64BIT
#define SET_SYM_VALUE(r,v) do {\
union mrb_value_ mrb_value_union_variable;\
- mrb_value_union_variable.sym = v;\
- mrb_value_union_variable.sym_flag = BOXWORD_SYMBOL_FLAG;\
+ mrb_value_union_variable.sym.sym = v;\
+ mrb_value_union_variable.sym.flag = BOXWORD_SYMBOL_FLAG;\
(r) = mrb_value_union_variable.value;\
} while (0)
#else

MODIFY
include/mruby/hash.h
include/mruby/hash.h
@@ -29,7 +29,7 @@ struct RHash {
union {
struct hash_entry *ea;
struct hash_table *ht;
- };
+ } hsh;
};
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))

MODIFY
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
#define MIRB_USING_HISTORY()
#endif
-#ifndef _WIN32
+#if !defined(_WIN32) && defined(_POSIX_C_SOURCE)
#define MIRB_SIGSETJMP(env) sigsetjmp(env, 1)
#define MIRB_SIGLONGJMP(env, val) siglongjmp(env, val)
#define SIGJMP_BUF sigjmp_buf

MODIFY
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
@@ -125,7 +125,7 @@ gettimeofday(struct timeval *tv, void *tz)
# include <sys/time.h>
# endif
#endif
-#ifdef NO_GMTIME_R
+#if !(defined(_POSIX_C_SOURCE) || defined(_BSD_SOURCE) || defined(_SVID_SOURCE))
#define gmtime_r(t,r) gmtime(t)
#define localtime_r(t,r) localtime(t)
#endif
@@ -383,7 +383,7 @@ current_mrb_time(mrb_state *mrb)
sec = ts.tv_sec;
usec = ts.tv_nsec / 1000;
}
-#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && defined(_POSIX_MONOTONIC_CLOCK)
+#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && defined(CLOCK_MONOTONIC)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);

MODIFY
src/hash.c
src/hash.c
@@ -151,20 +151,20 @@ DEFINE_ACCESSOR(ht, ea_n_used, uint32_t, ea_n_used)
#else
DEFINE_FLAG_ACCESSOR(ar, ea_capa, uint32_t, AR_EA_CAPA)
DEFINE_FLAG_ACCESSOR(ar, ea_n_used, uint32_t, AR_EA_N_USED)
-DEFINE_ACCESSOR(ht, ea_capa, uint32_t, ht->ea_capa)
-DEFINE_ACCESSOR(ht, ea_n_used, uint32_t, ht->ea_n_used)
+DEFINE_ACCESSOR(ht, ea_capa, uint32_t, hsh.ht->ea_capa)
+DEFINE_ACCESSOR(ht, ea_n_used, uint32_t, hsh.ht->ea_n_used)
#endif
DEFINE_FLAG_ACCESSOR(ib, bit, uint32_t, IB_BIT)
DEFINE_ACCESSOR(ar, size, uint32_t, size)
-DEFINE_ACCESSOR(ar, ea, hash_entry*, ea)
+DEFINE_ACCESSOR(ar, ea, hash_entry*, hsh.ea)
DEFINE_DECREMENTER(ar, size)
DEFINE_ACCESSOR(ht, size, uint32_t, size)
-DEFINE_ACCESSOR(ht, ea, hash_entry*, ht->ea)
-DEFINE_GETTER(ht, ib, uint32_t*, ht->ib)
+DEFINE_ACCESSOR(ht, ea, hash_entry*, hsh.ht->ea)
+DEFINE_GETTER(ht, ib, uint32_t*, hsh.ht->ib)
DEFINE_INCREMENTER(ht, size)
DEFINE_DECREMENTER(ht, size)
DEFINE_GETTER(h, size, uint32_t, size)
-DEFINE_ACCESSOR(h, ht, hash_table*, ht)
+DEFINE_ACCESSOR(h, ht, hash_table*, hsh.ht)
DEFINE_SWITCHER(ht, HT)
#define ea_each_used(ea, n_used, entry_var, code) do { \
@@ -234,9 +234,9 @@ DEFINE_SWITCHER(ht, HT)
* `h_check_modified` raises an exception when a dangerous modification is
* made to `h` by executing `code`.
*
- * `h_check_modified` macro is not called if `h->ht` (`h->ea`) is `NULL`
+ * `h_check_modified` macro is not called if `h->hsh.ht` (`h->hsh.ea`) is `NULL`
* (`Hash` size is zero). And because the `hash_entry` is rather large,
- * `h->ht->ea` and `h->ht->ea_capa` are able to be safely accessed even for
+ * `h->hsh.ht->ea` and `h->hsh.ht->ea_capa` are able to be safely accessed even for
* AR. This nature is used to eliminate branch of AR or HT.
*
* `HT_ASSERT_SAFE_READ` checks if members can be accessed according to its
@@ -261,7 +261,7 @@ HT_ASSERT_SAFE_READ(ea_capa);
struct RHash *h__ = h; \
uint32_t mask__ = MRB_HASH_HT|MRB_HASH_IB_BIT_MASK|MRB_HASH_AR_EA_CAPA_MASK; \
uint32_t flags__ = h__->flags & mask__; \
- void* tbl__ = (mrb_assert(h__->ht), h__->ht); \
+ void* tbl__ = (mrb_assert(h__->hsh.ht), h__->hsh.ht); \
uint32_t ht_ea_capa__ = 0; \
hash_entry *ht_ea__ = NULL; \
if (H_CHECK_MODIFIED_USE_HT_EA_CAPA_FOR_AR || h_ht_p(h__)) { \
@@ -272,7 +272,7 @@ HT_ASSERT_SAFE_READ(ea_capa);
} \
code; \
if (flags__ != (h__->flags & mask__) || \
- tbl__ != h__->ht || \
+ tbl__ != h__->hsh.ht || \
((H_CHECK_MODIFIED_USE_HT_EA_CAPA_FOR_AR || h_ht_p(h__)) && \
ht_ea_capa__ != ht_ea_capa(h__)) || \
((H_CHECK_MODIFIED_USE_HT_EA_FOR_AR || h_ht_p(h__)) && \

ISO C99 doesn't support unnamed unions; fix #5354