diff options
author | Andrew Cagney <cagney@redhat.com> | 1998-03-22 05:06:27 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 1998-03-22 05:06:27 +0000 |
commit | e5f0d498af49da4680564df06b9709423523ba6e (patch) | |
tree | 0e052b4638713a10794e9fbd11df0651dcf974c7 /sim/common/hw-device.h | |
parent | b1e9223cee0728b89f6b909c445a896d9fe41452 (diff) | |
download | gdb-e5f0d498af49da4680564df06b9709423523ba6e.zip gdb-e5f0d498af49da4680564df06b9709423523ba6e.tar.gz gdb-e5f0d498af49da4680564df06b9709423523ba6e.tar.bz2 |
Add hw_{malloc,zalloc,free} functions to hw_device. Any memory
allocated using these functions is reclaimed when the corresponding
device is deleted.
Diffstat (limited to 'sim/common/hw-device.h')
-rw-r--r-- | sim/common/hw-device.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h index ecbedca..4abe207 100644 --- a/sim/common/hw-device.h +++ b/sim/common/hw-device.h @@ -350,6 +350,25 @@ typedef int (hw_unit_size_to_attach_size_callback) +/* Memory allocator / de-allocator. + + All memory allocated using the below will be automatically + reclaimed when the device is deleted. + + A device implementation can either use these functions when + allocating memory or use malloc/zalloc/free an co-ordinate its own + garbage collection. */ + +#define HW_ZALLOC(me,type) (type*) hw_zalloc (me, sizeof (type)) +#define HW_MALLOC(me,type) (type*) hw_malloc (me, sizeof (type)) + +extern void *hw_zalloc (struct hw *me, unsigned long size); +extern void *hw_malloc (struct hw *me, unsigned long size); +extern void hw_free (struct hw *me, void *); +extern void hw_free_all (struct hw *me); + + + /* Utilities: */ @@ -435,6 +454,7 @@ void volatile NORETURN hw_abort struct hw_property_data; struct hw_port_data; struct hw_base_data; +struct hw_alloc_data; /* Finally the hardware device - keep your grubby little mits off of these internals! :-) */ @@ -489,6 +509,7 @@ struct hw { struct hw_property_data *properties_of_hw; struct hw_port_data *ports_of_hw; struct hw_base_data *base_of_hw; + struct hw_alloc_data *alloc_of_hw; }; |