From b738a646adb577c0e6514e128131bc24030eb9b3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 2 Nov 2016 09:29:16 -0600 Subject: [PATCH] sem_getprotocol() can be in C library --- include/sys/syscall.h | 5 ++--- libc/semaphore/Make.defs | 6 +++++- {sched => libc}/semaphore/sem_getprotocol.c | 6 ++---- sched/semaphore/Make.defs | 3 +-- syscall/syscall.csv | 1 - syscall/syscall_lookup.h | 1 - syscall/syscall_stublookup.c | 1 - 7 files changed, 10 insertions(+), 13 deletions(-) rename {sched => libc}/semaphore/sem_getprotocol.c (96%) diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 134b2cb27d..d0bfcd9597 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -92,9 +92,8 @@ #define SYS_sem_wait (CONFIG_SYS_RESERVED+19) #ifdef CONFIG_PRIORITY_INHERITANCE -# define SYS_sem_getprotocol (CONFIG_SYS_RESERVED+20) -# define SYS_sem_setprotocol (CONFIG_SYS_RESERVED+21) -# define __SYS_named_sem (CONFIG_SYS_RESERVED+22) +# define SYS_sem_setprotocol (CONFIG_SYS_RESERVED+20) +# define __SYS_named_sem (CONFIG_SYS_RESERVED+21) #else # define __SYS_named_sem (CONFIG_SYS_RESERVED+20) #endif diff --git a/libc/semaphore/Make.defs b/libc/semaphore/Make.defs index b6551ff96a..d456f07520 100644 --- a/libc/semaphore/Make.defs +++ b/libc/semaphore/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # libc/semaphore/Make.defs # -# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,6 +37,10 @@ CSRCS += sem_init.c sem_getvalue.c +ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) +CSRCS += sem_getprotocol.c +endif + # Add the semaphore directory to the build DEPPATH += --dep-path semaphore diff --git a/sched/semaphore/sem_getprotocol.c b/libc/semaphore/sem_getprotocol.c similarity index 96% rename from sched/semaphore/sem_getprotocol.c rename to libc/semaphore/sem_getprotocol.c index f3dc169e6e..abbc4c02db 100644 --- a/sched/semaphore/sem_getprotocol.c +++ b/libc/semaphore/sem_getprotocol.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/semaphore/sem_getprotocol.c + * libc/semaphore/sem_getprotocol.c * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -42,8 +42,6 @@ #include #include -#include "semaphore/semaphore.h" - #ifdef CONFIG_PRIORITY_INHERITANCE /**************************************************************************** @@ -70,7 +68,7 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol) { - DEBUGASSERT(sem != NULL); + DEBUGASSERT(sem != NULL && protocol != NULL); if ((sem->flags & PRIOINHERIT_FLAGS_DISABLE) != 0) { diff --git a/sched/semaphore/Make.defs b/sched/semaphore/Make.defs index 70b9e356bd..7eb1740424 100644 --- a/sched/semaphore/Make.defs +++ b/sched/semaphore/Make.defs @@ -40,8 +40,7 @@ CSRCS += sem_timedwait.c sem_timeout.c sem_post.c sem_recover.c CSRCS += sem_reset.c sem_waitirq.c ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) -CSRCS += sem_initialize.c sem_holder.c -CSRCS += sem_setprotocol.c sem_getprotocol.c +CSRCS += sem_initialize.c sem_holder.c sem_setprotocol.c endif ifeq ($(CONFIG_SPINLOCK),y) diff --git a/syscall/syscall.csv b/syscall/syscall.csv index b745998c4b..8d8307f42a 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -117,7 +117,6 @@ "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","defined(CONFIG_FS_NAMED_SEMAPHORES)","FAR sem_t*","FAR const char*","int","..." -"sem_getprotocol","semaphore.h","defined(CONFIG_PRIORITY_INHERITANCE)","int","FAR sem_t*","FAR int*" "sem_post","semaphore.h","","int","FAR sem_t*" "sem_setprotocol","semaphore.h","defined(CONFIG_PRIORITY_INHERITANCE)","int","FAR sem_t*","int" "sem_timedwait","semaphore.h","","int","FAR sem_t*","FAR const struct timespec *" diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index e3506707d8..0c16b8ce1e 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -68,7 +68,6 @@ SYSCALL_LOOKUP(sem_trywait, 1, STUB_sem_trywait) SYSCALL_LOOKUP(sem_wait, 1, STUB_sem_wait) #ifdef CONFIG_PRIORITY_INHERITANCE -SYSCALL_LOOKUP(sem_getprotocol, 2, STUB_sem_getprotocol) SYSCALL_LOOKUP(sem_setprotocol, 2, STUB_sem_setprotocol) #endif diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 996763daea..f655e0800d 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -82,7 +82,6 @@ uintptr_t STUB_uname(int nbr, uintptr_t parm1); uintptr_t STUB_sem_close(int nbr, uintptr_t parm1); uintptr_t STUB_sem_destroy(int nbr, uintptr_t parm1); -uintptr_t STUB_sem_getprotocol(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_sem_open(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); uintptr_t STUB_sem_post(int nbr, uintptr_t parm1);