LibJuno is a lightweight C99 library designed specifically for embedded systems. It focuses on providing essential functionalities like memory management, data structures, string operations, and more without dynamic memory allocation. LibJuno optimizes for memory safety, determinism, and efficiency in constrained environments.
Library Architecture
LibJuno is structured around several key modules, each providing specialized functionality while maintaining a consistent API pattern:
- Memory Management: Provides block-based allocation, deallocation, and memory tracking
- String Operations: Handles string initialization, manipulation, concatenation, and cleanup
- CRC: Offers various CRC calculation algorithms (ARC, BINHEX, CCITT, etc.)
- Hash: Implements hash table functionality with configurable hash functions
- Map: Provides key-value pair storage and retrieval
- Table: Implements structured data storage with optional persistence
General Design Principles
LibJuno follows several core design principles:
- No Dynamic Memory Allocation: All memory is pre-allocated and managed using block allocators, ensuring deterministic behavior.
- Minimal Dependencies: The library minimizes dependencies on the standard C library, enhancing portability.
- Consistent API Structure: Each module provides both direct function calls and a structured API interface.
- Error Handling: Comprehensive error codes and optional failure handlers for robust error management.
- Reference Counting: Memory objects use reference counting to prevent premature deallocation of shared resources.
Common Patterns
API Structure
Each module follows a consistent pattern:
const JUNO_MODULE_API_T* Juno_ModuleApi(void);
enum JUNO_STATUS_TAG JUNO_STATUS_T
Error Handling
LibJuno uses a standardized error handling approach:
}
@ JUNO_STATUS_SUCCESS
Definition status.h:8
Modules also support optional failure handlers that can be registered during initialization:
}
Juno_ModuleInit(..., MyFailureHandler, pvUserData);
void JUNO_USER_DATA_T
Definition status.h:25
Memory Management
Memory in LibJuno is typically managed through pre-allocated blocks:
JUNO_STATUS_T Juno_MemoryBlkInit(JUNO_MEMORY_BLOCK_T *ptMemBlk, void *pvMemory, JUNO_MEMORY_BLOCK_METADATA_T *pvMetadata, size_t zTypeSize, size_t zLength, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
Initializes a memory block for allocation. Sets up a memory block with an associated free stack for m...
Definition juno_memory.c:32
#define JUNO_MEMORY_BLOCK_METADATA(name, length)
Macro to declare a static array for memory metadata.
Definition memory_types.h:23
#define JUNO_MEMORY_BLOCK(name, type, length)
Macro to declare a static memory block and its associated free stack.
Definition memory_types.h:17
Structure representing a block-based memory allocator. Manages a fixed-size memory area along with as...
Definition memory_types.h:74
Reference Counting
Memory objects support reference counting to manage shared resources:
Juno_MemoryPutRef(ptMemRef);
Structure for an allocated memory segment. Describes the allocated memory with a pointer to the start...
Definition memory_types.h:60
Module Documentation
For detailed documentation on individual modules, please refer to: