Skip to content

Commit 5ecb6c5

Browse files
Merge pull request #584 from goblint/preprocessor_exclude_stdlib
Preprocessor directives to disable Goblint includes
2 parents 1eb0db3 + e1b052a commit 5ecb6c5

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

includes/pthread.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifndef GOBLINT_NO_PTHREAD_ONCE
12
#include <pthread.h>
23

34
int pthread_once(pthread_once_t *once_control,void (*init_routine)(void)) __attribute__((goblint_stub));
@@ -7,3 +8,4 @@ int pthread_once(pthread_once_t *once_control,void (*init_routine)(void)) {
78
init_routine();
89
return top;
910
}
11+
#endif

includes/stdlib.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
#if !defined(GOBLINT_NO_QSORT) || !defined(GOBLINT_NO_BSEARCH)
12
#include <stddef.h>
3+
#endif
24

5+
#ifndef GOBLINT_NO_QSORT
36
void qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) __attribute__((goblint_stub));
47
void qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) {
58
// call all possible compares first, before invalidating array elements
@@ -28,8 +31,9 @@ void qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const
2831

2932
// array isn't actually sorted! just pretend calls for Goblint
3033
}
34+
#endif
3135

32-
36+
#ifndef GOBLINT_NO_BSEARCH
3337
void* bsearch(const void *key, const void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) __attribute__((goblint_stub));
3438
void* bsearch(const void *key, const void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) {
3539
// linear search for simplicity
@@ -42,3 +46,4 @@ void* bsearch(const void *key, const void *ptr, size_t count, size_t size, int (
4246

4347
return NULL;
4448
}
49+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// PARAM: --set cppflags[+] -DGOBLINT_NO_QSORT
2+
#include<stddef.h>
3+
4+
// There should be no CIL warning about multiple definitions here
5+
void qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*), int more) {
6+
}
7+
8+
int main() {
9+
10+
}

0 commit comments

Comments
 (0)