Porting Guide (libshared)
Introduction
To permit libshared to work on a range of platforms a porting abstraction layer has been written. Porting simply involves implementing the porting abstraction layer; the library will then compile and work. Implementation involves providing values to a small set defines, macros and typedefs and implementing one or two functions.
The Porting Abstraction Layer
The porting abstraction layer consists of one header file and two C files, thus;
└───test_and_benchmark └───libshared ├───inc │ └───libshared │ lfds710_porting_abstraction_layer_operating_system.h └───src ├───lfds710_porting_abstraction_layer_thread_start.c └───lfds710_porting_abstraction_layer_thread_wait.c
Each header file uses #ifdefs and compiler defined macros to select the appropriate porting abstraction layer implementation for the local platform.
Accordingly, to add a new platform, introduce a new #ifdef, which matches the appropriate compiler defined macros for your platform.
#define LIBSHARED_PAL_OS_STRING #define LIBSHARED_PAL_THREAD_CALLING_CONVENTION #define LIBSHARED_PAL_THREAD_RETURN_TYPE #define LIBSHARED_PAL_THREAD_RETURN_CAST( return_value ) typedef [type] libshared_pal_thread_handle_t; typedef [type] libshared_pal_thread_return_t;
Additionally, in this file, include any needed OS provided header files.
int libshared_pal_thread_start( libshared_pal_thread_handle_t *thread_handle, struct libshared_pal_thread_info *pti )
void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )