[2/7] move platform depended include into system.h
Commit Message
All of these files either #include <system.h> directly or #include "libelfP.h"
And now "libelfP.h also #include <system.h>, so the platform depended include
can be moved to system.h safely
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
lib/system.h | 11 +++++++----
libebl/eblmachineflagname.c | 1 -
libebl/eblobjnotetypename.c | 2 --
libebl/eblopenbackend.c | 1 -
libelf/common.h | 3 ---
libelf/elf32_checksum.c | 1 -
libelf/elf32_getphdr.c | 2 --
libelf/elf32_getshdr.c | 2 --
libelf/elf32_updatefile.c | 3 ---
libelf/elf32_updatenull.c | 2 --
libelf/elf32_xlatetof.c | 1 -
libelf/elf32_xlatetom.c | 1 -
libelf/elf_begin.c | 3 ---
libelf/elf_cntl.c | 2 --
libelf/elf_compress.c | 2 --
libelf/elf_end.c | 1 -
libelf/elf_error.c | 1 -
libelf/elf_getarsym.c | 4 ----
libelf/elf_getdata.c | 2 --
libelf/elf_getdata_rawchunk.c | 2 --
libelf/elf_getshdrstrndx.c | 2 --
libelf/elf_readall.c | 2 --
libelf/elf_update.c | 2 --
libelf/gelf_xlate.c | 1 -
libelf/libelfP.h | 1 +
libelf/nlist.c | 1 -
26 files changed, 8 insertions(+), 48 deletions(-)
Comments
On Tue, Sep 20, 2022 at 04:43:02PM +0800, Yonggang Luo via Elfutils-devel wrote:
> All of these files either #include <system.h> directly or #include "libelfP.h"
> And now "libelfP.h also #include <system.h>, so the platform depended include
> can be moved to system.h safely
I like this in theory since it cleans up some of the includes.
But it doesn't work as is.
libebl/eblobjnotetypename.c only included system.h so now doesn't
compile anymore. And libintl.h is removed from libelf/elf_error.c
which really is necessary.
Cheers,
Mark
OK, updated in v2
On Sat, Oct 15, 2022 at 5:16 AM Mark Wielaard <mark@klomp.org> wrote:
>
> On Tue, Sep 20, 2022 at 04:43:02PM +0800, Yonggang Luo via Elfutils-devel
wrote:
> > All of these files either #include <system.h> directly or #include
"libelfP.h"
> > And now "libelfP.h also #include <system.h>, so the platform depended
include
> > can be moved to system.h safely
>
> I like this in theory since it cleans up some of the includes.
> But it doesn't work as is.
>
> libebl/eblobjnotetypename.c only included system.h so now doesn't
> compile anymore. And libintl.h is removed from libelf/elf_error.c
> which really is necessary.
>
> Cheers,
>
> Mark
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
@@ -35,14 +35,17 @@
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
-#include <sys/param.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
+/* System dependend headers */
+#include <byteswap.h>
+#include <endian.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <unistd.h>
+
#if defined(HAVE_ERROR_H)
#include <error.h>
#elif defined(HAVE_ERR_H)
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string.h>
-#include <system.h>
#include <libeblP.h>
@@ -31,8 +31,6 @@
# include <config.h>
#endif
-#include <system.h>
-
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
@@ -38,7 +38,6 @@
#include <string.h>
#include <stdio.h>
-#include <system.h>
#include <libeblP.h>
Ebl *i386_init (Elf *, GElf_Half, Ebl *);
@@ -30,9 +30,6 @@
#ifndef _COMMON_H
#define _COMMON_H 1
-#include <ar.h>
-#include <byteswap.h>
-#include <endian.h>
#include <stdlib.h>
#include <string.h>
@@ -32,7 +32,6 @@
#endif
#include <assert.h>
-#include <endian.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
@@ -34,10 +34,8 @@
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <unistd.h>
#include <assert.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -34,9 +34,7 @@
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
-#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -37,10 +37,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <system.h>
#include "libelfP.h"
@@ -32,12 +32,10 @@
#endif
#include <assert.h>
-#include <endian.h>
#include <libelf.h>
#include <stdbool.h>
#include <string.h>
-#include <system.h>
#include "libelfP.h"
#include "elf-knowledge.h"
@@ -32,7 +32,6 @@
#endif
#include <assert.h>
-#include <endian.h>
#include <string.h>
#include "libelfP.h"
@@ -32,7 +32,6 @@
#endif
#include <assert.h>
-#include <endian.h>
#include <string.h>
#include "libelfP.h"
@@ -39,11 +39,8 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
#include <sys/stat.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -31,8 +31,6 @@
# include <config.h>
#endif
-#include <unistd.h>
-
#include "libelfP.h"
@@ -31,14 +31,12 @@
#endif
#include <libelf.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <zlib.h>
/* Cleanup and return result. Don't leak memory. */
@@ -34,7 +34,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
-#include <sys/mman.h>
#include "libelfP.h"
@@ -32,7 +32,6 @@
#endif
#include <assert.h>
-#include <libintl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -32,16 +32,12 @@
#endif
#include <assert.h>
-#include <byteswap.h>
-#include <endian.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <system.h>
#include <dl-hash.h>
#include "libelfP.h"
@@ -35,10 +35,8 @@
#include <errno.h>
#include <stddef.h>
#include <string.h>
-#include <unistd.h>
#include "libelfP.h"
-#include <system.h>
#include "common.h"
#include "elf-knowledge.h"
@@ -35,9 +35,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -35,9 +35,7 @@
#include <errno.h>
#include <gelf.h>
#include <stddef.h>
-#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -32,10 +32,8 @@
#endif
#include <errno.h>
-#include <unistd.h>
#include <sys/stat.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -33,8 +33,6 @@
#include <libelf.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <sys/mman.h>
#include <sys/stat.h>
#include "libelfP.h"
@@ -32,7 +32,6 @@
# include <config.h>
#endif
-#include <byteswap.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
@@ -39,6 +39,7 @@
#include <stdio.h>
#include <string.h>
+#include <system.h>
/* Helper Macros to write 32 bit and 64 bit functions. */
#define __elfw2_(Bits, Name) __elf##Bits##_##Name
@@ -35,7 +35,6 @@
#include <gelf.h>
#include <libelf.h>
#include <nlist.h>
-#include <unistd.h>
#include "libelfP.h"