Porting Guide (libbenchmark)

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

Introduction

To permit libbenchmark 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 and two C files, thus;

└───test_and_benchmark
    └───libbenchmark
        ├───inc
        │   └───libbenchmark
        │       └───libbenchmark_porting_abstraction_layer_operating_system.h
        └───src
            └───libbenchmark_porting_abstraction_layer
                ├───libbenchmark_porting_abstraction_layer_populate_topology.c
                └───libbenchmark_porting_abstraction_layer_print_string.c

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 LIBBENCHMARK_PAL_OS_STRING
#define LIBBENCHMARK_PAL_TIME_UNITS_PER_SECOND( pointer_to_time_units_per_second )
#define LIBBENCHMARK_PAL_GET_HIGHRES_TIME( pointer_to_time )

Additionally, in this file, include any needed OS provided header files.

libbenchmark_porting_abstraction_layer_populate_topology.c

int libbenchmark_pal_populate_topology( struct libbenchmark_topology_state *ts,
                                        struct libshared_memory_state *ms );

libbenchmark_porting_abstraction_layer_print_string.c

void libbenchmark_pal_print_string( char const * const string );

See Also