diff options
author | Eric Biggers <ebiggers@google.com> | 2023-01-21 12:31:58 -0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-01-27 12:33:59 -0500 |
commit | 11f1e85ee3b96bdd08c69d8617cd82f5462e7f0b (patch) | |
tree | 4a3a5ce95eb71f9e87995f2fb6d8ce75f3358c4c | |
parent | 073feec96664cd241c9e300b42f63aba1a2c9f4f (diff) | |
download | e2fsprogs-11f1e85ee3b96bdd08c69d8617cd82f5462e7f0b.tar.gz |
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 <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | include/mingw/arpa/inet.h | 5 | ||||
-rw-r--r-- | lib/e2p/Android.bp | 4 | ||||
-rw-r--r-- | lib/ext2fs/Android.bp | 2 | ||||
-rw-r--r-- | lib/ext2fs/jfs_compat.h | 4 | ||||
-rw-r--r-- | misc/Android.bp | 1 | ||||
-rw-r--r-- | util/android_config.h | 1 |
6 files changed, 5 insertions, 12 deletions
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 <netinet/in.h> #endif -#ifdef HAVE_WINSOCK_H -#include <winsock.h> -#else #include <arpa/inet.h> -#endif #include <stdbool.h> #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 |