Skip to content

Commit 0080994

Browse files
Merge pull request #547 from goblint/pthread_once
Add implementation for `pthread_once`
2 parents dca6188 + 262fdaa commit 0080994

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

includes/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(files
55
assert.h
66
stdlib.c
7+
pthread.c
78
linuxlight.h
89
sv-comp.c
910
(linux/goblint_preconf.h as linux/goblint_preconf.h) ; must repeat directory, otherwise gets stripped from target

includes/pthread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <pthread.h>
2+
3+
int pthread_once(pthread_once_t *once_control,void (*init_routine)(void)) __attribute__((goblint_stub));
4+
int pthread_once(pthread_once_t *once_control,void (*init_routine)(void)) {
5+
// Not actually once, just call it
6+
int top;
7+
init_routine();
8+
return top;
9+
}

src/maingoblint.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ let preprocess_files () =
280280

281281
let extra_arg_files = ref [] in
282282

283-
extra_arg_files := find_custom_include "stdlib.c" :: !extra_arg_files;
283+
extra_arg_files := find_custom_include "stdlib.c" :: find_custom_include "pthread.c" :: !extra_arg_files;
284284

285285
if get_bool "ana.sv-comp.functions" then
286286
extra_arg_files := find_custom_include "sv-comp.c" :: !extra_arg_files;

sv-comp/archive.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ zip goblint/sv-comp/goblint.zip \
1414
goblint/goblint \
1515
goblint/conf/svcomp22.json \
1616
goblint/includes/stdlib.c \
17+
goblint/includes/pthread.c \
1718
goblint/includes/sv-comp.c \
1819
goblint/README.md \
1920
goblint/LICENSE

tests/regression/02-base/10-init_allfuns.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// PARAM: --enable allfuns --set ana.activated "['base','threadid','threadflag','escape','mutex','access','mallocWrapper']"
2-
32
int glob1 = 5;
43
int glob2 = 7;
54

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//PARAM: --disable sem.unknown_function.spawn
2+
#include <pthread.h>
3+
#include <assert.h>
4+
5+
int g;
6+
pthread_once_t once = PTHREAD_ONCE_INIT;
7+
8+
void t_fun() {
9+
assert(1); // reachable!
10+
return NULL;
11+
}
12+
13+
int main() {
14+
pthread_once(&once,t_fun);
15+
return 0;
16+
}

tests/regression/07-uninit/14-struct_in_struct.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int main(){
4343

4444
mod_S1(&tt1.s); //NOWARN
4545
mod_S2(&tt2.s); //NOWARN
46+
4647
mod_S31(&tt3.s); //NOWARN
4748
mod_S32(&tt3.s); //NOWARN
4849

0 commit comments

Comments
 (0)