Skip to content

Commit

Permalink
Introduce public method prefix macros
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 committed Jun 6, 2023
1 parent 6c50a43 commit 2c58b2a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/c_kzg_4844.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ extern "C" {
// Macros
///////////////////////////////////////////////////////////////////////////////

// Public function prefix functions

// If LIB_PREFIX is defined the following functions will prepend `LIB_PREFIX` to all public methods of this library
// If LIB_PREFIX is undefined, everything stays as is

#define CONCAT_IMPL(a, b) a##_##b
#define CONCAT(a, b) CONCAT_IMPL(a, b)
#define PREFIX_FUNCNAME(name) CONCAT(LIB_PREFIX, name)

#ifdef LIB_PREFIX

#define PUB_FUNC_DECL(rv, funcname, arglist) \
rv PREFIX_FUNCNAME(funcname) arglist;
#define PUB_FUNC_IMPL(rv, funcname, arglist) \
rv(*funcname) arglist = PREFIX_FUNCNAME(funcname); \
rv PREFIX_FUNCNAME(funcname) arglist

# else

#define PUB_FUNC_DECL(rv, funcname, arglist) \
rv funcname arglist
#define PUB_FUNC_IMPL(rv, funcname, arglist) \
rv funcname arglist

#endif

/*
* This value represents the number of field elements in a blob. It must be
* supplied externally. It is expected to be 4096 for mainnet and 4 for minimal.
Expand Down

0 comments on commit 2c58b2a

Please sign in to comment.