mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
Move memory manager into user space
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3460 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -106,7 +106,7 @@ endif
|
|||||||
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
|
# USERDIRS - When NuttX is build is a monolithic kernel, this provides the
|
||||||
# list of directories that must be built
|
# list of directories that must be built
|
||||||
|
|
||||||
NONFSDIRS = sched $(ARCH_SRC) mm $(NUTTX_ADDONS)
|
NONFSDIRS = sched $(ARCH_SRC) $(NUTTX_ADDONS)
|
||||||
FSDIRS = fs drivers binfmt
|
FSDIRS = fs drivers binfmt
|
||||||
NETFSDIRS = fs drivers
|
NETFSDIRS = fs drivers
|
||||||
CONTEXTDIRS = $(APPDIR)
|
CONTEXTDIRS = $(APPDIR)
|
||||||
@@ -115,9 +115,9 @@ USERDIRS =
|
|||||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||||
NONFSDIRS += syscall
|
NONFSDIRS += syscall
|
||||||
CONTEXTDIRS += syscall
|
CONTEXTDIRS += syscall
|
||||||
USERDIRS += syscall lib $(USER_ADDONS)
|
USERDIRS += syscall lib mm $(USER_ADDONS)
|
||||||
else
|
else
|
||||||
NONFSDIRS += lib
|
NONFSDIRS += lib mm
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NX),y)
|
ifeq ($(CONFIG_NX),y)
|
||||||
@@ -175,16 +175,18 @@ endif
|
|||||||
# USERLIBS is the list of libraries used to build the final user-space
|
# USERLIBS is the list of libraries used to build the final user-space
|
||||||
# application
|
# application
|
||||||
|
|
||||||
NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
|
NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) lib/liblib$(LIBEXT)
|
||||||
lib/liblib$(LIBEXT)
|
|
||||||
USERLIBS =
|
USERLIBS =
|
||||||
|
|
||||||
# Add libraries for syscall support. The C library will be needed by
|
# 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)
|
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||||
NUTTXLIBS += syscall/libstubs$(LIBEXT)
|
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
|
endif
|
||||||
|
|
||||||
# Add libraries for network support. CXX, CXXFLAGS, and COMPILEXX must
|
# Add libraries for network support. CXX, CXXFLAGS, and COMPILEXX must
|
||||||
@@ -332,11 +334,6 @@ graphics/libgraphics$(LIBEXT): context
|
|||||||
syscall/libstubs$(LIBEXT): context
|
syscall/libstubs$(LIBEXT): context
|
||||||
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libstubs$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
@$(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
|
# Possible user-mode builds
|
||||||
|
|
||||||
lib/liblib$(LIBEXT): context
|
lib/liblib$(LIBEXT): context
|
||||||
@@ -345,6 +342,9 @@ lib/liblib$(LIBEXT): context
|
|||||||
libxx/liblibxx$(LIBEXT): context
|
libxx/liblibxx$(LIBEXT): context
|
||||||
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
|
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
|
||||||
|
|
||||||
|
mm/libmm$(LIBEXT): context
|
||||||
|
@$(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||||
|
|
||||||
$(APPDIR)/libapps$(LIBEXT): context
|
$(APPDIR)/libapps$(LIBEXT): context
|
||||||
@$(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
|
@$(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
|
|||||||
|
|
||||||
if (!tcb->stack_alloc_ptr)
|
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)
|
if (tcb->stack_alloc_ptr)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
|
|||||||
|
|
||||||
if (!tcb->stack_alloc_ptr)
|
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)
|
if (tcb->stack_alloc_ptr)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
|
|||||||
|
|
||||||
if (!tcb->stack_alloc_ptr)
|
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)
|
if (tcb->stack_alloc_ptr)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# configs/ea3131/locked/mklocked.sh
|
# configs/ea3131/locked/mklocked.sh
|
||||||
#
|
#
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_files.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ void files_initialize(void)
|
|||||||
FAR struct filelist *files_alloclist(void)
|
FAR struct filelist *files_alloclist(void)
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
list = (FAR struct filelist*)kzmalloc(sizeof(struct filelist));
|
list = (FAR struct filelist*)kzalloc(sizeof(struct filelist));
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
/* Start with a reference count of one */
|
/* Start with a reference count of one */
|
||||||
|
|||||||
+13
-6
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/kmalloc.h
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -63,21 +63,28 @@ extern "C" {
|
|||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# define kmalloc(s) malloc(s)
|
# define kmalloc(s) malloc(s)
|
||||||
#else
|
#else
|
||||||
KMALLOC_EXTERN FAR void *kmalloc(size_t);
|
KMALLOC_EXTERN FAR void *kmalloc(size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_KZMALLOC
|
#ifndef CONFIG_ARCH_KZALLOC
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# define kzmalloc(s) zalloc(s)
|
# define kzalloc(s) zalloc(s)
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_KFREE
|
#ifndef CONFIG_ARCH_KFREE
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# define kfree(p) free(p)
|
# define kfree(p) free(p)
|
||||||
#else
|
#else
|
||||||
KMALLOC_EXTERN void kfree(FAR void*);
|
KMALLOC_EXTERN void kfree(FAR void*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Functions defined in os_list.c *******************************************/
|
/* Functions defined in os_list.c *******************************************/
|
||||||
|
|||||||
+8
-4
@@ -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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -37,12 +37,16 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <nuttx/kmalloc.h>
|
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
#include <nuttx/lib.h>
|
#include <nuttx/lib.h>
|
||||||
|
|
||||||
#include "lib_internal.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 *lib_alloclist(void)
|
||||||
{
|
{
|
||||||
FAR struct streamlist *list;
|
FAR struct streamlist *list;
|
||||||
list = (FAR struct streamlist*)kzmalloc(sizeof(struct streamlist));
|
list = (FAR struct streamlist*)zalloc(sizeof(struct streamlist));
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ extern void mm_addregion(FAR void *heapstart, size_t heapsize);
|
|||||||
# define mvdbg(format, arg...) printf(format, ##arg)
|
# define mvdbg(format, arg...) printf(format, ##arg)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define mm_errno (*get_errno_ptr())
|
# define mm_errno get_errno()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ void net_initialize(void)
|
|||||||
FAR struct socketlist *net_alloclist(void)
|
FAR struct socketlist *net_alloclist(void)
|
||||||
{
|
{
|
||||||
FAR struct socketlist *list;
|
FAR struct socketlist *list;
|
||||||
list = (FAR struct socketlist*)kzmalloc(sizeof(struct socketlist));
|
list = (FAR struct socketlist*)kzalloc(sizeof(struct socketlist));
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
/* Start with a reference count of one */
|
/* Start with a reference count of one */
|
||||||
|
|||||||
+5
-2
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/env_dup.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -45,6 +45,9 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "env_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 */
|
/* Yes..The parent task has an environment, duplicate it */
|
||||||
|
|
||||||
size_t envlen = parent->envp->ev_alloc;
|
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)
|
if (!envp)
|
||||||
{
|
{
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
|||||||
+6
-3
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* eched/env_dupenv.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,7 +43,9 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "os_internal.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 */
|
/* Yes..The parent task has an environment, duplicate it */
|
||||||
|
|
||||||
size_t envlen = ptcb->envp->ev_alloc
|
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)
|
if (envp)
|
||||||
{
|
{
|
||||||
envp->ev_crefs = 1;
|
envp->ev_crefs = 1;
|
||||||
@@ -99,6 +101,7 @@ FAR environ_t *dupenv(FAR _TCB *ptcb)
|
|||||||
memcmp( envp->ev_env, ptcb->envp->ev_env, envlen );
|
memcmp( envp->ev_env, ptcb->envp->ev_env, envlen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return envp;
|
return envp;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/env_putenv.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,9 +43,10 @@
|
|||||||
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -106,11 +107,12 @@ int putenv(FAR const char *string)
|
|||||||
*pequal = '\0';
|
*pequal = '\0';
|
||||||
ret = setenv(pname, pequal+1, TRUE);
|
ret = setenv(pname, pequal+1, TRUE);
|
||||||
}
|
}
|
||||||
free(pname);
|
|
||||||
|
kfree(pname);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
*get_errno_ptr() = ret;
|
errno = ret;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/env_setenv.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,9 +44,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "env_internal.h"
|
#include "env_internal.h"
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ int setenv(const char *name, const char *value, int overwrite)
|
|||||||
if (envp)
|
if (envp)
|
||||||
{
|
{
|
||||||
int alloc = envp->ev_alloc;
|
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)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
@@ -169,7 +170,7 @@ int setenv(const char *name, const char *value, int overwrite)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
envp = (environ_t*)malloc(SIZEOF_ENVIRON_T(varlen));
|
envp = (environ_t*)kmalloc(SIZEOF_ENVIRON_T(varlen));
|
||||||
if (!envp)
|
if (!envp)
|
||||||
{
|
{
|
||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
@@ -196,7 +197,7 @@ int setenv(const char *name, const char *value, int overwrite)
|
|||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
errout:
|
errout:
|
||||||
*get_errno_ptr() = ret;
|
errno = ret;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/env_unsetenv.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,9 +43,10 @@
|
|||||||
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "env_internal.h"
|
#include "env_internal.h"
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ int unsetenv(const char *name)
|
|||||||
/* Reallocate the new environment buffer */
|
/* Reallocate the new environment buffer */
|
||||||
|
|
||||||
alloc = envp->ev_alloc;
|
alloc = envp->ev_alloc;
|
||||||
tmp = (environ_t*)realloc(envp, SIZEOF_ENVIRON_T(alloc));
|
tmp = (environ_t*)krealloc(envp, SIZEOF_ENVIRON_T(alloc));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
@@ -127,7 +128,7 @@ int unsetenv(const char *name)
|
|||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
errout:
|
errout:
|
||||||
*get_errno_ptr() = ret;
|
errno = ret;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/mq_open.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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.
|
* 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)
|
if (msgq)
|
||||||
{
|
{
|
||||||
/* Create a message queue descriptor for the TCB */
|
/* Create a message queue descriptor for the TCB */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/pthread_create.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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. */
|
/* Allocate a TCB for the new task. */
|
||||||
|
|
||||||
ptcb = (FAR _TCB*)kzmalloc(sizeof(_TCB));
|
ptcb = (FAR _TCB*)kzalloc(sizeof(_TCB));
|
||||||
if (!ptcb)
|
if (!ptcb)
|
||||||
{
|
{
|
||||||
return ENOMEM;
|
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 */
|
/* 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)
|
if (!pjoin)
|
||||||
{
|
{
|
||||||
sched_releasetcb(ptcb);
|
sched_releasetcb(ptcb);
|
||||||
|
|||||||
@@ -38,8 +38,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
|
|
||||||
@@ -111,7 +110,7 @@ void sched_garbagecollection(void)
|
|||||||
|
|
||||||
if (address)
|
if (address)
|
||||||
{
|
{
|
||||||
free(address);
|
kfree(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -38,11 +38,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "env_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. */
|
/* Allocate a TCB for the new task. */
|
||||||
|
|
||||||
tcb = (FAR _TCB*)kzmalloc(sizeof(_TCB));
|
tcb = (FAR _TCB*)kzalloc(sizeof(_TCB));
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
*get_errno_ptr() = ENOMEM;
|
errno = ENOMEM;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* sched/timer_create.c
|
* 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>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -40,13 +40,14 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wdog.h>
|
#include <wdog.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
#include "timer_internal.h"
|
#include "timer_internal.h"
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
||||||
@@ -99,7 +100,7 @@ static struct posix_timer_s *timer_allocate(void)
|
|||||||
{
|
{
|
||||||
/* Allocate a new timer from the heap */
|
/* 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;
|
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)
|
if (!timerid || clockid != CLOCK_REALTIME)
|
||||||
{
|
{
|
||||||
*get_errno_ptr() = EINVAL;
|
errno = EINVAL;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
|
|||||||
wdog = wd_create();
|
wdog = wd_create();
|
||||||
if (!wdog)
|
if (!wdog)
|
||||||
{
|
{
|
||||||
*get_errno_ptr() = EAGAIN;
|
errno = EAGAIN;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +202,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
|
|||||||
ret = timer_allocate();
|
ret = timer_allocate();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
*get_errno_ptr() = EAGAIN;
|
errno = EAGAIN;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user