From b52e4e5ecd924f1da7e8346c435ae5a795c203fe Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 10 Dec 2016 09:08:26 -0600 Subject: [PATCH] Move cancellation point definitions to their own header file. --- fs/vfs/fs_close.c | 2 +- fs/vfs/fs_fcntl.c | 2 +- fs/vfs/fs_fsync.c | 2 +- fs/vfs/fs_open.c | 2 +- fs/vfs/fs_poll.c | 2 +- fs/vfs/fs_pread.c | 2 +- fs/vfs/fs_pwrite.c | 2 +- fs/vfs/fs_read.c | 2 +- fs/vfs/fs_select.c | 2 +- fs/vfs/fs_write.c | 2 +- include/nuttx/cancelpt.h | 152 ++++++++++++++++++++++++++ include/nuttx/pthread.h | 88 --------------- net/socket/accept.c | 2 +- net/socket/connect.c | 2 +- net/socket/recvfrom.c | 2 +- net/socket/send.c | 2 +- net/socket/sendto.c | 2 +- sched/mqueue/mq_rcvinternal.c | 2 +- sched/mqueue/mq_receive.c | 2 +- sched/mqueue/mq_send.c | 2 +- sched/mqueue/mq_sndinternal.c | 2 +- sched/mqueue/mq_timedreceive.c | 2 +- sched/mqueue/mq_timedsend.c | 2 +- sched/pthread/pthread_condtimedwait.c | 2 +- sched/pthread/pthread_condwait.c | 2 +- sched/pthread/pthread_join.c | 2 +- sched/pthread/pthread_testcancel.c | 2 +- sched/sched/sched_wait.c | 1 - sched/sched/sched_waitid.c | 2 +- sched/sched/sched_waitpid.c | 2 +- sched/semaphore/sem_timedwait.c | 2 +- sched/semaphore/sem_wait.c | 2 +- sched/signal/sig_nanosleep.c | 2 +- sched/signal/sig_pause.c | 2 +- sched/signal/sig_suspend.c | 2 +- sched/signal/sig_timedwait.c | 2 +- sched/signal/sig_waitinfo.c | 2 +- sched/task/task_cancelpt.c | 2 +- 38 files changed, 187 insertions(+), 124 deletions(-) create mode 100644 include/nuttx/cancelpt.h diff --git a/fs/vfs/fs_close.c b/fs/vfs/fs_close.c index 2fcf2cb9b8..6020af5731 100644 --- a/fs/vfs/fs_close.c +++ b/fs/vfs/fs_close.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index 0fb10e9aa1..4d8e74b497 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include diff --git a/fs/vfs/fs_fsync.c b/fs/vfs/fs_fsync.c index b8ad29ccf3..60c5563497 100644 --- a/fs/vfs/fs_fsync.c +++ b/fs/vfs/fs_fsync.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include "inode/inode.h" diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 0c3bb5ffa5..a2a662f722 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -48,7 +48,7 @@ #include #endif -#include +#include #include #include "inode/inode.h" diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 9389c3e6d1..f0cc6ce2a9 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include diff --git a/fs/vfs/fs_pread.c b/fs/vfs/fs_pread.c index 0d63307c36..2385ea00a0 100644 --- a/fs/vfs/fs_pread.c +++ b/fs/vfs/fs_pread.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include /**************************************************************************** diff --git a/fs/vfs/fs_pwrite.c b/fs/vfs/fs_pwrite.c index 3e90e971b9..8e841247ca 100644 --- a/fs/vfs/fs_pwrite.c +++ b/fs/vfs/fs_pwrite.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include /**************************************************************************** diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c index aa792d648e..6da412c379 100644 --- a/fs/vfs/fs_read.c +++ b/fs/vfs/fs_read.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "inode/inode.h" diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index ca074bb2c7..acb42b35ae 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include "inode/inode.h" diff --git a/fs/vfs/fs_write.c b/fs/vfs/fs_write.c index c6f2292968..4731f26bb1 100644 --- a/fs/vfs/fs_write.c +++ b/fs/vfs/fs_write.c @@ -50,7 +50,7 @@ # include #endif -#include +#include #include "inode/inode.h" diff --git a/include/nuttx/cancelpt.h b/include/nuttx/cancelpt.h new file mode 100644 index 0000000000..8adfc8c217 --- /dev/null +++ b/include/nuttx/cancelpt.h @@ -0,0 +1,152 @@ +/**************************************************************************** + * include/nuttx/cancelpt.h + * Definitions related to cancellation points + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_CANCELPT_H +#define __INCLUDE_NUTTX_CANCELPT_H + +/**************************************************************************** + * Cancellation Points. + * + * Cancellation points shall occur when a thread is executing the following + * functions: + * + * accept() mq_timedsend() putpmsg() sigtimedwait() + * aio_suspend() msgrcv() pwrite() sigwait() + * clock_nanosleep() msgsnd() read() sigwaitinfo() + * close() msync() readv() sleep() + * connect() nanosleep() recv() system() + * creat() open() recvfrom() tcdrain() + * fcntl() pause() recvmsg() usleep() + * fdatasync() poll() select() wait() + * fsync() pread() sem_timedwait() waitid() + * getmsg() pselect() sem_wait() waitpid() + * getpmsg() pthread_cond_timedwait() send() write() + * lockf() pthread_cond_wait() sendmsg() writev() + * mq_receive() pthread_join() sendto() + * mq_send() pthread_testcancel() sigpause() + * mq_timedreceive() putmsg() sigsuspend() + * + * Each of the above function must call enter_cancellation_point() on entry + * in order to establish the cancellation point and leave_cancellation_point() + * on exit. These functions are described below. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: enter_cancellation_point + * + * Description: + * Called at the beginning of the cancellation point to establish the + * cancellation point. This function does the following: + * + * 1. If deferred cancellation does not apply to this thread, nothing is + * done, otherwise, it + * 2. Sets state information in the caller's TCB and increments a nesting + * count. + * 3. If this is the outermost nesting level, it checks if there is a + * pending cancellation and, if so, calls either exit() or + * pthread_exit(), depending upon the type of the thread. + * + * Input Parameters: + * None + * + * Returned Value + * true is returned if a cancellation is pending but cannot be performed + * now due to the nesting level. + * + ****************************************************************************/ + +#ifdef CONFIG_CANCELLATION_POINTS +bool enter_cancellation_point(void); +#else +# define enter_cancellation_point() false +#endif + +/**************************************************************************** + * Name: leave_cancellation_point + * + * Description: + * Called at the end of the cancellation point. This function does the + * following: + * + * 1. If deferred cancellation does not apply to this thread, nothing is + * done, otherwise, it + * 2. Clears state information in the caller's TCB and decrements a + * nesting count. + * 3. If this is the outermost nesting level, it checks if there is a + * pending cancellation and, if so, calls either exit() or + * pthread_exit(), depending upon the type of the thread. + * + * Input Parameters: + * None + * + * Returned Value + * None + * + ****************************************************************************/ + +#ifdef CONFIG_CANCELLATION_POINTS +void leave_cancellation_point(void); +#else +# define leave_cancellation_point() +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_CANCELPT_H */ diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h index 3250da7894..27fb5dd99c 100644 --- a/include/nuttx/pthread.h +++ b/include/nuttx/pthread.h @@ -43,7 +43,6 @@ #include -#include #include #include @@ -129,93 +128,6 @@ EXTERN const pthread_attr_t g_default_pthread_attr; * Public Function Prototypes ****************************************************************************/ -/**************************************************************************** - * Cancellation Points. - * - * Cancellation points shall occur when a thread is executing the following - * functions: - * - * accept() mq_timedsend() putpmsg() sigtimedwait() - * aio_suspend() msgrcv() pwrite() sigwait() - * clock_nanosleep() msgsnd() read() sigwaitinfo() - * close() msync() readv() sleep() - * connect() nanosleep() recv() system() - * creat() open() recvfrom() tcdrain() - * fcntl() pause() recvmsg() usleep() - * fdatasync() poll() select() wait() - * fsync() pread() sem_timedwait() waitid() - * getmsg() pselect() sem_wait() waitpid() - * getpmsg() pthread_cond_timedwait() send() write() - * lockf() pthread_cond_wait() sendmsg() writev() - * mq_receive() pthread_join() sendto() - * mq_send() pthread_testcancel() sigpause() - * mq_timedreceive() putmsg() sigsuspend() - * - * Each of the above function must call enter_cancellation_point() on entry - * in order to establish the cancellation point and leave_cancellation_point() - * on exit. These functions are described below. - * - ****************************************************************************/ - -/**************************************************************************** - * Name: enter_cancellation_point - * - * Description: - * Called at the beginning of the cancellation point to establish the - * cancellation point. This function does the following: - * - * 1. If deferred cancellation does not apply to this thread, nothing is - * done, otherwise, it - * 2. Sets state information in the caller's TCB and increments a nesting - * count. - * 3. If this is the outermost nesting level, it checks if there is a - * pending cancellation and, if so, calls either exit() or - * pthread_exit(), depending upon the type of the thread. - * - * Input Parameters: - * None - * - * Returned Value - * true is returned if a cancellation is pending but cannot be performed - * now due to the nesting level. - * - ****************************************************************************/ - -#ifdef CONFIG_CANCELLATION_POINTS -bool enter_cancellation_point(void); -#else -# define enter_cancellation_point() false -#endif - -/**************************************************************************** - * Name: leave_cancellation_point - * - * Description: - * Called at the end of the cancellation point. This function does the - * following: - * - * 1. If deferred cancellation does not apply to this thread, nothing is - * done, otherwise, it - * 2. Clears state information in the caller's TCB and decrements a - * nesting count. - * 3. If this is the outermost nesting level, it checks if there is a - * pending cancellation and, if so, calls either exit() or - * pthread_exit(), depending upon the type of the thread. - * - * Input Parameters: - * None - * - * Returned Value - * None - * - ****************************************************************************/ - -#ifdef CONFIG_CANCELLATION_POINTS -void leave_cancellation_point(void); -#else -# define leave_cancellation_point() -#endif - #undef EXTERN #ifdef __cplusplus } diff --git a/net/socket/accept.c b/net/socket/accept.c index 9179a8bd6f..4bf35dc7f2 100644 --- a/net/socket/accept.c +++ b/net/socket/accept.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include "tcp/tcp.h" diff --git a/net/socket/connect.c b/net/socket/connect.c index da5d9fb14e..6a0140ea55 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include #include diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index 88185aaeab..9a692fea8a 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -57,7 +57,7 @@ #include #include -#include +#include #include #include #include diff --git a/net/socket/send.c b/net/socket/send.c index c0c4dc75db..e90b27b116 100644 --- a/net/socket/send.c +++ b/net/socket/send.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include "tcp/tcp.h" #include "udp/udp.h" diff --git a/net/socket/sendto.c b/net/socket/sendto.c index 1de63028df..db51b73c79 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include "udp/udp.h" diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 55a72378cc..1b9c249e75 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "mqueue/mqueue.h" diff --git a/sched/mqueue/mq_receive.c b/sched/mqueue/mq_receive.c index 9a46b0d36d..31878a29a5 100644 --- a/sched/mqueue/mq_receive.c +++ b/sched/mqueue/mq_receive.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include "mqueue/mqueue.h" diff --git a/sched/mqueue/mq_send.c b/sched/mqueue/mq_send.c index 354d76e5c7..59e6eecebe 100644 --- a/sched/mqueue/mq_send.c +++ b/sched/mqueue/mq_send.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "mqueue/mqueue.h" diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index 0d7682dee2..10721add0a 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include "sched/sched.h" #ifndef CONFIG_DISABLE_SIGNALS diff --git a/sched/mqueue/mq_timedreceive.c b/sched/mqueue/mq_timedreceive.c index d764fbf396..9df2a6ab61 100644 --- a/sched/mqueue/mq_timedreceive.c +++ b/sched/mqueue/mq_timedreceive.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "sched/sched.h" #include "clock/clock.h" diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c index 588ae041fc..83e25515eb 100644 --- a/sched/mqueue/mq_timedsend.c +++ b/sched/mqueue/mq_timedsend.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "clock/clock.h" #include "sched/sched.h" diff --git a/sched/pthread/pthread_condtimedwait.c b/sched/pthread/pthread_condtimedwait.c index 0c1001a630..9027c305ef 100644 --- a/sched/pthread/pthread_condtimedwait.c +++ b/sched/pthread/pthread_condtimedwait.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "pthread/pthread.h" diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c index 06d691dfcd..e7c6a9af25 100644 --- a/sched/pthread/pthread_condwait.c +++ b/sched/pthread/pthread_condwait.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include "pthread/pthread.h" diff --git a/sched/pthread/pthread_join.c b/sched/pthread/pthread_join.c index 6eb795a199..01c1c713ea 100644 --- a/sched/pthread/pthread_join.c +++ b/sched/pthread/pthread_join.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "group/group.h" diff --git a/sched/pthread/pthread_testcancel.c b/sched/pthread/pthread_testcancel.c index 5f34ea86b7..d93af13807 100644 --- a/sched/pthread/pthread_testcancel.c +++ b/sched/pthread/pthread_testcancel.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include "sched/sched.h" diff --git a/sched/sched/sched_wait.c b/sched/sched/sched_wait.c index 8987098528..c558de50bf 100644 --- a/sched/sched/sched_wait.c +++ b/sched/sched/sched_wait.c @@ -44,7 +44,6 @@ #include #include -#include #include "sched/sched.h" diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c index 7f99a92e44..dd3dd86211 100644 --- a/sched/sched/sched_waitid.c +++ b/sched/sched/sched_waitid.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "group/group.h" diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 9aa0bada89..aca86d093f 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "group/group.h" diff --git a/sched/semaphore/sem_timedwait.c b/sched/semaphore/sem_timedwait.c index ec795c80e4..23c16cc2d5 100644 --- a/sched/semaphore/sem_timedwait.c +++ b/sched/semaphore/sem_timedwait.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include "sched/sched.h" #include "clock/clock.h" diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index 8baa20ea92..80827b62db 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "semaphore/semaphore.h" diff --git a/sched/signal/sig_nanosleep.c b/sched/signal/sig_nanosleep.c index 6f61dc45b9..05f2c88af7 100644 --- a/sched/signal/sig_nanosleep.c +++ b/sched/signal/sig_nanosleep.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "clock/clock.h" diff --git a/sched/signal/sig_pause.c b/sched/signal/sig_pause.c index 3c3ffa1497..5a83f1a735 100644 --- a/sched/signal/sig_pause.c +++ b/sched/signal/sig_pause.c @@ -42,7 +42,7 @@ #include #include -#include +#include /**************************************************************************** * Public Functions diff --git a/sched/signal/sig_suspend.c b/sched/signal/sig_suspend.c index 626683ca45..ab5cfd25fe 100644 --- a/sched/signal/sig_suspend.c +++ b/sched/signal/sig_suspend.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "signal/signal.h" diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c index f0451b3b43..bdb5376d8b 100644 --- a/sched/signal/sig_timedwait.c +++ b/sched/signal/sig_timedwait.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include "sched/sched.h" #include "signal/signal.h" diff --git a/sched/signal/sig_waitinfo.c b/sched/signal/sig_waitinfo.c index e332614583..73afb186de 100644 --- a/sched/signal/sig_waitinfo.c +++ b/sched/signal/sig_waitinfo.c @@ -41,7 +41,7 @@ #include -#include +#include /**************************************************************************** * Public Functions diff --git a/sched/task/task_cancelpt.c b/sched/task/task_cancelpt.c index b94ee7c336..07b4a664c8 100644 --- a/sched/task/task_cancelpt.c +++ b/sched/task/task_cancelpt.c @@ -71,7 +71,7 @@ #include #include -#include +#include #include "sched/sched.h" #include "semaphore/semaphore.h"