From b4598662a39ff6974119c900ea56a4d020eac366 Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bvanassche@acm.org>
Date: Wed, 20 Dec 2023 13:08:06 -0800
Subject: [PATCH] Android: Fix the build

Include <sys/select.h> for the fd_set type. In the configure script,
check whether 'unsigned long' is the underlying type of fd_set. Use
u_long instead of ulong.

Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/b4598662a39ff6974119c900ea56a4d020eac366]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 agent/mibgroup/ip-mib/data_access/ipaddress_linux.c | 4 ++--
 configure                                           | 2 +-
 configure.d/config_project_types                    | 2 +-
 include/net-snmp/types.h                            | 3 +++
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
index b38beb57dd..232202d0f9 100644
--- a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
+++ b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
@@ -50,7 +50,7 @@ int _load_v6(netsnmp_container *container, int idx_offset);
 int
 netsnmp_access_ipaddress_extra_prefix_info(int index,
                                            u_long *preferedlt,
-                                           ulong *validlt,
+                                           u_long *validlt,
                                            char *addr);
 #endif
 
@@ -523,7 +523,7 @@ out:
 
 int
 netsnmp_access_ipaddress_extra_prefix_info(int index, u_long *preferedlt,
-                                           ulong *validlt, char *addr)
+                                           u_long *validlt, char *addr)
 {
 
     struct {
diff --git a/configure b/configure
index e7bf859bba..48abcbab11 100755
--- a/configure
+++ b/configure
@@ -31577,7 +31577,7 @@ CFLAGS="$CFLAGS -Werror"
 
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the type of fd_set::fds_bits" >&5
 printf %s "checking for the type of fd_set::fds_bits... " >&6; }
-for type in __fd_mask __int32_t long\ int unknown; do
+for type in __fd_mask __int32_t long 'unsigned long' unknown; do
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
diff --git a/configure.d/config_project_types b/configure.d/config_project_types
index a78e8ebb06..ac958d6712 100644
--- a/configure.d/config_project_types
+++ b/configure.d/config_project_types
@@ -66,7 +66,7 @@ netsnmp_save_CFLAGS=$CFLAGS
 CFLAGS="$CFLAGS -Werror"
 
 AC_MSG_CHECKING([for the type of fd_set::fds_bits])
-for type in __fd_mask __int32_t long\ int unknown; do
+for type in __fd_mask __int32_t long 'unsigned long' unknown; do
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 #include <sys/select.h>
 #include <stddef.h>
diff --git a/include/net-snmp/types.h b/include/net-snmp/types.h
index b78f53ffd7..6228170e5f 100644
--- a/include/net-snmp/types.h
+++ b/include/net-snmp/types.h
@@ -23,6 +23,9 @@
 #endif
 
 #include <sys/types.h>
+#ifdef __ANDROID__
+#include <sys/select.h>
+#endif
 
 #if defined(WIN32) && !defined(cygwin)
 typedef HANDLE netsnmp_pid_t;
-- 
2.44.0

