Discussion:
[Ipmitool-devel] [PATCH v3 1/2] Avoid wchar_t redefinition
Jörg Krause
2016-04-11 19:22:22 UTC
Permalink
The musl C library does not define _WCHAR_T. Use autoconf to check for wchar_t.

Signed-off-by: Jörg Krause <***@embedded.rocks>
---
Changes v2 -> v3:
- The check for _WCHAR_T is redundant and potentially wrong. If autoconf didn't
detect wchar_t and _WCHAR_T is still defined, something is amiss.

Changes v1 -> v2:
- use autoconf to check for type wchar_t instead of using non-standardized
GNU C extension macro __WCHAR_TYPE__

---
configure.ac | 2 ++
src/plugins/imb/imbapi.h | 7 ++++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 1d74fcf..c2ba1eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,8 @@ AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h paths.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/socket.h])
AC_CHECK_HEADERS([sys/byteorder.h byteswap.h])

+AC_CHECK_TYPES([wchar_t])
+
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
diff --git a/src/plugins/imb/imbapi.h b/src/plugins/imb/imbapi.h
index 74975c6..ead8956 100644
--- a/src/plugins/imb/imbapi.h
+++ b/src/plugins/imb/imbapi.h
@@ -35,6 +35,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*----------------------------------------------------------------------*/
#ifndef _WINDEFS_H
#define _WINDEFS_H
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#ifndef FALSE
#define FALSE 0
#endif
@@ -46,7 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#ifndef WIN32
/* WIN32 defines this in stdio.h */
-#ifndef _WCHAR_T
+#if !defined(HAVE_WCHAR_T)
#define _WCHAR_T
typedef long wchar_t;
#endif
--
2.8.0
Jörg Krause
2016-04-11 19:22:23 UTC
Permalink
Fixes the following build failure under musl:

imbapi.c: In function 'MapPhysicalMemory':
imbapi.c:109:19: error: 'EXEC_PAGESIZE' undeclared (first use in this function)
# define PAGESIZE EXEC_PAGESIZE

Signed-off-by: Jörg Krause <***@embedded.rocks>
---
Changes v2 -> v3:
- none

Changes v1 -> v2:
- Improve commit message

---
src/plugins/imb/imbapi.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/plugins/imb/imbapi.c b/src/plugins/imb/imbapi.c
index 899c47a..8a6421d 100644
--- a/src/plugins/imb/imbapi.c
+++ b/src/plugins/imb/imbapi.c
@@ -95,6 +95,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
+#ifdef __linux__
+#include <linux/param.h>
+#endif
#endif
#include "imbapi.h"
#include <asm/socket.h>
--
2.8.0
Loading...