#ifndef FRSH_FOSA_H_
#define FRSH_FOSA_H_
+#include <stdlib.h> /* For size_t */
#include "frsh_fosa_opaque.h"
+/**
+ * @file frsh_fosa.h
+ **/
+
+
/**
* @defgroup frshfosa FRSH FOSA public interfaces
*
* functions into neutral names so that FRSH can compile and be used in
* non-POSIX operating systems such as OSE.
*
- * This module contains the minimum FOSA functionality that the
- * application needs to use to interface with FRSH in an OS neutral
- * layer.
+ * It is divided in two parts:
+ * - FRSH_FOSA: Types visibles to the application via FRSH_API
+ * (thread, signal, mutexes).
+ * - FOSA: Types and functions only used within FRSH.
+ *
+ * The former reside in the FRSH subversion directory and the latter
+ * have their own. They need to be separated because the application
+ * must not see FOSA itself.
*
- * frsh_fosa_opaque.h is the only file in which there is some
- * conditional compilation. This means that in order to compile
- * FRSH you will have to give a define for the platform.
+ * For simplicity, we have chosen to hide the operation function on
+ * signals and mutexes with the assumption that a direct mapping
+ * exists for frsh_signal_t, frsh_signal_info_t and frsh_mutext_t in
+ * the native OS.
*
- * Currently supported defines are:
+ * Since there are some parts which are platform dependent a define
+ * has been introduced for each platform. Currently the supported
+ * defines are:
*
* -DRT_LINUX
- * -DMARTE_OS
* -DOSE
+ * -DMARTE_OS
+ * -DAQuoSA
+ * -DVIRTUAL_TIME
+ *
+ * This module contains the FOSA part exposed by the FRSH_API and
+ * visible for the application.
*
* On the other hand, there was another file in the API which was also
* OS-dependent: frsh_os_compatibility.h. However this dependency
* @{
**/
+/**
+ * Bool as a byte value (char)
+ *
+ * We will revisit this if we have a problem with bool in C++
+ **/
/** identifier of a frsh thread **/
/** thread attributes object **/
typedef FOSA_THREAD_ATTR_T_OPAQUE frsh_thread_attr_t;
+/**
+ * The type references a function that may become a thread's
+ * code
+ **/
+typedef void * (*frsh_thread_code_t) (void *);
+
+
/** signal number; it is an integer type **/
typedef FOSA_SIGNAL_T_OPAQUE frsh_signal_t;
#define FRSH_NULL_SIGNAL FOSA_NULL_SIGNAL
#define FRSH_SIGNAL_MIN FOSA_SIGNAL_MIN
#define FRSH_SIGNAL_MAX FOSA_SIGNAL_MAX
+
+
/** information associated to a signal **/
-typedef union {int value; void * area; } frsh_signal_info_t;
+#if defined(VIRTUAL_TIME)
+
+#include <vt_ose.h>
+typedef vt_posix_signal_info_t frsh_signal_info_t;
+
+#else
+
+typedef union {int sival_int; void * sival_ptr; } frsh_signal_info_t;
+/* typedef FRSH_SIGNAL_INFO_T_OPAQUE frsh_signal_info_t; */
+
+#endif
+
+
+
/** Mutex object. Attributes are handled by FOSA **/
typedef FOSA_MUTEX_T_OPAQUE frsh_mutex_t;
* This function initializes the object pointed to by attr to all
* the default values defined by FRSH
*
- * Returns 0 if successful; otherwise it returns
- * ENOMEM: insufficient memory exists to initialize the thread
+ * @return 0 if successful; otherwise it returns \n
+ * FOSA_ENOMEM: insufficient memory exists to initialize the thread
* attributes object
**/
int frsh_thread_attr_init(frsh_thread_attr_t *attr);
* attributes object is used to create a thread, when it will be
* created with the specified minimum stack size
*
- * Returns 0 if successful, or the following error code:
- * EINVAL: the specified stacksize value is not supported in
+ * @return 0 if successful, or the following error code:
+ * FOSA_EINVAL: the specified stacksize value is not supported in
* this implementation
*/
int frsh_thread_attr_set_stacksize(frsh_thread_attr_t *attr, size_t stacksize);
* This function sets the variable pointed to by stacksize to the
* minimum stack size stored in the thread attributes object attr.
*
- * Returns 0
+ * @return 0
*/
int frsh_thread_attr_get_stacksize
(const frsh_thread_attr_t *attr, size_t *stacksize);