File 0847-Move-the-check-for-stack-direction-to-utils.c.patch of Package erlang
From 322d954a38fe86137045d074009f5329d04ff0a8 Mon Sep 17 00:00:00 2001
From: Sergei Golovan <sgolovan@gmail.com>
Date: Wed, 2 Oct 2019 11:06:51 +0300
Subject: [PATCH 4/4] Move the check for stack direction to utils.c
---
erts/emulator/beam/erl_bif_re.c | 12 +-----------
erts/emulator/beam/global.h | 1 +
erts/emulator/beam/utils.c | 8 ++++++++
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c
index d22ba1ce11..c66f688f1c 100644
--- a/erts/emulator/beam/erl_bif_re.c
+++ b/erts/emulator/beam/erl_bif_re.c
@@ -90,16 +90,6 @@ stack_guard_upwards(void)
return erts_check_above_limit(&c, limit - ERTS_PCRE_STACK_MARGIN);
}
-static ERTS_NOINLINE
-int stack_grows_downwards(char *prev_c)
-{
- char c;
- if (erts_check_below_limit(&c, prev_c))
- return 1;
- else
- return 0;
-}
-
void erts_init_bif_re(void)
{
char c;
@@ -107,7 +97,7 @@ void erts_init_bif_re(void)
erts_pcre_free = &erts_erts_pcre_free;
erts_pcre_stack_malloc = &erts_erts_pcre_stack_malloc;
erts_pcre_stack_free = &erts_erts_pcre_stack_free;
- if (stack_grows_downwards(&c))
+ if (erts_check_if_stack_grows_downwards(&c))
erts_pcre_stack_guard = stack_guard_downwards;
else
erts_pcre_stack_guard = stack_guard_upwards;
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index 40c65461bc..5594c372db 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -1253,6 +1253,7 @@ void *erts_calc_stacklimit(char *prev_c, UWord stacksize) ERTS_NOINLINE;
int erts_check_below_limit(char *ptr, char *limit) ERTS_NOINLINE;
int erts_check_above_limit(char *ptr, char *limit) ERTS_NOINLINE;
void *erts_ptr_id(void *ptr) ERTS_NOINLINE;
+int erts_check_if_stack_grows_downwards(char *ptr) ERTS_NOINLINE;
Eterm store_external_or_ref_in_proc_(Process *, Eterm);
Eterm store_external_or_ref_(Uint **, ErlOffHeap*, Eterm);
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index 0bbae65e28..9fb37f77fc 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -4789,3 +4789,11 @@ erts_ptr_id(void *ptr)
return ptr;
}
+int erts_check_if_stack_grows_downwards(char *ptr)
+{
+ char c;
+ if (erts_check_below_limit(&c, ptr))
+ return 1;
+ else
+ return 0;
+}
--
2.16.4