mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-09-27 01:30:43 +02:00
Explicitly specify C symbol visibility
In order for blake3 to be usable as a shared library on Windows it is required to annotate public symbols. Use this as an opportunity to prune the symbol table for other OSes, too.
This commit is contained in:
parent
e45c0c6795
commit
96487de258
@ -35,10 +35,19 @@ add_library(blake3
|
||||
add_library(BLAKE3::blake3 ALIAS blake3)
|
||||
|
||||
# library configuration
|
||||
set(BLAKE3_PKGCONFIG_CFLAGS)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(blake3
|
||||
PUBLIC BLAKE3_DLL
|
||||
PRIVATE BLAKE3_DLL_EXPORTS
|
||||
)
|
||||
list(APPEND BLAKE3_PKGCONFIG_CFLAGS -DBLAKE3_DLL)
|
||||
endif()
|
||||
target_include_directories(blake3 PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
set_target_properties(blake3 PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION 0
|
||||
C_VISIBILITY_PRESET hidden
|
||||
)
|
||||
|
||||
# optional SIMD sources
|
||||
|
50
c/blake3.h
50
c/blake3.h
@ -4,6 +4,28 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(BLAKE3_API)
|
||||
# if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# if defined(BLAKE3_DLL)
|
||||
# if defined(BLAKE3_DLL_EXPORTS)
|
||||
# define BLAKE3_API __declspec(dllexport)
|
||||
# else
|
||||
# define BLAKE3_API __declspec(dllimport)
|
||||
# endif
|
||||
# define BLAKE3_PRIVATE
|
||||
# else
|
||||
# define BLAKE3_API
|
||||
# define BLAKE3_PRIVATE
|
||||
# endif
|
||||
# elif __GNUC__ >= 4
|
||||
# define BLAKE3_API __attribute__((visibility("default")))
|
||||
# define BLAKE3_PRIVATE __attribute__((visibility("hidden")))
|
||||
# else
|
||||
# define BLAKE3_API
|
||||
# define BLAKE3_PRIVATE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -38,20 +60,20 @@ typedef struct {
|
||||
uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN];
|
||||
} blake3_hasher;
|
||||
|
||||
const char *blake3_version(void);
|
||||
void blake3_hasher_init(blake3_hasher *self);
|
||||
void blake3_hasher_init_keyed(blake3_hasher *self,
|
||||
const uint8_t key[BLAKE3_KEY_LEN]);
|
||||
void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context);
|
||||
void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context,
|
||||
size_t context_len);
|
||||
void blake3_hasher_update(blake3_hasher *self, const void *input,
|
||||
size_t input_len);
|
||||
void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out,
|
||||
size_t out_len);
|
||||
void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
|
||||
uint8_t *out, size_t out_len);
|
||||
void blake3_hasher_reset(blake3_hasher *self);
|
||||
BLAKE3_API const char *blake3_version(void);
|
||||
BLAKE3_API void blake3_hasher_init(blake3_hasher *self);
|
||||
BLAKE3_API void blake3_hasher_init_keyed(blake3_hasher *self,
|
||||
const uint8_t key[BLAKE3_KEY_LEN]);
|
||||
BLAKE3_API void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context);
|
||||
BLAKE3_API void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context,
|
||||
size_t context_len);
|
||||
BLAKE3_API void blake3_hasher_update(blake3_hasher *self, const void *input,
|
||||
size_t input_len);
|
||||
BLAKE3_API void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out,
|
||||
size_t out_len);
|
||||
BLAKE3_API void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
|
||||
uint8_t *out, size_t out_len);
|
||||
BLAKE3_API void blake3_hasher_reset(blake3_hasher *self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -9,4 +9,4 @@ Version: @PROJECT_VERSION@
|
||||
|
||||
Requires:
|
||||
Libs: -L${libdir} -lblake3
|
||||
Cflags: -I${includedir}
|
||||
Cflags: -I${includedir} @BLAKE3_PKGCONFIG_CFLAGS@
|
Loading…
Reference in New Issue
Block a user