| 1 | #ifndef __CIVL_SVCOMP__
|
|---|
| 2 | #define __CIVL_SVCOMP__
|
|---|
| 3 | #include <civlc.cvh>
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #ifndef SVCOM_INT_UPPER
|
|---|
| 6 | #define SVCOM_INT_UPPER 5
|
|---|
| 7 | #endif
|
|---|
| 8 |
|
|---|
| 9 | #ifndef SVCOM_INT_LOWER
|
|---|
| 10 | #define SVCOM_INT_LOWER -5
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | #ifndef SVCOM_UINT_UPPER
|
|---|
| 15 | #define SVCOM_UINT_UPPER 4
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 | #ifndef SVCOM_LONG_UPPER
|
|---|
| 19 | #define SVCOM_LONG_UPPER 5
|
|---|
| 20 | #endif
|
|---|
| 21 |
|
|---|
| 22 | #ifndef SVCOM_ULONG_UPPER
|
|---|
| 23 | #define SVCOM_ULONG_UPPER 4
|
|---|
| 24 | #endif
|
|---|
| 25 |
|
|---|
| 26 | int _bool_count=0;
|
|---|
| 27 | int _pointer_count=0;
|
|---|
| 28 |
|
|---|
| 29 | void* __VERIFIER_nondet_pointer(){
|
|---|
| 30 | void* x;
|
|---|
| 31 |
|
|---|
| 32 | $havoc(&x);
|
|---|
| 33 | return x;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | long __VERIFIER_nondet_long(){
|
|---|
| 37 | long temp;
|
|---|
| 38 |
|
|---|
| 39 | $havoc(&temp);
|
|---|
| 40 | $assume(temp<=SVCOM_LONG_UPPER);
|
|---|
| 41 | return temp;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | unsigned long __VERIFIER_nondet_ulong(){
|
|---|
| 45 | unsigned long temp;
|
|---|
| 46 |
|
|---|
| 47 | $havoc(&temp);
|
|---|
| 48 | $assume(temp>=0 && temp<=SVCOM_ULONG_UPPER);
|
|---|
| 49 | return temp;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | int __VERIFIER_nondet_int(){
|
|---|
| 53 | int temp;
|
|---|
| 54 |
|
|---|
| 55 | $havoc(&temp);
|
|---|
| 56 | $assume(temp<=SVCOM_INT_UPPER && temp>=SVCOM_INT_LOWER);
|
|---|
| 57 | return temp;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | char __VERIFIER_nondet_char(){
|
|---|
| 61 | char temp;
|
|---|
| 62 |
|
|---|
| 63 | $havoc(&temp);
|
|---|
| 64 | return temp;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | double __VERIFIER_nondet_double(){
|
|---|
| 68 | double temp;
|
|---|
| 69 |
|
|---|
| 70 | $havoc(&temp);
|
|---|
| 71 | return temp;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | float __VERIFIER_nondet_float(){
|
|---|
| 75 | float temp;
|
|---|
| 76 |
|
|---|
| 77 | $havoc(&temp);
|
|---|
| 78 | return temp;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | unsigned int __VERIFIER_nondet_uint(){
|
|---|
| 82 | int temp;
|
|---|
| 83 |
|
|---|
| 84 | $havoc(&temp);
|
|---|
| 85 | $assume(temp>=0 && temp<=SVCOM_UINT_UPPER);
|
|---|
| 86 | return temp;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | _Bool __VERIFIER_nondet_bool(){
|
|---|
| 90 | int x;
|
|---|
| 91 |
|
|---|
| 92 | $havoc(&x);
|
|---|
| 93 | return x != 0;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | void __VERIFIER_error(){
|
|---|
| 97 | $assert($false, "__VERIFIER_error() is called.\n");
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | void __VERIFIER_assume(int expression) {
|
|---|
| 101 | //$elaborate(expression);
|
|---|
| 102 | if (!expression)
|
|---|
| 103 | {
|
|---|
| 104 | LOOP:
|
|---|
| 105 | goto LOOP;
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | void __VERIFIER_atomic_end(){
|
|---|
| 110 | return;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | /*
|
|---|
| 114 | int _nondet_int(){
|
|---|
| 115 | int result;
|
|---|
| 116 |
|
|---|
| 117 | $havoc(&result);
|
|---|
| 118 | return result;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | int access_ok(int type, const void *addr, unsigned long size){
|
|---|
| 122 | return _nondet_int();
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | int alloc_chrdev_region(unsigned int * a, unsigned b, unsigned c, const char * d) {
|
|---|
| 126 | return _nondet_int();
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | int printk(const char * fmt, ...){
|
|---|
| 130 | return 0;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | int register_chrdev_region(unsigned int, unsigned, const char *) {
|
|---|
| 134 | return _nondet_int();
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void unregister_chrdev_region(unsigned int, unsigned) {
|
|---|
| 138 | return;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | loff_t no_llseek(struct file *file, loff_t offset, int origin) {
|
|---|
| 142 | return _nondet_int();
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | int nonseekable_open(struct inode * inode, struct file * filp) {
|
|---|
| 146 | return _nondet_int();
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | struct resource {
|
|---|
| 150 | unsigned long start, end;
|
|---|
| 151 | const char *name;
|
|---|
| 152 | unsigned long flags;
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | typedef struct resource resource_type;
|
|---|
| 156 |
|
|---|
| 157 | void __release_region(struct resource * a, resource_size_t b, resource_size_t c) {
|
|---|
| 158 | return;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | int __get_user(int size, const void *ptr){
|
|---|
| 162 | return _nondet_int();
|
|---|
| 163 | }
|
|---|
| 164 | */
|
|---|
| 165 | #endif
|
|---|
| 166 |
|
|---|