Skip to content

Commit 838556a

Browse files
authored
Merge pull request #10825 from drwootton/symbol_pollution_statics
Part 1 of resolving global symbol name pollution issue #10708
2 parents e67d1aa + 8ebf0d2 commit 838556a

File tree

6 files changed

+70
-67
lines changed

6 files changed

+70
-67
lines changed

ompi/mca/coll/libnbc/libdict/dict.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Implementation of generic dictionary routines.
55
* Copyright (C) 2001-2004 Farooq Mela.
6+
* Copyright (c) 2022 IBM Corporation. All rights reserved.
67
*
78
* $Id: dict.c,v 1.7 2001/11/25 06:00:49 farooq Exp farooq $
89
*/
@@ -15,15 +16,23 @@
1516
dict_malloc_func _dict_malloc = malloc;
1617
dict_free_func _dict_free = free;
1718

18-
dict_malloc_func
19+
static void dict_destroy __P((dict *dct, int del));
20+
static void dict_itor_destroy __P((dict_itor *itor));
21+
static int dict_int_cmp __P((const void *k1, const void *k2));
22+
static int dict_uint_cmp __P((const void *k1, const void *k2));
23+
static int dict_long_cmp __P((const void *k1, const void *k2));
24+
static int dict_ulong_cmp __P((const void *k1, const void *k2));
25+
static int dict_str_cmp __P((const void *k1, const void *k2));
26+
27+
static dict_malloc_func
1928
dict_set_malloc(dict_malloc_func func)
2029
{
2130
dict_malloc_func old = _dict_malloc;
2231
_dict_malloc = func ? func : malloc;
2332
return old;
2433
}
2534

26-
dict_free_func
35+
static dict_free_func
2736
dict_set_free(dict_free_func func)
2837
{
2938
dict_free_func old = _dict_free;
@@ -35,31 +44,31 @@ dict_set_free(dict_free_func func)
3544
* In comparing, we cannot simply subtract because that might result in signed
3645
* overflow.
3746
*/
38-
int
47+
static int
3948
dict_int_cmp(const void *k1, const void *k2)
4049
{
4150
const int *a = (int*)k1, *b = (int*)k2;
4251

4352
return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
4453
}
4554

46-
int
55+
static int
4756
dict_uint_cmp(const void *k1, const void *k2)
4857
{
4958
const unsigned int *a = (unsigned int*)k1, *b = (unsigned int*)k2;
5059

5160
return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
5261
}
5362

54-
int
63+
static int
5564
dict_long_cmp(const void *k1, const void *k2)
5665
{
5766
const long *a = (long*)k1, *b = (long*)k2;
5867

5968
return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
6069
}
6170

62-
int
71+
static int
6372
dict_ulong_cmp(const void *k1, const void *k2)
6473
{
6574
const unsigned long *a = (unsigned long*)k1, *b = (unsigned long*)k2;
@@ -73,7 +82,7 @@ dict_ptr_cmp(const void *k1, const void *k2)
7382
return (k1 > k2) - (k1 < k2);
7483
}
7584

76-
int
85+
static int
7786
dict_str_cmp(const void *k1, const void *k2)
7887
{
7988
const char *a = (char*)k1, *b = (char*)k2;
@@ -87,7 +96,7 @@ dict_str_cmp(const void *k1, const void *k2)
8796
return (p > q) - (p < q);
8897
}
8998

90-
void
99+
static void
91100
dict_destroy(dict *dct, int del)
92101
{
93102
ASSERT(dct != NULL);
@@ -96,7 +105,7 @@ dict_destroy(dict *dct, int del)
96105
FREE(dct);
97106
}
98107

99-
void
108+
static void
100109
dict_itor_destroy(dict_itor *itor)
101110
{
102111
ASSERT(itor != NULL);

ompi/mca/coll/libnbc/libdict/dict.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Interface for generic access to dictionary library.
55
* Copyright (C) 2001-2004 Farooq Mela.
6+
* Copyright (c) 2022 IBM Corporation. All rights reserved.
67
*
78
* $Id: dict.h,v 1.6 2001/11/14 05:21:10 farooq Exp farooq $
89
*/
@@ -46,9 +47,6 @@ BEGIN_DECL
4647
typedef void *(*dict_malloc_func)(size_t);
4748
typedef void (*dict_free_func)(void *);
4849

49-
dict_malloc_func dict_set_malloc __P((dict_malloc_func func));
50-
dict_free_func dict_set_free __P((dict_free_func func));
51-
5250
typedef int (*dict_cmp_func) __P((const void *, const void *));
5351
typedef void (*dict_del_func) __P((void *));
5452
typedef int (*dict_vis_func) __P((const void *, void *));
@@ -78,7 +76,6 @@ struct dict {
7876
#define dict_walk(dct,f) (dct)->_walk((dct)->_object, (f))
7977
#define dict_count(dct) (dct)->_count((dct)->_object)
8078
#define dict_empty(dct,d) (dct)->_empty((dct)->_object, (d))
81-
void dict_destroy __P((dict *dct, int del));
8279
#define dict_itor_new(dct) (dct)->_inew((dct)->_object)
8380

8481
struct dict_itor {
@@ -116,14 +113,8 @@ struct dict_itor {
116113
#define dict_itor_cdata(i) (i)->_cdata((i)->_itor)
117114
#define dict_itor_set_data(i,dat,d) (i)->_setdata((i)->_itor, (dat), (d))
118115
#define dict_itor_remove(i) (i)->_remove((i)->_itor)
119-
void dict_itor_destroy __P((dict_itor *itor));
120116

121-
int dict_int_cmp __P((const void *k1, const void *k2));
122-
int dict_uint_cmp __P((const void *k1, const void *k2));
123-
int dict_long_cmp __P((const void *k1, const void *k2));
124-
int dict_ulong_cmp __P((const void *k1, const void *k2));
125117
int dict_ptr_cmp __P((const void *k1, const void *k2));
126-
int dict_str_cmp __P((const void *k1, const void *k2));
127118

128119
END_DECL
129120

ompi/mca/coll/libnbc/libdict/hb_tree.c

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Implementation of height balanced tree.
55
* Copyright (C) 2001-2004 Farooq Mela.
6+
* Copyright (c) 2022 IBM Corporation. All rights reserved.
67
*
78
* $Id: hb_tree.c,v 1.10 2001/11/25 08:30:21 farooq Exp farooq $
89
*
@@ -51,6 +52,30 @@ static hb_node *node_max __P((hb_node *node));
5152
static hb_node *node_next __P((hb_node *node));
5253
static hb_node *node_prev __P((hb_node *node));
5354

55+
static dict *hb_dict_new __P((dict_cmp_func key_cmp, dict_del_func key_del,
56+
dict_del_func dat_del));
57+
static dict_itor *hb_dict_itor_new __P((hb_tree *tree));
58+
static void hb_itor_invalidate __P((hb_itor *itor));
59+
static int hb_itor_first __P((hb_itor *itor));
60+
static void *hb_itor_data __P((hb_itor *itor));
61+
static const void *hb_itor_cdata __P((const hb_itor *itor));
62+
static int hb_itor_last __P((hb_itor *itor));
63+
static int hb_itor_nextn __P((hb_itor *itor, unsigned count));
64+
static int hb_itor_prev __P((hb_itor *itor));
65+
static int hb_itor_prevn __P((hb_itor *itor, unsigned count));
66+
static int hb_itor_search __P((hb_itor *itor, const void *key));
67+
static int hb_itor_set_data __P((hb_itor *itor, void *dat, int del));
68+
static unsigned hb_tree_count __P((const hb_tree *tree));
69+
static void hb_tree_destroy __P((hb_tree *tree, int del));
70+
static void hb_tree_empty __P((hb_tree *tree, int del));
71+
static unsigned hb_tree_height __P((const hb_tree *tree));
72+
static const void *hb_tree_max __P((const hb_tree *tree));
73+
static unsigned hb_tree_mheight __P((const hb_tree *tree));
74+
static const void *hb_tree_min __P((const hb_tree *tree));
75+
static unsigned hb_tree_pathlen __P((const hb_tree *tree));
76+
static int hb_tree_probe __P((hb_tree *tree, void *key, void **dat));
77+
static void hb_tree_walk __P((hb_tree *tree, dict_vis_func visit));
78+
5479
hb_tree *
5580
hb_tree_new(dict_cmp_func key_cmp, dict_del_func key_del,
5681
dict_del_func dat_del)
@@ -69,7 +94,7 @@ hb_tree_new(dict_cmp_func key_cmp, dict_del_func key_del,
6994
return tree;
7095
}
7196

72-
dict *
97+
static dict *
7398
hb_dict_new(dict_cmp_func key_cmp, dict_del_func key_del,
7499
dict_del_func dat_del)
75100
{
@@ -98,7 +123,7 @@ hb_dict_new(dict_cmp_func key_cmp, dict_del_func key_del,
98123
return dct;
99124
}
100125

101-
void
126+
static void
102127
hb_tree_destroy(hb_tree *tree, int del)
103128
{
104129
ASSERT(tree != NULL);
@@ -109,7 +134,7 @@ hb_tree_destroy(hb_tree *tree, int del)
109134
FREE(tree);
110135
}
111136

112-
void
137+
static void
113138
hb_tree_empty(hb_tree *tree, int del)
114139
{
115140
hb_node *node, *parent;
@@ -236,7 +261,7 @@ hb_tree_insert(hb_tree *tree, void *key, void *dat, int overwrite)
236261
return 0;
237262
}
238263

239-
int
264+
static int
240265
hb_tree_probe(hb_tree *tree, void *key, void **dat)
241266
{
242267
int rv = 0;
@@ -402,7 +427,7 @@ hb_tree_remove(hb_tree *tree, const void *key, int del)
402427
return 0;
403428
}
404429

405-
const void *
430+
static const void *
406431
hb_tree_min(const hb_tree *tree)
407432
{
408433
const hb_node *node;
@@ -417,7 +442,7 @@ hb_tree_min(const hb_tree *tree)
417442
return node->key;
418443
}
419444

420-
const void *
445+
static const void *
421446
hb_tree_max(const hb_tree *tree)
422447
{
423448
const hb_node *node;
@@ -432,7 +457,7 @@ hb_tree_max(const hb_tree *tree)
432457
return node->key;
433458
}
434459

435-
void
460+
static void
436461
hb_tree_walk(hb_tree *tree, dict_vis_func visit)
437462
{
438463
hb_node *node;
@@ -446,31 +471,31 @@ hb_tree_walk(hb_tree *tree, dict_vis_func visit)
446471
break;
447472
}
448473

449-
unsigned
474+
static unsigned
450475
hb_tree_count(const hb_tree *tree)
451476
{
452477
ASSERT(tree != NULL);
453478

454479
return tree->count;
455480
}
456481

457-
unsigned
482+
static unsigned
458483
hb_tree_height(const hb_tree *tree)
459484
{
460485
ASSERT(tree != NULL);
461486

462487
return tree->root ? node_height(tree->root) : 0;
463488
}
464489

465-
unsigned
490+
static unsigned
466491
hb_tree_mheight(const hb_tree *tree)
467492
{
468493
ASSERT(tree != NULL);
469494

470495
return tree->root ? node_mheight(tree->root) : 0;
471496
}
472497

473-
unsigned
498+
static unsigned
474499
hb_tree_pathlen(const hb_tree *tree)
475500
{
476501
ASSERT(tree != NULL);
@@ -697,7 +722,7 @@ hb_itor_new(hb_tree *tree)
697722
return itor;
698723
}
699724

700-
dict_itor *
725+
static dict_itor *
701726
hb_dict_itor_new(hb_tree *tree)
702727
{
703728
dict_itor *itor;
@@ -748,7 +773,7 @@ hb_itor_valid(const hb_itor *itor)
748773
RETVALID(itor);
749774
}
750775

751-
void
776+
static void
752777
hb_itor_invalidate(hb_itor *itor)
753778
{
754779
ASSERT(itor != NULL);
@@ -768,7 +793,7 @@ hb_itor_next(hb_itor *itor)
768793
RETVALID(itor);
769794
}
770795

771-
int
796+
static int
772797
hb_itor_prev(hb_itor *itor)
773798
{
774799
ASSERT(itor != NULL);
@@ -780,7 +805,7 @@ hb_itor_prev(hb_itor *itor)
780805
RETVALID(itor);
781806
}
782807

783-
int
808+
static int
784809
hb_itor_nextn(hb_itor *itor, unsigned count)
785810
{
786811
ASSERT(itor != NULL);
@@ -798,7 +823,7 @@ hb_itor_nextn(hb_itor *itor, unsigned count)
798823
RETVALID(itor);
799824
}
800825

801-
int
826+
static int
802827
hb_itor_prevn(hb_itor *itor, unsigned count)
803828
{
804829
ASSERT(itor != NULL);
@@ -816,7 +841,7 @@ hb_itor_prevn(hb_itor *itor, unsigned count)
816841
RETVALID(itor);
817842
}
818843

819-
int
844+
static int
820845
hb_itor_first(hb_itor *itor)
821846
{
822847
hb_tree *t;
@@ -828,7 +853,7 @@ hb_itor_first(hb_itor *itor)
828853
RETVALID(itor);
829854
}
830855

831-
int
856+
static int
832857
hb_itor_last(hb_itor *itor)
833858
{
834859
hb_tree *t;
@@ -840,7 +865,7 @@ hb_itor_last(hb_itor *itor)
840865
RETVALID(itor);
841866
}
842867

843-
int
868+
static int
844869
hb_itor_search(hb_itor *itor, const void *key)
845870
{
846871
int rv;
@@ -868,23 +893,23 @@ hb_itor_key(const hb_itor *itor)
868893
return itor->node ? itor->node->key : NULL;
869894
}
870895

871-
void *
896+
static void *
872897
hb_itor_data(hb_itor *itor)
873898
{
874899
ASSERT(itor != NULL);
875900

876901
return itor->node ? itor->node->dat : NULL;
877902
}
878903

879-
const void *
904+
static const void *
880905
hb_itor_cdata(const hb_itor *itor)
881906
{
882907
ASSERT(itor != NULL);
883908

884909
return itor->node ? itor->node->dat : NULL;
885910
}
886911

887-
int
912+
static int
888913
hb_itor_set_data(hb_itor *itor, void *dat, int del)
889914
{
890915
ASSERT(itor != NULL);

0 commit comments

Comments
 (0)