/* Library support for -fsplit-stack. */
-/* Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2009-2017 Free Software Foundation, Inc.
Contributed by Ian Lance Taylor <iant@google.com>.
This file is part of GCC.
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+/* powerpc 32-bit not supported. */
+#if !defined __powerpc__ || defined __powerpc64__
+
#include "tconfig.h"
#include "tsystem.h"
#include "coretypes.h"
{
void *guard;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
guard = space;
space = (char *) space + pagesize;
#else
to the nearest 512 byte boundary. It's not essential that we be
precise here; getting it wrong will just leave some stack space
unused. */
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
sp = (void *) ((((__UINTPTR_TYPE__) sp + 511U) / 512U) * 512U);
#else
sp = (void *) ((((__UINTPTR_TYPE__) sp - 511U) / 512U) * 512U);
char *to;
void *ret;
size_t i;
+ size_t aligned;
current = __morestack_current_segment;
*pframe_size = current->size - param_size;
-#ifdef STACK_GROWS_DOWNWARD
+ /* Align the returned stack to a 32-byte boundary. */
+ aligned = (param_size + 31) & ~ (size_t) 31;
+
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
{
char *bottom = (char *) (current + 1) + current->size;
- to = bottom - param_size;
- ret = bottom - param_size;
+ to = bottom - aligned;
+ ret = bottom - aligned;
}
#else
to = current + 1;
- ret = (char *) (current + 1) + param_size;
+ to += aligned - param_size;
+ ret = (char *) (current + 1) + aligned;
#endif
/* We don't call memcpy to avoid worrying about the dynamic linker
if (current != NULL)
{
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
*pavailable = (char *) old_stack - (char *) (current + 1);
#else
*pavailable = (char *) (current + 1) + current->size - (char *) old_stack;
size_t used;
/* We have popped back to the original stack. */
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
if ((char *) old_stack >= (char *) __morestack_initial_sp.sp)
used = 0;
else
&& (char *) pss + pss->size > (char *) stack)
{
__morestack_current_segment = pss;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
return (char *) stack - (char *) (pss + 1);
#else
return (char *) (pss + 1) + pss->size - (char *) stack;
if (__morestack_initial_sp.sp == NULL)
return 0;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
if ((char *) stack >= (char *) __morestack_initial_sp.sp)
used = 0;
else
*next_segment = (void *) (uintptr_type) 2;
*next_sp = NULL;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
if ((char *) sp >= isp)
return NULL;
*len = (char *) isp - (char *) sp;
nsp -= 12 * sizeof (void *);
#elif defined (__i386__)
nsp -= 6 * sizeof (void *);
+#elif defined __powerpc64__
+#elif defined __s390x__
+ nsp -= 2 * 160;
+#elif defined __s390__
+ nsp -= 2 * 96;
#else
#error "unrecognized target"
#endif
*next_sp = (void *) nsp;
}
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
*len = (char *) (segment + 1) + segment->size - (char *) sp;
ret = (void *) sp;
#else
segment = allocate_segment (stack_size);
context[MORESTACK_SEGMENTS] = segment;
context[CURRENT_SEGMENT] = segment;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
initial_sp = (void *) ((char *) (segment + 1) + segment->size);
#else
initial_sp = (void *) (segment + 1);
initial_sp = context[INITIAL_SP];
initial_size = (uintptr_type) context[INITIAL_SP_LEN];
ret = initial_sp;
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
ret = (void *) ((char *) ret - initial_size);
#endif
}
else
{
-#ifdef STACK_GROWS_DOWNWARD
+#ifdef __LIBGCC_STACK_GROWS_DOWNWARD__
initial_sp = (void *) ((char *) (segment + 1) + segment->size);
#else
initial_sp = (void *) (segment + 1);
void
__splitstack_releasecontext (void *context[10])
{
- __morestack_release_segments (context[MORESTACK_SEGMENTS], 1);
+ __morestack_release_segments (((struct stack_segment **)
+ &context[MORESTACK_SEGMENTS]),
+ 1);
}
/* Like __splitstack_block_signals, but operating on CONTEXT, rather
}
#endif /* !defined (inhibit_libc) */
+#endif /* not powerpc 32-bit */