Require Export compcert.cfrontend.Ctypes.
Definition strict_bool_val (v: val) (t: type) : option bool :=
match v, t with
| Vint n, Tint _ _ _ => Some (negb (Int.eq n Int.zero))
| Vlong n, Tlong _ _ => Some (negb (Int64.eq n Int64.zero))
| (Vint n), (Tpointer _ _ | Tarray _ _ _ | Tfunction _ _ _ ) =>
if Archi.ptr64 then None else if Int.eq n Int.zero then Some false else None
| Vlong n, (Tpointer _ _ | Tarray _ _ _ | Tfunction _ _ _ ) =>
if Archi.ptr64 then if Int64.eq n Int64.zero then Some false else None else None
| Vptr b ofs, (Tpointer _ _ | Tarray _ _ _ | Tfunction _ _ _ ) => Some true
| Vfloat f, Tfloat F64 _ => Some (negb(Float.cmp Ceq f Float.zero))
| Vsingle f, Tfloat F32 _ => Some (negb(Float32.cmp Ceq f Float32.zero))
| _, _ => None
end.
Definition type_is_by_value (t:type) : bool :=
match t with
| Tint _ _ _
| Tlong _ _
| Tfloat _ _
| Tpointer _ _ => true
| _ => false
end.
Definition type_is_by_reference t : bool :=
match t with
| Tarray _ _ _
| Tfunction _ _ _ => true
| _ => false
end.
(** GENERAL KV-Maps **)
Set Implicit Arguments.
Module Map. Section map.
Variables (B : Type).
Definition t := positive -> option B.
Definition get (h: t) (a:positive) : option B := h a.
Definition set (a:positive) (v: B) (h: t) : t :=
fun i => if ident_eq i a then Some v else h i.
Definition remove (a: positive) (h: t) : t :=
fun i => if ident_eq i a then None else h i.
Definition empty : t := fun _ => None.
(** MAP Axioms **)

(* Specifications: *)
Lemma gss h x v : get (set x v h) x = Some v.
unfold get, set; if_tac; intuition.