LibJuno 1.0.1
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
45
55
58{
60 ptMtx &&
61 ptMtx->ptApi &&
62 ptMtx->ptApi->TryLock &&
63 ptMtx->ptApi->Lock &&
64 ptMtx->ptApi->Free
65 );
67}
68
69#ifdef __cplusplus
70}
71#endif
72#endif // JUNO_MP_MTX_API_H
#define JUNO_ASSERT_EXISTS(ptr)
Returns JUNO_STATUS_NULLPTR_ERROR if the expression is falsy.
Definition macros.h:50
#define JUNO_MODULE_EMPTY
Helper for module definitions with no additional members.
Definition module.h:86
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:126
#define JUNO_STATUS_SUCCESS
Operation completed successfully.
Definition status.h:56
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:49
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:57
Status codes and failure-handling helpers for LibJuno.
Definition mtx_api.h:47
JUNO_STATUS_T(* Lock)(JUNO_MP_MTX_ROOT_T *ptMtx)
Busy-wait until the lock is acquired.
Definition mtx_api.h:51
JUNO_STATUS_T(* Free)(JUNO_MP_MTX_ROOT_T *ptMtx)
Release the lock.
Definition mtx_api.h:53
JUNO_RESULT_BOOL_T(* TryLock)(JUNO_MP_MTX_ROOT_T *ptMtx)
Attempt to acquire the lock and return immediately.
Definition mtx_api.h:49
Common module result type aliases used throughout LibJuno.