From 74f84988126c9680e5e05513a42016f0dbe6c185 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Thu, 13 Aug 2020 14:34:05 +0200
Subject: [PATCH 1/7] Remove OS/2 support

We haven't provided OS/2 packages in years, it complicates the code
and it depends on the fallback snprintf implementation which is GPLv2
only.

No objections from privoxy-devel@.
---
 configure.in |   2 +-
 errlog.c     | 118 ++++-------------------------------------------------------
 filters.c    |   6 ---
 gateway.c    |   4 --
 jbsockets.c  |  87 ++++++++-----------------------------------
 jcc.c        |  39 ++------------------
 list.c       |   2 +-
 loadcfg.c    |   4 --
 loaders.c    |   2 +-
 miscutil.c   |  20 ++++------
 parsers.c    |   2 +-
 ssl_common.c |   6 +--
 urlmatch.c   |   2 +-
 13 files changed, 42 insertions(+), 252 deletions(-)

diff --git a/configure.in b/configure.in
index c1e8dbac..c542038a 100644
--- a/configure.in
+++ b/configure.in
@@ -163,7 +163,7 @@ dnl Check for user and group validity
 dnl =================================================================
 
 
-if test "$EMXOS2" = yes || test "$host_os" = haiku; then
+if test "$host_os" = haiku; then
   echo "Skipping user and group validity stuff.";
 
 else
diff --git a/errlog.c b/errlog.c
index 7cc4e200..dd06387e 100644
--- a/errlog.c
+++ b/errlog.c
@@ -45,9 +45,9 @@
 /* For gettimeofday() */
 #include <sys/time.h>
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
-#endif /* !defined(_WIN32) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) */
 
 #include <errno.h>
 #include <assert.h>
@@ -65,12 +65,6 @@
 #define inline __inline
 #endif /* def _MSC_VER */
 
-#ifdef __OS2__
-#include <sys/socket.h> /* For sock_errno */
-#define INCL_DOS
-#include <os2.h>
-#endif
-
 #include "errlog.h"
 #include "project.h"
 #include "jcc.h"
@@ -96,9 +90,6 @@ static void fatal_error(const char * error_message);
 #ifdef _WIN32
 static char *w32_socket_strerr(int errcode, char *tmp_buf);
 #endif
-#ifdef __OS2__
-static char *os2_socket_strerr(int errcode, char *tmp_buf);
-#endif
 
 #ifdef MUTEX_LOCKS_AVAILABLE
 static inline void lock_logfile(void)
@@ -331,9 +322,9 @@ void init_error_log(const char *prog_name, const char *logfname)
    if ((NULL == fp) && (logfp != NULL))
    {
       /*
-       * Some platforms (like OS/2) don't allow us to open
-       * the same file twice, therefore we give it another
-       * shot after closing the old file descriptor first.
+       * Some platforms (like OS/2 (XXX: no longer supported)) don't
+       * allow us to open the same file twice, therefore we give it
+       * another shot after closing the old file descriptor first.
        *
        * We don't do it right away because it prevents us
        * from logging the "can't open logfile" message to
@@ -418,11 +409,6 @@ static long get_thread_id(void)
 {
    long this_thread;
 
-#ifdef __OS2__
-   PTIB     ptib;
-   APIRET   ulrc; /* XXX: I have no clue what this does */
-#endif /* __OS2__ */
-
    /* FIXME get current thread id */
 #ifdef FEATURE_PTHREAD
    this_thread = (long)pthread_self();
@@ -436,10 +422,6 @@ static long get_thread_id(void)
 #endif /* def __MACH__ */
 #elif defined(_WIN32)
    this_thread = GetCurrentThreadId();
-#elif defined(__OS2__)
-   ulrc = DosGetInfoBlocks(&ptib, NULL);
-   if (ulrc == 0)
-     this_thread = ptib -> tib_ptib2 -> tib2_ultid;
 #else
    /* Forking instead of threading. */
    this_thread = 1;
@@ -746,7 +728,8 @@ void log_error(int loglevel, const char *fmt, ...)
          /*
           * XXX: Only necessary on platforms where multiple threads
           * can write to the buffer at the same time because we
-          * don't support mutexes (OS/2 for example).
+          * don't support mutexes.
+          * XXX: Are there any such platforms left now that OS/2 is gone?
           */
          outbuf[length] = '\0';
          continue;
@@ -844,17 +827,6 @@ void log_error(int loglevel, const char *fmt, ...)
 #ifdef _WIN32
             ival = WSAGetLastError();
             format_string = w32_socket_strerr(ival, tempbuf);
-#elif __OS2__
-            ival = sock_errno();
-            if (ival != 0)
-            {
-               format_string = os2_socket_strerr(ival, tempbuf);
-            }
-            else
-            {
-               ival = errno;
-               format_string = strerror(ival);
-            }
 #else /* ifndef _WIN32 */
             ival = errno;
 #ifdef HAVE_STRERROR
@@ -1077,82 +1049,6 @@ static char *w32_socket_strerr(int errcode, char *tmp_buf)
 #endif /* def _WIN32 */
 
 
-#ifdef __OS2__
-/*********************************************************************
- *
- * Function    :  os2_socket_strerr
- *
- * Description :  Translate the return value from sock_errno()
- *                into a string.
- *
- * Parameters  :
- *          1  :  errcode = The return value from sock_errno().
- *          2  :  tmp_buf = A temporary buffer that might be used to
- *                          store the string.
- *
- * Returns     :  String representing the error code.  This may be
- *                a global string constant or a string stored in
- *                tmp_buf.
- *
- *********************************************************************/
-static char *os2_socket_strerr(int errcode, char *tmp_buf)
-{
-#define TEXT_FOR_ERROR(code,text) \
-   if (errcode == code)           \
-   {                              \
-      return #code " - " text;    \
-   }
-
-   TEXT_FOR_ERROR(SOCEPERM          , "Not owner.")
-   TEXT_FOR_ERROR(SOCESRCH          , "No such process.")
-   TEXT_FOR_ERROR(SOCEINTR          , "Interrupted system call.")
-   TEXT_FOR_ERROR(SOCENXIO          , "No such device or address.")
-   TEXT_FOR_ERROR(SOCEBADF          , "Bad file number.")
-   TEXT_FOR_ERROR(SOCEACCES         , "Permission denied.")
-   TEXT_FOR_ERROR(SOCEFAULT         , "Bad address.")
-   TEXT_FOR_ERROR(SOCEINVAL         , "Invalid argument.")
-   TEXT_FOR_ERROR(SOCEMFILE         , "Too many open files.")
-   TEXT_FOR_ERROR(SOCEPIPE          , "Broken pipe.")
-   TEXT_FOR_ERROR(SOCEWOULDBLOCK    , "Operation would block.")
-   TEXT_FOR_ERROR(SOCEINPROGRESS    , "Operation now in progress.")
-   TEXT_FOR_ERROR(SOCEALREADY       , "Operation already in progress.")
-   TEXT_FOR_ERROR(SOCENOTSOCK       , "Socket operation on non-socket.")
-   TEXT_FOR_ERROR(SOCEDESTADDRREQ   , "Destination address required.")
-   TEXT_FOR_ERROR(SOCEMSGSIZE       , "Message too long.")
-   TEXT_FOR_ERROR(SOCEPROTOTYPE     , "Protocol wrong type for socket.")
-   TEXT_FOR_ERROR(SOCENOPROTOOPT    , "Protocol not available.")
-   TEXT_FOR_ERROR(SOCEPROTONOSUPPORT, "Protocol not supported.")
-   TEXT_FOR_ERROR(SOCESOCKTNOSUPPORT, "Socket type not supported.")
-   TEXT_FOR_ERROR(SOCEOPNOTSUPP     , "Operation not supported.")
-   TEXT_FOR_ERROR(SOCEPFNOSUPPORT   , "Protocol family not supported.")
-   TEXT_FOR_ERROR(SOCEAFNOSUPPORT   , "Address family not supported by protocol family.")
-   TEXT_FOR_ERROR(SOCEADDRINUSE     , "Address already in use.")
-   TEXT_FOR_ERROR(SOCEADDRNOTAVAIL  , "Can't assign requested address.")
-   TEXT_FOR_ERROR(SOCENETDOWN       , "Network is down.")
-   TEXT_FOR_ERROR(SOCENETUNREACH    , "Network is unreachable.")
-   TEXT_FOR_ERROR(SOCENETRESET      , "Network dropped connection on reset.")
-   TEXT_FOR_ERROR(SOCECONNABORTED   , "Software caused connection abort.")
-   TEXT_FOR_ERROR(SOCECONNRESET     , "Connection reset by peer.")
-   TEXT_FOR_ERROR(SOCENOBUFS        , "No buffer space available.")
-   TEXT_FOR_ERROR(SOCEISCONN        , "Socket is already connected.")
-   TEXT_FOR_ERROR(SOCENOTCONN       , "Socket is not connected.")
-   TEXT_FOR_ERROR(SOCESHUTDOWN      , "Can't send after socket shutdown.")
-   TEXT_FOR_ERROR(SOCETOOMANYREFS   , "Too many references: can't splice.")
-   TEXT_FOR_ERROR(SOCETIMEDOUT      , "Operation timed out.")
-   TEXT_FOR_ERROR(SOCECONNREFUSED   , "Connection refused.")
-   TEXT_FOR_ERROR(SOCELOOP          , "Too many levels of symbolic links.")
-   TEXT_FOR_ERROR(SOCENAMETOOLONG   , "File name too long.")
-   TEXT_FOR_ERROR(SOCEHOSTDOWN      , "Host is down.")
-   TEXT_FOR_ERROR(SOCEHOSTUNREACH   , "No route to host.")
-   TEXT_FOR_ERROR(SOCENOTEMPTY      , "Directory not empty.")
-   TEXT_FOR_ERROR(SOCEOS2ERR        , "OS/2 Error.")
-
-   sprintf(tmp_buf, "(error number %d)", errcode);
-   return tmp_buf;
-}
-#endif /* def __OS2__ */
-
-
 /*
   Local Variables:
   tab-width: 3
diff --git a/filters.c b/filters.c
index a9d97676..9d350e7c 100644
--- a/filters.c
+++ b/filters.c
@@ -42,18 +42,12 @@
 #include <assert.h>
 
 #ifndef _WIN32
-#ifndef __OS2__
 #include <unistd.h>
-#endif /* ndef __OS2__ */
 #include <netinet/in.h>
 #else
 #include <winsock2.h>
 #endif /* ndef _WIN32 */
 
-#ifdef __OS2__
-#include <utils.h>
-#endif /* def __OS2__ */
-
 #include "project.h"
 #include "filters.h"
 #include "encode.h"
diff --git a/gateway.c b/gateway.c
index 07752b00..9b21aa53 100644
--- a/gateway.c
+++ b/gateway.c
@@ -55,10 +55,6 @@
 #include <netdb.h>
 #endif /* def __BEOS__ */
 
-#ifdef __OS2__
-#include <utils.h>
-#endif /* def __OS2__ */
-
 #include "project.h"
 #include "jcc.h"
 #include "errlog.h"
diff --git a/jbsockets.c b/jbsockets.c
index 5e4b28c7..ed9f9eae 100644
--- a/jbsockets.c
+++ b/jbsockets.c
@@ -56,9 +56,7 @@
 
 #else
 
-#ifndef __OS2__
 #include <unistd.h>
-#endif
 #include <sys/time.h>
 #include <netinet/in.h>
 #include <sys/ioctl.h>
@@ -67,20 +65,11 @@
 
 #ifndef __BEOS__
 #include <netinet/tcp.h>
-#ifndef __OS2__
 #include <arpa/inet.h>
-#endif
 #else
 #include <socket.h>
 #endif
 
-#if defined(__EMX__) || defined (__OS2__)
-#include <sys/select.h>  /* OS/2/EMX needs a little help with select */
-#ifdef __OS2__
-#include <nerrno.h>
-#endif
-#endif
-
 #endif
 
 #ifdef HAVE_POLL
@@ -213,7 +202,7 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
    fd_set wfds;
    struct timeval timeout;
 #endif
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
    int   flags;
 #endif
    int connect_failed;
@@ -271,11 +260,7 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
 
       if (block_acl(dst, csp))
       {
-#ifdef __OS2__
-         socket_error = errno = SOCEPERM;
-#else
          socket_error = errno = EPERM;
-#endif
          continue;
       }
 #endif /* def FEATURE_ACL */
@@ -320,26 +305,22 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
 
       set_no_delay_flag(fd);
 
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
       if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
       {
          flags |= O_NDELAY;
          fcntl(fd, F_SETFL, flags);
       }
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
 
       connect_failed = 0;
       while (connect(fd, rp->ai_addr, rp->ai_addrlen) == JB_INVALID_SOCKET)
       {
-#ifdef __OS2__
-         errno = sock_errno();
-#endif /* __OS2__ */
-
 #ifdef _WIN32
          if (errno == WSAEINPROGRESS)
 #else /* ifndef _WIN32 */
          if (errno == EINPROGRESS)
-#endif /* ndef _WIN32 || __OS2__ */
+#endif /* ndef _WIN32 */
          {
             break;
          }
@@ -357,13 +338,13 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
          continue;
       }
 
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
       if (flags != -1)
       {
          flags &= ~O_NDELAY;
          fcntl(fd, F_SETFL, flags);
       }
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
 
 #ifdef HAVE_POLL
       poll_fd[0].fd = fd;
@@ -464,7 +445,7 @@ static jb_socket no_rfc2553_connect_to(const char *host, int portnum, struct cli
    fd_set wfds;
    struct timeval tv[1];
 #endif
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
    int   flags;
 #endif
 
@@ -489,11 +470,7 @@ static jb_socket no_rfc2553_connect_to(const char *host, int portnum, struct cli
 
    if (block_acl(dst, csp))
    {
-#ifdef __OS2__
-      errno = SOCEPERM;
-#else
       errno = EPERM;
-#endif
       return(JB_INVALID_SOCKET);
    }
 #endif /* def FEATURE_ACL */
@@ -540,7 +517,7 @@ static jb_socket no_rfc2553_connect_to(const char *host, int portnum, struct cli
 
    set_no_delay_flag(fd);
 
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
    if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
    {
       flags |= O_NDELAY;
@@ -549,39 +526,33 @@ static jb_socket no_rfc2553_connect_to(const char *host, int portnum, struct cli
       mark_socket_for_close_on_execute(fd);
 #endif
    }
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
 
    while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == JB_INVALID_SOCKET)
    {
 #ifdef _WIN32
       if (errno == WSAEINPROGRESS)
-#elif __OS2__
-      if (sock_errno() == EINPROGRESS)
 #else /* ifndef _WIN32 */
       if (errno == EINPROGRESS)
-#endif /* ndef _WIN32 || __OS2__ */
+#endif /* ndef _WIN32 */
       {
          break;
       }
 
-#ifdef __OS2__
-      if (sock_errno() != EINTR)
-#else
       if (errno != EINTR)
-#endif /* __OS2__ */
       {
          close_socket(fd);
          return(JB_INVALID_SOCKET);
       }
    }
 
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
    if (flags != -1)
    {
       flags &= ~O_NDELAY;
       fcntl(fd, F_SETFL, flags);
    }
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
 
 #ifdef HAVE_POLL
    poll_fd[0].fd = fd;
@@ -645,27 +616,6 @@ int write_socket(jb_socket fd, const char *buf, size_t len)
    return (send(fd, buf, (int)len, 0) != (int)len);
 #elif defined(__BEOS__)
    return (send(fd, buf, len, 0) != len);
-#elif defined(__OS2__)
-   /*
-    * Break the data up into SOCKET_SEND_MAX chunks for sending...
-    * OS/2 seemed to complain when the chunks were too large.
-    */
-#define SOCKET_SEND_MAX 65000
-   {
-      int send_len, send_rc = 0, i = 0;
-      while ((i < len) && (send_rc != -1))
-      {
-         if ((i + SOCKET_SEND_MAX) > len)
-            send_len = len - i;
-         else
-            send_len = SOCKET_SEND_MAX;
-         send_rc = send(fd,(char*)buf + i, send_len, 0);
-         if (send_rc == -1)
-            return 1;
-         i = i + send_len;
-      }
-      return 0;
-   }
 #else
    return (write(fd, buf, len) != len);
 #endif
@@ -763,7 +713,7 @@ int read_socket(jb_socket fd, char *buf, int len)
 
 #if defined(_WIN32)
    ret = recv(fd, buf, len, 0);
-#elif defined(__BEOS__) || defined(__OS2__)
+#elif defined(__BEOS__)
    ret = recv(fd, buf, (size_t)len, 0);
 #else
    ret = (int)read(fd, buf, (size_t)len);
@@ -810,12 +760,7 @@ int data_is_available(jb_socket fd, int seconds_to_wait)
    memset(&timeout, 0, sizeof(timeout));
    timeout.tv_sec = seconds_to_wait;
 
-#ifdef __OS2__
-   /* Copy and pasted from jcc.c ... */
-   memset(&rfds, 0, sizeof(fd_set));
-#else
    FD_ZERO(&rfds);
-#endif
    FD_SET(fd, &rfds);
 
    n = select(fd+1, &rfds, NULL, NULL, &timeout);
@@ -844,8 +789,6 @@ void close_socket(jb_socket fd)
 {
 #if defined(_WIN32) || defined(__BEOS__)
    closesocket(fd);
-#elif defined(__OS2__)
-   soclose(fd);
 #else
    close(fd);
 #endif
@@ -1170,7 +1113,7 @@ void get_host_information(jb_socket afd, char **ip_address, char **port,
    struct sockaddr_in server;
    struct hostent *host = NULL;
 #endif /* HAVE_RFC2553 */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
    /* according to accept_connection() this fixes a warning. */
    int s_length, s_length_provided;
 #else
@@ -1322,7 +1265,7 @@ int accept_connection(struct client_state * csp, jb_socket fds[])
    struct sockaddr_in client;
 #endif
    jb_socket afd;
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
    /* Weirdness - fix a warning. */
    int c_length;
 #else
diff --git a/jcc.c b/jcc.c
index ec492ef6..4db217f2 100644
--- a/jcc.c
+++ b/jcc.c
@@ -62,10 +62,8 @@
 
 #else /* ifndef _WIN32 */
 
-# if !defined (__OS2__)
 # include <unistd.h>
 # include <sys/wait.h>
-# endif /* ndef __OS2__ */
 # include <sys/time.h>
 # include <sys/stat.h>
 # include <sys/ioctl.h>
@@ -86,14 +84,6 @@
 #  include <OS.h>      /* declarations for threads and stuff. */
 # endif
 
-# if defined(__EMX__) || defined(__OS2__)
-#  include <sys/select.h>  /* OS/2/EMX needs a little help with select */
-# endif
-# ifdef __OS2__
-#define INCL_DOS
-# include <os2.h>
-# endif
-
 #ifdef HAVE_POLL
 #ifdef __GLIBC__
 #include <sys/poll.h>
@@ -143,7 +133,7 @@ int urls_rejected = 0;     /* total nr of urls rejected */
 int g_terminate = 0;
 #endif
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 static void sig_handler(int the_signal);
 #endif
 static int client_protocol_is_unsupported(struct client_state *csp, char *req);
@@ -177,10 +167,6 @@ static int32 server_thread(void *data);
 #define sleep(N)  Sleep(((N) * 1000))
 #endif
 
-#ifdef __OS2__
-#define sleep(N)  DosSleep(((N) * 100))
-#endif
-
 #ifdef FUZZ
 int process_fuzzed_input(char *fuzz_input_type, char *fuzz_input_file);
 void show_fuzz_usage(const char *name);
@@ -347,7 +333,7 @@ static const struct cruncher crunchers_light[] = {
  *
  * here?
  */
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 /*********************************************************************
  *
  * Function    :  sig_handler
@@ -2631,15 +2617,7 @@ static void handle_established_connection(struct client_state *csp)
    for (;;)
    {
 #ifndef HAVE_POLL
-#ifdef __OS2__
-      /*
-       * FD_ZERO here seems to point to an errant macro which crashes.
-       * So do this by hand for now...
-       */
-      memset(&rfds,0x00,sizeof(fd_set));
-#else
       FD_ZERO(&rfds);
-#endif
 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
       if (!watch_client_socket)
       {
@@ -5012,7 +4990,7 @@ int main(int argc, char **argv)
     * are handled when and where they occur without relying
     * on a signal.
     */
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 {
    int idx;
    const int catched_signals[] = { SIGTERM, SIGINT, SIGHUP };
@@ -5474,7 +5452,7 @@ static void listen_loop(void)
    for (;;)
 #endif
    {
-#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__)
       while (waitpid(-1, NULL, WNOHANG) > 0)
       {
          /* zombie children */
@@ -5619,15 +5597,6 @@ static void listen_loop(void)
             csp);
 #endif
 
-#if defined(__OS2__) && !defined(SELECTED_ONE_OPTION)
-#define SELECTED_ONE_OPTION
-         child_id = _beginthread(
-            (void(* _Optlink)(void*))serve,
-            NULL,
-            64 * 1024,
-            csp);
-#endif
-
 #if defined(__BEOS__) && !defined(SELECTED_ONE_OPTION)
 #define SELECTED_ONE_OPTION
          {
diff --git a/list.c b/list.c
index 89bb0102..b9963af1 100644
--- a/list.c
+++ b/list.c
@@ -45,7 +45,7 @@
 #endif
 #include <string.h>
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
 #endif
 
diff --git a/loadcfg.c b/loadcfg.c
index 55874d57..539d2b1c 100644
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -62,10 +62,8 @@
 
 #else /* ifndef _WIN32 */
 
-#ifndef __OS2__
 # include <unistd.h>
 # include <sys/wait.h>
-#endif
 # include <sys/time.h>
 # include <sys/stat.h>
 # include <signal.h>
@@ -1488,8 +1486,6 @@ struct configuration_spec * load_config(void)
              *
              * On platforms were we use poll() we don't have to enforce
              * an upper connection limit either.
-             *
-             * XXX: Do OS/2 etc. belong here as well?
              */
             if (max_client_connections < 1)
             {
diff --git a/loaders.c b/loaders.c
index 3bfcdd27..654a1b9f 100644
--- a/loaders.c
+++ b/loaders.c
@@ -46,7 +46,7 @@
 #include <ctype.h>
 #include <assert.h>
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
 #endif
 
diff --git a/miscutil.c b/miscutil.c
index 488a774b..cba589bf 100644
--- a/miscutil.c
+++ b/miscutil.c
@@ -48,9 +48,9 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <stdlib.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
-#endif /* #if !defined(_WIN32) && !defined(__OS2__) */
+#endif /* #if !defined(_WIN32) */
 #include <string.h>
 #include <ctype.h>
 #include <assert.h>
@@ -647,11 +647,11 @@ char * make_path(const char * dir, const char * file)
    }
 
    if ((dir == NULL) || (*dir == '\0') /* No directory specified */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
       || (*file == '\\') || (file[1] == ':') /* Absolute path (DOS) */
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
       || (*file == '/') /* Absolute path (U*ix) */
-#endif /* ifndef _WIN32 || __OS2__  */
+#endif /* ifndef _WIN32 */
       )
    {
       return strdup(file);
@@ -683,17 +683,17 @@ char * make_path(const char * dir, const char * file)
       }
 
       assert(NULL != path);
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
       if (path[strlen(path)-1] != '\\')
       {
          strlcat(path, "\\", path_size);
       }
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
       if (path[strlen(path)-1] != '/')
       {
          strlcat(path, "/", path_size);
       }
-#endif /* ifndef _WIN32 || __OS2__ */
+#endif /* ifndef _WIN32 */
       strlcat(path, file, path_size);
 
       return path;
@@ -842,10 +842,6 @@ int privoxy_millisleep(unsigned milliseconds)
    Sleep(milliseconds);
 
    return 0;
-#elif defined(__OS2__)
-   DosSleep(milliseconds * 10);
-
-   return 0;
 #else
 #warning Missing privoxy_milisleep() implementation. delay-response{} will not work.
 
diff --git a/parsers.c b/parsers.c
index 9b4a1298..ec3ad71e 100644
--- a/parsers.c
+++ b/parsers.c
@@ -68,7 +68,7 @@
 #include <brotli/decode.h>
 #endif
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
 #endif
 
diff --git a/ssl_common.c b/ssl_common.c
index add68a28..6ad59241 100644
--- a/ssl_common.c
+++ b/ssl_common.c
@@ -487,12 +487,12 @@ extern char *make_certs_path(const char *conf_dir, const char *file_name,
       + strlen(file_name) + strlen(suffix) + 2;
 
    /* Setting delimiter and editing path length */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
    char delim[] = "\\";
    path_size += 1;
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
    char delim[] = "/";
-#endif /* ifndef _WIN32 || __OS2__ */
+#endif /* ifndef _WIN32 */
 
    /*
     * Building up path from many parts
diff --git a/urlmatch.c b/urlmatch.c
index a028361e..4886e4c4 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -45,7 +45,7 @@
 #include <assert.h>
 #include <string.h>
 
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
 #include <unistd.h>
 #endif
 
-- 
2.11.0

