(** ** Semantics of dynamic memory allocation (malloc) *)

Inductive extcall_malloc_sem (ge: Senv.t):
              list val -> mem -> trace -> val -> mem -> Prop :=
  | extcall_malloc_sem_intro: forall sz m m' b m'',
      Mem.alloc m (- size_chunk Mptr) (Ptrofs.unsigned sz) = (m', b) ->
      Mem.store Mptr m' b (- size_chunk Mptr) (Vptrofs sz) = Some m'' ->
      extcall_malloc_sem ge (Vptrofs sz :: nil) m E0 (Vptr b Ptrofs.zero) m''.(** ** Semantics of dynamic memory allocation (malloc) *)

Inductive extcall_malloc_sem (ge: Senv.t):
              list val -> mem -> trace -> val -> mem -> Prop :=
  | extcall_malloc_sem_intro: forall sz m m' b m'',
      Mem.alloc m (- size_chunk Mptr) (Ptrofs.unsigned sz) = (m', b) ->
      Mem.store Mptr m' b (- size_chunk Mptr) (Vptrofs sz) = Some m'' ->
      extcall_malloc_sem ge (Vptrofs sz :: nil) m E0 (Vptr b Ptrofs.zero) m''.

Lemma alloc_parallel_inject' : forall (f : meminj) (m1 m2 : mem) (lo1 hi1 : Z) (m1' : Mem.mem') (b1 : block) (lo2 hi2 : Z), Mem.inject f m1 m2 -> Mem.alloc m1 lo1 hi1 = (m1', b1) -> injection_full f m1 -> lo2 <= lo1 -> hi1 <= hi2 -> exists (f' : meminj) (m2' : Mem.mem') (b2 : block), Mem.alloc m2 lo2 hi2 = (m2', b2) /\ Mem.inject f' m1' m2' /\ inject_incr f f' /\ f' b1 = Some (b2, 0) /\ (forall b : block, b <> b1 -> f' b = f b) /\ injection_full f' m1'.