public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Rename "sun" variable to avoid conflicts on Solaris
  2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
  2019-12-19  0:01 ` [PATCH 3/3] Make the literal argument to pow a double, not an integer Christian Biesinger via gdb-patches
@ 2019-12-19  0:01 ` Christian Biesinger via gdb-patches
  2019-12-19  0:01 ` [PATCH 2/3] Cast the log10 argument to double to disambiguate it Christian Biesinger via gdb-patches
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19  0:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

A Solaris system header has a #define for "sun".  This renames
that variable to avoid the conflict, fixing a build error with
--enable-targets=all on Solaris.

gdb/ChangeLog:

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

	* fbsd-tdep.c (fbsd_info_proc_files_entry): Rename local var
	"sun" to "saddr_un".

Change-Id: I07a5cd801db1e28ccab8a473ebad74d7afe017c2
---
 gdb/fbsd-tdep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 937f696f44..d7482d3b58 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -1018,12 +1018,12 @@ fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
 
 	    /* For local sockets, print out the first non-nul path
 	       rather than both paths.  */
-	    const struct fbsd_sockaddr_un *sun
+	    const struct fbsd_sockaddr_un *saddr_un
 	      = reinterpret_cast<const struct fbsd_sockaddr_un *> (kf_sa_local);
-	    if (sun->sun_path[0] == 0)
-	      sun = reinterpret_cast<const struct fbsd_sockaddr_un *>
+	    if (saddr_un->sun_path[0] == 0)
+	      saddr_un = reinterpret_cast<const struct fbsd_sockaddr_un *>
 		(kf_sa_peer);
-	    printf_filtered ("%s", sun->sun_path);
+	    printf_filtered ("%s", saddr_un->sun_path);
 	    break;
 	  }
 	case FBSD_AF_INET:
-- 
2.24.1.735.g03f4e72817-goog

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

* [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header
  2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
                   ` (2 preceding siblings ...)
  2019-12-19  0:01 ` [PATCH 2/3] Cast the log10 argument to double to disambiguate it Christian Biesinger via gdb-patches
@ 2019-12-19  0:01 ` Christian Biesinger via gdb-patches
  2019-12-19 18:18   ` Tom Tromey
  2019-12-19 19:14 ` [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
  4 siblings, 1 reply; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19  0:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

This breaks the compile on Solaris with enable-targets=all.

include/ChangeLog:

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

	* opcode/s12z.h: Undef REG_Y.

Change-Id: I028b2663affce50d6ca37ccdc301bde8de80d45c
---
 include/opcode/s12z.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/opcode/s12z.h b/include/opcode/s12z.h
index 7e38ac5e1c..717b4a9cbb 100644
--- a/include/opcode/s12z.h
+++ b/include/opcode/s12z.h
@@ -20,6 +20,10 @@ struct reg
 
 extern const struct reg registers[S12Z_N_REGISTERS];
 
+/* Solaris defines REG_Y in sys/regset.h; undef it here to avoid
+   breaking compilation when this target is enabled.  */
+#undef REG_Y
+
 enum {
     REG_D2 = 0,
     REG_D3,
-- 
2.24.1.735.g03f4e72817-goog

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

* [PATCH 2/3] Cast the log10 argument to double to disambiguate it
  2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
  2019-12-19  0:01 ` [PATCH 3/3] Make the literal argument to pow a double, not an integer Christian Biesinger via gdb-patches
  2019-12-19  0:01 ` [PATCH] Rename "sun" variable to avoid conflicts on Solaris Christian Biesinger via gdb-patches
@ 2019-12-19  0:01 ` Christian Biesinger via gdb-patches
  2019-12-19  3:35   ` Eli Zaretskii
  2019-12-19  0:01 ` [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header Christian Biesinger via gdb-patches
  2019-12-19 19:14 ` [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
  4 siblings, 1 reply; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19  0:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
using std::log10; directive. This is unfortunate because std::log10 has
overloads for float/double/long double. To disambiguate this call,
cast the argument to double to fix the build.

Change-Id: I6c0c52e9c172b529c899a435d430e5916aeef69f
---
 gdb/tui/tui-source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 32877d7bc8..1274e81674 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -85,7 +85,7 @@ tui_source_window::set_contents (struct gdbarch *arch,
 	  int digits = 0;
 	  if (compact_source)
 	    {
-	      double l = log10 (offsets->size ());
+	      double l = log10 ((double) offsets->size ());
 	      digits = 1 + (int) l;
 	    }
 
-- 
2.24.1.735.g03f4e72817-goog

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

* [PATCH 0/3] Fix Solaris build with enable-targets=all
@ 2019-12-19  0:01 Christian Biesinger via gdb-patches
  2019-12-19  0:01 ` [PATCH 3/3] Make the literal argument to pow a double, not an integer Christian Biesinger via gdb-patches
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19  0:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

I tried compiling gdb on gcc211.fsffrance.org with enable-targets=all
and found a few issues. This patch series fixes the remaining ones.

https://sourceware.org/ml/gdb-patches/2019-12/msg00798.html should be part
of this series too; I apologize for not including it. When I sent that one
I hadn't decided yet to continue working on these build errors and thus
didn't make it a series.

Christian Biesinger (3):
  Undef REG_Y in s12z.h, it may be defined in a system header
  Cast the log10 argument to double to disambiguate it
  Make the literal argument to pow a double, not an integer

 gdb/score-tdep.c      | 4 ++--
 gdb/tui/tui-source.c  | 2 +-
 include/opcode/s12z.h | 4 ++++
 3 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.24.1.735.g03f4e72817-goog

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

* [PATCH 3/3] Make the literal argument to pow a double, not an integer
  2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
@ 2019-12-19  0:01 ` Christian Biesinger via gdb-patches
  2019-12-19 18:19   ` Tom Tromey
  2019-12-19  0:01 ` [PATCH] Rename "sun" variable to avoid conflicts on Solaris Christian Biesinger via gdb-patches
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19  0:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

Since pow takes doubles, pass 2.0 instead of 2 to pow ().

Conveniently, this fixes the ambiguous call to pow on Solaris 11
with gcc 5.5 (gcc211 on the compile farm), which has a "using std::pow"
directive in a system header, which brings in float/double/long double
overloads.  Fixes the build on Solaris with enable-targets=all.

gdb/ChangeLog:

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

	* score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
	2 to pow ().

Change-Id: Ib18e7e4749ddcbff0727b72a31198f8cb84d1993
---
 gdb/score-tdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 5ca763c40f..691051729e 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -918,13 +918,13 @@ score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* subei! r0, n */
-              sp_offset += (int) pow (2, G_FLD (inst->v, 6, 3));
+              sp_offset += (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
           else if (G_FLD (inst->v, 14, 7) == 0xc0
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* addei! r0, n */
-              sp_offset -= (int) pow (2, G_FLD (inst->v, 6, 3));
+              sp_offset -= (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
         }
       else
-- 
2.24.1.735.g03f4e72817-goog

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

* Re: [PATCH 2/3] Cast the log10 argument to double to disambiguate it
  2019-12-19  0:01 ` [PATCH 2/3] Cast the log10 argument to double to disambiguate it Christian Biesinger via gdb-patches
@ 2019-12-19  3:35   ` Eli Zaretskii
  2019-12-19 18:17     ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2019-12-19  3:35 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

> Date: Wed, 18 Dec 2019 18:01:02 -0600
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
> 
> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
> using std::log10; directive. This is unfortunate because std::log10 has
> overloads for float/double/long double. To disambiguate this call,
> cast the argument to double to fix the build.

We may wish to have a comment in the code referring to the original
problem, including perhaps the OS and the compiler versions?
Otherwise the need for this cast is not immediately obvious, IMO.

Thanks.

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

* Re: [PATCH 2/3] Cast the log10 argument to double to disambiguate it
  2019-12-19  3:35   ` Eli Zaretskii
@ 2019-12-19 18:17     ` Tom Tromey
  2019-12-19 19:11       ` Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2019-12-19 18:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Christian Biesinger, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Wed, 18 Dec 2019 18:01:02 -0600
>> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
>> Cc: Christian Biesinger <cbiesinger@google.com>
>> 
>> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
>> using std::log10; directive. This is unfortunate because std::log10 has
>> overloads for float/double/long double. To disambiguate this call,
>> cast the argument to double to fix the build.

Eli> We may wish to have a comment in the code referring to the original
Eli> problem, including perhaps the OS and the compiler versions?
Eli> Otherwise the need for this cast is not immediately obvious, IMO.

Agreed; this is ok with that change.

Tom

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

* Re: [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header
  2019-12-19  0:01 ` [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header Christian Biesinger via gdb-patches
@ 2019-12-19 18:18   ` Tom Tromey
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2019-12-19 18:18 UTC (permalink / raw)
  To: Christian Biesinger via gdb-patches; +Cc: Christian Biesinger

>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> This breaks the compile on Solaris with enable-targets=all.
Christian> include/ChangeLog:

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

Christian> 	* opcode/s12z.h: Undef REG_Y.

I think this one should go to the binutils list.

Tom

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

* Re: [PATCH 3/3] Make the literal argument to pow a double, not an integer
  2019-12-19  0:01 ` [PATCH 3/3] Make the literal argument to pow a double, not an integer Christian Biesinger via gdb-patches
@ 2019-12-19 18:19   ` Tom Tromey
  2019-12-19 19:13     ` Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2019-12-19 18:19 UTC (permalink / raw)
  To: Christian Biesinger via gdb-patches; +Cc: Christian Biesinger

>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

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

Christian> 	* score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
Christian> 	2 to pow ().

It probably makes sense to add a comment about Solaris here as well.
It's a bit borderline for me, considering it is a constant, but on the
other hand, a comment is definitely safe.  So, ok with that change.

thanks,
Tom

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

* Re: [PATCH 2/3] Cast the log10 argument to double to disambiguate it
  2019-12-19 18:17     ` Tom Tromey
@ 2019-12-19 19:11       ` Christian Biesinger via gdb-patches
  0 siblings, 0 replies; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19 19:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Eli Zaretskii, gdb-patches

On Thu, Dec 19, 2019 at 12:17 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> >> Date: Wed, 18 Dec 2019 18:01:02 -0600
> >> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> >> Cc: Christian Biesinger <cbiesinger@google.com>
> >>
> >> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
> >> using std::log10; directive. This is unfortunate because std::log10 has
> >> overloads for float/double/long double. To disambiguate this call,
> >> cast the argument to double to fix the build.
>
> Eli> We may wish to have a comment in the code referring to the original
> Eli> problem, including perhaps the OS and the compiler versions?
> Eli> Otherwise the need for this cast is not immediately obvious, IMO.
>
> Agreed; this is ok with that change.

OK, will push with this comment:
      /* Solaris 11+gcc 5.5 has ambiguous overloads of log10, so we
         cast to double to get the right one.  */

Christian

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

* Re: [PATCH 3/3] Make the literal argument to pow a double, not an integer
  2019-12-19 18:19   ` Tom Tromey
@ 2019-12-19 19:13     ` Christian Biesinger via gdb-patches
  0 siblings, 0 replies; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19 19:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Christian Biesinger via gdb-patches

On Thu, Dec 19, 2019 at 12:19 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> 2019-12-18  Christian Biesinger  <cbiesinger@google.com>
>
> Christian>      * score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
> Christian>      2 to pow ().
>
> It probably makes sense to add a comment about Solaris here as well.
> It's a bit borderline for me, considering it is a constant, but on the
> other hand, a comment is definitely safe.  So, ok with that change.

OK, added this comment:
+             /* Solaris 11+gcc 5.5 has ambiguous overloads of pow, so we
+                pass 2.0 instead of 2 to get the right one.  */

Christian

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

* Re: [PATCH 0/3] Fix Solaris build with enable-targets=all
  2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
                   ` (3 preceding siblings ...)
  2019-12-19  0:01 ` [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header Christian Biesinger via gdb-patches
@ 2019-12-19 19:14 ` Christian Biesinger via gdb-patches
  4 siblings, 0 replies; 12+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-19 19:14 UTC (permalink / raw)
  To: gdb-patches

On Wed, Dec 18, 2019 at 6:01 PM Christian Biesinger
<cbiesinger@google.com> wrote:
>
> I tried compiling gdb on gcc211.fsffrance.org with enable-targets=all
> and found a few issues. This patch series fixes the remaining ones.
>
> https://sourceware.org/ml/gdb-patches/2019-12/msg00798.html should be part
> of this series too; I apologize for not including it. When I sent that one
> I hadn't decided yet to continue working on these build errors and thus
> didn't make it a series.
>
> Christian Biesinger (3):
>   Undef REG_Y in s12z.h, it may be defined in a system header
>   Cast the log10 argument to double to disambiguate it
>   Make the literal argument to pow a double, not an integer

Pushed patches 2 and 3 with the comments addressed, and sent patch 1
to binutils@

Christian

>  gdb/score-tdep.c      | 4 ++--
>  gdb/tui/tui-source.c  | 2 +-
>  include/opcode/s12z.h | 4 ++++
>  3 files changed, 7 insertions(+), 3 deletions(-)
>
> --
> 2.24.1.735.g03f4e72817-goog
>

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19  0:01 [PATCH 0/3] Fix Solaris build with enable-targets=all Christian Biesinger via gdb-patches
2019-12-19  0:01 ` [PATCH 3/3] Make the literal argument to pow a double, not an integer Christian Biesinger via gdb-patches
2019-12-19 18:19   ` Tom Tromey
2019-12-19 19:13     ` Christian Biesinger via gdb-patches
2019-12-19  0:01 ` [PATCH] Rename "sun" variable to avoid conflicts on Solaris Christian Biesinger via gdb-patches
2019-12-19  0:01 ` [PATCH 2/3] Cast the log10 argument to double to disambiguate it Christian Biesinger via gdb-patches
2019-12-19  3:35   ` Eli Zaretskii
2019-12-19 18:17     ` Tom Tromey
2019-12-19 19:11       ` Christian Biesinger via gdb-patches
2019-12-19  0:01 ` [PATCH 1/3] Undef REG_Y in s12z.h, it may be defined in a system header Christian Biesinger via gdb-patches
2019-12-19 18:18   ` Tom Tromey
2019-12-19 19:14 ` [PATCH 0/3] Fix Solaris build with enable-targets=all 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).