[06/25] move platform depended include into system.h of libebl

Message ID 20221020182603.815-7-luoyonggang@gmail.com
State Superseded
Headers
Series Patches for building with mingw/gcc msvc/clang-cl |

Commit Message

Yonggang Luo Oct. 20, 2022, 6:25 p.m. UTC
  Because all source in libebl #include <libeblP.h>, so #include <system.h> in
libeblP.h is enough, there is multiple memory-access.h file, so use relative path to
include it properly,

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com
---
 libebl/eblauxvinfo.c        |  3 +--
 libebl/eblcorenote.c        |  3 +--
 libebl/ebldynamictagname.c  |  2 +-
 libebl/eblobjnote.c         | 10 +++++-----
 libebl/eblobjnotetypename.c |  3 +--
 libebl/eblopenbackend.c     |  4 ++--
 libebl/eblresolvesym.c      |  3 ++-
 libebl/libeblP.h            |  4 +++-
 8 files changed, 16 insertions(+), 16 deletions(-)
  

Comments

Mark Wielaard Oct. 28, 2022, 11:35 a.m. UTC | #1
Unaddressed
On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
wrote:
> Because all source in libebl #include <libeblP.h>, so #include
> <system.h> in
> libeblP.h is enough, there is multiple memory-access.h file, so use
> relative path to
> include it properly,

I am not a fan of the relative path trick, especially if there it is
clear only one is every needed. You also use it for other files, why?

Cheers,

Mark
  
lilydjwg--- via Elfutils-devel Dec. 16, 2022, 9:19 p.m. UTC | #2
On Fri, Oct 28, 2022 at 7:35 PM Mark Wielaard <mark@klomp.org> wrote:
>
> On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
> wrote:
> > Because all source in libebl #include <libeblP.h>, so #include
> > <system.h> in
> > libeblP.h is enough, there is multiple memory-access.h file, so use
> > relative path to
> > include it properly,
>
> I am not a fan of the relative path trick, especially if there it is
> clear only one is every needed. You also use it for other files, why?
>

I am respect the original code
looks at
https://github.com/sourceware-org/elfutils/blob/master/libdwfl/core-file.c#L31

> Cheers,
>
> Mark



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
Mark Wielaard Dec. 20, 2022, 1:59 p.m. UTC | #3
Hi,

On Sat, 2022-12-17 at 05:19 +0800, 罗勇刚(Yonggang Luo) wrote:
> On Fri, Oct 28, 2022 at 7:35 PM Mark Wielaard <mark@klomp.org> wrote:
> > 
> > On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
> > wrote:
> > > Because all source in libebl #include <libeblP.h>, so #include
> > > <system.h> in
> > > libeblP.h is enough, there is multiple memory-access.h file, so
> > > use
> > > relative path to
> > > include it properly,
> > 
> > I am not a fan of the relative path trick, especially if there it
> > is
> > clear only one is every needed. You also use it for other files,
> > why?
> 
> I am respect the original code
> looks at
> https://github.com/sourceware-org/elfutils/blob/master/libdwfl/core-file.c#L31

I see. But I rather fix that than do the same in new files.

The attached patch does that so no relative paths are needed in
#include statements.

Cheers,

Mark
  
Mark Wielaard Dec. 20, 2022, 5:44 p.m. UTC | #4
On Tue, 2022-12-20 at 14:59 +0100, Mark Wielaard wrote:
> The attached patch does that so no relative paths are needed in
> #include statements.

The try-bot looked good:
https://builder.sourceware.org/buildbot/#/changes/16025

So I pushed this:

commit 6ecd16410ce1fe5cb0ac5b7c3342c5cc330e3a04
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Dec 20 14:53:43 2022 +0100

    Do not use relative include paths in library files.
    
    Rely on include dirs being set up correctly. Setup libdw AM_CPPFLAGS
    to include libebl directory. In libdwfl note that debuginfod.h is a
    generated file in the builddir. Only include it in the one file
    debuginfod-client.c that really needs it.
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>
  

Patch

diff --git a/libebl/eblauxvinfo.c b/libebl/eblauxvinfo.c
index ce1141b8..36554693 100644
--- a/libebl/eblauxvinfo.c
+++ b/libebl/eblauxvinfo.c
@@ -31,11 +31,10 @@ 
 #endif
 
 #include <assert.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stddef.h>
+
 #include <libeblP.h>
 
 #define AUXV_TYPES							      \
diff --git a/libebl/eblcorenote.c b/libebl/eblcorenote.c
index 7fab3974..9573e93e 100644
--- a/libebl/eblcorenote.c
+++ b/libebl/eblcorenote.c
@@ -31,12 +31,11 @@ 
 #endif
 
 #include <assert.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stddef.h>
 #include <string.h>
+
 #include <libeblP.h>
 
 
diff --git a/libebl/ebldynamictagname.c b/libebl/ebldynamictagname.c
index 5d4a3a58..018a2ff7 100644
--- a/libebl/ebldynamictagname.c
+++ b/libebl/ebldynamictagname.c
@@ -33,8 +33,8 @@ 
 
 #include <inttypes.h>
 #include <stdio.h>
+
 #include <libeblP.h>
-#include "system.h"
 
 
 const char *
diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 5a7c5c62..83ac4f47 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -35,13 +35,13 @@ 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <libeblP.h>
 
-#include "common.h"
-#include "libelfP.h"
-#include "libdwP.h"
-#include "memory-access.h"
+#include <libeblP.h>
 
+#include "../libelf/common.h"
+#include "../libelf/libelfP.h"
+#include "../libdw/libdwP.h"
+#include "../libdw/memory-access.h"
 
 void
 ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type,
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 473a1f2f..c15379d6 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -31,11 +31,10 @@ 
 # include <config.h>
 #endif
 
-#include <system.h>
-
 #include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
+
 #include <libeblP.h>
 
 
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 02f80653..7dc760d8 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -31,15 +31,15 @@ 
 #endif
 
 #include <assert.h>
-#include <libelfP.h>
 #include <dwarf.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 
-#include <system.h>
 #include <libeblP.h>
 
+#include "../libelf/libelfP.h"
+
 Ebl *i386_init (Elf *, GElf_Half, Ebl *);
 Ebl *sh_init (Elf *, GElf_Half, Ebl *);
 Ebl *x86_64_init (Elf *, GElf_Half, Ebl *);
diff --git a/libebl/eblresolvesym.c b/libebl/eblresolvesym.c
index 470f6f06..b859bba3 100644
--- a/libebl/eblresolvesym.c
+++ b/libebl/eblresolvesym.c
@@ -30,9 +30,10 @@ 
 # include <config.h>
 #endif
 
-#include <libeblP.h>
 #include <assert.h>
 
+#include <libeblP.h>
+
 bool
 ebl_resolve_sym_value (Ebl *ebl, GElf_Addr *addr)
 {
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index c408ed97..14cb70f3 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -30,9 +30,11 @@ 
 #define _LIBEBLP_H 1
 
 #include <gelf.h>
-#include <libasm.h>
 #include <libebl.h>
 
+#include <system.h>
+
+#include <../libasm/libasm.h>
 
 /* Backend handle.  */
 struct ebl