LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
thread_linux.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24*/
25
62#ifndef JUNO_THREAD_LINUX_H
63#define JUNO_THREAD_LINUX_H
64
65#include "juno/thread_api.h"
66#include <pthread.h>
67
68#ifdef __cplusplus
69extern "C"
70{
71#endif
72
73/* -------------------------------------------------------------------------
74 * Linux/POSIX derivation
75 * ---------------------------------------------------------------------- */
76
89// @{"req": ["REQ-THREAD-010", "REQ-THREAD-015"]}
90struct JUNO_THREAD_LINUX_TAG JUNO_MODULE_DERIVE(JUNO_THREAD_ROOT_T,
93 pthread_t _tHandle;
94);
95typedef struct JUNO_THREAD_LINUX_TAG JUNO_THREAD_LINUX_T;
96
97/* -------------------------------------------------------------------------
98 * Module union
99 * ---------------------------------------------------------------------- */
100
124 JUNO_THREAD_LINUX_T tLinux;
125);
126
127/* -------------------------------------------------------------------------
128 * Platform initialisation (RAII)
129 * ---------------------------------------------------------------------- */
130
159// @{"req": ["REQ-THREAD-003", "REQ-THREAD-004", "REQ-THREAD-011", "REQ-THREAD-012", "REQ-THREAD-013"]}
161 JUNO_THREAD_T *ptThread,
162 void *(*pfcnEntry)(void *),
163 void *pvArg,
164 JUNO_FAILURE_HANDLER_T pfcnFailureHandler,
165 void *pvFailureUserData
166);
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif /* JUNO_THREAD_LINUX_H */
#define JUNO_MODULE(API_T, ROOT_T,...)
Define a module union consisting of the root and all derivations.
Definition module.h:112
#define JUNO_MODULE_DERIVE(ROOT_T,...)
Implement a derived module embedding the root as the first member.
Definition module.h:161
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:110
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
Thread module vtable (API struct).
Definition thread_api.h:144
Freestanding C11 interface for the LibJuno Thread module.
struct JUNO_THREAD_ROOT_TAG JUNO_THREAD_ROOT_T
Forward declaration of the Thread module root struct.
Definition thread_api.h:83
union JUNO_THREAD_TAG JUNO_THREAD_T
Forward declaration of the Thread module union. The full union body is defined in juno/thread_linux....
Definition thread_api.h:94
struct JUNO_THREAD_LINUX_TAG JUNO_THREAD_LINUX_T
Forward declaration of the Linux/POSIX derivation struct.
Definition thread_api.h:89
JUNO_STATUS_T JunoThread_LinuxInit(JUNO_THREAD_T *ptThread, void *(*pfcnEntry)(void *), void *pvArg, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData)
Initialise a Thread module instance and immediately spawn the OS thread.
Definition linux_thread_impl.cpp:158