Porting Guide (libbenchmark)

From liblfds.org
Jump to navigation Jump to search


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;

        │   └───libbenchmark
        │       └───libbenchmark_porting_abstraction_layer_operating_system.h

Accordingly, to add a new platform, introduce a new #ifdef, which matches the appropriate compiler defined macros for your platform.


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


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


void libbenchmark_pal_print_string( char const * const string );

See Also