LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
mtx_api.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
31#ifndef JUNO_MP_MTX_API_H
32#define JUNO_MP_MTX_API_H
33#include "juno/macros.h"
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38#include "juno/status.h"
39#include "juno/module.h"
40#include "juno/types.h"
41typedef struct JUNO_MP_MTX_ROOT_TAG JUNO_MP_MTX_ROOT_T;
43
44// @{"req": ["REQ-MTX-001"]}
46
48{
50 // @{"req": ["REQ-MTX-002"]}
51 JUNO_RESULT_BOOL_T (*TryLock)(JUNO_MP_MTX_ROOT_T *ptMtx);
53 // @{"req": ["REQ-MTX-003"]}
56 // @{"req": ["REQ-MTX-004"]}
58};
59
61// @{"req": ["REQ-MTX-005"]}
63{
65 ptMtx &&
66 ptMtx->ptApi &&
67 ptMtx->ptApi->TryLock &&
68 ptMtx->ptApi->Lock &&
69 ptMtx->ptApi->Free
70 );
72}
73
74#ifdef __cplusplus
75}
76#endif
77#endif // JUNO_MP_MTX_API_H
#define JUNO_ASSERT_EXISTS(ptr)
Returns JUNO_STATUS_NULLPTR_ERROR if the expression is falsy.
Definition macros.h:51
#define JUNO_MODULE_EMPTY
Helper for module definitions with no additional members.
Definition module.h:87
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:129
#define JUNO_STATUS_SUCCESS
Operation completed successfully.
Definition status.h:59
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
Common assertion and helper macros for LibJuno modules.
Module system and dependency injection primitives for LibJuno.
struct JUNO_MP_MTX_ROOT_TAG JUNO_MP_MTX_ROOT_T
Definition mtx_api.h:41
static JUNO_STATUS_T JunoMp_MtxVerify(const JUNO_MP_MTX_ROOT_T *ptMtx)
Verify a mutex instance and its API table.
Definition mtx_api.h:62
Status codes and failure-handling helpers for LibJuno.
Definition mtx_api.h:48
JUNO_STATUS_T(* Lock)(JUNO_MP_MTX_ROOT_T *ptMtx)
Busy-wait until the lock is acquired.
Definition mtx_api.h:54
JUNO_STATUS_T(* Free)(JUNO_MP_MTX_ROOT_T *ptMtx)
Release the lock.
Definition mtx_api.h:57
JUNO_RESULT_BOOL_T(* TryLock)(JUNO_MP_MTX_ROOT_T *ptMtx)
Attempt to acquire the lock and return immediately.
Definition mtx_api.h:51
Common module result type aliases used throughout LibJuno.