LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
Pointer API

Data Structures

struct  JUNO_POINTER_API_TAG
 Pointer operations API (copy/reset). More...
 
struct  JUNO_VALUE_POINTER_API_TAG
 Value-pointer operations API (equality by contents). More...
 

Macros

#define JunoMemory_PointerInit(ptApi, TYPE_T, pvAddr)   (JUNO_POINTER_T){ptApi, pvAddr, sizeof(TYPE_T), alignof(TYPE_T)}
 Initialize a JUNO_POINTER_T with API, type, and address.
 
#define JunoMemory_PointerVerifyType(pointer, type, tApi)
 Verify pointer descriptor matches an expected type and API.
 
#define JUNO_ASSERT_POINTER_TYPE(tStatus, tPointer, tType, tApi)   JUNO_ASSERT_SUCCESS((tStatus = JunoMemory_PointerVerifyType(tPointer, tType, tApi)), return tStatus)
 Assert a pointer descriptor's type and API, returning on failure.
 

Functions

 JUNO_MODULE_RESULT (JUNO_RESULT_POINTER_T, JUNO_POINTER_T)
 Result type carrying a pointer descriptor.
 
 JUNO_MODULE_OPTION (JUNO_OPTION_POINTER_T, JUNO_POINTER_T)
 Option type carrying a pointer descriptor.
 
static JUNO_STATUS_T JunoMemory_PointerApiVerify (const JUNO_POINTER_API_T *ptPointerApi)
 Verify that a pointer API provides required functions.
 
static JUNO_STATUS_T JunoMemory_ValuePointerApiVerify (const JUNO_VALUE_POINTER_API_T *ptPointerApi)
 Verify that a value-pointer API provides required functions.
 
static JUNO_STATUS_T JunoMemory_PointerVerify (const JUNO_POINTER_T tPointer)
 Verify a pointer descriptor (API non-null, address non-null, size non-zero).
 

Detailed Description

Defines a portable pointer trait (JUNO_POINTER_T) with an associated API for copying and resetting memory, along with helpers to verify type and alignment. A separate value-pointer API allows equality checks over pointer contents. These utilities are used by allocators and callers to enforce size/alignment constraints and perform safe operations in a freestanding-friendly way.

Macro Definition Documentation

◆ JUNO_ASSERT_POINTER_TYPE

#define JUNO_ASSERT_POINTER_TYPE (   tStatus,
  tPointer,
  tType,
  tApi 
)    JUNO_ASSERT_SUCCESS((tStatus = JunoMemory_PointerVerifyType(tPointer, tType, tApi)), return tStatus)

Assert a pointer descriptor's type and API, returning on failure.

Parameters
tStatusLvalue to receive the resulting status.
tPointerThe pointer descriptor to validate.
tTypeThe expected type of the pointee.
tApiThe expected pointer API symbol.

◆ JunoMemory_PointerInit

#define JunoMemory_PointerInit (   ptApi,
  TYPE_T,
  pvAddr 
)    (JUNO_POINTER_T){ptApi, pvAddr, sizeof(TYPE_T), alignof(TYPE_T)}

Initialize a JUNO_POINTER_T with API, type, and address.

Parameters
ptApiPointer to a valid JUNO_POINTER_API_T.
TYPE_TThe value type at pvAddr (deduces size and alignment).
pvAddrAddress of the value or buffer.
Returns
A populated JUNO_POINTER_T describing the location, size, and alignment.

◆ JunoMemory_PointerVerifyType

#define JunoMemory_PointerVerifyType (   pointer,
  type,
  tApi 
)
Value:
(( \
JunoMemory_PointerVerify(pointer) == JUNO_STATUS_SUCCESS && \
pointer.ptApi == &tApi && \
pointer.zSize == sizeof(type) && \
pointer.zAlignment == alignof(type) && \
(uintptr_t) pointer.pvAddr % pointer.zAlignment == 0 \
#define JUNO_STATUS_ERR
Unspecified error.
Definition status.h:58
#define JUNO_STATUS_SUCCESS
Operation completed successfully.
Definition status.h:56

Verify pointer descriptor matches an expected type and API.

Parameters
pointerThe JUNO_POINTER_T descriptor to verify.
typeThe expected C type for the memory region.
tApiThe expected JUNO_POINTER_API_T symbol.
Returns
JUNO_STATUS_SUCCESS if the descriptor is valid and matches, error otherwise.

Function Documentation

◆ JUNO_MODULE_OPTION()

JUNO_MODULE_OPTION ( JUNO_OPTION_POINTER_T  ,
JUNO_POINTER_T   
)

Option type carrying a pointer descriptor.

◆ JUNO_MODULE_RESULT()

JUNO_MODULE_RESULT ( JUNO_RESULT_POINTER_T  ,
JUNO_POINTER_T   
)

Result type carrying a pointer descriptor.

◆ JunoMemory_PointerApiVerify()

static JUNO_STATUS_T JunoMemory_PointerApiVerify ( const JUNO_POINTER_API_T ptPointerApi)
inlinestatic

Verify that a pointer API provides required functions.

Parameters
ptPointerApiPointer to the API vtable.
Returns
JUNO_STATUS_SUCCESS if all required functions are present.

◆ JunoMemory_PointerVerify()

static JUNO_STATUS_T JunoMemory_PointerVerify ( const JUNO_POINTER_T  tPointer)
inlinestatic

Verify a pointer descriptor (API non-null, address non-null, size non-zero).

Parameters
tPointerThe pointer descriptor to check.
Returns
JUNO_STATUS_SUCCESS if valid; error otherwise.

◆ JunoMemory_ValuePointerApiVerify()

static JUNO_STATUS_T JunoMemory_ValuePointerApiVerify ( const JUNO_VALUE_POINTER_API_T ptPointerApi)
inlinestatic

Verify that a value-pointer API provides required functions.

Parameters
ptPointerApiPointer to the value-pointer API vtable.
Returns
JUNO_STATUS_SUCCESS if all required functions are present.