Skip to content

Commit 3b2a432

Browse files
Disambiguate some attribute placement relative to gcc's more strict rules.
1 parent 371e07c commit 3b2a432

13 files changed

+123
-140
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AllowShortCaseLabelsOnASingleLine: true
44
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
55
AllowShortLoopsOnASingleLine: true
66
AlwaysBreakTemplateDeclarations: Yes
7-
AttributeMacros: ['Q_UNUSED', 'STACKLEFT_NOINLINE']
7+
AttributeMacros: ['Q_UNUSED', 'STACKLEFT_NOINLINE', 'API_FUNC']
88
BinPackArguments: false
99
BinPackParameters: false
1010
BreakArrays: false

src/ds/dictionary/dictionary_shavit.c

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

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

347-
void *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
348-
void *key,
349-
void *value) {
347+
API_FUNC void *
348+
qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
350349
return qt_hash_put(dict, key, value, PUT_IF_ABSENT);
351350
}
352351

@@ -368,7 +367,7 @@ static inline void *qt_hash_get(qt_hash h, qt_key_t const key) {
368367
&(h->B[bucket]), so_regularkey(lkey), key, NULL, NULL, NULL, h->op_equals);
369368
}
370369

371-
void *API_FUNC qt_dictionary_get(qt_dictionary *dict, void *key) {
370+
API_FUNC void *qt_dictionary_get(qt_dictionary *dict, void *key) {
372371
return qt_hash_get(dict, key);
373372
}
374373

@@ -392,7 +391,7 @@ static inline int qt_hash_remove(qt_hash h, qt_key_t const key) {
392391
return 1;
393392
}
394393

395-
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
394+
API_FUNC void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
396395
void *val = qt_hash_get(dict, key); // TODO : this is inefficient!
397396
int ret = qt_hash_remove(dict, key);
398397

@@ -472,7 +471,7 @@ static inline qt_hash qt_hash_create(qt_dict_key_equals_f eq,
472471
return tmp;
473472
}
474473

475-
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
474+
API_FUNC qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
476475
qt_dict_hash_f hash,
477476
qt_dict_cleanup_f cleanup) {
478477
return qt_hash_create(eq, hash, cleanup);
@@ -499,7 +498,7 @@ static inline void qt_hash_destroy(qt_hash h) {
499498
FREE(h, sizeof(qt_hash));
500499
}
501500

502-
void API_FUNC qt_dictionary_destroy(qt_dictionary *d) { qt_hash_destroy(d); }
501+
API_FUNC void qt_dictionary_destroy(qt_dictionary *d) { qt_hash_destroy(d); }
503502

504503
/*
505504
* void qt_hash_destroy_deallocate(qt_hash h,
@@ -557,7 +556,7 @@ struct qt_dictionary_iterator {
557556
int bkt; // = -1 if iterator is newly created; =1 otherwise.
558557
};
559558

560-
qt_dictionary_iterator *API_FUNC
559+
API_FUNC qt_dictionary_iterator *
561560
qt_dictionary_iterator_create(qt_dictionary *dict) {
562561
if (dict == NULL) { return ERROR; }
563562
qt_dictionary_iterator *it =
@@ -568,7 +567,7 @@ qt_dictionary_iterator_create(qt_dictionary *dict) {
568567
return it;
569568
}
570569

571-
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
570+
API_FUNC void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
572571
if (it == NULL) { return; }
573572
FREE(it, sizeof(qt_dictionary_iterator));
574573
}
@@ -595,7 +594,7 @@ qt_dictionary_iterator_next_element(qt_dictionary_iterator *it) {
595594
return it->crt;
596595
}
597596

598-
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
597+
API_FUNC list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
599598
list_entry *ret = qt_dictionary_iterator_next_element(it);
600599

601600
while (ret != ERROR && ret != NULL && ret->key == NULL) {
@@ -604,28 +603,28 @@ list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
604603
return ret;
605604
}
606605

607-
list_entry *API_FUNC
606+
API_FUNC list_entry *
608607
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
609608
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
610609
qt_dictionary *h = it->dict;
611610
if ((h->count == 0) || (it->crt == UNINITIALIZED)) { return NULL; }
612611
return it->crt;
613612
}
614613

615-
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
614+
API_FUNC qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
616615
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(dict);
617616

618617
ret->bkt = 1;
619618
return ret;
620619
}
621620

622-
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
621+
API_FUNC int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
623622
qt_dictionary_iterator *b) {
624623
if ((a == NULL) || (b == NULL)) { return a == b; }
625624
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
626625
}
627626

628-
qt_dictionary_iterator *API_FUNC
627+
API_FUNC qt_dictionary_iterator *
629628
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
630629
if (b == NULL) { return NULL; }
631630
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);

src/ds/dictionary/dictionary_simple.c

+14-15
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int qthread_library_initialized = 1;
102102
extern int qthread_library_initialized;
103103
#endif
104104

105-
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
105+
API_FUNC qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
106106
qt_dict_hash_f hash,
107107
qt_dict_cleanup_f cleanup) {
108108
assert(qthread_library_initialized &&
@@ -120,7 +120,7 @@ qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
120120
return ret;
121121
}
122122

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

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

259-
void *API_FUNC qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
259+
API_FUNC void *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 *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
264-
void *key,
265-
void *value) {
263+
API_FUNC void *
264+
qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
266265
return qt_dictionary_put_helper(dict, key, value, PUT_IF_ABSENT);
267266
}
268267

269-
void *API_FUNC qt_dictionary_get(qt_dictionary *dict, void *key) {
268+
API_FUNC void *qt_dictionary_get(qt_dictionary *dict, void *key) {
270269
int hash = dict->op_hash(key);
271270
int bucket = GET_BUCKET(hash);
272271

@@ -285,7 +284,7 @@ void *API_FUNC qt_dictionary_get(qt_dictionary *dict, void *key) {
285284
return NULL;
286285
}
287286

288-
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
287+
API_FUNC void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
289288
void *to_ret = NULL;
290289
list_entry *to_free = NULL;
291290
int hash = dict->op_hash(key);
@@ -342,7 +341,7 @@ void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
342341
return to_ret;
343342
}
344343

345-
qt_dictionary_iterator *API_FUNC
344+
API_FUNC qt_dictionary_iterator *
346345
qt_dictionary_iterator_create(qt_dictionary *dict) {
347346
if ((dict == NULL) || (dict->content == NULL)) { return ERROR; }
348347
qt_dictionary_iterator *it =
@@ -356,12 +355,12 @@ qt_dictionary_iterator_create(qt_dictionary *dict) {
356355
return it;
357356
}
358357

359-
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
358+
API_FUNC void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
360359
if (it == NULL) { return; }
361360
FREE(it, sizeof(qt_dictionary_iterator));
362361
}
363362

364-
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
363+
API_FUNC list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
365364
if ((it == NULL) || (it->dict == NULL) || (it->dict->content == NULL)) {
366365
return ERROR;
367366
}
@@ -403,7 +402,7 @@ list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
403402
return NULL;
404403
}
405404

406-
list_entry *API_FUNC
405+
API_FUNC list_entry *
407406
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
408407
if ((it == NULL) || (it->dict == NULL) || (it->dict->content == NULL)) {
409408
printf(" Inside dictionary get, found NULL, will return ERROR\n");
@@ -413,7 +412,7 @@ qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
413412
return it->crt;
414413
}
415414

416-
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
415+
API_FUNC qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
417416
if ((dict == NULL) || (dict->content == NULL)) { return NULL; }
418417
qt_dictionary_iterator *it = qt_dictionary_iterator_create(dict);
419418
it->crt = NULL;
@@ -422,13 +421,13 @@ qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
422421
return it;
423422
}
424423

425-
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
424+
API_FUNC int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
426425
qt_dictionary_iterator *b) {
427426
if ((a == NULL) || (b == NULL)) { return a == b; }
428427
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
429428
}
430429

431-
qt_dictionary_iterator *API_FUNC
430+
API_FUNC qt_dictionary_iterator *
432431
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
433432
if (b == NULL) { return NULL; }
434433
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);

src/ds/dictionary/dictionary_trie.c

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

110-
qt_dictionary *API_FUNC qt_dictionary_create(qt_dict_key_equals_f eq,
110+
API_FUNC qt_dictionary *qt_dictionary_create(qt_dict_key_equals_f eq,
111111
qt_dict_hash_f hash,
112112
qt_dict_cleanup_f cleanup) {
113113
return qt_hash_create(eq, hash, cleanup);
@@ -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 API_FUNC qt_dictionary_destroy(qt_hash h) {
230+
API_FUNC void 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,19 +401,18 @@ void *qt_hash_put_helper(qt_dictionary *h,
401401
} while (1);
402402
}
403403

404-
void *API_FUNC qt_dictionary_put(qt_dictionary *dict, void *key, void *value) {
404+
API_FUNC void *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 *API_FUNC qt_dictionary_put_if_absent(qt_dictionary *dict,
409-
void *key,
410-
void *value) {
408+
API_FUNC void *
409+
qt_dictionary_put_if_absent(qt_dictionary *dict, void *key, void *value) {
411410
return qt_hash_put_helper(dict, key, value, PUT_IF_ABSENT);
412411
}
413412

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

416-
int API_FUNC qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
415+
API_FUNC int qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
417416
uint64_t lkey = (uint64_t)(uintptr_t)(h->op_hash(key));
418417

419418
HASH_KEY(lkey);
@@ -495,7 +494,7 @@ int API_FUNC qt_dictionary_remove(qt_dictionary *h, qt_key_t const key) {
495494
} while (1);
496495
}
497496

498-
void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
497+
API_FUNC void *qt_dictionary_delete(qt_dictionary *dict, void *key) {
499498
void *val = qt_dictionary_get(dict, key); // TODO : this is inefficient!
500499
int ret = qt_dictionary_remove(dict, key);
501500

@@ -506,7 +505,7 @@ void *API_FUNC qt_dictionary_delete(qt_dictionary *dict, void *key) {
506505
}
507506
}
508507

509-
void *API_FUNC qt_dictionary_get(qt_dictionary *h, qt_key_t const key) {
508+
API_FUNC void *qt_dictionary_get(qt_dictionary *h, qt_key_t const key) {
510509
uint64_t lkey = (uint64_t)(uintptr_t)(h->op_hash(key));
511510

512511
HASH_KEY(lkey);
@@ -614,7 +613,7 @@ struct qt_dictionary_iterator {
614613
int base_index;
615614
};
616615

617-
qt_dictionary_iterator *API_FUNC
616+
API_FUNC qt_dictionary_iterator *
618617
qt_dictionary_iterator_create(qt_dictionary *dict) {
619618
if (dict == NULL) { return ERROR; }
620619
qt_dictionary_iterator *it =
@@ -627,12 +626,12 @@ qt_dictionary_iterator_create(qt_dictionary *dict) {
627626
return it;
628627
}
629628

630-
void API_FUNC qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
629+
API_FUNC void qt_dictionary_iterator_destroy(qt_dictionary_iterator *it) {
631630
if (it == NULL) { return; }
632631
FREE(it, sizeof(qt_dictionary_iterator));
633632
}
634633

635-
list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
634+
API_FUNC list_entry *qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
636635
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
637636

638637
if ((it->crt != NULL) && (it->crt->next != NULL)) {
@@ -674,26 +673,26 @@ list_entry *API_FUNC qt_dictionary_iterator_next(qt_dictionary_iterator *it) {
674673
return NULL;
675674
}
676675

677-
list_entry *API_FUNC
676+
API_FUNC list_entry *
678677
qt_dictionary_iterator_get(qt_dictionary_iterator const *it) {
679678
if ((it == NULL) || (it->dict == NULL)) { return ERROR; }
680679
return it->crt;
681680
}
682681

683-
qt_dictionary_iterator *API_FUNC qt_dictionary_end(qt_dictionary *dict) {
682+
API_FUNC qt_dictionary_iterator *qt_dictionary_end(qt_dictionary *dict) {
684683
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(dict);
685684

686685
ret->bkt = ret->dict->maxspines;
687686
return ret;
688687
}
689688

690-
int API_FUNC qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
689+
API_FUNC int qt_dictionary_iterator_equals(qt_dictionary_iterator *a,
691690
qt_dictionary_iterator *b) {
692691
if ((a == NULL) || (b == NULL)) { return a == b; }
693692
return (a->crt == b->crt) && (a->dict == b->dict) && (a->bkt == b->bkt);
694693
}
695694

696-
qt_dictionary_iterator *API_FUNC
695+
API_FUNC qt_dictionary_iterator *
697696
qt_dictionary_iterator_copy(qt_dictionary_iterator *b) {
698697
if (b == NULL) { return NULL; }
699698
qt_dictionary_iterator *ret = qt_dictionary_iterator_create(b->dict);

0 commit comments

Comments
 (0)