Porting Guide (libtest)

From liblfds.org
Revision as of 15:56, 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 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
    └───libtest
        ├───inc
        │   └───libtest
        │       ├───libtest_porting_abstraction_layer_compiler.h
        │       └───libtest_porting_abstraction_layer_operating_system.h
        └───src
            └───libtest_porting_abstraction_layer
                ├───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.

libtest_porting_abstraction_layer_compiler.h

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

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

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 lfds711_list_asu_state *lasus,
                                                 struct libshared_memory_state *ms );

libtest_porting_abstraction_layer_malloc.c

void *libtest_pal_malloc( size_t size );

See Also