2016-08-07 22:25:30 +08:00
|
|
|
/****************************************************************************
|
2014-08-09 04:55:16 +08:00
|
|
|
* sched/timer/timer_delete.c
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
2020-03-12 04:09:41 +08: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
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
2020-03-12 04:09:41 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
2020-03-12 04:09:41 +08: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.
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
2016-08-07 22:25:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-21 08:56:49 +08:00
|
|
|
|
2016-08-07 22:25:30 +08:00
|
|
|
/****************************************************************************
|
2007-03-21 08:56:49 +08:00
|
|
|
* Included Files
|
2016-08-07 22:25:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-21 08:56:49 +08:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2011-04-05 23:50:01 +08:00
|
|
|
|
2007-03-21 08:56:49 +08:00
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
2008-06-03 09:31:13 +08:00
|
|
|
|
2014-08-09 04:55:16 +08:00
|
|
|
#include "timer/timer.h"
|
2007-03-21 08:56:49 +08:00
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
|
|
|
|
2016-08-07 22:25:30 +08:00
|
|
|
/****************************************************************************
|
2007-03-21 08:56:49 +08:00
|
|
|
* Public Functions
|
2016-08-07 22:25:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-21 08:56:49 +08:00
|
|
|
|
2016-08-07 22:25:30 +08:00
|
|
|
/****************************************************************************
|
2012-07-15 03:30:31 +08:00
|
|
|
* Name: timer_delete
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
|
|
|
* Description:
|
2016-08-07 22:25:30 +08:00
|
|
|
* The timer_delete() function deletes the specified timer, timerid,
|
|
|
|
* previously created by the timer_create() function. If the timer is
|
|
|
|
* armed when timer_delete() is called, the timer will be automatically
|
|
|
|
* disarmed before removal. The disposition of pending signals for the
|
|
|
|
* deleted timer is unspecified.
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
2018-03-13 23:52:27 +08:00
|
|
|
* Input Parameters:
|
2008-06-03 09:21:12 +08:00
|
|
|
* timerid - The per-thread timer, previously created by the call to
|
2007-03-21 08:56:49 +08:00
|
|
|
* timer_create(), to be deleted.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Returned Value:
|
2016-08-07 22:25:30 +08:00
|
|
|
* If the call succeeds, timer_create() will return 0 (OK). Otherwise,
|
|
|
|
* the function will return a value of -1 (ERROR) and set errno to
|
|
|
|
* indicate the error.
|
2007-03-21 08:56:49 +08:00
|
|
|
*
|
|
|
|
* EINVAL - The timer specified timerid is not valid.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
2016-08-07 22:25:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-21 08:56:49 +08:00
|
|
|
|
|
|
|
int timer_delete(timer_t timerid)
|
|
|
|
{
|
2022-11-01 02:11:18 +08:00
|
|
|
int ret = timer_release(timer_gethandle(timerid));
|
2008-06-03 09:21:12 +08:00
|
|
|
if (ret < 0)
|
2008-06-02 01:46:26 +08:00
|
|
|
{
|
2012-07-15 03:30:31 +08:00
|
|
|
set_errno(-ret);
|
|
|
|
return ERROR;
|
2008-06-02 01:46:26 +08:00
|
|
|
}
|
2012-07-15 03:30:31 +08:00
|
|
|
|
2007-03-22 01:21:26 +08:00
|
|
|
return OK;
|
2007-03-21 08:56:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_DISABLE_POSIX_TIMERS */
|