summaryrefslogtreecommitdiff
path: root/nuttx/sched/pthread_keycreate.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-03 16:43:58 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-03 16:43:58 +0000
commit32dde889e28f1e15c4a97f3e701800ba22ab849d (patch)
tree83fc8fbb0fcef9302298d1ccb819cfba26ec8825 /nuttx/sched/pthread_keycreate.c
parent0066db82f921ad84a9017242396e37259f3d71f4 (diff)
downloadpx4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.tar.gz
px4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.tar.bz2
px4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.zip
Move pthread join and key creation data into the task group
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5602 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/pthread_keycreate.c')
-rw-r--r--nuttx/sched/pthread_keycreate.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/nuttx/sched/pthread_keycreate.c b/nuttx/sched/pthread_keycreate.c
index 7579e4c11..db09d035f 100644
--- a/nuttx/sched/pthread_keycreate.c
+++ b/nuttx/sched/pthread_keycreate.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/pthread_keycreate.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,10 @@
#include <sched.h>
#include <errno.h>
+#include <assert.h>
#include <debug.h>
+#include "os_internal.h"
#include "pthread_internal.h"
/****************************************************************************
@@ -109,19 +111,23 @@
int pthread_key_create(FAR pthread_key_t *key, CODE void (*destructor)(void*))
{
#if CONFIG_NPTHREAD_KEYS > 0
+ FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
+ FAR struct task_group_s *group = rtcb->group;
int ret = EAGAIN;
+ DEBUGASSERT(group);
+
/* Check if we have exceeded the system-defined number of keys. */
- if (g_pthread_num_keys < PTHREAD_KEYS_MAX)
+ if (group->tg_nkeys < PTHREAD_KEYS_MAX)
{
/* Return the key value */
- *key = g_pthread_num_keys;
+ *key = group->tg_nkeys;
/* Increment the count of global keys. */
- g_pthread_num_keys++;
+ group->tg_nkeys++;
/* Return success. */