summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-04-03 20:41:49 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-04-03 20:41:49 +0000
commit5fb8eb530ad4c493a0d6a6ac0f91b07bc8acb037 (patch)
treee689f42a002a2fd57548de0a3eb2aab98fe8f0f0
parent0fe79fa1bf4823f1c783ce7ddcb386e28f1dbb4e (diff)
Move memory manager into user space
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3460 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rw-r--r--nuttx/Makefile24
-rw-r--r--nuttx/arch/sh/src/common/up_createstack.c2
-rw-r--r--nuttx/arch/z16/src/common/up_createstack.c2
-rw-r--r--nuttx/arch/z80/src/common/up_createstack.c2
-rwxr-xr-xnuttx/configs/ea3131/locked/mklocked.sh2
-rw-r--r--nuttx/fs/fs_files.c5
-rw-r--r--nuttx/include/nuttx/kmalloc.h19
-rw-r--r--nuttx/lib/misc/lib_init.c12
-rw-r--r--nuttx/mm/mm_environment.h2
-rw-r--r--nuttx/net/net_sockets.c2
-rw-r--r--nuttx/sched/env_dup.c7
-rw-r--r--nuttx/sched/env_dupenv.c9
-rw-r--r--nuttx/sched/env_putenv.c10
-rw-r--r--nuttx/sched/env_setenv.c11
-rw-r--r--nuttx/sched/env_unsetenv.c9
-rw-r--r--nuttx/sched/mq_open.c4
-rw-r--r--nuttx/sched/pthread_create.c6
-rwxr-xr-xnuttx/sched/sched_garbage.c5
-rw-r--r--nuttx/sched/task_create.c8
-rw-r--r--nuttx/sched/timer_create.c13
20 files changed, 90 insertions, 64 deletions
diff --git a/nuttx/Makefile b/nuttx/Makefile
index 88ccec36d3..30e92e1352 100644
--- a/nuttx/Makefile
+++ b/nuttx/Makefile
@@ -106,7 +106,7 @@ endif
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
# list of directories that must be built
-NONFSDIRS = sched $(ARCH_SRC) mm $(NUTTX_ADDONS)
+NONFSDIRS = sched $(ARCH_SRC) $(NUTTX_ADDONS)
FSDIRS = fs drivers binfmt
NETFSDIRS = fs drivers
CONTEXTDIRS = $(APPDIR)
@@ -115,9 +115,9 @@ USERDIRS =
ifeq ($(CONFIG_NUTTX_KERNEL),y)
NONFSDIRS += syscall
CONTEXTDIRS += syscall
-USERDIRS += syscall lib $(USER_ADDONS)
+USERDIRS += syscall lib mm $(USER_ADDONS)
else
-NONFSDIRS += lib
+NONFSDIRS += lib mm
endif
ifeq ($(CONFIG_NX),y)
@@ -175,16 +175,18 @@ endif
# USERLIBS is the list of libraries used to build the final user-space
# application
-NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
- lib/liblib$(LIBEXT)
+NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) lib/liblib$(LIBEXT)
USERLIBS =
# Add libraries for syscall support. The C library will be needed by
-# both the kernel- and user-space builds.
+# both the kernel- and user-space builds. For now, the memory manager (mm)
+# is placed in user space (only).
ifeq ($(CONFIG_NUTTX_KERNEL),y)
NUTTXLIBS += syscall/libstubs$(LIBEXT)
-USERLIBS += syscall/libproxies$(LIBEXT) lib/liblib$(LIBEXT)
+USERLIBS += syscall/libproxies$(LIBEXT) lib/liblib$(LIBEXT) mm/libmm$(LIBEXT)
+else
+NUTTXLIBS += mm/libmm$(LIBEXT)
endif
# Add libraries for network support. CXX, CXXFLAGS, and COMPILEXX must
@@ -332,11 +334,6 @@ graphics/libgraphics$(LIBEXT): context
syscall/libstubs$(LIBEXT): context
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libstubs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
-# Still need to think about this one
-
-mm/libmm$(LIBEXT): context
- @$(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT)
-
# Possible user-mode builds
lib/liblib$(LIBEXT): context
@@ -345,6 +342,9 @@ lib/liblib$(LIBEXT): context
libxx/liblibxx$(LIBEXT): context
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
+mm/libmm$(LIBEXT): context
+ @$(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
+
$(APPDIR)/libapps$(LIBEXT): context
@$(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
diff --git a/nuttx/arch/sh/src/common/up_createstack.c b/nuttx/arch/sh/src/common/up_createstack.c
index 35651fe863..37346b84b3 100644
--- a/nuttx/arch/sh/src/common/up_createstack.c
+++ b/nuttx/arch/sh/src/common/up_createstack.c
@@ -94,7 +94,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
if (!tcb->stack_alloc_ptr)
{
- tcb->stack_alloc_ptr = (uint32_t*)kzmalloc(stack_size);
+ tcb->stack_alloc_ptr = (uint32_t*)kzalloc(stack_size);
}
if (tcb->stack_alloc_ptr)
diff --git a/nuttx/arch/z16/src/common/up_createstack.c b/nuttx/arch/z16/src/common/up_createstack.c
index a59c79c845..1adcc78358 100644
--- a/nuttx/arch/z16/src/common/up_createstack.c
+++ b/nuttx/arch/z16/src/common/up_createstack.c
@@ -95,7 +95,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
if (!tcb->stack_alloc_ptr)
{
- tcb->stack_alloc_ptr = (uint32_t*)kzmalloc(stack_size);
+ tcb->stack_alloc_ptr = (uint32_t*)kzalloc(stack_size);
}
if (tcb->stack_alloc_ptr)
diff --git a/nuttx/arch/z80/src/common/up_createstack.c b/nuttx/arch/z80/src/common/up_createstack.c
index c9da4cb9f2..6ffaa272bf 100644
--- a/nuttx/arch/z80/src/common/up_createstack.c
+++ b/nuttx/arch/z80/src/common/up_createstack.c
@@ -93,7 +93,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
if (!tcb->stack_alloc_ptr)
{
- tcb->stack_alloc_ptr = (uint32_t*)kzmalloc(stack_size);
+ tcb->stack_alloc_ptr = (uint32_t*)kzalloc(stack_size);
}
if (tcb->stack_alloc_ptr)
diff --git a/nuttx/configs/ea3131/locked/mklocked.sh b/nuttx/configs/ea3131/locked/mklocked.sh
index bf6d526147..3bfd0726d3 100755
--- a/nuttx/configs/ea3131/locked/mklocked.sh
+++ b/nuttx/configs/ea3131/locked/mklocked.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
###########################################################################
# configs/ea3131/locked/mklocked.sh
#
diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c
index 4ea735b695..1444d88052 100644
--- a/nuttx/fs/fs_files.c
+++ b/nuttx/fs/fs_files.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_files.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
#include <assert.h>
#include <sched.h>
#include <errno.h>
+
#include <nuttx/fs.h>
#include <nuttx/kmalloc.h>
@@ -157,7 +158,7 @@ void files_initialize(void)
FAR struct filelist *files_alloclist(void)
{
FAR struct filelist *list;
- list = (FAR struct filelist*)kzmalloc(sizeof(struct filelist));
+ list = (FAR struct filelist*)kzalloc(sizeof(struct filelist));
if (list)
{
/* Start with a reference count of one */
diff --git a/nuttx/include/nuttx/kmalloc.h b/nuttx/include/nuttx/kmalloc.h
index 2f2df36634..7fb37a5d04 100644
--- a/nuttx/include/nuttx/kmalloc.h
+++ b/nuttx/include/nuttx/kmalloc.h
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/kmalloc.h
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -63,21 +63,28 @@ extern "C" {
# include <stdlib.h>
# define kmalloc(s) malloc(s)
#else
-KMALLOC_EXTERN FAR void *kmalloc(size_t);
+KMALLOC_EXTERN FAR void *kmalloc(size_t);
#endif
-#ifndef CONFIG_ARCH_KZMALLOC
+#ifndef CONFIG_ARCH_KZALLOC
# include <stdlib.h>
-# define kzmalloc(s) zalloc(s)
+# define kzalloc(s) zalloc(s)
#else
-KMALLOC_EXTERN FAR void *kzalloc(size_t);
+KMALLOC_EXTERN FAR void *kzalloc(size_t);
+#endif
+
+#ifndef CONFIG_ARCH_KREALLOC
+# include <stdlib.h>
+# define krealloc(p,s) realloc(p,s)
+#else
+KMALLOC_EXTERN FAR void *krealloc(FAR void*, size_t);
#endif
#ifndef CONFIG_ARCH_KFREE
# include <stdlib.h>
# define kfree(p) free(p)
#else
-KMALLOC_EXTERN void kfree(FAR void*);
+KMALLOC_EXTERN void kfree(FAR void*);
#endif
/* Functions defined in os_list.c *******************************************/
diff --git a/nuttx/lib/misc/lib_init.c b/nuttx/lib/misc/lib_init.c
index bd2c6e7ba5..107c73c07a 100644
--- a/nuttx/lib/misc/lib_init.c
+++ b/nuttx/lib/misc/lib_init.c
@@ -1,7 +1,7 @@
/************************************************************
- * lib_init.c
+ * lib/misc/lib_init.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -37,12 +37,16 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
+
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <nuttx/kmalloc.h>
+
#include <nuttx/fs.h>
#include <nuttx/lib.h>
+
#include "lib_internal.h"
/************************************************************
@@ -79,7 +83,7 @@ void weak_const_function lib_initialize(void)
FAR struct streamlist *lib_alloclist(void)
{
FAR struct streamlist *list;
- list = (FAR struct streamlist*)kzmalloc(sizeof(struct streamlist));
+ list = (FAR struct streamlist*)zalloc(sizeof(struct streamlist));
if (list)
{
int i;
diff --git a/nuttx/mm/mm_environment.h b/nuttx/mm/mm_environment.h
index 67c2ec05a1..3525eccc06 100644
--- a/nuttx/mm/mm_environment.h
+++ b/nuttx/mm/mm_environment.h
@@ -114,7 +114,7 @@ extern void mm_addregion(FAR void *heapstart, size_t heapsize);
# define mvdbg(format, arg...) printf(format, ##arg)
#else
-# define mm_errno (*get_errno_ptr())
+# define mm_errno get_errno()
#endif
/****************************************************************************
diff --git a/nuttx/net/net_sockets.c b/nuttx/net/net_sockets.c
index dce8aa1f05..a1e8f15b02 100644
--- a/nuttx/net/net_sockets.c
+++ b/nuttx/net/net_sockets.c
@@ -121,7 +121,7 @@ void net_initialize(void)
FAR struct socketlist *net_alloclist(void)
{
FAR struct socketlist *list;
- list = (FAR struct socketlist*)kzmalloc(sizeof(struct socketlist));
+ list = (FAR struct socketlist*)kzalloc(sizeof(struct socketlist));
if (list)
{
/* Start with a reference count of one */
diff --git a/nuttx/sched/env_dup.c b/nuttx/sched/env_dup.c
index 716dcc47c1..cbde5251d8 100644
--- a/nuttx/sched/env_dup.c
+++ b/nuttx/sched/env_dup.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/env_dup.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,9 @@
#include <sched.h>
#include <string.h>
#include <errno.h>
+
+#include <nuttx/kmalloc.h>
+
#include "os_internal.h"
#include "env_internal.h"
@@ -101,7 +104,7 @@ int env_dup(FAR _TCB *ptcb)
/* Yes..The parent task has an environment, duplicate it */
size_t envlen = parent->envp->ev_alloc;
- envp = (environ_t*)malloc(SIZEOF_ENVIRON_T( envlen ));
+ envp = (environ_t*)kmalloc(SIZEOF_ENVIRON_T( envlen ));
if (!envp)
{
ret = -ENOMEM;
diff --git a/nuttx/sched/env_dupenv.c b/nuttx/sched/env_dupenv.c
index d11e44330b..fd3ccd7b70 100644
--- a/nuttx/sched/env_dupenv.c
+++ b/nuttx/sched/env_dupenv.c
@@ -1,7 +1,7 @@
/****************************************************************************
* eched/env_dupenv.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
#include <sys/types.h>
#include <sched.h>
-#include <stdlib.h>
+
+#include <nuttx/kmalloc.h>
+
#include "os_internal.h"
/****************************************************************************
@@ -91,7 +93,7 @@ FAR environ_t *dupenv(FAR _TCB *ptcb)
/* Yes..The parent task has an environment, duplicate it */
size_t envlen = ptcb->envp->ev_alloc
- envp = (environ_t*)malloc(SIZEOF_ENVIRON_T( envlen ));
+ envp = (environ_t*)kmalloc(SIZEOF_ENVIRON_T( envlen ));
if (envp)
{
envp->ev_crefs = 1;
@@ -99,6 +101,7 @@ FAR environ_t *dupenv(FAR _TCB *ptcb)
memcmp( envp->ev_env, ptcb->envp->ev_env, envlen );
}
}
+
sched_unlock();
return envp;
}
diff --git a/nuttx/sched/env_putenv.c b/nuttx/sched/env_putenv.c
index 43ca44d4d5..65c3d4c032 100644
--- a/nuttx/sched/env_putenv.c
+++ b/nuttx/sched/env_putenv.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/env_putenv.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,9 +43,10 @@
#include <sched.h>
#include <string.h>
-#include <stdlib.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -106,11 +107,12 @@ int putenv(FAR const char *string)
*pequal = '\0';
ret = setenv(pname, pequal+1, TRUE);
}
- free(pname);
+
+ kfree(pname);
return ret;
errout:
- *get_errno_ptr() = ret;
+ errno = ret;
return ERROR;
}
diff --git a/nuttx/sched/env_setenv.c b/nuttx/sched/env_setenv.c
index 0eacd77938..8193aa5640 100644
--- a/nuttx/sched/env_setenv.c
+++ b/nuttx/sched/env_setenv.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/env_setenv.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,9 +44,10 @@
#include <stdio.h>
#include <sched.h>
#include <string.h>
-#include <stdlib.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
+
#include "os_internal.h"
#include "env_internal.h"
@@ -156,7 +157,7 @@ int setenv(const char *name, const char *value, int overwrite)
if (envp)
{
int alloc = envp->ev_alloc;
- environ_t *tmp = (environ_t*)realloc(envp, SIZEOF_ENVIRON_T(alloc + varlen));
+ environ_t *tmp = (environ_t*)krealloc(envp, SIZEOF_ENVIRON_T(alloc + varlen));
if (!tmp)
{
ret = ENOMEM;
@@ -169,7 +170,7 @@ int setenv(const char *name, const char *value, int overwrite)
}
else
{
- envp = (environ_t*)malloc(SIZEOF_ENVIRON_T(varlen));
+ envp = (environ_t*)kmalloc(SIZEOF_ENVIRON_T(varlen));
if (!envp)
{
ret = ENOMEM;
@@ -196,7 +197,7 @@ int setenv(const char *name, const char *value, int overwrite)
errout_with_lock:
sched_unlock();
errout:
- *get_errno_ptr() = ret;
+ errno = ret;
return ERROR;
}
diff --git a/nuttx/sched/env_unsetenv.c b/nuttx/sched/env_unsetenv.c
index f397eab6b7..a751661c70 100644
--- a/nuttx/sched/env_unsetenv.c
+++ b/nuttx/sched/env_unsetenv.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/env_unsetenv.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,9 +43,10 @@
#include <sched.h>
#include <string.h>
-#include <stdlib.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
+
#include "os_internal.h"
#include "env_internal.h"
@@ -109,7 +110,7 @@ int unsetenv(const char *name)
/* Reallocate the new environment buffer */
alloc = envp->ev_alloc;
- tmp = (environ_t*)realloc(envp, SIZEOF_ENVIRON_T(alloc));
+ tmp = (environ_t*)krealloc(envp, SIZEOF_ENVIRON_T(alloc));
if (!tmp)
{
ret = ENOMEM;
@@ -127,7 +128,7 @@ int unsetenv(const char *name)
errout_with_lock:
sched_unlock();
errout:
- *get_errno_ptr() = ret;
+ errno = ret;
return ERROR;
}
diff --git a/nuttx/sched/mq_open.c b/nuttx/sched/mq_open.c
index 9e3a3e77cb..de93881953 100644
--- a/nuttx/sched/mq_open.c
+++ b/nuttx/sched/mq_open.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/mq_open.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -157,7 +157,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
* of the message queue name+1.
*/
- msgq = (FAR msgq_t*)kzmalloc(SIZEOF_MQ_HEADER + namelen + 1);
+ msgq = (FAR msgq_t*)kzalloc(SIZEOF_MQ_HEADER + namelen + 1);
if (msgq)
{
/* Create a message queue descriptor for the TCB */
diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c
index bedb7d3baa..d1f838a9e7 100644
--- a/nuttx/sched/pthread_create.c
+++ b/nuttx/sched/pthread_create.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/pthread_create.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -262,7 +262,7 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
/* Allocate a TCB for the new task. */
- ptcb = (FAR _TCB*)kzmalloc(sizeof(_TCB));
+ ptcb = (FAR _TCB*)kzalloc(sizeof(_TCB));
if (!ptcb)
{
return ENOMEM;
@@ -283,7 +283,7 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
/* Allocate a detachable structure to support pthread_join logic */
- pjoin = (FAR join_t*)kzmalloc(sizeof(join_t));
+ pjoin = (FAR join_t*)kzalloc(sizeof(join_t));
if (!pjoin)
{
sched_releasetcb(ptcb);
diff --git a/nuttx/sched/sched_garbage.c b/nuttx/sched/sched_garbage.c
index 7c9f434a1b..946198ede1 100755
--- a/nuttx/sched/sched_garbage.c
+++ b/nuttx/sched/sched_garbage.c
@@ -38,8 +38,7 @@
****************************************************************************/
#include <nuttx/config.h>
-
-#include <stdlib.h>
+#include <nuttx/kmalloc.h>
#include "os_internal.h"
@@ -111,7 +110,7 @@ void sched_garbagecollection(void)
if (address)
{
- free(address);
+ kfree(address);
}
}
}
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c
index d70f337c0b..3965e61efd 100644
--- a/nuttx/sched/task_create.c
+++ b/nuttx/sched/task_create.c
@@ -38,11 +38,15 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <errno.h>
#include <debug.h>
+
#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
+
#include "os_internal.h"
#include "env_internal.h"
@@ -121,10 +125,10 @@ int task_create(const char *name, int priority,
/* Allocate a TCB for the new task. */
- tcb = (FAR _TCB*)kzmalloc(sizeof(_TCB));
+ tcb = (FAR _TCB*)kzalloc(sizeof(_TCB));
if (!tcb)
{
- *get_errno_ptr() = ENOMEM;
+ errno = ENOMEM;
return ERROR;
}
diff --git a/nuttx/sched/timer_create.c b/nuttx/sched/timer_create.c
index c4f3cbd872..b1ad142c75 100644
--- a/nuttx/sched/timer_create.c
+++ b/nuttx/sched/timer_create.c
@@ -1,7 +1,7 @@
/********************************************************************************
* sched/timer_create.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,13 +40,14 @@
#include <nuttx/config.h>
#include <stdint.h>
-#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <wdog.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
+
#include "timer_internal.h"
#ifndef CONFIG_DISABLE_POSIX_TIMERS
@@ -99,7 +100,7 @@ static struct posix_timer_s *timer_allocate(void)
{
/* Allocate a new timer from the heap */
- ret = (struct posix_timer_s*)malloc(sizeof(struct posix_timer_s));
+ ret = (struct posix_timer_s*)kmalloc(sizeof(struct posix_timer_s));
pt_flags = 0;
}
@@ -183,7 +184,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
if (!timerid || clockid != CLOCK_REALTIME)
{
- *get_errno_ptr() = EINVAL;
+ errno = EINVAL;
return ERROR;
}
@@ -192,7 +193,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
wdog = wd_create();
if (!wdog)
{
- *get_errno_ptr() = EAGAIN;
+ errno = EAGAIN;
return ERROR;
}
@@ -201,7 +202,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
ret = timer_allocate();
if (!ret)
{
- *get_errno_ptr() = EAGAIN;
+ errno = EAGAIN;
return ERROR;
}