-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model and specs for atomic library
- Loading branch information
Showing
5 changed files
with
84 additions
and
25 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
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
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 |
---|---|---|
@@ -1,24 +1,25 @@ | ||
From Perennial.goose_lang Require Import notation. | ||
From Perennial.goose_lang Require Import notation typing typed_mem.impl. | ||
|
||
(* this code is intended to be used qualified with the atomic module *) | ||
Module atomic. | ||
Section goose_lang. | ||
Context {ext:ffi_syntax}. | ||
|
||
Definition LoadUint64 : val := | ||
λ: "l", Load "l". | ||
|
||
Definition LoadUint32 : val := LoadUint64. | ||
|
||
Definition StoreUint64 : val := | ||
λ: "l" "x", AtomicStore "l" "x". | ||
|
||
Definition StoreUint32 : val := StoreUint64. | ||
|
||
Definition CompareAndSwapUint64 : val := | ||
λ: "l" "old" "new", CmpXchg "l" "old" "new". | ||
|
||
Definition CompareAndSwapUint32 : val := CompareAndSwapUint64. | ||
Context {ext:ffi_syntax} {ext_ty: ext_types ext}. | ||
|
||
(* these are not values so that they are Atomic *) | ||
|
||
Definition LoadUint64 : expr → expr := Load. | ||
Definition LoadUint32 : expr → expr := LoadUint64. | ||
Definition StoreUint64 : expr → expr → expr := AtomicStore. | ||
Definition StoreUint32 : expr → expr → expr := StoreUint64. | ||
Definition CompareAndSwapUint64 : expr → expr → expr → expr := CmpXchg. | ||
Definition CompareAndSwapUint32 : expr → expr → expr → expr := CompareAndSwapUint64. | ||
|
||
(* the type arguments to these functions are passed since that's the GooseLang | ||
calling convention. They are not needed in the model, since these operations | ||
only load pointers, and we don't need to know what the shape of the referenced | ||
data is to write the model. *) | ||
Definition Pointer__Load (_: ty) : expr → expr := Load. | ||
Definition Pointer__Store (_: ty) : expr → expr → expr := AtomicStore. | ||
|
||
End goose_lang. | ||
End atomic. |