summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch/powerpc/powerpc/pthread_md.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread/arch/powerpc/powerpc/pthread_md.c')
-rw-r--r--lib/libpthread/arch/powerpc/powerpc/pthread_md.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/libpthread/arch/powerpc/powerpc/pthread_md.c b/lib/libpthread/arch/powerpc/powerpc/pthread_md.c
index c8445b177c54..2e552bfafa2d 100644
--- a/lib/libpthread/arch/powerpc/powerpc/pthread_md.c
+++ b/lib/libpthread/arch/powerpc/powerpc/pthread_md.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>
+ * Copyright (c) 2006 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +30,8 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <strings.h>
+
+#include "rtld_tls.h"
#include "pthread_md.h"
/*
@@ -39,19 +42,18 @@ _tcb_ctor(struct pthread *thread, int initial)
{
struct tcb *tcb;
- if ((tcb = malloc(sizeof(struct tcb))) != NULL) {
- bzero(tcb, sizeof(struct tcb));
- tcb->tcb_thread = thread;
- /* Allocate TDV */
- }
+ tcb = _rtld_allocate_tls((initial) ? _tp - TP_OFFSET : NULL,
+ sizeof(struct tcb), 8);
+ if (tcb == NULL)
+ return (NULL);
+ tcb->tcb_thread = thread;
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
- /* Free TDV */
- free(tcb);
+ _rtld_free_tls(tcb, sizeof(struct tcb), 8);
}
struct kcb *
@@ -59,13 +61,14 @@ _kcb_ctor(struct kse *kse)
{
struct kcb *kcb;
- if ((kcb = malloc(sizeof(struct kcb))) != NULL) {
- bzero(kcb, sizeof(struct kcb));
- kcb->kcb_faketcb.tcb_isfake = 1;
- kcb->kcb_faketcb.tcb_tmbx.tm_flags = TMF_NOUPCALL;
- kcb->kcb_curtcb = &kcb->kcb_faketcb;
- kcb->kcb_kse = kse;
- }
+ kcb = malloc(sizeof(struct kcb));
+ if (kcb == NULL)
+ return (NULL);
+ bzero(kcb, sizeof(struct kcb));
+ kcb->kcb_kse = kse;
+ kcb->kcb_faketcb.tcb_isfake = 1;
+ kcb->kcb_faketcb.tcb_tmbx.tm_flags = TMF_NOUPCALL;
+ kcb->kcb_curtcb = &kcb->kcb_faketcb;
return (kcb);
}