summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-07 10:46:58 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-07 10:46:58 -0600
commit0c7ac0730d92870bb63f3017d45c9909df6b3ac7 (patch)
tree16ce75ae1c279f28383bc56154e7b2d14fed58ca
parentc5711dd525c2eae779fb8ec384f3aa9c4253edaf (diff)
downloadpx4-nuttx-0c7ac0730d92870bb63f3017d45c9909df6b3ac7.tar.gz
px4-nuttx-0c7ac0730d92870bb63f3017d45c9909df6b3ac7.tar.bz2
px4-nuttx-0c7ac0730d92870bb63f3017d45c9909df6b3ac7.zip
Fix some conditional compilation in kernel build mode. And, while we are touching this logic, make g_default_pthread_attr const.
-rw-r--r--nuttx/include/nuttx/pthread.h6
-rw-r--r--nuttx/libc/pthread/pthread_attrinit.c8
-rw-r--r--nuttx/sched/pthread/pthread_create.c11
3 files changed, 14 insertions, 11 deletions
diff --git a/nuttx/include/nuttx/pthread.h b/nuttx/include/nuttx/pthread.h
index 2bdb88340..cd896e8f8 100644
--- a/nuttx/include/nuttx/pthread.h
+++ b/nuttx/include/nuttx/pthread.h
@@ -70,11 +70,11 @@ extern "C" {
#define EXTERN extern
#endif
-/* Default pthread attributes (see sched/pthread_create.c). This global
- * can only be shared within the kernel- or within the user- address space.
+/* Default pthread attributes. This global can only be shared within the
+ * kernel- or within the user- address space.
*/
-EXTERN pthread_attr_t g_default_pthread_attr;
+EXTERN const pthread_attr_t g_default_pthread_attr;
/****************************************************************************
* Public Function Prototypes
diff --git a/nuttx/libc/pthread/pthread_attrinit.c b/nuttx/libc/pthread/pthread_attrinit.c
index d4a3e0f93..644e94e2c 100644
--- a/nuttx/libc/pthread/pthread_attrinit.c
+++ b/nuttx/libc/pthread/pthread_attrinit.c
@@ -58,15 +58,15 @@
* Global Variables
****************************************************************************/
-/* Default pthread attributes (see included/nuttx/pthread.h). When configured
+/* Default pthread attributes (see include/nuttx/pthread.h). When configured
* to build separate kernel- and user-address spaces, this global is
* duplicated in each address spaced. This copy can only be shared within
* the user address space.
*/
-#if (defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)) && \
- !defined(CONFIG_BUILD_KERNEL)
-pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
+#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \
+ !defined(__KERNEL__)
+const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
#endif
/****************************************************************************
diff --git a/nuttx/sched/pthread/pthread_create.c b/nuttx/sched/pthread/pthread_create.c
index d777d0cc8..34f568c3f 100644
--- a/nuttx/sched/pthread/pthread_create.c
+++ b/nuttx/sched/pthread/pthread_create.c
@@ -68,10 +68,13 @@
/****************************************************************************
* Global Variables
****************************************************************************/
+/* Default pthread attributes (see include/nuttx/pthread.h). When configured
+ * to build separate kernel- and user-address spaces, this global is
+ * duplicated in each address spaced. This copy can only be shared within
+ * the kernel address space.
+ */
-/* Default pthread attributes */
-
-pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
+const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
/****************************************************************************
* Private Variables
@@ -242,7 +245,7 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
if (!attr)
{
- attr = &g_default_pthread_attr;
+ attr = (FAR pthread_attr_t *)&g_default_pthread_attr;
}
/* Allocate a TCB for the new task. */