Browse code

Remove a number of platform specific checks in configure.ac

- Remove windows XP/old mingw compat code in socket.c
- Use _WIN32 instead checking for existence of windows.h, winsock2.h
and ws2tcpip.h in autconf
- Remove check for unlink. The last remaining use is a check inside
a Unix socket.
- Even Windows has umask, so remove the check for it
- Move epoll.h inclusion to event.c

Patch V2: Add epoll.h syshead.h that accidently was put into another
patch

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210422152939.2134046-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22201.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Arne Schwabe authored on 2021/04/23 00:29:39
Showing 5 changed files
... ...
@@ -419,7 +419,6 @@ AC_CHECK_HEADERS([ \
419 419
 	unistd.h dlfcn.h \
420 420
 	netinet/in.h netinet/in_systm.h \
421 421
 	netinet/tcp.h arpa/inet.h netdb.h \
422
-	windows.h winsock2.h ws2tcpip.h \
423 422
 	versionhelpers.h \
424 423
 ])
425 424
 AC_CHECK_HEADERS([ \
... ...
@@ -445,13 +444,13 @@ SOCKET_INCLUDES="
445 445
 #ifdef HAVE_NETINET_IN_H
446 446
 #include <netinet/in.h>
447 447
 #endif
448
-#ifdef HAVE_WINDOWS_H
448
+#ifdef _WIN32
449 449
 #include <windows.h>
450 450
 #endif
451
-#ifdef HAVE_WINSOCK2_H
451
+#ifdef _WIN32
452 452
 #include <winsock2.h>
453 453
 #endif
454
-#ifdef HAVE_WS2TCPIP_H
454
+#ifdef _WIN32
455 455
 #include <ws2tcpip.h>
456 456
 #endif
457 457
 #ifdef HAVE_NETINET_IN_SYSTM_H
... ...
@@ -630,8 +629,8 @@ AC_CHECK_FUNCS([ \
630 630
 	daemon chroot getpwnam setuid nice system getpid dup dup2 \
631 631
 	syslog openlog mlockall getrlimit getgrnam setgid \
632 632
 	setgroups flock readv writev time gettimeofday \
633
-	setsid chdir getpeername unlink \
634
-	chsize ftruncate execve getpeereid umask basename dirname access \
633
+	setsid chdir getpeername \
634
+	chsize ftruncate execve getpeereid basename dirname access \
635 635
 	epoll_create strsep \
636 636
 ])
637 637
 
... ...
@@ -24,11 +24,8 @@
24 24
 #ifndef COMPAT_H
25 25
 #define COMPAT_H
26 26
 
27
-#ifdef HAVE_WINSOCK2_H
27
+#ifdef _WIN32
28 28
 #include <winsock2.h>
29
-#endif
30
-
31
-#ifdef HAVE_WS2TCPIP_H
32 29
 #include <ws2tcpip.h>
33 30
 #endif
34 31
 
... ...
@@ -35,6 +35,10 @@
35 35
 #include "event.h"
36 36
 #include "fdmisc.h"
37 37
 
38
+#if EPOLL
39
+#include <sys/epoll.h>
40
+#endif
41
+
38 42
 #include "memdbg.h"
39 43
 
40 44
 /*
... ...
@@ -1385,14 +1385,6 @@ socket_listen_accept(socket_descriptor_t sd,
1385 1385
     return new_sd;
1386 1386
 }
1387 1387
 
1388
-/* older mingw versions and WinXP do not have this define,
1389
- * but Vista and up support the functionality - just define it here
1390
- */
1391
-#ifdef _WIN32
1392
-#ifndef IPV6_V6ONLY
1393
-#define IPV6_V6ONLY 27
1394
-#endif
1395
-#endif
1396 1388
 void
1397 1389
 socket_bind(socket_descriptor_t sd,
1398 1390
             struct addrinfo *local,
... ...
@@ -3913,10 +3905,7 @@ socket_bind_unix(socket_descriptor_t sd,
3913 3913
                  const char *prefix)
3914 3914
 {
3915 3915
     struct gc_arena gc = gc_new();
3916
-
3917
-#ifdef HAVE_UMASK
3918 3916
     const mode_t orig_umask = umask(0);
3919
-#endif
3920 3917
 
3921 3918
     if (bind(sd, (struct sockaddr *) local, sizeof(struct sockaddr_un)))
3922 3919
     {
... ...
@@ -3927,10 +3916,7 @@ socket_bind_unix(socket_descriptor_t sd,
3927 3927
             sockaddr_unix_name(local, "NULL"));
3928 3928
     }
3929 3929
 
3930
-#ifdef HAVE_UMASK
3931 3930
     umask(orig_umask);
3932
-#endif
3933
-
3934 3931
     gc_free(&gc);
3935 3932
 }
3936 3933
 
... ...
@@ -3975,12 +3961,10 @@ void
3975 3975
 socket_delete_unix(const struct sockaddr_un *local)
3976 3976
 {
3977 3977
     const char *name = sockaddr_unix_name(local, NULL);
3978
-#ifdef HAVE_UNLINK
3979 3978
     if (name && strlen(name))
3980 3979
     {
3981 3980
         unlink(name);
3982 3981
     }
3983
-#endif
3984 3982
 }
3985 3983
 
3986 3984
 bool
... ...
@@ -100,10 +100,6 @@
100 100
 #include <fcntl.h>
101 101
 #endif
102 102
 
103
-#ifdef HAVE_IO_H
104
-#include <io.h>
105
-#endif
106
-
107 103
 #ifdef HAVE_SYS_FILE_H
108 104
 #include <sys/file.h>
109 105
 #endif
... ...
@@ -155,10 +151,6 @@
155 155
 #include <poll.h>
156 156
 #endif
157 157
 
158
-#ifdef HAVE_SYS_EPOLL_H
159
-#include <sys/epoll.h>
160
-#endif
161
-
162 158
 #ifdef ENABLE_SELINUX
163 159
 #include <selinux/selinux.h>
164 160
 #endif
... ...
@@ -342,6 +334,8 @@ typedef int MIB_TCP_STATE;
342 342
 #include <iphlpapi.h>
343 343
 #include <wininet.h>
344 344
 #include <shellapi.h>
345
+#include <io.h>
346
+
345 347
 /* The following two headers are needed of PF_INET6 */
346 348
 #include <winsock2.h>
347 349
 #include <ws2tcpip.h>
... ...
@@ -541,12 +535,6 @@ socket_defined(const socket_descriptor_t sd)
541 541
 #define EPOLL 0
542 542
 #endif
543 543
 
544
-/* Disable EPOLL */
545
-#if 0
546
-#undef EPOLL
547
-#define EPOLL 0
548
-#endif
549
-
550 544
 /*
551 545
  * Is non-blocking connect() supported?
552 546
  */