author | Olivier Brunel
<jjk@jjacky.com> 2023-03-28 07:47:13 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-05-20 18:05:44 UTC |
parent | ce7f4e42a1ac87be710daf9b86d2e075b37e15dd |
doc/gccattributes.h.0.md | +21 | -0 |
include/blake3.h | +19 | -18 |
include/hmap.h | +3 | -2 |
include/limb/gccattributes.h | +17 | -0 |
include/loadopt.h | +4 | -3 |
include/sha3/byte_order.h | +6 | -5 |
include/sha3/sha3.h | +3 | -2 |
diff --git a/doc/gccattributes.h.0.md b/doc/gccattributes.h.0.md new file mode 100644 index 0000000..d36a6be --- /dev/null +++ b/doc/gccattributes.h.0.md @@ -0,0 +1,21 @@ +% limb manual +% gccattributes.h(0) + +# NAME + +gccattributes.h - GCC attributes + +# SYNOPSIS + + #include <limb/gccattributes.h> + +# DESCRIPTION + +This header defines GCC macros to define objects' attributes. + +## Macros + +The following macros are defined : + +: :*gccattr_hidden* +:: Set visibility to hidden i.e. do not export this symbol. diff --git a/include/blake3.h b/include/blake3.h index 29cb678..696984a 100644 --- a/include/blake3.h +++ b/include/blake3.h @@ -8,6 +8,7 @@ #define LIMB_BLAKE3_BLAKE3_H #include "limb/blake3.h" +#include "limb/gccattributes.h" #include "limb/uint64.h" /* internal flags */ @@ -155,89 +156,89 @@ store_cv_words(u8 bytes_out[32], u32 cv_words[8]) void blake3_compress_in_place(u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], - u8 block_len, u64 counter, u8 flags); + u8 block_len, u64 counter, u8 flags) gccattr_hidden; void blake3_compress_xof(const u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], - u8 block_len, u64 counter, u8 flags, u8 out[64]); + u8 block_len, u64 counter, u8 flags, u8 out[64]) gccattr_hidden; void blake3_hash_many(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, - u8 flags_start, u8 flags_end, u8 *out); + u8 flags_start, u8 flags_end, u8 *out) gccattr_hidden; -size_t blake3_simd_degree(void); +size_t blake3_simd_degree(void) gccattr_hidden; // Declarations for implementation-specific functions. void blake3_compress_in_place_portable(u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], - u8 block_len, u64 counter, u8 flags); + u8 block_len, u64 counter, u8 flags) gccattr_hidden; void blake3_compress_xof_portable(const u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], - u8 block_len, u64 counter, u8 flags, u8 out[64]); + u8 block_len, u64 counter, u8 flags, u8 out[64]) gccattr_hidden; void blake3_hash_many_portable(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #if defined(IS_X86) #if !defined(BLAKE3_NO_SSE2) void blake3_compress_in_place_sse2(u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags); + u8 flags) gccattr_hidden; void blake3_compress_xof_sse2(const u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags, u8 out[64]); + u8 flags, u8 out[64]) gccattr_hidden; void blake3_hash_many_sse2(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #endif #if !defined(BLAKE3_NO_SSE41) void blake3_compress_in_place_sse41(u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags); + u8 flags) gccattr_hidden; void blake3_compress_xof_sse41(const u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags, u8 out[64]); + u8 flags, u8 out[64]) gccattr_hidden; void blake3_hash_many_sse41(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #endif #if !defined(BLAKE3_NO_AVX2) void blake3_hash_many_avx2(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #endif #if !defined(BLAKE3_NO_AVX512) void blake3_compress_in_place_avx512(u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags); + u8 flags) gccattr_hidden; void blake3_compress_xof_avx512(const u32 cv[8], const u8 block[BLAKE3_BLOCK_LEN], u8 block_len, u64 counter, - u8 flags, u8 out[64]); + u8 flags, u8 out[64]) gccattr_hidden; void blake3_hash_many_avx512(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #endif #endif @@ -246,7 +247,7 @@ void blake3_hash_many_neon(const u8 *const *inputs, size_t num_inputs, size_t blocks, const u32 key[8], u64 counter, char increment_counter, u8 flags, u8 flags_start, - u8 flags_end, u8 *out); + u8 flags_end, u8 *out) gccattr_hidden; #endif diff --git a/include/hmap.h b/include/hmap.h index 4f5b570..eca0277 100644 --- a/include/hmap.h +++ b/include/hmap.h @@ -6,6 +6,7 @@ #include <errno.h> #include "limb/hmap.h" +#include "limb/gccattributes.h" #define MINSIZE 8 #define MAXSIZE ((u32) -1 / 2 + 1) @@ -27,7 +28,7 @@ struct item { #define DLEN(hmap) (hmap->ilen - sizeof(u32)) #define ITEM(i,hmap) (void *) (hmap->sa.s + (i) * hmap->ilen) -struct item *lookup(u32 key, hmap *hmap); -int grow(size_t n, hmap *hmap); +struct item *lookup(u32 key, hmap *hmap) gccattr_hidden; +int grow(size_t n, hmap *hmap) gccattr_hidden; #endif /* LIMB_INTERNAL_HMAP_H */ diff --git a/include/limb/gccattributes.h b/include/limb/gccattributes.h new file mode 100644 index 0000000..48d8014 --- /dev/null +++ b/include/limb/gccattributes.h @@ -0,0 +1,17 @@ +/* This file is part of limb https://lila.oss/limb + * Copyright (C) 2023 Olivier Brunel jjk@jjacky.com */ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LIMB_GCCATTRIBUTES_H +#define LIMB_GCCATTRIBUTES_H + +#ifdef __GNUC__ + +#define gccattr_hidden __attribute__ ((visibility ("hidden"))) + +#else + +#define gccattr_hidden + +#endif + +#endif /* LIMB_GCCATTRIBUTES_H */ diff --git a/include/loadopt.h b/include/loadopt.h index 3dfa494..71b5045 100644 --- a/include/loadopt.h +++ b/include/loadopt.h @@ -5,6 +5,7 @@ #define LIMB_LIMB_LOADOPT_H #include "limb/parseopt.h" +#include "limb/gccattributes.h" enum state { STATE_NONE = 0, @@ -25,9 +26,9 @@ enum { LOADOPT_EOF = 1 << 3, }; -void add_optflags(u8 *optflags, u16 idx, u8 val); -u8 get_optflags(const u8 *optflags, u16 idx); +void add_optflags(u8 *optflags, u16 idx, u8 val) gccattr_hidden; +u8 get_optflags(const u8 *optflags, u16 idx) gccattr_hidden; -int loadopt_handle_noconfig(int idx, const struct option *options, struct loadopt *ctx); +int loadopt_handle_noconfig(int idx, const struct option *options, struct loadopt *ctx) gccattr_hidden; #endif /* LIMB_LIMB_LOADOPT_H */ diff --git a/include/sha3/byte_order.h b/include/sha3/byte_order.h index 1807119..08d0613 100644 --- a/include/sha3/byte_order.h +++ b/include/sha3/byte_order.h @@ -7,6 +7,7 @@ #define BYTE_ORDER_H #include <unistd.h> #include <stdlib.h> +#include "limb/gccattributes.h" #include "limb/int.h" #if defined(__GLIBC__) @@ -120,13 +121,13 @@ extern "C" { /* GCC >= 3.4 or clang */ # define rhash_ctz(x) __builtin_ctz(x) #else -unsigned rhash_ctz(unsigned); /* define as function */ +unsigned rhash_ctz(unsigned) gccattr_hidden; /* define as function */ #endif -void rhash_swap_copy_str_to_u32(void *to, int index, const void *from, size_t length); -void rhash_swap_copy_str_to_u64(void *to, int index, const void *from, size_t length); -void rhash_swap_copy_u64_to_str(void *to, const void *from, size_t length); -void rhash_u32_mem_swap(unsigned *p, int length_in_u32); +void rhash_swap_copy_str_to_u32(void *to, int index, const void *from, size_t length); gccattr_hidden +void rhash_swap_copy_str_to_u64(void *to, int index, const void *from, size_t length); gccattr_hidden +void rhash_swap_copy_u64_to_str(void *to, const void *from, size_t length); gccattr_hidden +void rhash_u32_mem_swap(unsigned *p, int length_in_u32); gccattr_hidden /* bswap definitions */ #if (defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)) || \ diff --git a/include/sha3/sha3.h b/include/sha3/sha3.h index 308698e..0c99824 100644 --- a/include/sha3/sha3.h +++ b/include/sha3/sha3.h @@ -6,12 +6,13 @@ #ifndef LIMB_SHA3_SHA3_H #define LIMB_SHA3_SHA3_H +#include "limb/gccattributes.h" #include "limb/sha3.h" #include "sha3/byte_order.h" #define SHA3_FINALIZED 0x80000000 -void sha3_init(unsigned bits, sha3_ctx *ctx); -void rhash_sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size); +void sha3_init(unsigned bits, sha3_ctx *ctx) gccattr_hidden; +void rhash_sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size) gccattr_hidden; #endif /* LIMB_SHA3_SHA3_H */