Porting Guide (libtest)

From liblfds.org
Jump to navigation Jump to search

Introduction

To permit libtest 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 three header files and three C files, thus;

└───test_and_benchmark
    └───libshared
        ├───inc
        │   └───libshared
        │       ├───lfds710_porting_abstraction_layer_compiler.h
        │       ├───lfds710_porting_abstraction_layer_operating_system.h
        │       └───lfds710_porting_abstraction_layer_processor.h
        └───src
            ├───libtest_porting_abstraction_layer_free.c
            ├───libtest_porting_abstraction_layer_get_full_logical_processor_set.c
            └───libtest_porting_abstraction_layer_malloc.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.

The abstraction layer for libtest seems much larger than it is. Most of it is optional or invariant. The only actually vital function is libtest_pal_get_full_logical_processor_set.

libshared_porting_abstraction_layer_compiler.h

#define LIBTEST_PAL_LOAD_LINKED( destination, source )
#define LIBTEST_PAL_STORE_CONDITIONAL( destination, source, stored_flag )

libshared_porting_abstraction_layer_operating_system.h

#define LIBTEST_PAL_OS_STRING

Additionally, in this file, include any needed OS provided header files. Currently, stdlib.h and time.h are required and because of this, libtest requires a hosted implementation. This will be fixed in an upcoming release.

libshared_porting_abstraction_layer_processor.h

#define LIBTEST_PAL_STDLIB_CALLBACK_CALLING_CONVENTION

libtest_porting_abstraction_layer_free.c

void libtest_pal_free( void *memory );

libtest_porting_abstraction_layer_get_full_logical_processor_set.c

void libtest_pal_get_full_logical_processor_set( struct lfds710_list_asu_state *lasus,
                                                 struct libshared_memory_state *ms );

libtest_porting_abstraction_layer_malloc.c

void *libtest_pal_malloc( size_t size );

See Also