mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
value.h: enable mrb_ro_data_p() on __linux__ and __APPLE__.
Probably we should add conditions for FreeBSD, etc.
This commit is contained in:
@@ -418,7 +418,7 @@ mrb_undef_value(void)
|
||||
#if defined(MRB_USE_CUSTOM_RO_DATA_P)
|
||||
/* If you define `MRB_USE_CUSTOM_RO_DATA_P`, you must implement `mrb_ro_data_p()`. */
|
||||
mrb_bool mrb_ro_data_p(const char *p);
|
||||
#elif defined(MRB_USE_LINK_TIME_RO_DATA_P)
|
||||
#elif defined(MRB_USE_LINK_TIME_RO_DATA_P) || defined(__linux__)
|
||||
extern char __ehdr_start[];
|
||||
extern char __init_array_start[];
|
||||
|
||||
@@ -427,6 +427,13 @@ mrb_ro_data_p(const char *p)
|
||||
{
|
||||
return __ehdr_start < p && p < __init_array_start;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#include <mach-o/getsect.h>;
|
||||
static inline mrb_bool
|
||||
mrb_ro_data_p(const char *p)
|
||||
{
|
||||
return (void*)get_edata() < p && p < (void*)get_end();
|
||||
}
|
||||
#else
|
||||
# define mrb_ro_data_p(p) FALSE
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user