Skip to content

Commit

Permalink
some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonin Reitz committed Jul 10, 2024
1 parent da901b2 commit 39b5cdd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib_avl_mono/Impl.Trees.Cast.M.fst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module G = FStar.Ghost
open Constants
open Utils2

/// lib_avl_mono/Impl.Trees.Cast.M.fst contains axiomatization that is required to reuse the slab allocator for the allocation of the large allocation metadata AVL tree's nodes. In particular, it consists mostly of corresponding casts.

// this is a compilation-time assert, see c/utils.c static_assert usage
assume val avl_data_size_aux : v:U32.t{U32.v v <= 64}

Expand Down
2 changes: 2 additions & 0 deletions src/ArrayAlignment.fst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ unfold let same_base_array (#a: Type) (arr1 arr2: array a)
=
A.base (A.ptr_of arr1) == A.base (A.ptr_of arr2)

/// src/ArrayAlignment.fst contains axiomatization of array alignments.

// abstract property that the underlying pointer v-bytes aligned
assume val array_u8_alignment (arr: array U8.t) (v: U32.t{U32.v v > 0}): prop

Expand Down
10 changes: 9 additions & 1 deletion src/ExternUtils.fst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ module A = Steel.Array

open Utils2

/// src/ExternUtils.fst contains axiomatizations of various compiler builtins or basic C code.
///
let check (_:unit)
=
assert (not (nth_is_zero U64.one (U32.uint_to_t 0)));
assert (nth_is_zero U64.one (U32.uint_to_t 1));
()

// bitwise-operations compiler builtin
assume val ffs64 (x: U64.t) (bound: G.erased U32.t)
: Pure U32.t
(requires
Expand All @@ -34,6 +37,7 @@ assume val ffs64 (x: U64.t) (bound: G.erased U32.t)

// count leading zeroes,
// returns r, the number of rightmost bits set to zero
// bitwise-operations compiler builtin
assume val clz (x: U64.t)
: Pure U32.t
(requires U64.v x > 0)
Expand All @@ -45,6 +49,7 @@ assume val clz (x: U64.t)

open FStar.Mul

// compiler builtin
assume val builtin_mul_overflow(x y: US.t)
: Pure US.t
(requires True)
Expand All @@ -53,7 +58,7 @@ assume val builtin_mul_overflow(x y: US.t)
US.v r == US.v x * US.v y
)


// explicit_bzero zeroing function wrapper
assume val apply_zeroing_u8
(ptr: array U8.t)
(n: US.t)
Expand All @@ -65,9 +70,11 @@ assume val apply_zeroing_u8
)
(ensures fun h0 _ h1 ->
A.length ptr >= US.v n /\
// n first bytes of ptr are zeroes after execution of the function
zf_u8 (Seq.slice (A.asel ptr h1) 0 (US.v n))
)

// check whether an array is zeroed
assume val check_zeroing_u8
(ptr: array U8.t)
(n: US.t)
Expand All @@ -82,6 +89,7 @@ assume val check_zeroing_u8
(b ==> zf_u8 (Seq.slice (A.asel ptr h1) 0 (US.v n)))
)

// memcpy function wrapper
assume val memcpy_u8
(dest src: array U8.t) (n: US.t)
: Steel (array U8.t)
Expand Down
5 changes: 1 addition & 4 deletions src/FatalError.fst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ open Config
open Utils2
open NullOrVarray

// fatal_error wrappers
// these functions only perform a fatal_error call
// thus, postcondition does not really matter as it is are tailored
// to respect caller postcondition so that verification works
/// src/FatalError.fst contains context-specific wrappers of the C fatal_error function.

open Impl.Trees.Cast.M
open Impl.Trees.Types
Expand Down
7 changes: 4 additions & 3 deletions src/Mman.fst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ open Constants
open Config
open Utils2

/// Memory management axiomatizations

/// 1) Initialization of the allocator
// all functions with a _init suffix
// are only meant to be used at initialization
Expand Down Expand Up @@ -113,7 +115,7 @@ open PtrdiffWrapper
// POSIX spec: mmap returns a page-aligned array of bytes;
// thus, mmap_u8 returns a page-aligned array of bytes;
// hence the postcondition array_u8_alignment page_size
//noextract
/// mmap syscall wrapper
assume val mmap_u8
(size: US.t)
: Steel (array U8.t)
Expand All @@ -131,8 +133,7 @@ assume val mmap_u8
)
)

// TODO: should the underlying munmap fail in a stricter manner?
//noextract
/// munmap syscall wrapper
assume val munmap_u8 (ptr: array U8.t) (size: US.t)
: Steel unit
(A.varray ptr)
Expand Down
2 changes: 2 additions & 0 deletions src/Mman2.fst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module R = Steel.Reference
open Impl.Trees.Types
module G = FStar.Ghost

/// Memory management axiomatizations

assume val mmap_ptr_metadata_init (_:unit)
: SteelT (R.ref t)
emp
Expand Down

0 comments on commit 39b5cdd

Please sign in to comment.