2012-11-10 17:06:01 +01:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/signal/sig_addset.c
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <signal.h>
|
2015-04-09 16:05:47 +02:00
|
|
|
#include <errno.h>
|
2023-03-23 21:36:14 +01:00
|
|
|
#include <nuttx/signal.h>
|
2012-11-10 17:06:01 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2020-04-29 18:53:36 +02:00
|
|
|
* Name: nxsig_addset
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function adds the signal specified by signo to the signal set
|
|
|
|
* specified by set.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2023-03-23 21:36:14 +01:00
|
|
|
* set - Signal set to add signal to
|
2012-11-10 17:06:01 +01:00
|
|
|
* signo - Signal to add
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2020-04-29 18:53:36 +02:00
|
|
|
* This is an internal OS interface and should not be used by applications.
|
|
|
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
|
|
|
* returned on success. A negated errno value is returned on failure.
|
|
|
|
*
|
|
|
|
* EINVAL - The signo argument is invalid.
|
2012-11-10 17:06:01 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
int nxsig_addset(FAR sigset_t *set, int signo)
|
2012-11-10 17:06:01 +01:00
|
|
|
{
|
|
|
|
/* Verify the signal */
|
|
|
|
|
2015-04-09 16:05:47 +02:00
|
|
|
if (!GOOD_SIGNO(signo))
|
|
|
|
{
|
2020-04-29 18:53:36 +02:00
|
|
|
return -EINVAL;
|
2015-04-09 16:05:47 +02:00
|
|
|
}
|
|
|
|
else
|
2012-11-10 17:06:01 +01:00
|
|
|
{
|
|
|
|
/* Add the signal to the set */
|
|
|
|
|
2023-03-23 21:36:14 +01:00
|
|
|
set->_elem[_SIGSET_NDX(signo)] |= _SIGNO2SET(signo);
|
2015-04-09 16:05:47 +02:00
|
|
|
return OK;
|
2012-11-10 17:06:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-29 18:53:36 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: sigaddset
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function adds the signal specified by signo to the signal set
|
|
|
|
* specified by set.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* set - Signal set to add signal to
|
|
|
|
* signo - Signal to add
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0 (OK), or -1 (ERROR) if the signal number is invalid.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int sigaddset(FAR sigset_t *set, int signo)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Let nxsig_addset do all the work. */
|
|
|
|
|
|
|
|
ret = nxsig_addset(set, signo);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
set_errno(EINVAL);
|
|
|
|
ret = ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|