public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] libasm: Make libasm.h include work without relying on any other include.
Date: Sun,  5 Jul 2020 00:17:42 +0200	[thread overview]
Message-ID: <20200704221742.18953-1-mark@klomp.org> (raw)

The public headers should be usable when includes as is.
libasm.h wasn't because it was using gelf.h data structures without
include gelf.h. Include it now in libasm.h.

Add a new testcase run-test-includes.sh to test all public headers
can be included "standalone".

https://sourceware.org/bugzilla/show_bug.cgi?id=26176

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libasm/ChangeLog           |  4 ++++
 libasm/libasm.h            |  1 +
 tests/ChangeLog            |  6 ++++++
 tests/Makefile.am          |  5 +++--
 tests/run-test-includes.sh | 26 ++++++++++++++++++++++++++
 5 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100755 tests/run-test-includes.sh

diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 2c092abe..8ed7fc20 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2020-07-05  Mark Wielaard  <mark@klomp.org>
+
+	* libasm.h: Include gelf.h.
+
 2020-04-25  Mark Wielaard  <mark@klomp.org>
 
 	* asm_end.c (text_end): Call fflush instead of fclose.
diff --git a/libasm/libasm.h b/libasm/libasm.h
index a45c9fa3..b67b77dc 100644
--- a/libasm/libasm.h
+++ b/libasm/libasm.h
@@ -31,6 +31,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <gelf.h>
 
 typedef struct ebl Ebl;
 
diff --git a/tests/ChangeLog b/tests/ChangeLog
index b27037ee..620a1615 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2020-07-05  Mark Wielaard  <mark@klomp.org>
+
+	* run-test-includes.sh: New test.
+	* Makefile.am (TESTS): Add run-test-includes.sh.
+	(EXTRA_DIST): Likewise.
+
 2020-06-19  Mark Wielaard  <mark@klomp.org>
 
 	* Makefile.am (TESTS): Don't add run-debuginfod-find.sh when
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ac805c5..d30b8218 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -184,7 +184,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
 	run-elfclassify.sh run-elfclassify-self.sh \
 	run-disasm-riscv64.sh \
 	run-pt_gnu_prop-tests.sh \
-	run-getphdrnum.sh
+	run-getphdrnum.sh run-test-includes.sh
 
 if !BIARCH
 export ELFUTILS_DISABLE_BIARCH = 1
@@ -505,7 +505,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 	     debuginfod-tars/pacman-sources/hello.c \
 	     run-pt_gnu_prop-tests.sh \
 	     testfile_pt_gnu_prop.bz2 testfile_pt_gnu_prop32.bz2 \
-	     run-getphdrnum.sh testfile-phdrs.elf.bz2
+	     run-getphdrnum.sh testfile-phdrs.elf.bz2 \
+	     run-test-includes.sh
 
 
 if USE_VALGRIND
diff --git a/tests/run-test-includes.sh b/tests/run-test-includes.sh
new file mode 100755
index 00000000..b0ccdd9b
--- /dev/null
+++ b/tests/run-test-includes.sh
@@ -0,0 +1,26 @@
+# All public include headers should be usable "standalone".
+
+. $srcdir/test-subr.sh
+
+echo '#include "libelf.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
+echo '#include "gelf.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
+
+echo '#include "dwarf.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+        -I ${abs_srcdir}/../libdw -xc -
+echo '#include "libdw.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+        -I ${abs_srcdir}/../libdw -xc -
+
+echo '#include "libdwfl.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+    -I ${abs_srcdir}/../libdw -I ${abs_srcdir}/../libdwfl -xc -
+echo '#include "libdwelf.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+    -I ${abs_srcdir}/../libdw -I ${abs_srcdir}/../libdwelf -xc -
+
+echo '#include "libasm.h"' \
+  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf \
+    -I ${abs_srcdir}/../libasm -xc -
-- 
2.18.4


             reply	other threads:[~2020-07-04 22:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 22:17 Mark Wielaard [this message]
2020-07-17 23:50 ` Mark Wielaard

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=20200704221742.18953-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@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).