-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
64 lines (58 loc) · 1016 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "stdlib.h"
struct file {
void *f_data;
};
int copyin()
//@ requires true;
//@ ensures true;
{
return 0;
}
void fdrop(struct file *fp)
//@ requires file_f_data(fp, _) &*& malloc_block_file(fp);
//@ ensures true;
{
free(fp);
}
int getmq_read(struct file **fpp)
//@ requires pointer(fpp, _);
/*@
ensures
result == 0 ? // success
pointer(fpp, ?p) &*& file_f_data(p, _) &*& malloc_block_file(p)
: // failure
pointer(fpp, _)
;
@*/
{
*fpp = malloc(sizeof(struct file));
if (*fpp == NULL) {
return 1;
}
return 0;
}
int sys_kmq_timedreceive()
//@ requires true;
//@ ensures true;
{
struct file *fp;
int error;
error = getmq_read(&fp);
if (error) {
return error;
}
error = copyin();
if (error) {
return error;
}
// Do something
out:
fdrop(fp);
return 0;
}
int main()
//@ requires true;
//@ ensures true;
{
return 0;
}