[06/13] sim/m32r: fix unused function warnings on non-Linux hosts

Message ID 20260817151646.152571-7-simon.marchi@efficios.com
State New
Headers
Series Fix various warnings when building on macOS |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Simon Marchi Aug. 17, 2026, 3:16 p.m. UTC
  When building on macOS, I get:

    /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:141:1: error: unused function 't2h_addr' [-Werror,-Wunused-function]
      141 | t2h_addr (host_callback *cb, struct cb_syscall *sc,
          | ^~~~~~~~
    /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:158:1: error: unused function 'translate_endian_h2t' [-Werror,-Wunused-function]
      158 | translate_endian_h2t (void *addr, size_t size)
          | ^~~~~~~~~~~~~~~~~~~~
    /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:171:1: error: unused function 'translate_endian_t2h' [-Werror,-Wunused-function]
      171 | translate_endian_t2h (void *addr, size_t size)
          | ^~~~~~~~~~~~~~~~~~~~

These three helpers are only called from the TRAP_LINUX_SYSCALL case,
which is guarded by `#ifdef __linux__'.  Put them behind the same guard.

Change-Id: I8c8744727eb27abc08231be2a10f8d0de44d7ea6
---
 sim/m32r/traps.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Andrew Burgess Aug. 17, 2026, 3:37 p.m. UTC | #1
Simon Marchi <simon.marchi@efficios.com> writes:

> When building on macOS, I get:
>
>     /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:141:1: error: unused function 't2h_addr' [-Werror,-Wunused-function]
>       141 | t2h_addr (host_callback *cb, struct cb_syscall *sc,
>           | ^~~~~~~~
>     /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:158:1: error: unused function 'translate_endian_h2t' [-Werror,-Wunused-function]
>       158 | translate_endian_h2t (void *addr, size_t size)
>           | ^~~~~~~~~~~~~~~~~~~~
>     /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:171:1: error: unused function 'translate_endian_t2h' [-Werror,-Wunused-function]
>       171 | translate_endian_t2h (void *addr, size_t size)
>           | ^~~~~~~~~~~~~~~~~~~~
>
> These three helpers are only called from the TRAP_LINUX_SYSCALL case,
> which is guarded by `#ifdef __linux__'.  Put them behind the same
> guard.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> Change-Id: I8c8744727eb27abc08231be2a10f8d0de44d7ea6
> ---
>  sim/m32r/traps.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
> index bb82ae80e2aa..43a81c915d1c 100644
> --- a/sim/m32r/traps.c
> +++ b/sim/m32r/traps.c
> @@ -134,7 +134,9 @@ m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
>      sim_core_signal (sd, current_cpu, cia, map, nr_bytes, addr,
>  		     transfer, sig);
>  }
> -
> +
> +#ifdef __linux__
> +
>  /* Translate target's address to host's address.  */
>  
>  static void *
> @@ -180,6 +182,8 @@ translate_endian_t2h (void *addr, size_t size)
>      *((unsigned short *) p) = T2H_2 (*((unsigned short *) p));
>  }
>  
> +#endif /* __linux__ */
> +
>  /* Trap support.
>     The result is the pc address to continue at.
>     Preprocessing like saving the various registers has already been done.  */
> -- 
> 2.55.0
  

Patch

diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
index bb82ae80e2aa..43a81c915d1c 100644
--- a/sim/m32r/traps.c
+++ b/sim/m32r/traps.c
@@ -134,7 +134,9 @@  m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
     sim_core_signal (sd, current_cpu, cia, map, nr_bytes, addr,
 		     transfer, sig);
 }
-
+
+#ifdef __linux__
+
 /* Translate target's address to host's address.  */
 
 static void *
@@ -180,6 +182,8 @@  translate_endian_t2h (void *addr, size_t size)
     *((unsigned short *) p) = T2H_2 (*((unsigned short *) p));
 }
 
+#endif /* __linux__ */
+
 /* Trap support.
    The result is the pc address to continue at.
    Preprocessing like saving the various registers has already been done.  */