Lines 1-4
Link Here
|
1 |
/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc. |
1 |
/* Copyright (C) 2002-2007, 2009, 2010 Free Software Foundation, Inc. |
2 |
This file is part of the GNU C Library. |
2 |
This file is part of the GNU C Library. |
3 |
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. |
3 |
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. |
4 |
|
4 |
|
Lines 354-359
Link Here
|
354 |
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0)) |
354 |
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0)) |
355 |
{ |
355 |
{ |
356 |
uintptr_t adj; |
356 |
uintptr_t adj; |
|
|
357 |
#if _STACK_GROWS_DOWN |
358 |
char * stackaddr = (char *) attr->stackaddr; |
359 |
#else |
360 |
/* Assume the same layout as the _STACK_GROWS_DOWN case, |
361 |
with struct pthread at the top of the stack block. |
362 |
Later we adjust the guard location and stack address |
363 |
to match the _STACK_GROWS_UP case. */ |
364 |
char * stackaddr = (char *) attr->stackaddr + attr->stacksize; |
365 |
#endif |
357 |
|
366 |
|
358 |
/* If the user also specified the size of the stack make sure it |
367 |
/* If the user also specified the size of the stack make sure it |
359 |
is large enough. */ |
368 |
is large enough. */ |
Lines 363-373
Link Here
|
363 |
|
372 |
|
364 |
/* Adjust stack size for alignment of the TLS block. */ |
373 |
/* Adjust stack size for alignment of the TLS block. */ |
365 |
#if TLS_TCB_AT_TP |
374 |
#if TLS_TCB_AT_TP |
366 |
adj = ((uintptr_t) attr->stackaddr - TLS_TCB_SIZE) |
375 |
adj = ((uintptr_t) stackaddr - TLS_TCB_SIZE) |
367 |
& __static_tls_align_m1; |
376 |
& __static_tls_align_m1; |
368 |
assert (size > adj + TLS_TCB_SIZE); |
377 |
assert (size > adj + TLS_TCB_SIZE); |
369 |
#elif TLS_DTV_AT_TP |
378 |
#elif TLS_DTV_AT_TP |
370 |
adj = ((uintptr_t) attr->stackaddr - __static_tls_size) |
379 |
adj = ((uintptr_t) stackaddr - __static_tls_size) |
371 |
& __static_tls_align_m1; |
380 |
& __static_tls_align_m1; |
372 |
assert (size > adj); |
381 |
assert (size > adj); |
373 |
#endif |
382 |
#endif |
Lines 377-386
Link Here
|
377 |
the stack. It is the user's responsibility to do this if it |
386 |
the stack. It is the user's responsibility to do this if it |
378 |
is wanted. */ |
387 |
is wanted. */ |
379 |
#if TLS_TCB_AT_TP |
388 |
#if TLS_TCB_AT_TP |
380 |
pd = (struct pthread *) ((uintptr_t) attr->stackaddr |
389 |
pd = (struct pthread *) ((uintptr_t) stackaddr |
381 |
- TLS_TCB_SIZE - adj); |
390 |
- TLS_TCB_SIZE - adj); |
382 |
#elif TLS_DTV_AT_TP |
391 |
#elif TLS_DTV_AT_TP |
383 |
pd = (struct pthread *) (((uintptr_t) attr->stackaddr |
392 |
pd = (struct pthread *) (((uintptr_t) stackaddr |
384 |
- __static_tls_size - adj) |
393 |
- __static_tls_size - adj) |
385 |
- TLS_PRE_TCB_SIZE); |
394 |
- TLS_PRE_TCB_SIZE); |
386 |
#endif |
395 |
#endif |
Lines 392-398
Link Here
|
392 |
pd->specific[0] = pd->specific_1stblock; |
401 |
pd->specific[0] = pd->specific_1stblock; |
393 |
|
402 |
|
394 |
/* Remember the stack-related values. */ |
403 |
/* Remember the stack-related values. */ |
395 |
pd->stackblock = (char *) attr->stackaddr - size; |
404 |
pd->stackblock = (char *) stackaddr - size; |
396 |
pd->stackblock_size = size; |
405 |
pd->stackblock_size = size; |
397 |
|
406 |
|
398 |
/* This is a user-provided stack. It will not be queued in the |
407 |
/* This is a user-provided stack. It will not be queued in the |
Lines 617-623
Link Here
|
617 |
char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1); |
626 |
char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1); |
618 |
#elif _STACK_GROWS_DOWN |
627 |
#elif _STACK_GROWS_DOWN |
619 |
char *guard = mem; |
628 |
char *guard = mem; |
620 |
# elif _STACK_GROWS_UP |
629 |
#elif _STACK_GROWS_UP |
621 |
char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1); |
630 |
char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1); |
622 |
#endif |
631 |
#endif |
623 |
if (mprotect (guard, guardsize, PROT_NONE) != 0) |
632 |
if (mprotect (guard, guardsize, PROT_NONE) != 0) |
Lines 716-722
Link Here
|
716 |
*stack = stacktop; |
725 |
*stack = stacktop; |
717 |
#elif _STACK_GROWS_UP |
726 |
#elif _STACK_GROWS_UP |
718 |
*stack = pd->stackblock; |
727 |
*stack = pd->stackblock; |
719 |
assert (*stack > 0); |
|
|
720 |
#endif |
728 |
#endif |
721 |
|
729 |
|
722 |
return 0; |
730 |
return 0; |