]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
lib, misc: eliminate dependency on Winsock
authorEric Biggers <ebiggers@google.com>
Sat, 21 Jan 2023 20:31:58 +0000 (12:31 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 27 Jan 2023 17:33:59 +0000 (12:33 -0500)
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>
include/mingw/arpa/inet.h [new file with mode: 0644]
lib/e2p/Android.bp
lib/ext2fs/Android.bp
lib/ext2fs/jfs_compat.h
misc/Android.bp
util/android_config.h

diff --git a/include/mingw/arpa/inet.h b/include/mingw/arpa/inet.h
new file mode 100644 (file)
index 0000000..55dfa36
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+/* Windows is always little endian. */
+#define htonl  __builtin_bswap32
+#define ntohl  __builtin_bswap32
index 6f0620af06be6ee032cef46d4c50231e8d102b5a..050d869b367f7316a96e8f1161edc871efda775a 100644 (file)
@@ -59,10 +59,6 @@ cc_library {
                 "-Wno-unused-variable",
                 "-Wno-error=typedef-redefinition",
             ],
-
-            host_ldlibs: [
-                "-lws2_32",
-            ],
         },
     },
 
index 365ca709f9f15fda2a7419934e70043639b823b1..eb4482d7967bed51998448004a86c36075f9899d 100644 (file)
@@ -126,8 +126,6 @@ cc_library {
                 "-Wno-unused-variable",
                 "-Wno-error=typedef-redefinition",
             ],
-
-            host_ldlibs: ["-lws2_32"],
         },
     },
 
index e11cf494e02a95e4899d04926e194b688f2281bc..0e96b56c1589ccc6fef4c1142e8fca06a2f1b692 100644 (file)
@@ -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
index 78e18e420719fca3ef9137757f052460b7bb73c5..2baeac2add8dbdf78ac4d24c435d3e1a0cb9800d 100644 (file)
@@ -91,7 +91,6 @@ cc_binary {
                 "-Wno-error"
             ],
             ldflags: ["-static"],
-            host_ldlibs: ["-lws2_32"],
             enabled: true
         },
         android: {
index 6ac16fec15b60f79ae1b61d4a2d1aef3c86fbf8b..90b8f8a8ff829f7b6f31c451a61270749568c45a 100644 (file)
@@ -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