public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Put bcache inside "namespace gdb"
@ 2019-12-02 21:15 Christian Biesinger via gdb-patches
  2019-12-05 21:32 ` [PATCH v2] " Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-02 21:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

This avoids a conflict with a system "struct bcache" on
Solaris (see e.g.
https://www.isi.edu/nsnam/archive/ns-users/webarch/2001/msg05393.html)

Note that the Solaris conflict for now only surfaces with
--enable-targets=all (which the build bot doesn't use).

Some callers of hash should probably be switched to fast_hash, and
perhaps that function should be entirely be replaced by that one,
but I am not doing that as part of this patch.

gdb/ChangeLog:

2019-12-02  Christian Biesinger  <cbiesinger@google.com>

	* bcache.c: Put in namespace gdb.
	* bcache.h: Likewise.
	* gdbtypes.c (check_types_worklist): Update.
	(types_deeply_equal): Update.
	* macrotab.c (struct macro_table) <bcache>: Update.
	(new_macro_table): Update.
	* macrotab.h (struct bcache): Put this forward declaration
	inside namespace gdb.
	(new_macro_table): Update.
	* objfiles.h (struct objfile_per_bfd_storage) <filename_cache>:
	Update.
	<macro_cache>: Update.
	* psymtab.c (psymbol_hash): Update.
	* psymtab.h: (psymtab_storage) <psymbol_cache>: Update.
	* stabsread.c (hashname): Update.

Change-Id: I843d5e91f7ccb3db6d1099a8214c15a74510256f
---
 gdb/bcache.c    |  4 ++++
 gdb/bcache.h    |  4 ++++
 gdb/gdbtypes.c  |  4 ++--
 gdb/macrotab.c  |  4 ++--
 gdb/macrotab.h  |  7 +++++--
 gdb/objfiles.h  |  4 ++--
 gdb/psymtab.c   | 13 +++++++------
 gdb/psymtab.h   |  2 +-
 gdb/stabsread.c |  2 +-
 9 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/gdb/bcache.c b/gdb/bcache.c
index 3f0a63be22..42ca3a2e12 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -25,6 +25,8 @@
 
 #include <algorithm>
 
+namespace gdb {
+
 /* The type used to hold a single bcache string.  The user data is
    stored in d.data.  Since it can be any type, it needs to have the
    same alignment as the most strict alignment of any type on the host
@@ -403,3 +405,5 @@ bcache::memory_used ()
     return 0;
   return obstack_memory_used (&m_cache);
 }
+
+} /* namespace gdb */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 15dcc63440..96bf880b48 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -136,6 +136,8 @@
   
 */
 
+namespace gdb {
+
 struct bstring;
 
 /* The hash functions */
@@ -221,4 +223,6 @@ private:
   void expand_hash_table ();
 };
 
+} /* namespace gdb */
+
 #endif /* BCACHE_H */
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f10f65d0da..6bc13c5071 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3783,7 +3783,7 @@ check_types_equal (struct type *type1, struct type *type2,
 
 static bool
 check_types_worklist (std::vector<type_equality_entry> *worklist,
-		      struct bcache *cache)
+		      gdb::bcache *cache)
 {
   while (!worklist->empty ())
     {
@@ -3819,7 +3819,7 @@ types_deeply_equal (struct type *type1, struct type *type2)
   if (type1 == type2)
     return true;
 
-  struct bcache cache (nullptr, nullptr);
+  gdb::bcache cache (nullptr, nullptr);
   worklist.emplace_back (type1, type2);
   return check_types_worklist (&worklist, &cache);
 }
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 90f29439c0..e500cf5cbe 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -40,7 +40,7 @@ struct macro_table
 
   /* The bcache we should use to hold macro names, argument names, and
      definitions, or zero if we should use xmalloc.  */
-  struct bcache *bcache;
+  gdb::bcache *bcache;
 
   /* The main source file for this compilation unit --- the one whose
      name was given to the compiler.  This is the root of the
@@ -1025,7 +1025,7 @@ macro_for_each_in_scope (struct macro_source_file *file, int line,
 
 
 struct macro_table *
-new_macro_table (struct obstack *obstack, struct bcache *b,
+new_macro_table (struct obstack *obstack, gdb::bcache *b,
 		 struct compunit_symtab *cust)
 {
   struct macro_table *t;
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 045d1625a1..83a7dfad23 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -23,9 +23,12 @@
 #include "gdbsupport/function-view.h"
 
 struct obstack;
-struct bcache;
 struct compunit_symtab;
 
+namespace gdb {
+struct bcache;
+}
+
 /* How do we represent a source location?  I mean, how should we
    represent them within GDB; the user wants to use all sorts of
    ambiguous abbreviations, like "break 32" and "break foo.c:32"
@@ -170,7 +173,7 @@ struct macro_source_file
    the same source location (although 'gcc -DFOO -UFOO -DFOO=2' does
    do that in GCC 4.1.2.).  */
 struct macro_table *new_macro_table (struct obstack *obstack,
-                                     struct bcache *bcache,
+                                     gdb::bcache *bcache,
 				     struct compunit_symtab *cust);
 
 
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 0c044582e4..1601cfe591 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -244,11 +244,11 @@ struct objfile_per_bfd_storage
 
   /* Byte cache for file names.  */
 
-  struct bcache filename_cache;
+  gdb::bcache filename_cache;
 
   /* Byte cache for macros.  */
 
-  struct bcache macro_cache;
+  gdb::bcache macro_cache;
 
   /* The gdbarch associated with the BFD.  Note that this gdbarch is
      determined solely from BFD information, without looking at target
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 7074a32956..1718868fd7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1530,14 +1530,15 @@ psymbol_hash (const void *addr, int length)
   unsigned int domain = psymbol->domain;
   unsigned int theclass = psymbol->aclass;
 
-  h = hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h);
-  h = hash_continue (&lang, sizeof (unsigned int), h);
-  h = hash_continue (&domain, sizeof (unsigned int), h);
-  h = hash_continue (&theclass, sizeof (unsigned int), h);
+  h = gdb::hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value),
+			  h);
+  h = gdb::hash_continue (&lang, sizeof (unsigned int), h);
+  h = gdb::hash_continue (&domain, sizeof (unsigned int), h);
+  h = gdb::hash_continue (&theclass, sizeof (unsigned int), h);
   /* Note that psymbol names are interned via symbol_set_names, so
      there's no need to hash the contents of the name here.  */
-  h = hash_continue (&psymbol->ginfo.name,
-		     sizeof (psymbol->ginfo.name), h);
+  h = gdb::hash_continue (&psymbol->ginfo.name,
+			  sizeof (psymbol->ginfo.name), h);
 
   return h;
 }
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index a4ac35a791..a4281c80bf 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -120,7 +120,7 @@ public:
   /* A byte cache where we can stash arbitrary "chunks" of bytes that
      will not change.  */
 
-  struct bcache psymbol_cache;
+  gdb::bcache psymbol_cache;
 
   /* Vectors of all partial symbols read in from file.  The actual data
      is stored in the objfile_obstack.  */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 979df0266c..96a886f85a 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -4778,7 +4778,7 @@ find_name_end (const char *name)
 int
 hashname (const char *name)
 {
-  return hash (name, strlen (name)) % HASHSIZE;
+  return gdb::hash (name, strlen (name)) % HASHSIZE;
 }
 
 /* Initializer for this module.  */
-- 
2.24.0.393.g34dc348eaf-goog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] Put bcache inside "namespace gdb"
  2019-12-02 21:15 [PATCH] Put bcache inside "namespace gdb" Christian Biesinger via gdb-patches
@ 2019-12-05 21:32 ` Christian Biesinger via gdb-patches
  2019-12-06 18:51   ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-05 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

[Updated for https://sourceware.org/ml/gdb-patches/2019-12/msg00073.html,
which has been pushed]

This avoids a conflict with a system "struct bcache" on
Solaris (see e.g.
https://www.isi.edu/nsnam/archive/ns-users/webarch/2001/msg05393.html)

Note that the Solaris conflict for now only surfaces with
--enable-targets=all (which the build bot doesn't use).

gdb/ChangeLog:

2019-12-02  Christian Biesinger  <cbiesinger@google.com>

	* bcache.c: Put in namespace gdb.
	* bcache.h: Likewise.
	* gdbtypes.c (check_types_worklist): Update.
	(types_deeply_equal): Update.
	* macrotab.c (struct macro_table) <bcache>: Update.
	(new_macro_table): Update.
	* macrotab.h (struct bcache): Put this forward declaration
	inside namespace gdb.
	(new_macro_table): Update.
	* objfiles.h (struct objfile_per_bfd_storage) <filename_cache>:
	Update.
	<macro_cache>: Update.
	* psymtab.h: (psymtab_storage) <psymbol_cache>: Update.

Change-Id: I843d5e91f7ccb3db6d1099a8214c15a74510256f
---
 gdb/bcache.c   | 4 ++++
 gdb/bcache.h   | 4 ++++
 gdb/gdbtypes.c | 4 ++--
 gdb/macrotab.c | 4 ++--
 gdb/macrotab.h | 7 +++++--
 gdb/objfiles.h | 4 ++--
 gdb/psymtab.h  | 2 +-
 7 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/gdb/bcache.c b/gdb/bcache.c
index 497efe96cb..348ad152f6 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -25,6 +25,8 @@
 
 #include <algorithm>
 
+namespace gdb {
+
 /* The type used to hold a single bcache string.  The user data is
    stored in d.data.  Since it can be any type, it needs to have the
    same alignment as the most strict alignment of any type on the host
@@ -378,3 +380,5 @@ bcache::memory_used ()
     return 0;
   return obstack_memory_used (&m_cache);
 }
+
+} /* namespace gdb */
diff --git a/gdb/bcache.h b/gdb/bcache.h
index f26f79dca3..4b2b42e2de 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -136,6 +136,8 @@
   
 */
 
+namespace gdb {
+
 struct bstring;
 
 struct bcache
@@ -222,4 +224,6 @@ private:
   void expand_hash_table ();
 };
 
+} /* namespace gdb */
+
 #endif /* BCACHE_H */
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 775e8c18f9..37fe63599a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3813,7 +3813,7 @@ check_types_equal (struct type *type1, struct type *type2,
 
 static bool
 check_types_worklist (std::vector<type_equality_entry> *worklist,
-		      struct bcache *cache)
+		      gdb::bcache *cache)
 {
   while (!worklist->empty ())
     {
@@ -3849,7 +3849,7 @@ types_deeply_equal (struct type *type1, struct type *type2)
   if (type1 == type2)
     return true;
 
-  struct bcache cache (nullptr, nullptr);
+  gdb::bcache cache (nullptr, nullptr);
   worklist.emplace_back (type1, type2);
   return check_types_worklist (&worklist, &cache);
 }
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 90f29439c0..e500cf5cbe 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -40,7 +40,7 @@ struct macro_table
 
   /* The bcache we should use to hold macro names, argument names, and
      definitions, or zero if we should use xmalloc.  */
-  struct bcache *bcache;
+  gdb::bcache *bcache;
 
   /* The main source file for this compilation unit --- the one whose
      name was given to the compiler.  This is the root of the
@@ -1025,7 +1025,7 @@ macro_for_each_in_scope (struct macro_source_file *file, int line,
 
 
 struct macro_table *
-new_macro_table (struct obstack *obstack, struct bcache *b,
+new_macro_table (struct obstack *obstack, gdb::bcache *b,
 		 struct compunit_symtab *cust)
 {
   struct macro_table *t;
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 045d1625a1..83a7dfad23 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -23,9 +23,12 @@
 #include "gdbsupport/function-view.h"
 
 struct obstack;
-struct bcache;
 struct compunit_symtab;
 
+namespace gdb {
+struct bcache;
+}
+
 /* How do we represent a source location?  I mean, how should we
    represent them within GDB; the user wants to use all sorts of
    ambiguous abbreviations, like "break 32" and "break foo.c:32"
@@ -170,7 +173,7 @@ struct macro_source_file
    the same source location (although 'gcc -DFOO -UFOO -DFOO=2' does
    do that in GCC 4.1.2.).  */
 struct macro_table *new_macro_table (struct obstack *obstack,
-                                     struct bcache *bcache,
+                                     gdb::bcache *bcache,
 				     struct compunit_symtab *cust);
 
 
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 0c044582e4..1601cfe591 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -244,11 +244,11 @@ struct objfile_per_bfd_storage
 
   /* Byte cache for file names.  */
 
-  struct bcache filename_cache;
+  gdb::bcache filename_cache;
 
   /* Byte cache for macros.  */
 
-  struct bcache macro_cache;
+  gdb::bcache macro_cache;
 
   /* The gdbarch associated with the BFD.  Note that this gdbarch is
      determined solely from BFD information, without looking at target
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index a4ac35a791..a4281c80bf 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -120,7 +120,7 @@ public:
   /* A byte cache where we can stash arbitrary "chunks" of bytes that
      will not change.  */
 
-  struct bcache psymbol_cache;
+  gdb::bcache psymbol_cache;
 
   /* Vectors of all partial symbols read in from file.  The actual data
      is stored in the objfile_obstack.  */
-- 
2.24.0.393.g34dc348eaf-goog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Put bcache inside "namespace gdb"
  2019-12-05 21:32 ` [PATCH v2] " Christian Biesinger via gdb-patches
@ 2019-12-06 18:51   ` Pedro Alves
  2019-12-06 19:20     ` Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2019-12-06 18:51 UTC (permalink / raw)
  To: Christian Biesinger, gdb-patches

On 12/5/19 9:32 PM, Christian Biesinger via gdb-patches wrote:
> [Updated for https://sourceware.org/ml/gdb-patches/2019-12/msg00073.html,
> which has been pushed]
> 
> This avoids a conflict with a system "struct bcache" on
> Solaris (see e.g.
> https://www.isi.edu/nsnam/archive/ns-users/webarch/2001/msg05393.html)
> 
> Note that the Solaris conflict for now only surfaces with
> --enable-targets=all (which the build bot doesn't use).
> 

OK.

I still haven't managed to submit the "namespace gdb everywhere" [1]
patch series in this cycle.  :-/  Maybe after we branch.  Once 
we have that, then we can drop the "gdb::"'s sprinkled throughout.

[1] https://github.com/palves/gdb/commits/palves/cxx-gdb-namespace

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Put bcache inside "namespace gdb"
  2019-12-06 18:51   ` Pedro Alves
@ 2019-12-06 19:20     ` Christian Biesinger via gdb-patches
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-06 19:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Fri, Dec 6, 2019 at 12:51 PM Pedro Alves <palves@redhat.com> wrote:
>
> On 12/5/19 9:32 PM, Christian Biesinger via gdb-patches wrote:
> > [Updated for https://sourceware.org/ml/gdb-patches/2019-12/msg00073.html,
> > which has been pushed]
> >
> > This avoids a conflict with a system "struct bcache" on
> > Solaris (see e.g.
> > https://www.isi.edu/nsnam/archive/ns-users/webarch/2001/msg05393.html)
> >
> > Note that the Solaris conflict for now only surfaces with
> > --enable-targets=all (which the build bot doesn't use).
> >
>
> OK.
>
> I still haven't managed to submit the "namespace gdb everywhere" [1]
> patch series in this cycle.  :-/  Maybe after we branch.  Once
> we have that, then we can drop the "gdb::"'s sprinkled throughout.

Thanks, pushed.

Christian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-06 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 21:15 [PATCH] Put bcache inside "namespace gdb" Christian Biesinger via gdb-patches
2019-12-05 21:32 ` [PATCH v2] " Christian Biesinger via gdb-patches
2019-12-06 18:51   ` Pedro Alves
2019-12-06 19:20     ` Christian Biesinger via gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).