summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-09-09 16:15:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-09-09 16:15:25 +0900
commit49602f636d68ae34342b35121a85f50838ea92f3 (patch)
tree5d3f29294683d41518ee65b243fc6abf2b57ba8f /include
parent5dd8b04d91023dd2330833e141614f90f51d78e9 (diff)
downloadmruby-49602f636d68ae34342b35121a85f50838ea92f3.tar.gz
mruby-49602f636d68ae34342b35121a85f50838ea92f3.zip
value.h: add configuration macros around `mrb_ro_data_p()`; close #5547
- `MRB_USE_ETEXT_RO_DATA_P`: use `etext` and `edata` - `MRB_NO_DEFAULT_RO_DATA_P`: not use the default `mrb_ro_data_p()`
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h10
-rw-r--r--include/mruby/value.h7
2 files changed, 15 insertions, 2 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index df3f2989e..edc81d74d 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -113,6 +113,16 @@
/* number of object per heap page */
//#define MRB_HEAP_PAGE_SIZE 1024
+/* define if your platform does not support etext, edata */
+//#define MRB_NO_DEFAULT_RO_DATA_P
+
+/* define if your platform supports etext, edata */
+//#define MRB_USE_RO_DATA_P_ETEXT
+/* use MRB_USE_ETEXT_RO_DATA_P by default on Linux */
+#if (defined(__linux__) && !defined(__KERNEL__))
+#define MRB_USE_ETEXT_RO_DATA_P
+#endif
+
/* you can provide and use mrb_ro_data_p() for your platform.
prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */
//#define MRB_USE_CUSTOM_RO_DATA_P
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 733674b3a..6e0475ddd 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -411,7 +411,8 @@ 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(__linux__) && !defined(__KERNEL__))
+#elif !defined(MRB_NO_DEFAULT_RO_DATA_P)
+#if defined(MRB_USE_ETEXT_RO_DATA_P)
#define MRB_LINK_TIME_RO_DATA_P
extern char etext, edata;
static inline mrb_bool
@@ -427,7 +428,9 @@ mrb_ro_data_p(const char *p)
{
return (char*)get_etext() < p && p < (char*)get_edata();
}
-#else
+#endif /* Linux or macOS */
+#endif /* MRB_NO_DEFAULT_RO_DATA_P */
+#ifndef MRB_LINK_TIME_RO_DATA_P
# define mrb_ro_data_p(p) FALSE
#endif