mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
fs/vfs: Add file descriptor based timers support
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
committed by
Xiang Xiao
parent
187d9e58c9
commit
d445282566
@@ -90,7 +90,7 @@ extern "C"
|
||||
* Name: wd_start
|
||||
*
|
||||
* Description:
|
||||
* This function adds a watchdog timer to the actuve timer queue. The
|
||||
* This function adds a watchdog timer to the active timer queue. The
|
||||
* specified watchdog function at 'wdentry' will be called from the
|
||||
* interrupt level after the specified number of ticks has elapsed.
|
||||
* Watchdog timers may be started from the interrupt level.
|
||||
|
||||
@@ -218,6 +218,11 @@ SYSCALL_LOOKUP(pwrite, 4)
|
||||
#ifdef CONFIG_EVENT_FD
|
||||
SYSCALL_LOOKUP(eventfd, 2)
|
||||
#endif
|
||||
#ifdef CONFIG_TIMER_FD
|
||||
SYSCALL_LOOKUP(timerfd_create, 2)
|
||||
SYSCALL_LOOKUP(timerfd_settime, 4)
|
||||
SYSCALL_LOOKUP(timerfd_gettime, 2)
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
SYSCALL_LOOKUP(tcdrain, 1)
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* include/sys/timerfd.h
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_TIMERFD_H
|
||||
#define __INCLUDE_SYS_TIMERFD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define TFD_NONBLOCK O_NONBLOCK
|
||||
#define TFD_CLOEXEC O_CLOEXEC
|
||||
|
||||
#define TFD_TIMER_ABSTIME TIMER_ABSTIME
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/* Type for timer counter */
|
||||
|
||||
/* Type for event counter */
|
||||
|
||||
#ifdef __INT64_DEFINED
|
||||
typedef uint64_t timerfd_t;
|
||||
#else
|
||||
typedef uint32_t timerfd_t;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int timerfd_create(int clockid, int flags);
|
||||
|
||||
int timerfd_settime(int fd, int flags,
|
||||
FAR const struct itimerspec *new_value,
|
||||
FAR struct itimerspec *old_value);
|
||||
|
||||
int timerfd_gettime(int fd, FAR struct itimerspec *curr_value);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_TIMERFD_H */
|
||||
Reference in New Issue
Block a user