From: Eric Biggers Date: Sat, 21 Jan 2023 20:31:58 +0000 (-0800) Subject: lib, misc: eliminate dependency on Winsock X-Git-Tag: v1.46.6~82 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11f1e85ee3b96bdd08c69d8617cd82f5462e7f0b;p=thirdparty%2Fe2fsprogs.git lib, misc: eliminate dependency on Winsock Currently Windows builds of e2fsprogs rely on the Windows Socket API (Winsock) to provide htonl() and ntohl(). For this to actually work, though, HAVE_WINSOCK_H needs to be defined, and the binaries need to be linked to -lws2_32. The Android.bp files do this; however, the autotools-based build system does not. Since htonl() and ntohl() are trivial, let's instead just add a file include/mingw/arpa/inet.h with definitions for these. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o --- diff --git a/include/mingw/arpa/inet.h b/include/mingw/arpa/inet.h new file mode 100644 index 000000000..55dfa3691 --- /dev/null +++ b/include/mingw/arpa/inet.h @@ -0,0 +1,5 @@ +#pragma once + +/* Windows is always little endian. */ +#define htonl __builtin_bswap32 +#define ntohl __builtin_bswap32 diff --git a/lib/e2p/Android.bp b/lib/e2p/Android.bp index 6f0620af0..050d869b3 100644 --- a/lib/e2p/Android.bp +++ b/lib/e2p/Android.bp @@ -59,10 +59,6 @@ cc_library { "-Wno-unused-variable", "-Wno-error=typedef-redefinition", ], - - host_ldlibs: [ - "-lws2_32", - ], }, }, diff --git a/lib/ext2fs/Android.bp b/lib/ext2fs/Android.bp index 365ca709f..eb4482d79 100644 --- a/lib/ext2fs/Android.bp +++ b/lib/ext2fs/Android.bp @@ -126,8 +126,6 @@ cc_library { "-Wno-unused-variable", "-Wno-error=typedef-redefinition", ], - - host_ldlibs: ["-lws2_32"], }, }, diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index e11cf494e..0e96b56c1 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -7,11 +7,7 @@ #ifdef HAVE_NETINET_IN_H #include #endif -#ifdef HAVE_WINSOCK_H -#include -#else #include -#endif #include #define printk printf diff --git a/misc/Android.bp b/misc/Android.bp index 78e18e420..2baeac2ad 100644 --- a/misc/Android.bp +++ b/misc/Android.bp @@ -91,7 +91,6 @@ cc_binary { "-Wno-error" ], ldflags: ["-static"], - host_ldlibs: ["-lws2_32"], enabled: true }, android: { diff --git a/util/android_config.h b/util/android_config.h index 6ac16fec1..90b8f8a8f 100644 --- a/util/android_config.h +++ b/util/android_config.h @@ -36,7 +36,6 @@ #if defined(_WIN32) # define HAVE_LINUX_TYPES_H 1 -# define HAVE_WINSOCK_H 1 #endif #if defined(__APPLE__) || defined(__linux__) # define HAVE_FCNTL 1