summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads.old/internals.h
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/linuxthreads.old/internals.h')
-rw-r--r--libpthread/linuxthreads.old/internals.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index 637fcea62..110dd9d56 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -252,17 +252,25 @@ extern pthread_descr __pthread_main_thread;
Initially 0, meaning that the current thread is (by definition)
the initial thread. */
-/* For non-MMU systems also remember to stack top of the initial thread.
- * This is adapted when other stacks are malloc'ed since we don't know
- * the bounds a-priori. -StS */
-
extern char *__pthread_initial_thread_bos;
#ifndef __ARCH_USE_MMU__
-extern char *__pthread_initial_thread_tos;
+/* For non-MMU systems, we have no idea the bounds of the initial thread
+ * stack, so we have to track it on the fly relative to other stacks. Do
+ * so by scaling back our assumptions on the limits of the bos/tos relative
+ * to the known mid point. See also the comments in pthread_initialize(). */
+extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid;
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
- if ((tos)>=__pthread_initial_thread_bos \
- && (bos)<__pthread_initial_thread_tos) \
- __pthread_initial_thread_bos = (tos)+1
+ do { \
+ char *__tos = (tos); \
+ char *__bos = (bos); \
+ if (__tos >= __pthread_initial_thread_bos && \
+ __bos < __pthread_initial_thread_tos) { \
+ if (__bos < __pthread_initial_thread_mid) \
+ __pthread_initial_thread_bos = __tos; \
+ else \
+ __pthread_initial_thread_tos = __bos; \
+ } \
+ } while (0)
#else
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
#endif /* __ARCH_USE_MMU__ */