From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6580500195727257997==" MIME-Version: 1.0 From: Petr Machata To: elfutils-devel@lists.fedorahosted.org Subject: [PATCH] Support 1-sized reads in read_ubyte_unaligned_inc and read_sbyte_unaligned_inc Date: Wed, 10 Sep 2014 23:09:50 +0200 Message-ID: <40f6a3f1c6a66f860b64efbc56f5be9204d1d53c.1410383170.git.pmachata@redhat.com> --===============6580500195727257997== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable I propose this change mostly for consistency. Having one entry point for reading all (reasonable) widths is very convenient, and I make use of this interface in my upcoming patch for .debug_macro support. ---8<----------------------------------------------------------------- Signed-off-by: Petr Machata --- libdw/ChangeLog | 5 +++++ libdw/memory-access.h | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 5f9b097..b8c5acd 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2014-09-10 Petr Machata + + * memory-access.h (read_ubyte_unaligned_inc) + (read_sbyte_unaligned_inc): Read 1-sized fields as well. + 2014-08-15 Mark Wielaard = * dwarf_cu_die.c: New file. diff --git a/libdw/memory-access.h b/libdw/memory-access.h index f41f783..caa92f6 100644 --- a/libdw/memory-access.h +++ b/libdw/memory-access.h @@ -259,13 +259,15 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const= void *p) = = #define read_ubyte_unaligned_inc(Nbytes, Dbg, Addr) \ - ((Nbytes) =3D=3D 2 ? read_2ubyte_unaligned_inc (Dbg, Addr) \ - : (Nbytes) =3D=3D 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \ + ((Nbytes) =3D=3D 1 ? (uint8_t) *Addr++ \ + : (Nbytes) =3D=3D 2 ? read_2ubyte_unaligned_inc (Dbg, Addr) \ + : (Nbytes) =3D=3D 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \ : read_8ubyte_unaligned_inc (Dbg, Addr)) = #define read_sbyte_unaligned_inc(Nbytes, Dbg, Addr) \ - ((Nbytes) =3D=3D 2 ? read_2sbyte_unaligned_inc (Dbg, Addr) \ - : (Nbytes) =3D=3D 4 ? read_4sbyte_unaligned_inc (Dbg, Addr) \ + ((Nbytes) =3D=3D 1 ? (int8_t) *Addr++ \ + : (Nbytes) =3D=3D 2 ? read_2sbyte_unaligned_inc (Dbg, Addr) \ + : (Nbytes) =3D=3D 4 ? read_4sbyte_unaligned_inc (Dbg, Addr) \ : read_8sbyte_unaligned_inc (Dbg, Addr)) = #endif /* memory-access.h */ -- = 1.7.6.5 --===============6580500195727257997==--