// // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // memory.hfa -- Memory Management Tools for CFA // // Author : Andrew Beach // Created On : Tue Jun 2 16:48:00 2020 // Last Modified By : Andrew Beach // Last Modified On : Tue Jun 3 12:29:00 2020 // Update Count : 0 // #pragma once // Internal data object. forall(T & | sized(T)) { struct counter_data { unsigned int counter; T object; }; forall(Args... | { void ?{}(T &, Args); }) void ?{}(counter_data(T) & this, Args args); forall( | { void ^?{}(T &); }) void ^?{}(counter_data(T) & this); } // This is one of many pointers keeping this alive. forall(T & | sized(T)) { struct counter_ptr { counter_data(T) * data; }; void ?{}(counter_ptr(T) & this); void ?{}(counter_ptr(T) & this, zero_t); forall( | { void ^?{}(T &); }) void ?{}(counter_ptr(T) & this, counter_ptr(T) that); forall(Args... | { void ?{}(T&, Args); }) void ?{}(counter_ptr(T) & this, Args args); forall( | { void ^?{}(T &); }) void ^?{}(counter_ptr(T) & this); T & *?(counter_ptr(T) & this); forall( | { void ^?{}(T &); }) void ?=?(counter_ptr(T) & this, counter_ptr(T) that); forall( | { void ^?{}(T &); }) void ?=?(counter_ptr(T) & this, zero_t); int ?==?(counter_ptr(T) const & this, counter_ptr(T) const & that); int ?!=?(counter_ptr(T) const & this, counter_ptr(T) const & that); int ?==?(counter_ptr(T) const & this, zero_t); int ?!=?(counter_ptr(T) const & this, zero_t); } // This is the only pointer that keeps this alive. forall(T &) { struct unique_ptr { T * data; }; void ?{}(unique_ptr(T) & this); void ?{}(unique_ptr(T) & this, zero_t); void ?{}(unique_ptr(T) & this, unique_ptr(T) that) = void; forall( | sized(T), Args... | { void ?{}(T &, Args); }) void ?{}(unique_ptr(T) & this, Args args); forall( | { void ^?{}(T &); }) void ^?{}(unique_ptr(T) & this); T & *?(unique_ptr(T) & this); void ?=?(unique_ptr(T) & this, unique_ptr(T) that) = void; forall( | { void ^?{}(T &); }) void ?=?(unique_ptr(T) & this, zero_t); forall( | { void ^?{}(T &); }) void move(unique_ptr(T) & this, unique_ptr(T) & that); int ?==?(unique_ptr(T) const & this, unique_ptr(T) const & that); int ?!=?(unique_ptr(T) const & this, unique_ptr(T) const & that); int ?==?(unique_ptr(T) const & this, zero_t); int ?!=?(unique_ptr(T) const & this, zero_t); }