Create a build structure that will (eventually) support using the VFS to manage named semaphores

This commit is contained in:
Gregory Nutt 2014-09-28 12:19:01 -06:00
parent 7db12a638c
commit 242b34cf46
12 changed files with 121 additions and 22 deletions

View File

@ -644,6 +644,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
ONFIG_FS_NAMED_SEMAPHORES=y
CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y

View File

@ -644,6 +644,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
ONFIG_FS_NAMED_SEMAPHORES=y
CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y

View File

@ -608,6 +608,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
ONFIG_FS_NAMED_SEMAPHORES=y
CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y

View File

@ -598,6 +598,8 @@ CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial"
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
ONFIG_FS_NAMED_SEMAPHORES=y
CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
# CONFIG_FAT_LCNAMES is not set

View File

@ -618,6 +618,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
ONFIG_FS_NAMED_SEMAPHORES=y
CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y

View File

@ -48,6 +48,7 @@ config FS_WRITABLE
bool
default n
source fs/semaphore/Kconfig
source fs/mmap/Kconfig
source fs/fat/Kconfig
source fs/nfs/Kconfig

20
fs/semaphore/Kconfig Normal file
View File

@ -0,0 +1,20 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config FS_NAMED_SEMAPHORES
bool "Named semaphore support"
default n
---help---
Include support for named semaphores.
if FS_NAMED_SEMAPHORES
config FS_NAMED_SEMPATH
string "Path to semaphore storage"
default "/var/sem"
---help---
The path to where named semaphores will exist in the VFS namespace.
endif # FS_NAMED_SEMAPHORES

45
fs/semaphore/Make.defs Normal file
View File

@ -0,0 +1,45 @@
############################################################################
# fs/semaphore/Make.defs
#
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# Include named semaphore support
ifneq ($(CONFIG_FS_NAMED_SEMAPHORES),0)
# Include named semaphore build support
DEPPATH += --dep-path semaphore
VPATH += :semaphore
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)semaphore}
endif

View File

@ -129,15 +129,18 @@ struct timespec; /* Defined in time.h */
int sem_init(FAR sem_t *sem, int pshared, unsigned int value);
int sem_destroy(FAR sem_t *sem);
FAR sem_t *sem_open(FAR const char *name, int oflag, ...);
int sem_close(FAR sem_t *sem);
int sem_unlink(FAR const char *name);
int sem_wait(FAR sem_t *sem);
int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime);
int sem_trywait(FAR sem_t *sem);
int sem_post(FAR sem_t *sem);
int sem_getvalue(FAR sem_t *sem, FAR int *sval);
#ifdef CONFIG_FS_NAMED_SEMAPHORES
FAR sem_t *sem_open(FAR const char *name, int oflag, ...);
int sem_close(FAR sem_t *sem);
int sem_unlink(FAR const char *name);
#endif
#undef EXTERN
#ifdef __cplusplus
}

View File

@ -80,31 +80,42 @@
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+10)
#define SYS_sched_unlock (CONFIG_SYS_RESERVED+11)
#define SYS_sched_yield (CONFIG_SYS_RESERVED+12)
#define SYS_sem_close (CONFIG_SYS_RESERVED+13)
#define SYS_set_errno (CONFIG_SYS_RESERVED+13)
/* Semaphores */
#define SYS_sem_destroy (CONFIG_SYS_RESERVED+14)
#define SYS_sem_open (CONFIG_SYS_RESERVED+15)
#define SYS_sem_post (CONFIG_SYS_RESERVED+16)
#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+17)
#define SYS_sem_trywait (CONFIG_SYS_RESERVED+18)
#define SYS_sem_unlink (CONFIG_SYS_RESERVED+19)
#define SYS_sem_wait (CONFIG_SYS_RESERVED+20)
#define SYS_set_errno (CONFIG_SYS_RESERVED+21)
#define SYS_sem_post (CONFIG_SYS_RESERVED+15)
#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+16)
#define SYS_sem_trywait (CONFIG_SYS_RESERVED+17)
#define SYS_sem_wait (CONFIG_SYS_RESERVED+18)
/* Named semaphores */
#ifdef CONFIG_FS_NAMED_SEMAPHORES
# define SYS_sem_open (CONFIG_SYS_RESERVED+19)
# define SYS_sem_close (CONFIG_SYS_RESERVED+20)
# define SYS_sem_unlink (CONFIG_SYS_RESERVED+21)
# define __SYS_task_create (CONFIG_SYS_RESERVED+22)
#else
# define __SYS_task_create (CONFIG_SYS_RESERVED+19)
#endif
/* Task creation APIs based on global entry points cannot be use with
* address environments.
*/
#ifndef CONFIG_BUILD_KERNEL
# define SYS_task_create (CONFIG_SYS_RESERVED+22)
# define __SYS_task_delete (CONFIG_SYS_RESERVED+23)
# define SYS_task_create __SYS_task_create
# define __SYS_task_delete (__SYS_task_create+1)
/* pgalloc() is only available with address environments with the page
* allocator selected. MMU support from the CPU is also required.
*/
#else
# define SYS_pgalloc (CONFIG_SYS_RESERVED+22)
# define __SYS_task_delete (CONFIG_SYS_RESERVED+23)
# define SYS_pgalloc __SYS_task_create
# define __SYS_task_delete (__SYS_task_create+1)
#endif
# define SYS_task_delete __SYS_task_delete

View File

@ -99,13 +99,13 @@
"sched_yield","sched.h","","int"
"seekdir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","void","FAR DIR*","off_t"
"select","sys/select.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","FAR fd_set*","FAR fd_set*","FAR fd_set*","FAR struct timeval*"
"sem_close","semaphore.h","","int","FAR sem_t*"
"sem_close","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR sem_t*"
"sem_destroy","semaphore.h","","int","FAR sem_t*"
"sem_open","semaphore.h","","FAR sem_t*","FAR const char*","int","..."
"sem_open","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","FAR sem_t*","FAR const char*","int","..."
"sem_post","semaphore.h","","int","FAR sem_t*"
"sem_timedwait","semaphore.h","","int","FAR sem_t*","FAR const struct timespec *"
"sem_trywait","semaphore.h","","int","FAR sem_t*"
"sem_unlink","semaphore.h","","int","FAR const char*"
"sem_unlink","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR const char*"
"sem_wait","semaphore.h","","int","FAR sem_t*"
"send","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int"
"sendfile","sys/sendfile.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET_SENDFILE)","ssize_t","int","int","FAR off_t*","size_t"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -56,15 +56,24 @@ SYSCALL_LOOKUP(sched_setparam, 2, STUB_sched_setparam)
SYSCALL_LOOKUP(sched_setscheduler, 3, STUB_sched_setscheduler)
SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock)
SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield)
SYSCALL_LOOKUP(sem_close, 1, STUB_sem_close)
SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno)
/* Semaphores */
SYSCALL_LOOKUP(sem_destroy, 2, STUB_sem_destroy)
SYSCALL_LOOKUP(sem_open, 6, STUB_sem_open)
SYSCALL_LOOKUP(sem_post, 1, STUB_sem_post)
SYSCALL_LOOKUP(sem_timedwait, 2, STUB_sem_timedwait)
SYSCALL_LOOKUP(sem_trywait, 1, STUB_sem_trywait)
SYSCALL_LOOKUP(sem_unlink, 1, STUB_sem_unlink)
SYSCALL_LOOKUP(sem_wait, 1, STUB_sem_wait)
SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno)
/* Named semaphores */
#ifdef defined(CONFIG_FS_NAMED_SEMAPHORES)
SYSCALL_LOOKUP(sem_open, 6, STUB_sem_open)
SYSCALL_LOOKUP(sem_close, 1, STUB_sem_close)
SYSCALL_LOOKUP(sem_unlink, 1, STUB_sem_unlink)
#endif
#ifndef CONFIG_BUILD_KERNEL
SYSCALL_LOOKUP(task_create, 5, STUB_task_create)
#else