mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 06:13:33 +08:00
Manually fixup merge botches via direct comparison with NuttX r5447.
This commit is contained in:
+10
-1
@@ -214,12 +214,17 @@ config SCHED_ATEXIT
|
||||
config SCHED_ATEXIT_MAX
|
||||
int "Max number of atexit() functions"
|
||||
default 1
|
||||
depends on SCHED_ATEXIT
|
||||
depends on SCHED_ATEXIT && !SCHED_ONEXIT
|
||||
---help---
|
||||
By default if SCHED_ATEXIT is selected, only a single atexit() function
|
||||
is supported. That number can be increased by defined this setting to
|
||||
the number that you require.
|
||||
|
||||
If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
|
||||
on top of the on_exit() implementation. In that case, SCHED_ONEXIT_MAX
|
||||
determines the size of the combined number of atexit(0) and on_exit calls
|
||||
and SCHED_ATEXIT_MAX is not used.
|
||||
|
||||
config SCHED_ONEXIT
|
||||
bool "Enable on_exit() API"
|
||||
default n
|
||||
@@ -235,6 +240,10 @@ config SCHED_ONEXIT_MAX
|
||||
is supported. That number can be increased by defined this setting to the
|
||||
number that you require.
|
||||
|
||||
If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
|
||||
on top of the on_exit() implementation. In that case, SCHED_ONEXIT_MAX
|
||||
determines the size of the combined number of atexit(0) and on_exit calls.
|
||||
|
||||
config USER_ENTRYPOINT
|
||||
string "Application entry point"
|
||||
default "user_start"
|
||||
|
||||
@@ -94,7 +94,7 @@ SIGNAL_SRCS = sig_initialize.c \
|
||||
sig_findaction.c sig_allocatependingsigaction.c \
|
||||
sig_releasependingsigaction.c sig_unmaskpendingsignal.c \
|
||||
sig_removependingsignal.c sig_releasependingsignal.c sig_lowest.c \
|
||||
sig_mqnotempty.c sig_cleanup.c sig_received.c sig_deliver.c
|
||||
sig_mqnotempty.c sig_cleanup.c sig_received.c sig_deliver.c pause.c
|
||||
|
||||
MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c\
|
||||
mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c \
|
||||
@@ -188,6 +188,7 @@ OBJS = $(AOBJS) $(COBJS)
|
||||
BIN = libsched$(LIBEXT)
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: context depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
@@ -196,21 +197,20 @@ $(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
$(Q) $(MKDEP) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f $(BIN) *~ .*.swp
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
+14
-2
@@ -96,8 +96,13 @@
|
||||
* CONFIG_SCHED_ATEXIT_MAX defines a larger number.
|
||||
* 2. atexit functions are not inherited when a new task is
|
||||
* created.
|
||||
* 3. If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit()
|
||||
* is built on top of the on_exit() implementation. In that case,
|
||||
* CONFIG_SCHED_ONEXIT_MAX determines the size of the combined
|
||||
* number of atexit(0) and on_exit calls and SCHED_ATEXIT_MAX is
|
||||
* not used.
|
||||
*
|
||||
* Parameters:
|
||||
* Input Parameters:
|
||||
* func - A pointer to the function to be called when the task exits.
|
||||
*
|
||||
* Return Value:
|
||||
@@ -107,7 +112,14 @@
|
||||
|
||||
int atexit(void (*func)(void))
|
||||
{
|
||||
#if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
#if defined(CONFIG_SCHED_ONEXIT)
|
||||
/* atexit is equivalent to on_exit() with no argument (Assuming that the ABI
|
||||
* can handle a callback function that recieves more parameters than it expects).
|
||||
*/
|
||||
|
||||
return on_exit(onexitfunc_t func, NULL);
|
||||
|
||||
#elif defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int index;
|
||||
int ret = ERROR;
|
||||
|
||||
@@ -113,7 +113,6 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
|
||||
FAR msgq_t *msgq;
|
||||
mqd_t mqdes = NULL;
|
||||
va_list arg; /* Points to each un-named argument */
|
||||
mode_t mode; /* MQ creation mode parameter (ignored) */
|
||||
struct mq_attr *attr; /* MQ creation attributes */
|
||||
int namelen; /* Length of MQ name */
|
||||
|
||||
@@ -170,7 +169,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
|
||||
*/
|
||||
|
||||
va_start(arg, oflags);
|
||||
mode = va_arg(arg, mode_t);
|
||||
(void)va_arg(arg, mode_t); /* MQ creation mode parameter (ignored) */
|
||||
attr = va_arg(arg, struct mq_attr*);
|
||||
|
||||
/* Initialize the new named message queue */
|
||||
|
||||
@@ -117,7 +117,7 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
#if defined(CONFIG_SCHED_ONEXIT_MAX) && CONFIG_SCHED_ONEXIT_MAX > 1
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int index;
|
||||
int ret = ERROR;
|
||||
int ret = ENOSPC;
|
||||
|
||||
/* The following must be atomic */
|
||||
|
||||
@@ -131,7 +131,6 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
* indices.
|
||||
*/
|
||||
|
||||
available = -1;
|
||||
for (index = 0; index < CONFIG_SCHED_ONEXIT_MAX; index++)
|
||||
{
|
||||
if (!tcb->onexitfunc[index])
|
||||
@@ -149,7 +148,7 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
return ret;
|
||||
#else
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int ret = ERROR;
|
||||
int ret = ENOSPC;
|
||||
|
||||
/* The following must be atomic */
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
* sched/pause.c
|
||||
*
|
||||
* Copyright (C) 2012 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Preprocessor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pause
|
||||
*
|
||||
* Description:
|
||||
* The pause() function will suspend the calling thread until delivery of a
|
||||
* non-blocked signal.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Since pause() suspends thread execution indefinitely unless interrupted
|
||||
* a signal, there is no successful completion return value. A value of -1
|
||||
* will always be returned and errno set to indicate the error (EINTR).
|
||||
*
|
||||
* POSIX compatibility:
|
||||
* In the POSIX description of this function is the pause() function will
|
||||
* suspend the calling thread until delivery of a signal whose action is
|
||||
* either to execute a signal-catching function or to terminate the
|
||||
* process. This implementation only waits for any non-blocked signal
|
||||
* to be received.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int pause(void)
|
||||
{
|
||||
sigset_t set;
|
||||
struct siginfo value;
|
||||
|
||||
/* Set up for the sleep. Using the empty set means that we are not
|
||||
* waiting for any particular signal. However, any unmasked signal
|
||||
* can still awaken sigtimedwait().
|
||||
*/
|
||||
|
||||
(void)sigemptyset(&set);
|
||||
|
||||
/* sigtwaitinfo() cannot succeed. It should always return error EINTR
|
||||
* meaning that some unblocked signal was caught.
|
||||
*/
|
||||
|
||||
return sigwaitinfo(&set, &value);
|
||||
}
|
||||
@@ -129,3 +129,4 @@ int sched_getscheduler(pid_t pid)
|
||||
return SCHED_FIFO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ FAR sem_t *sem_open (FAR const char *name, int oflag, ...)
|
||||
FAR nsem_t *psem;
|
||||
FAR sem_t *sem = (FAR sem_t*)ERROR;
|
||||
va_list arg; /* Points to each un-named argument */
|
||||
mode_t mode; /* Creation mode parameter (ignored) */
|
||||
unsigned int value; /* Semaphore value parameter */
|
||||
|
||||
/* Make sure that a non-NULL name is supplied */
|
||||
@@ -165,7 +164,7 @@ FAR sem_t *sem_open (FAR const char *name, int oflag, ...)
|
||||
*/
|
||||
|
||||
va_start(arg, oflag);
|
||||
mode = va_arg(arg, mode_t);
|
||||
(void)va_arg(arg, mode_t); /* Creation mode parameter (ignored) */
|
||||
value = va_arg(arg, unsigned int);
|
||||
|
||||
/* Verify that a legal initial value was selected. */
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ unsigned int sleep(unsigned int seconds)
|
||||
if (seconds)
|
||||
{
|
||||
/* Set up for the sleep. Using the empty set means that we are not
|
||||
* waiting for any particualar signal. However, any unmasked signal
|
||||
* waiting for any particular signal. However, any unmasked signal
|
||||
* can still awaken sigtimedwait().
|
||||
*/
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
* Call any registerd atexit function(s)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_ATEXIT
|
||||
|
||||
#if defined(CONFIG_SCHED_ATEXIT) && !defined(CONFIG_SCHED_ONEXIT)
|
||||
static inline void task_atexit(FAR _TCB *tcb)
|
||||
{
|
||||
#if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
|
||||
@@ -137,7 +137,7 @@ int usleep(useconds_t usec)
|
||||
if (usec)
|
||||
{
|
||||
/* Set up for the sleep. Using the empty set means that we are not
|
||||
* waiting for any particualar signal. However, any unmasked signal
|
||||
* waiting for any particular signal. However, any unmasked signal
|
||||
* can still awaken sigtimedwait().
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user