Skip to content

Commit

Permalink
Fix fd_redblack symbol visibility
Browse files Browse the repository at this point in the history
Fixes an issue where fd_redblack produces externally linked symbols
even if the implementation style is set to 'local use only'.
  • Loading branch information
riptl authored and ripatel-fd committed Dec 10, 2024
1 parent 9ddc217 commit 53568e6
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 100 deletions.
5 changes: 2 additions & 3 deletions src/disco/rpcserver/fd_rpc_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ struct product_rb_node {
typedef struct product_rb_node product_rb_node_t;
#define REDBLK_T product_rb_node_t
#define REDBLK_NAME product_rb
FD_FN_PURE long product_rb_compare(product_rb_node_t* left, product_rb_node_t* right) {
FD_FN_PURE static long product_rb_compare(product_rb_node_t* left, product_rb_node_t* right) {
for( uint i = 0; i < sizeof(fd_pubkey_t)/sizeof(ulong); ++i ) {
ulong a = left->key.ul[i];
ulong b = right->key.ul[i];
Expand All @@ -574,7 +574,6 @@ FD_FN_PURE long product_rb_compare(product_rb_node_t* left, product_rb_node_t* r
return 0;
}
#include "../../util/tmpl/fd_redblack.c"
#undef REDBLK_NAME

static int
method_getBlockProduction(struct json_values* values, fd_rpc_ctx_t * ctx) {
Expand Down Expand Up @@ -1023,7 +1022,7 @@ struct leader_rb_node {
typedef struct leader_rb_node leader_rb_node_t;
#define REDBLK_T leader_rb_node_t
#define REDBLK_NAME leader_rb
FD_FN_PURE long leader_rb_compare(leader_rb_node_t* left, leader_rb_node_t* right) {
FD_FN_PURE static long leader_rb_compare(leader_rb_node_t* left, leader_rb_node_t* right) {
for( uint i = 0; i < sizeof(fd_pubkey_t)/sizeof(ulong); ++i ) {
ulong a = left->key.ul[i];
ulong b = right->key.ul[i];
Expand Down
14 changes: 0 additions & 14 deletions src/flamenco/types/fd_types.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/flamenco/types/fd_types.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/flamenco/types/fd_types_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ int fd_archive_decode_skip_field( fd_bincode_decode_ctx_t * ctx, ushort tag ) {
#define REDBLK_NAME fd_vote_reward_t_map
#define REDBLK_IMPL_STYLE 2
#include "../../util/tmpl/fd_redblack.c"
#undef REDBLK_T
#undef REDBLK_NAME

long fd_vote_reward_t_map_compare( fd_vote_reward_t_mapnode_t * left, fd_vote_reward_t_mapnode_t * right ) {
return memcmp( left->elem.pubkey.uc, right->elem.pubkey.uc, sizeof(right->elem.pubkey) );
}
4 changes: 1 addition & 3 deletions src/flamenco/types/fd_types_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ typedef struct fd_vote_reward_t_mapnode fd_vote_reward_t_mapnode_t;
#define REDBLK_NAME fd_vote_reward_t_map
#define REDBLK_IMPL_STYLE 1
#include "../../util/tmpl/fd_redblack.c"
#undef REDBLK_T
#undef REDBLK_NAME
struct fd_vote_reward_t_mapnode {
fd_vote_reward_t elem;
ulong redblack_parent;
Expand Down Expand Up @@ -388,7 +386,7 @@ typedef struct fd_epoch_reward_status fd_epoch_reward_status_t;
enum {
fd_epoch_reward_status_enum_Active = 0,
fd_epoch_reward_status_enum_Inactive = 1,
};
};

/*******************************************************************************************/
#endif
Expand Down
4 changes: 0 additions & 4 deletions src/flamenco/types/gen_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,6 @@ def emitPreamble(self):
print(f"#define REDBLK_NAME {mapname}", file=header)
print(f"#define REDBLK_IMPL_STYLE 1", file=header)
print(f'#include "../../util/tmpl/fd_redblack.c"', file=header)
print(f"#undef REDBLK_T", file=header)
print(f"#undef REDBLK_NAME", file=header)
print(f"struct {nodename} {{", file=header)
print(f" {element_type} elem;", file=header)
print(f" ulong redblack_parent;", file=header)
Expand All @@ -893,8 +891,6 @@ def emitPostamble(self):
print(f'#define REDBLK_NAME {mapname}', file=body)
print(f'#define REDBLK_IMPL_STYLE 2', file=body)
print(f'#include "../../util/tmpl/fd_redblack.c"', file=body)
print(f'#undef REDBLK_T', file=body)
print(f'#undef REDBLK_NAME', file=body)
print(f'long {mapname}_compare( {nodename} * left, {nodename} * right ) {{', file=body)
key = self.key
if key == "pubkey" or key == "account" or key == "key":
Expand Down
Loading

0 comments on commit 53568e6

Please sign in to comment.