Clean kernel-/user-mode module build
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3469 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
4388221844
commit
38fd6e5317
27
Makefile
27
Makefile
@ -175,7 +175,7 @@ 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) lib/liblib$(LIBEXT)
|
NUTTXLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(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
|
||||||
@ -183,10 +183,10 @@ USERLIBS =
|
|||||||
# is placed in user space (only).
|
# is placed in user space (only).
|
||||||
|
|
||||||
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
ifeq ($(CONFIG_NUTTX_KERNEL),y)
|
||||||
NUTTXLIBS += syscall/libstubs$(LIBEXT)
|
NUTTXLIBS += syscall/libstubs$(LIBEXT) lib/libklib$(LIBEXT)
|
||||||
USERLIBS += syscall/libproxies$(LIBEXT) lib/liblib$(LIBEXT) mm/libmm$(LIBEXT)
|
USERLIBS += syscall/libproxies$(LIBEXT) lib/libulib$(LIBEXT) mm/libmm$(LIBEXT)
|
||||||
else
|
else
|
||||||
NUTTXLIBS += mm/libmm$(LIBEXT)
|
NUTTXLIBS += mm/libmm$(LIBEXT) lib/liblib$(LIBEXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Add libraries for network support. CXX, CXXFLAGS, and COMPILEXX must
|
# Add libraries for network support. CXX, CXXFLAGS, and COMPILEXX must
|
||||||
@ -246,6 +246,7 @@ NUTTXLIBS += graphics/libgraphics$(LIBEXT)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# This is the name of the final target
|
# This is the name of the final target
|
||||||
|
|
||||||
BIN = nuttx$(EXEEXT)
|
BIN = nuttx$(EXEEXT)
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
@ -256,28 +257,34 @@ tools/mkconfig:
|
|||||||
@$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig
|
@$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig
|
||||||
|
|
||||||
# Create the include/nuttx/config.h file
|
# Create the include/nuttx/config.h file
|
||||||
|
|
||||||
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig
|
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig
|
||||||
tools/mkconfig $(TOPDIR) > include/nuttx/config.h
|
tools/mkconfig $(TOPDIR) > include/nuttx/config.h
|
||||||
|
|
||||||
# link the arch/<arch-name>/include dir to include/arch
|
# link the arch/<arch-name>/include dir to include/arch
|
||||||
|
|
||||||
include/arch: Make.defs
|
include/arch: Make.defs
|
||||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
|
@$(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
|
||||||
|
|
||||||
# Link the configs/<board-name>/include dir to include/arch/board
|
# Link the configs/<board-name>/include dir to include/arch/board
|
||||||
|
|
||||||
include/arch/board: include/arch Make.defs include/arch
|
include/arch/board: include/arch Make.defs include/arch
|
||||||
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
|
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
|
||||||
|
|
||||||
# Link the configs/<board-name>/src dir to arch/<arch-name>/src/board
|
# Link the configs/<board-name>/src dir to arch/<arch-name>/src/board
|
||||||
|
|
||||||
$(ARCH_SRC)/board: Make.defs
|
$(ARCH_SRC)/board: Make.defs
|
||||||
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
|
@$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
|
||||||
|
|
||||||
# Link arch/<arch-name>/include/<chip-name> to arch/<arch-name>/include/chip
|
# Link arch/<arch-name>/include/<chip-name> to arch/<arch-name>/include/chip
|
||||||
|
|
||||||
$(ARCH_SRC)/chip: Make.defs
|
$(ARCH_SRC)/chip: Make.defs
|
||||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
|
@$(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
|
# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
|
||||||
|
|
||||||
include/arch/chip: include/arch Make.defs
|
include/arch/chip: include/arch Make.defs
|
||||||
ifneq ($(CONFIG_ARCH_CHIP),)
|
ifneq ($(CONFIG_ARCH_CHIP),)
|
||||||
@$(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
|
@$(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
|
||||||
@ -307,6 +314,9 @@ check_context:
|
|||||||
|
|
||||||
# Possible kernel-mode builds
|
# Possible kernel-mode builds
|
||||||
|
|
||||||
|
lib/libklib$(LIBEXT): context
|
||||||
|
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" libklib$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||||
|
|
||||||
sched/libsched$(LIBEXT): context
|
sched/libsched$(LIBEXT): context
|
||||||
@$(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
@$(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
|
||||||
|
|
||||||
@ -336,8 +346,8 @@ syscall/libstubs$(LIBEXT): context
|
|||||||
|
|
||||||
# Possible user-mode builds
|
# Possible user-mode builds
|
||||||
|
|
||||||
lib/liblib$(LIBEXT): context
|
lib/libulib$(LIBEXT): context
|
||||||
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" liblib$(LIBEXT)
|
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" libulib$(LIBEXT)
|
||||||
|
|
||||||
libxx/liblibxx$(LIBEXT): context
|
libxx/liblibxx$(LIBEXT): context
|
||||||
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
|
@$(MAKE) -C libxx TOPDIR="$(TOPDIR)" liblibxx$(LIBEXT)
|
||||||
@ -351,6 +361,11 @@ $(APPDIR)/libapps$(LIBEXT): context
|
|||||||
syscall/libproxies$(LIBEXT): context
|
syscall/libproxies$(LIBEXT): context
|
||||||
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libproxies$(LIBEXT)
|
@$(MAKE) -C syscall TOPDIR="$(TOPDIR)" libproxies$(LIBEXT)
|
||||||
|
|
||||||
|
# Possible non-kernel builds
|
||||||
|
|
||||||
|
lib/liblib$(LIBEXT): context
|
||||||
|
@$(MAKE) -C lib TOPDIR="$(TOPDIR)" liblib$(LIBEXT)
|
||||||
|
|
||||||
# If the 2 pass build option is selected, then this pass1 target is
|
# If the 2 pass build option is selected, then this pass1 target is
|
||||||
# configured to built before the pass2 target. This pass1 target may, as an
|
# configured to built before the pass2 target. This pass1 target may, as an
|
||||||
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
|
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/common/up_createstack.c
|
* arch/arm/src/common/up_createstack.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010 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
|
||||||
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
@ -97,9 +96,9 @@ int up_create_stack(_TCB *tcb, size_t stack_size)
|
|||||||
if (!tcb->stack_alloc_ptr)
|
if (!tcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
tcb->stack_alloc_ptr = (uint32_t*)zalloc(stack_size);
|
tcb->stack_alloc_ptr = (uint32_t*)kzalloc(stack_size);
|
||||||
#else
|
#else
|
||||||
tcb->stack_alloc_ptr = (uint32_t*)malloc(stack_size);
|
tcb->stack_alloc_ptr = (uint32_t*)kmalloc(stack_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@
|
|||||||
* Configuration:
|
* Configuration:
|
||||||
* CONFIG_USBHOST_OHCIRAM_SIZE 1536
|
* CONFIG_USBHOST_OHCIRAM_SIZE 1536
|
||||||
* CONFIG_USBHOST_NEDS 2
|
* CONFIG_USBHOST_NEDS 2
|
||||||
* CONFIG_USBHOST_NEDS 3
|
* CONFIG_USBHOST_NTDS 3
|
||||||
* CONFIG_USBHOST_TDBUFFERS 3
|
* CONFIG_USBHOST_TDBUFFERS 3
|
||||||
* CONFIG_USBHOST_TDBUFSIZE 128
|
* CONFIG_USBHOST_TDBUFSIZE 128
|
||||||
* CONFIG_USBHOST_IOBUFSIZE 512
|
* CONFIG_USBHOST_IOBUFSIZE 512
|
||||||
|
@ -2596,7 +2596,7 @@ FAR struct usbhost_driver_s *usbhost_initialize(int controller)
|
|||||||
/* Initialize user-configurable request/descriptor transfer buffers */
|
/* Initialize user-configurable request/descriptor transfer buffers */
|
||||||
|
|
||||||
buffer = (uint8_t *)LPC17_TBFREE_BASE;
|
buffer = (uint8_t *)LPC17_TBFREE_BASE;
|
||||||
for (i = 0; i < CONFIG_USBHOST_NEDS; i++)
|
for (i = 0; i < CONFIG_USBHOST_TDBUFFERS; i++)
|
||||||
{
|
{
|
||||||
/* Put the TD buffer in a free list */
|
/* Put the TD buffer in a free list */
|
||||||
|
|
||||||
|
@ -66,17 +66,19 @@ all: $(TOPDIR)/nuttx_user.elf $(TOPDIR)/User.map $(BOARD_INCLUDE)/user_map.h
|
|||||||
# Create the nuttx_user.elf file containing all of the user-mode code
|
# Create the nuttx_user.elf file containing all of the user-mode code
|
||||||
|
|
||||||
nuttx_user.elf:
|
nuttx_user.elf:
|
||||||
@echo "LD: nuttx_user.elf"
|
|
||||||
@$(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
|
@$(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
|
||||||
|
|
||||||
$(TOPDIR)/nuttx_user.elf: nuttx_user.elf
|
$(TOPDIR)/nuttx_user.elf: nuttx_user.elf
|
||||||
|
@echo "LD: nuttx_user.elf"
|
||||||
@cp -a nuttx_user.elf $(TOPDIR)/nuttx_user.elf
|
@cp -a nuttx_user.elf $(TOPDIR)/nuttx_user.elf
|
||||||
|
|
||||||
$(TOPDIR)/User.map: nuttx_user.elf
|
$(TOPDIR)/User.map: nuttx_user.elf
|
||||||
|
@echo "MK: User.map"
|
||||||
@$(NM) nuttx_user.elf >$(TOPDIR)/User.map
|
@$(NM) nuttx_user.elf >$(TOPDIR)/User.map
|
||||||
@$(CROSSDEV)size nuttx_user.elf
|
@$(CROSSDEV)size nuttx_user.elf
|
||||||
|
|
||||||
$(BOARD_INCLUDE)/user_map.h: $(TOPDIR)/User.map
|
$(BOARD_INCLUDE)/user_map.h: $(TOPDIR)/User.map
|
||||||
|
@echo "MK: user_map.h"
|
||||||
@echo "/* configs/$(CONFIG_ARCH_BOARD)/include/user_map.h" > $(BOARD_INCLUDE)/user_map.h
|
@echo "/* configs/$(CONFIG_ARCH_BOARD)/include/user_map.h" > $(BOARD_INCLUDE)/user_map.h
|
||||||
@echo " *" >> $(BOARD_INCLUDE)/user_map.h
|
@echo " *" >> $(BOARD_INCLUDE)/user_map.h
|
||||||
@echo " * This is an auto-generated file.. Do not edit this file!" >> $(BOARD_INCLUDE)/user_map.h
|
@echo " * This is an auto-generated file.. Do not edit this file!" >> $(BOARD_INCLUDE)/user_map.h
|
||||||
|
@ -39,10 +39,10 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
#include <nuttx/dirent.h>
|
#include <nuttx/dirent.h>
|
||||||
|
|
||||||
@ -134,17 +134,17 @@ int closedir(FAR DIR *dirp)
|
|||||||
|
|
||||||
/* Then release the container */
|
/* Then release the container */
|
||||||
|
|
||||||
free(idir);
|
kfree(idir);
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||||
errout_with_inode:
|
errout_with_inode:
|
||||||
inode_release(inode);
|
inode_release(inode);
|
||||||
free(idir);
|
kfree(idir);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
*get_errno_ptr() = ret;
|
errno = ret;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -145,7 +145,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb)
|
|||||||
|
|
||||||
/* Allocate the IO buffer */
|
/* Allocate the IO buffer */
|
||||||
|
|
||||||
stream->fs_bufstart = malloc(CONFIG_STDIO_BUFFER_SIZE);
|
stream->fs_bufstart = kmalloc(CONFIG_STDIO_BUFFER_SIZE);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
{
|
{
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs_inode.c
|
* fs/fs_inode.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
|
||||||
@ -179,7 +179,7 @@ void inode_semtake(void)
|
|||||||
* the wait was awakened by a signal.
|
* the wait was awakened by a signal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ASSERT(*get_errno_ptr() == EINTR);
|
ASSERT(errno == EINTR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ void inode_free(FAR struct inode *node)
|
|||||||
{
|
{
|
||||||
inode_free(node->i_peer);
|
inode_free(node->i_peer);
|
||||||
inode_free(node->i_child);
|
inode_free(node->i_child);
|
||||||
free(node);
|
kfree(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
#include "fs_internal.h"
|
#include "fs_internal.h"
|
||||||
@ -95,7 +96,7 @@ void inode_release(FAR struct inode *node)
|
|||||||
{
|
{
|
||||||
inode_semgive();
|
inode_semgive();
|
||||||
inode_free(node->i_child);
|
inode_free(node->i_child);
|
||||||
free(node);
|
kfree(node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
#include "fs_internal.h"
|
#include "fs_internal.h"
|
||||||
@ -144,7 +145,7 @@ int inode_remove(const char *path)
|
|||||||
/* And delete it now -- recursively to delete all of its children */
|
/* And delete it now -- recursively to delete all of its children */
|
||||||
|
|
||||||
inode_free(node->i_child);
|
inode_free(node->i_child);
|
||||||
free(node);
|
kfree(node);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_registerreserve.c
|
* fs/fs_registerreserve.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
|
||||||
@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
#include "fs_internal.h"
|
#include "fs_internal.h"
|
||||||
@ -89,7 +90,7 @@ static void inode_namecpy(char *dest, const char *src)
|
|||||||
static FAR struct inode *inode_alloc(const char *name)
|
static FAR struct inode *inode_alloc(const char *name)
|
||||||
{
|
{
|
||||||
int namelen = inode_namelen(name);
|
int namelen = inode_namelen(name);
|
||||||
FAR struct inode *node = (FAR struct inode*)zalloc(FSNODE_SIZE(namelen));
|
FAR struct inode *node = (FAR struct inode*)kzalloc(FSNODE_SIZE(namelen));
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
inode_namecpy(node->i_name, name);
|
inode_namecpy(node->i_name, name);
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
#include <nuttx/dirent.h>
|
#include <nuttx/dirent.h>
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||||||
* container.
|
* container.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dir = (FAR struct fs_dirent_s *)zalloc(sizeof(struct fs_dirent_s));
|
dir = (FAR struct fs_dirent_s *)kzalloc(sizeof(struct fs_dirent_s));
|
||||||
if (!dir)
|
if (!dir)
|
||||||
{
|
{
|
||||||
/* Insufficient memory to complete the operation.*/
|
/* Insufficient memory to complete the operation.*/
|
||||||
@ -306,7 +306,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||||||
/* Nasty goto's make error handling simpler */
|
/* Nasty goto's make error handling simpler */
|
||||||
|
|
||||||
errout_with_direntry:
|
errout_with_direntry:
|
||||||
free(dir);
|
kfree(dir);
|
||||||
|
|
||||||
errout_with_semaphore:
|
errout_with_semaphore:
|
||||||
inode_semgive();
|
inode_semgive();
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -49,6 +48,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
#include "fs_internal.h"
|
#include "fs_internal.h"
|
||||||
@ -111,7 +111,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
|
|
||||||
/* Allocate the descriptor list for poll() */
|
/* Allocate the descriptor list for poll() */
|
||||||
|
|
||||||
pollset = (struct pollfd *)zalloc(nfds * sizeof(struct pollfd));
|
pollset = (struct pollfd *)kzalloc(nfds * sizeof(struct pollfd));
|
||||||
if (!pollset)
|
if (!pollset)
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
@ -208,7 +208,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pollset);
|
kfree(pollset);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
lib/Makefile
28
lib/Makefile
@ -80,6 +80,8 @@ QUEUEDEPPATH = --dep-path queue
|
|||||||
MISCDEPPATH = --dep-path misc
|
MISCDEPPATH = --dep-path misc
|
||||||
VPATH = stdio:stdlib:unistd:sched:string:pthread:semaphore:signal:mqueue:math:net:time:libgen:queue:misc
|
VPATH = stdio:stdlib:unistd:sched:string:pthread:semaphore:signal:mqueue:math:net:time:libgen:queue:misc
|
||||||
|
|
||||||
|
UBIN = libulib$(LIBEXT)
|
||||||
|
KBIN = libklib$(LIBEXT)
|
||||||
BIN = liblib$(LIBEXT)
|
BIN = liblib$(LIBEXT)
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
@ -95,6 +97,22 @@ $(BIN): $(OBJS)
|
|||||||
$(call ARCHIVE, $@, $${obj}); \
|
$(call ARCHIVE, $@, $${obj}); \
|
||||||
done ; )
|
done ; )
|
||||||
|
|
||||||
|
ifneq ($(BIN),$(UBIN))
|
||||||
|
.userlib:
|
||||||
|
@$(MAKE) $(UBIN) BIN=$(UBIN) TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
|
||||||
|
@touch .userlib
|
||||||
|
|
||||||
|
$(UBIN): kclean .userlib
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(BIN),$(KBIN))
|
||||||
|
.kernlib:
|
||||||
|
@$(MAKE) $(KBIN) BIN=$(KBIN) TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
|
||||||
|
@touch .kernlib
|
||||||
|
|
||||||
|
$(KBIN): uclean .kernlib
|
||||||
|
endif
|
||||||
|
|
||||||
.depend: Makefile $(SRCS)
|
.depend: Makefile $(SRCS)
|
||||||
@$(MKDEP) $(ROOTDEPPATH) $(STDIODEPPATH) $(STDLIBDEPPATH) \
|
@$(MKDEP) $(ROOTDEPPATH) $(STDIODEPPATH) $(STDLIBDEPPATH) \
|
||||||
$(UNISTDDEPPATH) $(SCHEDDEPPATH) $(STRINGDEPPATH) $(PTHREADDEPPATH) \
|
$(UNISTDDEPPATH) $(SCHEDDEPPATH) $(STRINGDEPPATH) $(PTHREADDEPPATH) \
|
||||||
@ -105,7 +123,15 @@ $(BIN): $(OBJS)
|
|||||||
|
|
||||||
depend: .depend
|
depend: .depend
|
||||||
|
|
||||||
clean:
|
uclean:
|
||||||
|
@rm -f $(UBIN) .userlib *~ .*.swp
|
||||||
|
$(call CLEAN)
|
||||||
|
|
||||||
|
kclean:
|
||||||
|
@rm -f $(KBIN) .kernlib *~ .*.swp
|
||||||
|
$(call CLEAN)
|
||||||
|
|
||||||
|
clean: uclean kclean
|
||||||
@rm -f $(BIN) *~ .*.swp
|
@rm -f $(BIN) *~ .*.swp
|
||||||
$(call CLEAN)
|
$(call CLEAN)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* lib/lib_internal.h
|
* lib/lib_internal.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010 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
|
||||||
@ -47,6 +47,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#include <nuttx/streams.h>
|
#include <nuttx/streams.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -57,12 +58,37 @@
|
|||||||
# define CONFIG_LIB_HOMEDIR "/"
|
# define CONFIG_LIB_HOMEDIR "/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* If C std I/O buffering is not supported, then we don't need its semaphore
|
||||||
|
* protection.
|
||||||
|
*/
|
||||||
|
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE <= 0
|
#if CONFIG_STDIO_BUFFER_SIZE <= 0
|
||||||
# define lib_sem_initialize(s)
|
# define lib_sem_initialize(s)
|
||||||
# define lib_take_semaphore(s)
|
# define lib_take_semaphore(s)
|
||||||
# define lib_give_semaphore(s)
|
# define lib_give_semaphore(s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The NuttX C library an be build in two modes: (1) as a standard, C-libary
|
||||||
|
* that can be used by normal, user-space applications, or (2) as a special,
|
||||||
|
* kernel-mode C-library only used within the OS. If NuttX is not being
|
||||||
|
* built as separated kernel- and user-space modules, then only the first
|
||||||
|
* mode is supported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
|
||||||
|
# include <nuttx/kmalloc.h>
|
||||||
|
# define lib_malloc(s) kmalloc(s)
|
||||||
|
# define lib_zalloc(s) kzalloc(s)
|
||||||
|
# define lib_realloc(p,s) krealloc(p,s)
|
||||||
|
# define lib_free(p) kfree(p)
|
||||||
|
#else
|
||||||
|
# include <stdlib.h>
|
||||||
|
# define lib_malloc(s) malloc(s)
|
||||||
|
# define lib_zalloc(s) zalloc(s)
|
||||||
|
# define lib_realloc(p,s) realloc(p,s)
|
||||||
|
# define lib_free(p) free(p)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LIB_BUFLEN_UNKNOWN INT_MAX
|
#define LIB_BUFLEN_UNKNOWN INT_MAX
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include <nuttx/config.h>
|
#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>
|
||||||
|
|
||||||
@ -83,7 +82,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*)zalloc(sizeof(struct streamlist));
|
list = (FAR struct streamlist*)lib_zalloc(sizeof(struct streamlist));
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -45,10 +45,11 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "lib_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -142,7 +143,7 @@ static Bigint *Balloc(int k)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = 1 << k;
|
x = 1 << k;
|
||||||
rv = (Bigint *) malloc(sizeof(Bigint) + (x - 1) * sizeof(long));
|
rv = (Bigint *)lib_malloc(sizeof(Bigint) + (x - 1) * sizeof(long));
|
||||||
rv->k = k;
|
rv->k = k;
|
||||||
rv->maxwds = x;
|
rv->maxwds = x;
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,13 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "lib_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -68,7 +69,7 @@ int fclose(FAR FILE *stream)
|
|||||||
|
|
||||||
if (stream->fs_bufstart)
|
if (stream->fs_bufstart)
|
||||||
{
|
{
|
||||||
free(stream->fs_bufstart);
|
lib_free(stream->fs_bufstart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the whole structure */
|
/* Clear the whole structure */
|
||||||
|
@ -39,9 +39,10 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "lib_internal.h"
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
@ -51,7 +52,7 @@ FAR char *strdup(const char *s)
|
|||||||
FAR char *news = NULL;
|
FAR char *news = NULL;
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
news = (FAR char*)malloc(strlen(s) + 1);
|
news = (FAR char*)lib_malloc(strlen(s) + 1);
|
||||||
if (news)
|
if (news)
|
||||||
{
|
{
|
||||||
strcpy(news, s);
|
strcpy(news, s);
|
||||||
|
@ -164,7 +164,7 @@ int chdir(FAR const char *path)
|
|||||||
|
|
||||||
alloc = strdup(oldpwd); /* kludge needed because environment is realloc'ed */
|
alloc = strdup(oldpwd); /* kludge needed because environment is realloc'ed */
|
||||||
setenv("OLDPWD", alloc, TRUE);
|
setenv("OLDPWD", alloc, TRUE);
|
||||||
free(alloc);
|
lib_free(alloc);
|
||||||
|
|
||||||
/* Set the cwd to the input 'path' */
|
/* Set the cwd to the input 'path' */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* tools/mkconfig.c
|
* tools/mkconfig.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010 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
|
||||||
@ -288,6 +288,15 @@ int main(int argc, char **argv, char **envp)
|
|||||||
printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
|
printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
|
||||||
printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
|
printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
|
||||||
printf("#endif\n\n");
|
printf("#endif\n\n");
|
||||||
|
printf("/* We are building a kernel version of the C library, then some user-space features\n");
|
||||||
|
printf(" * need to be disabled\n");
|
||||||
|
printf(" */\n\n");
|
||||||
|
printf("#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)\n");
|
||||||
|
printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
|
||||||
|
printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
|
||||||
|
printf("# undef CONFIG_NUNGET_CHARS\n");
|
||||||
|
printf("# define CONFIG_NUNGET_CHARS 0\n");
|
||||||
|
printf("#endif\n\n");
|
||||||
printf("/* If the maximum message size is zero, then we assume that message queues\n");
|
printf("/* If the maximum message size is zero, then we assume that message queues\n");
|
||||||
printf(" * support should be disabled\n");
|
printf(" * support should be disabled\n");
|
||||||
printf(" */\n\n");
|
printf(" */\n\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user