public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Yonggang Luo <luoyonggang@gmail.com>
To: elfutils-devel@sourceware.org
Cc: Yonggang Luo <luoyonggang@gmail.com>
Subject: [PATCH v2 2/7] move platform depended include into system.h of libelf
Date: Sun, 16 Oct 2022 00:36:20 +0800	[thread overview]
Message-ID: <20221015163622.129-2-luoyonggang@gmail.com> (raw)
In-Reply-To: <20221015163622.129-1-luoyonggang@gmail.com>

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 +++++++----
 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_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 -
 22 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index d3f42c91..48004df1 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -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)
diff --git a/libelf/common.h b/libelf/common.h
index 3718b3fd..4561854f 100644
--- a/libelf/common.h
+++ b/libelf/common.h
@@ -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>
 
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
index c5f27bbe..521668a7 100644
--- a/libelf/elf32_checksum.c
+++ b/libelf/elf32_checksum.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index 99b4ac09..4bfca24b 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -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"
 
diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
index 237d9122..fc696302 100644
--- a/libelf/elf32_getshdr.c
+++ b/libelf/elf32_getshdr.c
@@ -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"
 
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 1ff58900..46afa1f4 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -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"
 
 
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d0d4d1eb..6c06e5e4 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -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"
 
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 082d833f..377659c8 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf32_xlatetom.c b/libelf/elf32_xlatetom.c
index cb0bb8d5..fa3dc9a7 100644
--- a/libelf/elf32_xlatetom.c
+++ b/libelf/elf32_xlatetom.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 71eb3594..fe8c640a 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -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"
 
diff --git a/libelf/elf_cntl.c b/libelf/elf_cntl.c
index fd681789..04aa9132 100644
--- a/libelf/elf_cntl.c
+++ b/libelf/elf_cntl.c
@@ -31,8 +31,6 @@
 # include <config.h>
 #endif
 
-#include <unistd.h>
-
 #include "libelfP.h"
 
 
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index df0144e8..d7f53af2 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -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.  */
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 160f0b88..5c451f36 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -34,7 +34,6 @@
 #include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <sys/mman.h>
 
 #include "libelfP.h"
 
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 05ebf6a9..2203521f 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -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"
 
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c
index a704aae3..5ebd270f 100644
--- a/libelf/elf_getdata.c
+++ b/libelf/elf_getdata.c
@@ -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"
 
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index 2f55cbb4..5a35ccdc 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -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"
 
diff --git a/libelf/elf_getshdrstrndx.c b/libelf/elf_getshdrstrndx.c
index ad884fd3..2391317b 100644
--- a/libelf/elf_getshdrstrndx.c
+++ b/libelf/elf_getshdrstrndx.c
@@ -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"
 
diff --git a/libelf/elf_readall.c b/libelf/elf_readall.c
index 0a3a233d..d0f9a28c 100644
--- a/libelf/elf_readall.c
+++ b/libelf/elf_readall.c
@@ -32,10 +32,8 @@
 #endif
 
 #include <errno.h>
-#include <unistd.h>
 #include <sys/stat.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 97ca9ca9..56af3a1c 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -33,8 +33,6 @@
 
 #include <libelf.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 
 #include "libelfP.h"
diff --git a/libelf/gelf_xlate.c b/libelf/gelf_xlate.c
index 6f8c57b7..d8ad0634 100644
--- a/libelf/gelf_xlate.c
+++ b/libelf/gelf_xlate.c
@@ -32,7 +32,6 @@
 # include <config.h>
 #endif
 
-#include <byteswap.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 56331f45..d88a613c 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.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
diff --git a/libelf/nlist.c b/libelf/nlist.c
index 8593c1de..b3d60435 100644
--- a/libelf/nlist.c
+++ b/libelf/nlist.c
@@ -35,7 +35,6 @@
 #include <gelf.h>
 #include <libelf.h>
 #include <nlist.h>
-#include <unistd.h>
 
 #include "libelfP.h"
 
-- 
2.36.1.windows.1


  reply	other threads:[~2022-10-15 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15 16:36 [PATCH v2 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
2022-10-15 16:36 ` Yonggang Luo [this message]
2022-10-16 20:47   ` [PATCH v2 2/7] move platform depended include into system.h of libelf Mark Wielaard
2022-10-15 16:36 ` [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h Yonggang Luo
2022-10-16 20:49   ` Mark Wielaard
2022-10-15 16:36 ` [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h> Yonggang Luo
2022-10-16 20:55   ` 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=20221015163622.129-2-luoyonggang@gmail.com \
    --to=luoyonggang@gmail.com \
    --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).