reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
platform.h File Reference
#include "tag.h"
#include <assert.h>

Go to the source code of this file.

Macros

#define LF_TIMEOUT   1
 
#define DEPRECATED(X)   X
 

Typedefs

typedef struct environment_t environment_t
 
typedef void lf_mutex_t
 

Functions

int lf_notify_of_event (environment_t *env)
 Notify of new event by calling the unthreaded platform API.
 
int lf_critical_section_enter (environment_t *env)
 Enter critical section by disabling interrupts.
 
int lf_critical_section_exit (environment_t *env)
 Leave a critical section by enabling interrupts.
 
void _lf_initialize_clock (void)
 
int _lf_clock_now (instant_t *t)
 
int lf_sleep (interval_t sleep_duration)
 
int _lf_interruptable_sleep_until_locked (environment_t *env, instant_t wakeup_time)
 Sleep until the given wakeup time. Assumes the lock for the given environment is held.
 
 DEPRECATED (int lf_nanosleep(interval_t sleep_duration))
 

Macro Definition Documentation

◆ DEPRECATED

#define DEPRECATED (   X )    X

Macros for marking function as deprecated

◆ LF_TIMEOUT

#define LF_TIMEOUT   1

Typedef Documentation

◆ environment_t

Copyright (c) 2021, The University of California at Berkeley.

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.

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 HOLDER 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. Platform API support for the C target of Lingua Franca. This file detects the platform on which the C compiler is being run (e.g. Windows, Linux, Mac) and conditionally includes platform-specific files that define core datatypes and function signatures for Lingua Franca.

Author
{Soroush Bateni sorou.nosp@m.sh@u.nosp@m.tdall.nosp@m.as.e.nosp@m.du}

◆ lf_mutex_t

Function Documentation

◆ _lf_clock_now()

int _lf_clock_now ( instant_t t)

Fetch the value of an internal (and platform-specific) physical clock and store it in t.

Ideally, the underlying platform clock should be monotonic. However, the core lib tries to enforce monotonicity at higher level APIs (see tag.h).

Returns
0 for success, or -1 for failure

◆ _lf_initialize_clock()

void _lf_initialize_clock ( void  )

Initialize the LF clock. Must be called before using other clock-related APIs.

◆ _lf_interruptable_sleep_until_locked()

int _lf_interruptable_sleep_until_locked ( environment_t env,
instant_t  wakeup_time 
)

Sleep until the given wakeup time. Assumes the lock for the given environment is held.

Parameters
envThe environment within which to sleep.
wakeup_timeThe time instant at which to wake up.
Returns
int 0 if sleep completed, or -1 if it was interrupted.

◆ DEPRECATED()

DEPRECATED ( int   lf_nanosleepinterval_t sleep_duration)
Deprecated:
version of "lf_sleep"

◆ lf_critical_section_enter()

int lf_critical_section_enter ( environment_t env)

Enter critical section by disabling interrupts.

Parameters
envEnvironment in which we are executing.

Enter a critical section where logical time and the event queue are guaranteed to not change unless they are changed within the critical section. this can be implemented by disabling interrupts. Users of this function must ensure that lf_init_critical_sections() is called first and that lf_critical_section_exit() is called later.

Parameters
envIgnored (present for compatibility).
Returns
0 on success, platform-specific error number otherwise.

◆ lf_critical_section_exit()

int lf_critical_section_exit ( environment_t env)

Leave a critical section by enabling interrupts.

Parameters
envEnvironment in which we are executing.

Exit the critical section entered with lf_lock_time().

Parameters
envIgnored (present for compatibility).
Returns
0 on success, platform-specific error number otherwise.

◆ lf_notify_of_event()

int lf_notify_of_event ( environment_t env)

Notify of new event by calling the unthreaded platform API.

Parameters
envEnvironment in which we are executing.

◆ lf_sleep()

int lf_sleep ( interval_t  sleep_duration)

Pause execution for a given duration.

Returns
0 for success, or -1 for failure.