diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-18 21:44:17 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-19 12:52:10 +0900 |
| commit | 959383df75091668bfe4cea5529df676154242e3 (patch) | |
| tree | f54cf9cabdd39625c583940198a99b13e1ae007f | |
| parent | ef66406c507639871797e53e7bf82898c21ca022 (diff) | |
| download | mruby-959383df75091668bfe4cea5529df676154242e3.tar.gz mruby-959383df75091668bfe4cea5529df676154242e3.zip | |
value.h: enable `mrb_ro_data_p()` on `__linux__` and `__APPLE__`.
Probably we should add conditions for FreeBSD, etc.
| -rw-r--r-- | include/mruby/value.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/mruby/value.h b/include/mruby/value.h index 35d4b7005..c90c4cbb5 100644 --- a/include/mruby/value.h +++ b/include/mruby/value.h @@ -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 |
