Skip to content

Commit 41b64fc

Browse files
author
Ulrich Drepper
committed
Update.
2000-12-31 Ulrich Drepper <[email protected]> * sysdeps/powerpc/pspinlock.c: Don't include pt-machine.h here. * manager.c (pthread_allocate_stack): Prepare for removal of MAP_FIXED.
1 parent 09f5e16 commit 41b64fc

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

linuxthreads/ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2000-12-31 Ulrich Drepper <[email protected]>
2+
3+
* sysdeps/powerpc/pspinlock.c: Don't include pt-machine.h here.
4+
5+
* manager.c (pthread_allocate_stack): Prepare for removal of MAP_FIXED.
6+
17
2000-11-15 Wolfram Gloger <[email protected]>
28

39
* manager.c (pthread_free): [!FLOATING_STACKS]: Only remap the

linuxthreads/manager.c

+31-15
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
345345

346346
/* Allocate space for stack and thread descriptor at default address */
347347
#ifdef NEED_SEPARATE_REGISTER_STACK
348+
void *res_addr;
349+
348350
if (attr != NULL)
349351
{
350352
guardsize = page_roundup (attr->__guardsize, granularity);
@@ -371,18 +373,26 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
371373
/* XXX Fix for floating stacks with variable sizes. */
372374

373375
/* First the main stack: */
374-
if (mmap((caddr_t)((char *)(new_thread + 1) - stacksize / 2),
375-
stacksize / 2, PROT_READ | PROT_WRITE | PROT_EXEC,
376-
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)
377-
== MAP_FAILED)
378-
/* Bad luck, this segment is already mapped. */
379-
return -1;
376+
map_addr = (caddr_t)((char *)(new_thread + 1) - stacksize / 2);
377+
res_addr = mmap(map_addr, stacksize / 2,
378+
PROT_READ | PROT_WRITE | PROT_EXEC,
379+
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
380+
if (res_addr != map_addr)
381+
{
382+
/* Bad luck, this segment is already mapped. */
383+
if (res_addr != MAP_FAILED)
384+
munmap(res_addr, stacksize / 2);
385+
return -1;
386+
}
380387
/* Then the register stack: */
381-
if (mmap((caddr_t)new_thread_bottom, stacksize/2,
382-
PROT_READ | PROT_WRITE | PROT_EXEC,
383-
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)
384-
== MAP_FAILED)
388+
map_addr = (caddr_t)new_thread_bottom;
389+
res_addr = mmap(map_addr, stacksize/2,
390+
PROT_READ | PROT_WRITE | PROT_EXEC,
391+
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXES, -1, 0);
392+
if (res_addr != map_addr)
385393
{
394+
if (res_addr != MAP_FAILED)
395+
munmap(res_addr, stacksize / 2);
386396
munmap((caddr_t)((char *)(new_thread + 1) - stacksize/2),
387397
stacksize/2);
388398
return -1;
@@ -419,6 +429,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
419429
new_thread_bottom = (char *) map_addr + guardsize;
420430
new_thread = ((pthread_descr) (new_thread_bottom + stacksize)) - 1;
421431
# else /* !FLOATING_STACKS */
432+
void *res_addr;
433+
422434
if (attr != NULL)
423435
{
424436
guardsize = page_roundup (attr->__guardsize, granularity);
@@ -434,13 +446,17 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
434446

435447
new_thread = default_new_thread;
436448
new_thread_bottom = (char *) (new_thread + 1) - stacksize;
437-
map_addr = mmap((caddr_t)((char *)(new_thread + 1) - stacksize - guardsize),
438-
stacksize + guardsize,
449+
map_addr = new_thread_bottom - guardsize;
450+
res_addr = mmap(map_addr, stacksize + guardsize,
439451
PROT_READ | PROT_WRITE | PROT_EXEC,
440452
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
441-
if (map_addr == MAP_FAILED)
442-
/* Bad luck, this segment is already mapped. */
443-
return -1;
453+
if (res_addr != map_addr)
454+
{
455+
/* Bad luck, this segment is already mapped. */
456+
if (res_addr != MAP_FAILED)
457+
munmap (res_addr, stacksize + guardsize);
458+
return -1;
459+
}
444460

445461
/* We manage to get a stack. Protect the guard area pages if
446462
necessary. */

linuxthreads/sysdeps/powerpc/pspinlock.c

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include <errno.h>
2121
#include <pthread.h>
22-
#include <pt-machine.h>
2322
#include "internals.h"
2423

2524
int

0 commit comments

Comments
 (0)