public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>
To: binutils@sourceware.org
Subject: [RFC PATCH] bfd: use bfd_vma for the 64-bit version of put[lb] and get[lb]
Date: Tue, 4 Oct 2022 22:03:20 +0200	[thread overview]
Message-ID: <5f482299-6c60-b2b3-9abe-f4a55a5a26c5@univ-grenoble-alpes.fr> (raw)

Hi,

During summer (around Aug.4) Alan replaced in many places the use
of bfd_vma and such by the c99 types.
However,  when compiling for  an ad-hoc target of ours,  the fact
that the 64-bit version  of  the  put  and get functions does not
share the same prototypes as the other bit-width versions needs a
patch while making the prototypes consistent might be acceptable,
what do you think?

Thanks,
Frédéric


The 16-bit, 24-bit and 32-bit versions of these functions use an
argument of type  bfd_[signed_]vma while the 64-bit version uses
[u]int64_t.  Given the comment in front of the definition of the
bfd vma  types in  bfd-in.h, the  use of  the bfd specific types
should be possible and would make the code consistent across all
function versions.

bfd/
    * bfd-in.h: change argument or  return value types in put/get
                functions prototypes
    * libbfd.c: likewise for implementations


---
  bfd/bfd-in.h | 12 ++++++------
  bfd/libbfd.c | 12 ++++++------
  2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 4765ea80536..9efb5ce5a84 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -403,10 +403,10 @@ extern bool bfd_record_phdr

  /* Byte swapping routines.  */

-uint64_t bfd_getb64 (const void *);
-uint64_t bfd_getl64 (const void *);
-int64_t bfd_getb_signed_64 (const void *);
-int64_t bfd_getl_signed_64 (const void *);
+bfd_vma bfd_getb64 (const void *);
+bfd_vma bfd_getl64 (const void *);
+bfd_signed_vma bfd_getb_signed_64 (const void *);
+bfd_signed_vma bfd_getl_signed_64 (const void *);
  bfd_vma bfd_getb32 (const void *);
  bfd_vma bfd_getl32 (const void *);
  bfd_signed_vma bfd_getb_signed_32 (const void *);
@@ -415,8 +415,8 @@ bfd_vma bfd_getb16 (const void *);
  bfd_vma bfd_getl16 (const void *);
  bfd_signed_vma bfd_getb_signed_16 (const void *);
  bfd_signed_vma bfd_getl_signed_16 (const void *);
-void bfd_putb64 (uint64_t, void *);
-void bfd_putl64 (uint64_t, void *);
+void bfd_putb64 (bfd_vma, void *);
+void bfd_putl64 (bfd_vma, void *);
  void bfd_putb32 (bfd_vma, void *);
  void bfd_putl32 (bfd_vma, void *);
  void bfd_putb24 (bfd_vma, void *);
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index d33f3416206..5eab59d2e76 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -757,7 +757,7 @@ bfd_getl_signed_32 (const void *p)
    return COERCE32 (v);
  }

-uint64_t
+bfd_vma
  bfd_getb64 (const void *p)
  {
    const bfd_byte *addr = (const bfd_byte *) p;
@@ -775,7 +775,7 @@ bfd_getb64 (const void *p)
    return v;
  }

-uint64_t
+bfd_vma
  bfd_getl64 (const void *p)
  {
    const bfd_byte *addr = (const bfd_byte *) p;
@@ -793,7 +793,7 @@ bfd_getl64 (const void *p)
    return v;
  }

-int64_t
+bfd_signed_vma
  bfd_getb_signed_64 (const void *p)
  {
    const bfd_byte *addr = (const bfd_byte *) p;
@@ -811,7 +811,7 @@ bfd_getb_signed_64 (const void *p)
    return COERCE64 (v);
  }

-int64_t
+bfd_signed_vma
  bfd_getl_signed_64 (const void *p)
  {
    const bfd_byte *addr = (const bfd_byte *) p;
@@ -850,7 +850,7 @@ bfd_putl32 (bfd_vma data, void *p)
  }

  void
-bfd_putb64 (uint64_t data, void *p)
+bfd_putb64 (bfd_vma data, void *p)
  {
    bfd_byte *addr = (bfd_byte *) p;
    addr[0] = (data >> (7*8)) & 0xff;
@@ -864,7 +864,7 @@ bfd_putb64 (uint64_t data, void *p)
  }

  void
-bfd_putl64 (uint64_t data, void *p)
+bfd_putl64 (bfd_vma data, void *p)
  {
    bfd_byte *addr = (bfd_byte *) p;
    addr[7] = (data >> (7*8)) & 0xff;
-- 
2.30.2

-- 
+---------------------------------------------------------------------------+
| Frédéric Pétrot,                            Pr. Grenoble INP-Ensimag/TIMA |
| Mob/Pho: +33 6 74 57 99 65/+33 4 76 57 48 70      Ad augusta  per angusta |
| http://tima.univ-grenoble-alpes.fr frederic.petrot@univ-grenoble-alpes.fr |
+---------------------------------------------------------------------------+

             reply	other threads:[~2022-10-04 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 20:03 Frédéric Pétrot [this message]
2022-10-05  2:59 ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f482299-6c60-b2b3-9abe-f4a55a5a26c5@univ-grenoble-alpes.fr \
    --to=frederic.petrot@univ-grenoble-alpes.fr \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).