-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rpc-version
- Loading branch information
Showing
16 changed files
with
1,096 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
|
||
/* Increment the first byte pointed to by a 64-bit word pointer */ | ||
void incr_u64_ptr_byte (uint64_t *x) { | ||
uint8_t *x_byte = (uint8_t*)x; | ||
(*x_byte)++; | ||
} | ||
|
||
typedef struct padded_struct { | ||
uint64_t padded1; | ||
uint8_t padded2; | ||
uint64_t padded3; | ||
uint8_t padded4; | ||
} padded_struct; | ||
|
||
/* Allocated a padded_struct */ | ||
padded_struct *alloc_padded_struct (void) { | ||
padded_struct *ret = malloc (sizeof(padded_struct)); | ||
ret->padded1 = 0; | ||
ret->padded2 = 0; | ||
ret->padded3 = 0; | ||
ret->padded4 = 0; | ||
return ret; | ||
} | ||
|
||
/* Increment all fields of a padded_struct */ | ||
void padded_struct_incr_all (padded_struct *p) { | ||
p->padded1++; | ||
p->padded2++; | ||
p->padded3++; | ||
p->padded4++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
enable_experimental; | ||
env <- heapster_init_env "c_data" "c_data.bc"; | ||
|
||
/*** | ||
*** Type Definitions | ||
***/ | ||
|
||
// Integer types | ||
heapster_define_perm env "int8" " " "llvmptr 8" "exists x:bv 8.eq(llvmword(x))"; | ||
heapster_define_perm env "int64" " " "llvmptr 64" "exists x:bv 64.eq(llvmword(x))"; | ||
|
||
// padded_struct type | ||
heapster_define_llvmshape env "u64" 64 "" "fieldsh(int64<>)"; | ||
|
||
heapster_define_llvmshape env "padded_struct" 64 "" | ||
"fieldsh(int64<>);fieldsh(8,int8<>);fieldsh(56,true); \ | ||
\ fieldsh(int64<>);fieldsh(8,int8<>);fieldsh(56,true)"; | ||
|
||
|
||
/*** | ||
*** Assumed Functions | ||
***/ | ||
|
||
heapster_assume_fun env "malloc" | ||
"(sz:bv 64). arg0:eq(llvmword(8*sz)) -o \ | ||
\ arg0:true, ret:array(W,0,<sz,*8,fieldsh(true))" | ||
"\\ (sz:Vec 64 Bool) -> \ | ||
\ returnM (BVVec 64 sz #()) \ | ||
\ (genBVVec 64 sz #() (\\ (i:Vec 64 Bool) (_:is_bvult 64 i sz) -> ()))"; | ||
|
||
|
||
/*** | ||
*** Type-Checked Functions | ||
***/ | ||
|
||
// incr_u64_ptr_byte | ||
heapster_typecheck_fun env "incr_u64_ptr_byte" | ||
"(). arg0:ptr((W,0) |-> int64<>) -o arg0:ptr((W,0) |-> int64<>)"; | ||
|
||
// alloc_padded_struct | ||
heapster_typecheck_fun env "alloc_padded_struct" | ||
"(). empty -o ret:memblock(W,0,32,padded_struct<>)"; | ||
|
||
// padded_struct_incr_all | ||
heapster_typecheck_fun env "padded_struct_incr_all" | ||
"(). arg0:memblock(W,0,32,padded_struct<>) -o arg0:memblock(W,0,32,padded_struct<>)"; | ||
|
||
/*** | ||
*** Export to Coq | ||
***/ | ||
|
||
heapster_export_coq env "c_data_gen.v"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From Coq Require Import Lists.List. | ||
From Coq Require Import String. | ||
From Coq Require Import Vectors.Vector. | ||
From CryptolToCoq Require Import SAWCoreScaffolding. | ||
From CryptolToCoq Require Import SAWCoreVectorsAsCoqVectors. | ||
From CryptolToCoq Require Import SAWCoreBitvectors. | ||
|
||
From CryptolToCoq Require Import SAWCorePrelude. | ||
From CryptolToCoq Require Import CompMExtra. | ||
|
||
Require Import Examples.c_data_gen. | ||
Import c_data. | ||
|
||
Import SAWCorePrelude. | ||
|
||
Lemma no_errors_incr_u64_ptr_byte : | ||
refinesFun incr_u64_ptr_byte (fun _ => noErrorsSpec). | ||
unfold incr_u64_ptr_byte, incr_u64_ptr_byte__tuple_fun, noErrorsSpec. | ||
time "no_errors_incr_u64_ptr_byte" prove_refinement. | ||
Qed. | ||
|
||
Lemma no_errors_alloc_padded_struct : | ||
refinesFun alloc_padded_struct noErrorsSpec. | ||
unfold alloc_padded_struct, alloc_padded_struct__tuple_fun, noErrorsSpec, malloc. | ||
time "no_errors_alloc_padded_struct" prove_refinement. | ||
Qed. | ||
|
||
Lemma no_errors_padded_struct_incr_all : | ||
refinesFun padded_struct_incr_all (fun _ => noErrorsSpec). | ||
unfold padded_struct_incr_all, padded_struct_incr_all__tuple_fun, noErrorsSpec. | ||
time "no_errors_padded_struct_incr_all" prove_refinement. | ||
Qed. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.