@@ -33,47 +33,6 @@
#include <kernel-features.h>
-#ifndef NEED_SEPARATE_REGISTER_STACK
-
-/* Most architectures have exactly one stack pointer. Some have more. */
-# define STACK_VARIABLES void *stackaddr = NULL
-
-/* How to pass the values to the 'create_thread' function. */
-# define STACK_VARIABLES_ARGS stackaddr
-
-/* How to declare function which gets there parameters. */
-# define STACK_VARIABLES_PARMS void *stackaddr
-
-/* How to declare allocate_stack. */
-# define ALLOCATE_STACK_PARMS void **stack
-
-/* This is how the function is called. We do it this way to allow
- other variants of the function to have more parameters. */
-# define ALLOCATE_STACK(attr, pd) allocate_stack (attr, pd, &stackaddr)
-
-#else
-
-/* We need two stacks. The kernel will place them but we have to tell
- the kernel about the size of the reserved address space. */
-# define STACK_VARIABLES void *stackaddr = NULL; size_t stacksize = 0
-
-/* How to pass the values to the 'create_thread' function. */
-# define STACK_VARIABLES_ARGS stackaddr, stacksize
-
-/* How to declare function which gets there parameters. */
-# define STACK_VARIABLES_PARMS void *stackaddr, size_t stacksize
-
-/* How to declare allocate_stack. */
-# define ALLOCATE_STACK_PARMS void **stack, size_t *stacksize
-
-/* This is how the function is called. We do it this way to allow
- other variants of the function to have more parameters. */
-# define ALLOCATE_STACK(attr, pd) \
- allocate_stack (attr, pd, &stackaddr, &stacksize)
-
-#endif
-
-
/* Default alignment of stack. */
#ifndef STACK_ALIGN
# define STACK_ALIGN __alignof__ (long double)
@@ -361,7 +320,7 @@ advise_stack_range (void *mem, size_t size, uintptr_t pd, size_t guardsize)
PDP must be non-NULL. */
static int
allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
- ALLOCATE_STACK_PARMS)
+ void **stack, size_t *stacksize)
{
struct pthread *pd;
size_t size;
@@ -709,25 +668,17 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* We place the thread descriptor at the end of the stack. */
*pdp = pd;
-#if _STACK_GROWS_DOWN
void *stacktop;
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* The stack begins before the TCB and the static TLS block. */
stacktop = ((char *) (pd + 1) - __static_tls_size);
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
stacktop = (char *) (pd - 1);
-# endif
+#endif
-# ifdef NEED_SEPARATE_REGISTER_STACK
+ *stacksize = stacktop - pd->stackblock;
*stack = pd->stackblock;
- *stacksize = stacktop - *stack;
-# else
- *stack = stacktop;
-# endif
-#else
- *stack = pd->stackblock;
-#endif
return 0;
}
@@ -25,7 +25,8 @@
static int
create_thread (struct pthread *pd, const struct pthread_attr *attr,
- bool *stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran)
+ bool *stopped_start, void *stackaddr, size_t stacksize,
+ bool *thread_ran)
{
/* If the implementation needs to do some tweaks to the thread after
it has been created at the OS level, it can set STOPPED_START here. */
@@ -205,8 +205,8 @@ static struct rtld_global *__nptl_rtld_global __attribute_used__
be set to true iff the thread actually started up and then got
canceled before calling user code (*PD->start_routine). */
static int create_thread (struct pthread *pd, const struct pthread_attr *attr,
- bool *stopped_start, STACK_VARIABLES_PARMS,
- bool *thread_ran);
+ bool *stopped_start, void *stackaddr,
+ size_t stacksize, bool *thread_ran);
#include <createthread.c>
@@ -531,7 +531,8 @@ int
__pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
- STACK_VARIABLES;
+ void *stackaddr = NULL;
+ size_t stacksize = 0;
/* Avoid a data race in the multi-threaded case. */
if (__libc_single_threaded)
@@ -551,7 +552,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
}
struct pthread *pd = NULL;
- int err = ALLOCATE_STACK (iattr, &pd);
+ int err = allocate_stack (iattr, &pd, &stackaddr, &stacksize);
int retval = 0;
if (__glibc_unlikely (err != 0))
@@ -696,8 +697,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
/* We always create the thread stopped at startup so we can
notify the debugger. */
- retval = create_thread (pd, iattr, &stopped_start,
- STACK_VARIABLES_ARGS, &thread_ran);
+ retval = create_thread (pd, iattr, &stopped_start, stackaddr,
+ stacksize, &thread_ran);
if (retval == 0)
{
/* We retain ownership of PD until (a) (see CONCURRENCY NOTES
@@ -728,8 +729,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
}
}
else
- retval = create_thread (pd, iattr, &stopped_start,
- STACK_VARIABLES_ARGS, &thread_ran);
+ retval = create_thread (pd, iattr, &stopped_start, stackaddr,
+ stacksize, &thread_ran);
/* Return to the previous signal mask, after creating the new
thread. */