Porting Guide (libshared)

From liblfds.org
Revision as of 15:53, 1 April 2018 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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
        │       └───libshared_porting_abstraction_layer_operating_system.h
        └───src
            └───libshared_porting_abstraction_layer
                ├───lfds711_porting_abstraction_layer_thread_start.c
                └───lfds711_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.

libshared_porting_abstraction_layer_operating_system.h

#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.

libshared_porting_abstraction_layer_thread_start.c

int libshared_pal_thread_start( libshared_pal_thread_handle_t *thread_handle,
                                struct libshared_pal_thread_info *pti )

libshared_porting_abstraction_layer_thread_wait.c

void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )

See Also