Skip to content

Commit 1a2b8c0

Browse files
Merge pull request #320 from insertinterestingnamehere/cmake
Default to Hidden Symbol Visibility
2 parents e7c627e + a259b1b commit 1a2b8c0

19 files changed

+184
-150
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ add_library(qthread SHARED ${QTHREADS_SOURCES})
6767
target_include_directories(qthread
6868
PRIVATE "../include"
6969
)
70+
set_target_properties(qthread PROPERTIES C_VISIBILITY_PRESET hidden)
7071
target_link_libraries(qthread PUBLIC Threads::Threads)
7172
target_include_directories(qthread
7273
PUBLIC

src/cacheline.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <stdio.h>
33
#endif
44

5+
#include "qt_visibility.h"
6+
57
#ifdef HAVE_CONFIG_H
68
#include "config.h"
79
#endif
@@ -341,7 +343,7 @@ static void figure_out_cacheline_size(void) { /*{{{ */
341343
} /*}}} */
342344

343345
/* returns the cache line size */
344-
int qthread_cacheline(void) { /*{{{ */
346+
int API_FUNC qthread_cacheline(void) { /*{{{ */
345347
if (cacheline_bytes == 0) {
346348
figure_out_cacheline_size();
347349
if (cacheline_bytes == 0) { /* to cache errors in cacheline detection */

src/ds/dictionary/dictionary_shavit.c

+21-16
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,13 @@ qt_hash_put(qt_hash h, qt_key_t key, void *value, int put_choice) {
340340
return ret->value;
341341
}
342342

343-
void *qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
343+
void *API_FUNC qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
344344
return qt_hash_put(dict, key, value, PUT_ALWAYS);
345345
}
346346

347-
void *qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
347+
void *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
348+
void *key,
349+
void *value) {
348350
return qt_hash_put(dict, key, value, PUT_IF_ABSENT);
349351
}
350352

@@ -366,7 +368,7 @@ static inline void *qt_hash_get(qt_hash h, qt_key_t const key) {
366368
&(h->B[bucket]), so_regularkey(lkey), key, NULL, NULL, NULL, h->op_equals);
367369
}
368370

369-
void *qt_dictionary_get(qt_dictionary *dict, void *key) {
371+
void *API_FUNC qt_dictionary_get(qt_dictionary *dict, void *key) {
370372
return qt_hash_get(dict, key);
371373
}
372374

@@ -390,7 +392,7 @@ static inline int qt_hash_remove(qt_hash h, qt_key_t const key) {
390392
return 1;
391393
}
392394

393-
void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
395+
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
394396
void *val = qt_hash_get(dict, key); // TODO : this is inefficient!
395397
int ret = qt_hash_remove(dict, key);
396398

@@ -470,9 +472,9 @@ static inline qt_hash qt_hash_create(qt_dict_key_equals_f eq,
470472
return tmp;
471473
}
472474

473-
qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
474-
qt_dict_hash_f hash,
475-
qt_dict_cleanup_f cleanup) {
475+
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
476+
qt_dict_hash_f hash,
477+
qt_dict_cleanup_f cleanup) {
476478
return qt_hash_create(eq, hash, cleanup);
477479
}
478480

@@ -497,7 +499,7 @@ static inline void qt_hash_destroy(qt_hash h) {
497499
FREE(h, sizeof(qt_hash));
498500
}
499501

500-
void qt_dictionary_destroy(qt_dictionary *d) { qt_hash_destroy(d); }
502+
void API_FUNC qt_dictionary_destroy(qt_dictionary *d) { qt_hash_destroy(d); }
501503

502504
/*
503505
* void qt_hash_destroy_deallocate(qt_hash h,
@@ -555,7 +557,8 @@ struct qt_dictionary_iterator {
555557
int bkt; // = -1 if iterator is newly created; =1 otherwise.
556558
};
557559

558-
qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
560+
qt_dictionary_iterator *API_FUNC
561+
qt_dictionary_iterator_create(qt_dictionary *dict) {
559562
if (dict == NULL) { return ERROR; }
560563
qt_dictionary_iterator *it =
561564
(qt_dictionary_iterator *)MALLOC(sizeof(qt_dictionary_iterator));
@@ -565,7 +568,7 @@ qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
565568
return it;
566569
}
567570

568-
void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
571+
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
569572
if (it == NULL) { return; }
570573
FREE(it, sizeof(qt_dictionary_iterator));
571574
}
@@ -592,7 +595,7 @@ qt_dictionary_iterator_next_element(qt_dictionary_iterator *it) {
592595
return it->crt;
593596
}
594597

595-
list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
598+
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
596599
list_entry *ret = qt_dictionary_iterator_next_element(it);
597600

598601
while (ret != ERROR && ret != NULL && ret->key == NULL) {
@@ -601,27 +604,29 @@ list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
601604
return ret;
602605
}
603606

604-
list_entry *qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
607+
list_entry *API_FUNC
608+
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
605609
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
606610
qt_dictionary *h = it->dict;
607611
if ((h->count == 0) || (it->crt == UNINITIALIZED)) { return NULL; }
608612
return it->crt;
609613
}
610614

611-
qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
615+
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
612616
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(dict);
613617

614618
ret->bkt = 1;
615619
return ret;
616620
}
617621

618-
int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
619-
qt_dictionary_iterator *b) {
622+
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
623+
qt_dictionary_iterator *b) {
620624
if ((a == NULL) || (b == NULL)) { return a == b; }
621625
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
622626
}
623627

624-
qt_dictionary_iterator *qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
628+
qt_dictionary_iterator *API_FUNC
629+
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
625630
if (b == NULL) { return NULL; }
626631
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);
627632
if ((ret == NULL) || (ret == ERROR)) { return NULL; }

src/ds/dictionary/dictionary_simple.c

+21-16
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ static int qthread_library_initialized = 1;
102102
extern int qthread_library_initialized;
103103
#endif
104104

105-
qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
106-
qt_dict_hash_f hash,
107-
qt_dict_cleanup_f cleanup) {
105+
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
106+
qt_dict_hash_f hash,
107+
qt_dict_cleanup_f cleanup) {
108108
assert(qthread_library_initialized &&
109109
"Need to initialize qthreads before using the dictionary");
110110
qt_dictionary *ret = (qt_dictionary *)MALLOC(sizeof(qt_dictionary));
@@ -120,7 +120,7 @@ qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
120120
return ret;
121121
}
122122

123-
void qt_dictionary_destroy(qt_dictionary *d) {
123+
void API_FUNC qt_dictionary_destroy(qt_dictionary *d) {
124124
int i;
125125

126126
for (i = 0; i < NO_BUCKETS; i++) {
@@ -256,15 +256,17 @@ void *qt_dictionary_put_helper(qt_dictionary *dict,
256256
}
257257
#endif /* ifdef DICTIONARY_ADD_TO_HEAD */
258258

259-
void *qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
259+
void *API_FUNC qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
260260
return qt_dictionary_put_helper(dict, key, value, PUT_ALWAYS);
261261
}
262262

263-
void *qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
263+
void *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
264+
void *key,
265+
void *value) {
264266
return qt_dictionary_put_helper(dict, key, value, PUT_IF_ABSENT);
265267
}
266268

267-
void *qt_dictionary_get(qt_dictionary *dict, void *key) {
269+
void *API_FUNC qt_dictionary_get(qt_dictionary *dict, void *key) {
268270
int hash = dict->op_hash(key);
269271
int bucket = GET_BUCKET(hash);
270272

@@ -283,7 +285,7 @@ void *qt_dictionary_get(qt_dictionary *dict, void *key) {
283285
return NULL;
284286
}
285287

286-
void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
288+
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
287289
void *to_ret = NULL;
288290
list_entry *to_free = NULL;
289291
int hash = dict->op_hash(key);
@@ -340,7 +342,8 @@ void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
340342
return to_ret;
341343
}
342344

343-
qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
345+
qt_dictionary_iterator *API_FUNC
346+
qt_dictionary_iterator_create(qt_dictionary *dict) {
344347
if ((dict == NULL) || (dict->content == NULL)) { return ERROR; }
345348
qt_dictionary_iterator *it =
346349
(qt_dictionary_iterator *)MALLOC(sizeof(qt_dictionary_iterator));
@@ -353,12 +356,12 @@ qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
353356
return it;
354357
}
355358

356-
void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
359+
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
357360
if (it == NULL) { return; }
358361
FREE(it, sizeof(qt_dictionary_iterator));
359362
}
360363

361-
list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
364+
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
362365
if ((it == NULL) || (it->dict == NULL) || (it->dict->content == NULL)) {
363366
return ERROR;
364367
}
@@ -400,7 +403,8 @@ list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
400403
return NULL;
401404
}
402405

403-
list_entry *qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
406+
list_entry *API_FUNC
407+
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
404408
if ((it == NULL) || (it->dict == NULL) || (it->dict->content == NULL)) {
405409
printf(" Inside dictionary get, found NULL, will return ERROR\n");
406410
return ERROR;
@@ -409,7 +413,7 @@ list_entry *qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
409413
return it->crt;
410414
}
411415

412-
qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
416+
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
413417
if ((dict == NULL) || (dict->content == NULL)) { return NULL; }
414418
qt_dictionary_iterator *it = qt_dictionary_iterator_create(dict);
415419
it->crt = NULL;
@@ -418,13 +422,14 @@ qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
418422
return it;
419423
}
420424

421-
int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
422-
qt_dictionary_iterator *b) {
425+
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
426+
qt_dictionary_iterator *b) {
423427
if ((a == NULL) || (b == NULL)) { return a == b; }
424428
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
425429
}
426430

427-
qt_dictionary_iterator *qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
431+
qt_dictionary_iterator *API_FUNC
432+
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
428433
if (b == NULL) { return NULL; }
429434
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);
430435
if ((ret == NULL) || (ret == ERROR)) { return NULL; }

src/ds/dictionary/dictionary_trie.c

+23-18
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ static inline qt_hash qt_hash_create(qt_dict_key_equals_f eq,
107107
return tmp;
108108
}
109109

110-
qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
111-
qt_dict_hash_f hash,
112-
qt_dict_cleanup_f cleanup) {
110+
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
111+
qt_dict_hash_f hash,
112+
qt_dict_cleanup_f cleanup) {
113113
return qt_hash_create(eq, hash, cleanup);
114114
}
115115

@@ -227,7 +227,7 @@ static void destroy_element(hash_entry *element, qt_dict_cleanup_f f) {
227227
FREE(element, sizeof(hash_entry));
228228
}
229229

230-
void qt_dictionary_destroy(qt_hash h) {
230+
void API_FUNC qt_dictionary_destroy(qt_hash h) {
231231
assert(h);
232232
assert(h->spines);
233233
for (size_t i = 0; i < BASE_SPINE_LENGTH; ++i) {
@@ -401,17 +401,19 @@ void *qt_hash_put_helper(qt_dictionary *h,
401401
} while (1);
402402
}
403403

404-
void *qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
404+
void *API_FUNC qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
405405
return qt_hash_put_helper(dict, key, value, PUT_ALWAYS);
406406
}
407407

408-
void *qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
408+
void *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
409+
void *key,
410+
void *value) {
409411
return qt_hash_put_helper(dict, key, value, PUT_IF_ABSENT);
410412
}
411413

412-
int qt_dictionary_remove(qt_dictionary *h, qt_key_t const key);
414+
int API_FUNC qt_dictionary_remove(qt_dictionary *h, qt_key_t const key);
413415

414-
int qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
416+
int API_FUNC qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
415417
uint64_t lkey = (uint64_t)(uintptr_t)(h->op_hash(key));
416418

417419
HASH_KEY(lkey);
@@ -493,7 +495,7 @@ int qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
493495
} while (1);
494496
}
495497

496-
void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
498+
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
497499
void *val = qt_dictionary_get(dict, key); // TODO : this is inefficient!
498500
int ret = qt_dictionary_remove(dict, key);
499501

@@ -504,7 +506,7 @@ void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
504506
}
505507
}
506508

507-
void *qt_dictionary_get(qt_dictionary *h, qt_key_t const key) {
509+
void *API_FUNC qt_dictionary_get(qt_dictionary *h, qt_key_t const key) {
508510
uint64_t lkey = (uint64_t)(uintptr_t)(h->op_hash(key));
509511

510512
HASH_KEY(lkey);
@@ -612,7 +614,8 @@ struct qt_dictionary_iterator {
612614
int base_index;
613615
};
614616

615-
qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
617+
qt_dictionary_iterator *API_FUNC
618+
qt_dictionary_iterator_create(qt_dictionary *dict) {
616619
if (dict == NULL) { return ERROR; }
617620
qt_dictionary_iterator *it =
618621
(qt_dictionary_iterator *)MALLOC(sizeof(qt_dictionary_iterator));
@@ -624,12 +627,12 @@ qt_dictionary_iterator *qt_dictionary_iterator_create(qt_dictionary *dict) {
624627
return it;
625628
}
626629

627-
void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
630+
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
628631
if (it == NULL) { return; }
629632
FREE(it, sizeof(qt_dictionary_iterator));
630633
}
631634

632-
list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
635+
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
633636
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
634637

635638
if ((it->crt != NULL) && (it->crt->next != NULL)) {
@@ -671,25 +674,27 @@ list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
671674
return NULL;
672675
}
673676

674-
list_entry *qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
677+
list_entry *API_FUNC
678+
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
675679
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
676680
return it->crt;
677681
}
678682

679-
qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
683+
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
680684
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(dict);
681685

682686
ret->bkt = ret->dict->maxspines;
683687
return ret;
684688
}
685689

686-
int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
687-
qt_dictionary_iterator *b) {
690+
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
691+
qt_dictionary_iterator *b) {
688692
if ((a == NULL) || (b == NULL)) { return a == b; }
689693
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
690694
}
691695

692-
qt_dictionary_iterator *qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
696+
qt_dictionary_iterator *API_FUNC
697+
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
693698
if (b == NULL) { return NULL; }
694699
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);
695700
if ((ret == NULL) || (ret == ERROR)) { return NULL; }

0 commit comments

Comments
 (0)