Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * 
0006  * @brief POSIX Timers Internal Support
0007  *
0008  * This include files defines the internal support for implementation of
0009  * POSIX Timers.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2011.
0014  *  On-Line Applications Research Corporation (OAR).
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_POSIX_TIMER_H
0039 #define _RTEMS_POSIX_TIMER_H
0040 
0041 #include <rtems/score/objectdata.h>
0042 #include <rtems/score/watchdog.h>
0043 
0044 #include <pthread.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 /**
0051  * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support
0052  *
0053  * @ingroup POSIXAPI
0054  */
0055 /**@{*/
0056 
0057 /*
0058  * Data for a timer
0059  */
0060 typedef struct {
0061   Objects_Control   Object;
0062   Watchdog_Control  Timer;      /* Internal Timer                        */
0063   pthread_t         thread_id;  /* Thread identifier                     */
0064   char              state;      /* State of the timer                    */
0065   struct sigevent   inf;        /* Information associated to the timer   */
0066   struct itimerspec timer_data; /* Timing data of the timer              */
0067   uint32_t          ticks;      /* Number of ticks of the initialization */
0068   uint32_t          overrun;    /* Number of expirations of the timer    */
0069   struct timespec   time;       /* Time at which the timer was started   */
0070   clockid_t         clock_type; /* The type of timer */
0071 } POSIX_Timer_Control;
0072 
0073 /**
0074  * @brief The POSIX Timer objects information.
0075  */
0076 extern Objects_Information _POSIX_Timer_Information;
0077 
0078 /**
0079  * @brief Macro to define the objects information for the POSIX Timer objects.
0080  *
0081  * This macro should only be used by <rtems/confdefs.h>.
0082  *
0083  * @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag
0084  * may be set).
0085  */
0086 #define POSIX_TIMER_INFORMATION_DEFINE( max ) \
0087   OBJECTS_INFORMATION_DEFINE( \
0088     _POSIX_Timer, \
0089     OBJECTS_POSIX_API, \
0090     OBJECTS_POSIX_TIMERS, \
0091     POSIX_Timer_Control, \
0092     max, \
0093     OBJECTS_NO_STRING_NAME, \
0094     NULL \
0095   )
0096 
0097 /**
0098  * @brief Follow POSIX or FACE Technical Standard on timer_create
0099  *
0100  * POSIX allows for the creation of timers based on CLOCK_REALTIME.
0101  * This is viewed as a safety issue by the FACE Technical Standard
0102  * and required to return an error. These are conflicting behaviors.
0103  * This method is instanced by configuration when FACE conformant
0104  * behavior is desired by the application.
0105  *
0106  * @param[in] clock_id is the clock ID to validate
0107  *
0108  * @return 0 if @a clock_id is allowed for use. Otherwise an errno value.
0109  */
0110 int _POSIX_Timer_Is_allowed(
0111   clockid_t clock_id
0112 );
0113 
0114 
0115 /** @} */
0116 
0117 #ifdef __cplusplus
0118 }
0119 #endif
0120 
0121 #endif
0122 /* end of include file */