From 0b41cd9475f8cde8154f4fcd0d336ae78356c2c9 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Thu, 5 Nov 2015 22:40:44 +0200 Subject: [PATCH] Genconfig DUK_LOSE_CONST (unused initially) --- config/genconfig.py | 4 ++++ config/header-snippets/loseconst.h.in | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 config/header-snippets/loseconst.h.in diff --git a/config/genconfig.py b/config/genconfig.py index 6a7bbf87..8a451195 100644 --- a/config/genconfig.py +++ b/config/genconfig.py @@ -1058,6 +1058,8 @@ def generate_autodetect_duk_config_header(opts, meta_dir): ret.empty() ret.snippet_relative('unreferenced.h.in') ret.empty() + ret.snippet_relative('loseconst.h.in') + ret.empty() ret.snippet_relative('noreturn.h.in') ret.empty() ret.snippet_relative('unreachable.h.in') @@ -1421,6 +1423,8 @@ def generate_autodetect_duk_config_header_modular(opts, meta_dir): ret.empty() ret.snippet_relative('unreferenced.h.in') ret.empty() + ret.snippet_relative('loseconst.h.in') + ret.empty() ret.snippet_relative('noreturn.h.in') ret.empty() ret.snippet_relative('unreachable.h.in') diff --git a/config/header-snippets/loseconst.h.in b/config/header-snippets/loseconst.h.in new file mode 100644 index 00000000..3850d849 --- /dev/null +++ b/config/header-snippets/loseconst.h.in @@ -0,0 +1,5 @@ +/* Convert any input pointer into a "void *", losing a const qualifier. + * This is not fully portable because casting through duk_uintptr_t may + * not work on all architectures (e.g. those with long, segmented pointers). + */ +#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))