[1/1] Added address_space_init2().

Submitted by Alexander Barabash on Jan. 7, 2013, 12:07 p.m.

Details

Message ID 1357560425-15950-1-git-send-email-alexander_barabash@mentor.com
State New
Headers show

Commit Message

Alexander Barabash Jan. 7, 2013, 12:07 p.m.
address_space_init2: initializes a named address space.

Signed-off-by: Alexander Barabash <alexander_barabash@mentor.com>
---
 include/exec/memory.h |    9 +++++++++
 memory.c              |    6 ++++++
 2 files changed, 15 insertions(+)

Comments

Andreas Färber Jan. 7, 2013, 1:05 p.m.
A "memory: " prefix in the subject would've been nice for filtering.

Am 07.01.2013 13:07, schrieb Alexander Barabash:
> address_space_init2: initializes a named address space.

What for? There are no users in this patch that justify its utility over
setting the field manually.

The name is really awful, maybe ..._init_with_name or add a name
argument to the existing function and let the existing callers pass NULL?

Regards,
Andreas

> 
> Signed-off-by: Alexander Barabash <alexander_barabash@mentor.com>
> ---
>  include/exec/memory.h |    9 +++++++++
>  memory.c              |    6 ++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 2322732..8f8a31d 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -820,6 +820,15 @@ void mtree_info(fprintf_function mon_printf, void *f);
>   */
>  void address_space_init(AddressSpace *as, MemoryRegion *root);
>  
> +/**
> + * address_space_init2: initializes a named address space
> + *
> + * @as: an uninitialized #AddressSpace
> + * @root: a #MemoryRegion that routes addesses for the address space
> + * @name: used for debugging
> + */
> +void address_space_init2(AddressSpace *as, MemoryRegion *root,
> +                         const char *name);
>  
>  /**
>   * address_space_destroy: destroy an address space
> diff --git a/memory.c b/memory.c
> index 410c5f8..1652c10 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1574,6 +1574,12 @@ void address_space_init(AddressSpace *as, MemoryRegion *root)
>      address_space_init_dispatch(as);
>  }
>  
> +void address_space_init2(AddressSpace *as, MemoryRegion *root, const char *name)
> +{
> +    address_space_init(as, root);
> +    as->name = g_strdup(name);
> +}
> +
>  void address_space_destroy(AddressSpace *as)
>  {
>      /* Flush out anything from MemoryListeners listening in on this */
Alexander Barabash Jan. 8, 2013, 10:53 a.m.
Hi,
On 01/07/2013 03:05 PM, Andreas Färber wrote:
> A "memory: " prefix in the subject would've been nice for filtering.
OK
>
> Am 07.01.2013 13:07, schrieb Alexander Barabash:
>> address_space_init2: initializes a named address space.
> What for? There are no users in this patch that justify its utility over
> setting the field manually.
Names of memory regions and address spaces are used for debugging purposes.
Currently, there is no way for address spaces other than "memory" and 
"io" to
appear in debugging output.

This is used in some code to be posted later.

>
> The name is really awful, maybe ..._init_with_name or add a name
> argument to the existing function and let the existing callers pass NULL?
Changing the existing callers of address_space_init() is OK with me.
I did not do that primarily because that would be an obvious way to do
to start with. And since this was not implemented this way,
there should have been some some reason.

However, I'll send a PATCH along these lines.

>
> Regards,
> Andreas

Regards,
Alex

>
>> Signed-off-by: Alexander Barabash <alexander_barabash@mentor.com>
>> ---
>>   include/exec/memory.h |    9 +++++++++
>>   memory.c              |    6 ++++++
>>   2 files changed, 15 insertions(+)
>>
>> diff --git a/include/exec/memory.h b/include/exec/memory.h
>> index 2322732..8f8a31d 100644
>> --- a/include/exec/memory.h
>> +++ b/include/exec/memory.h
>> @@ -820,6 +820,15 @@ void mtree_info(fprintf_function mon_printf, void *f);
>>    */
>>   void address_space_init(AddressSpace *as, MemoryRegion *root);
>>   
>> +/**
>> + * address_space_init2: initializes a named address space
>> + *
>> + * @as: an uninitialized #AddressSpace
>> + * @root: a #MemoryRegion that routes addesses for the address space
>> + * @name: used for debugging
>> + */
>> +void address_space_init2(AddressSpace *as, MemoryRegion *root,
>> +                         const char *name);
>>   
>>   /**
>>    * address_space_destroy: destroy an address space
>> diff --git a/memory.c b/memory.c
>> index 410c5f8..1652c10 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -1574,6 +1574,12 @@ void address_space_init(AddressSpace *as, MemoryRegion *root)
>>       address_space_init_dispatch(as);
>>   }
>>   
>> +void address_space_init2(AddressSpace *as, MemoryRegion *root, const char *name)
>> +{
>> +    address_space_init(as, root);
>> +    as->name = g_strdup(name);
>> +}
>> +
>>   void address_space_destroy(AddressSpace *as)
>>   {
>>       /* Flush out anything from MemoryListeners listening in on this */

Patch hide | download patch | download mbox

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2322732..8f8a31d 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -820,6 +820,15 @@  void mtree_info(fprintf_function mon_printf, void *f);
  */
 void address_space_init(AddressSpace *as, MemoryRegion *root);
 
+/**
+ * address_space_init2: initializes a named address space
+ *
+ * @as: an uninitialized #AddressSpace
+ * @root: a #MemoryRegion that routes addesses for the address space
+ * @name: used for debugging
+ */
+void address_space_init2(AddressSpace *as, MemoryRegion *root,
+                         const char *name);
 
 /**
  * address_space_destroy: destroy an address space
diff --git a/memory.c b/memory.c
index 410c5f8..1652c10 100644
--- a/memory.c
+++ b/memory.c
@@ -1574,6 +1574,12 @@  void address_space_init(AddressSpace *as, MemoryRegion *root)
     address_space_init_dispatch(as);
 }
 
+void address_space_init2(AddressSpace *as, MemoryRegion *root, const char *name)
+{
+    address_space_init(as, root);
+    as->name = g_strdup(name);
+}
+
 void address_space_destroy(AddressSpace *as)
 {
     /* Flush out anything from MemoryListeners listening in on this */