[libxml2] Remove BeOS support



commit 13a663781501b25bd23f2db503bb42217d2cffc8
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Sun Sep 4 01:05:51 2022 +0200

    Remove BeOS support
    
    Haiku shouldn't be affected.

 configure.ac  |   4 --
 nanoftp.c     |   8 ----
 nanohttp.c    |  18 --------
 runtest.c     |  52 ---------------------
 testThreads.c |  60 +------------------------
 threads.c     | 142 ----------------------------------------------------------
 xmlmodule.c   | 108 --------------------------------------------
 7 files changed, 1 insertion(+), 391 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eba6be14..b0b13b4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -921,10 +921,6 @@ else
             WITH_THREADS="1"
             THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
             ;;
-        *beos*)
-            WITH_THREADS="1"
-           THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_BEOS_THREADS"
-            ;;
         *)
             dnl Use pthread by default in other cases
             _libs=$LIBS
diff --git a/nanoftp.c b/nanoftp.c
index aaae2164..44bc2a0c 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -75,16 +75,8 @@
  * A couple portability macros
  */
 #ifndef _WINSOCKAPI_
-#if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
-#endif
-
-#ifdef __BEOS__
-#ifndef PF_INET
-#define PF_INET AF_INET
-#endif
-#endif
 
 #ifdef _AIX
 #ifdef HAVE_BROKEN_SS_FAMILY
diff --git a/nanohttp.c b/nanohttp.c
index cc392b97..45d15eeb 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -76,19 +76,11 @@
  * A couple portability macros
  */
 #ifndef _WINSOCKAPI_
-#if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
-#endif
 #define SOCKET int
 #define INVALID_SOCKET (-1)
 #endif
 
-#ifdef __BEOS__
-#ifndef PF_INET
-#define PF_INET AF_INET
-#endif
-#endif
-
 #ifndef XML_SOCKLEN_T
 #define XML_SOCKLEN_T unsigned int
 #endif
@@ -890,15 +882,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
         status = ioctl(s, FIONBIO, &enable);
     }
 #else /* VMS */
-#if defined(__BEOS__) && !defined(__HAIKU__)
-    {
-        bool noblock = true;
-
-        status =
-            setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock,
-                       sizeof(noblock));
-    }
-#else /* __BEOS__ */
     if ((status = fcntl(s, F_GETFL, 0)) != -1) {
 #ifdef O_NONBLOCK
         status |= O_NONBLOCK;
@@ -917,7 +900,6 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
         closesocket(s);
         return INVALID_SOCKET;
     }
-#endif /* !__BEOS__ */
 #endif /* !VMS */
 #endif /* !_WINSOCKAPI_ */
 
diff --git a/runtest.c b/runtest.c
index 46a56ad4..791d624d 100644
--- a/runtest.c
+++ b/runtest.c
@@ -4175,58 +4175,6 @@ testThread(void)
     return (res);
 }
 
-#elif defined __BEOS__
-#include <OS.h>
-
-static thread_id tid[MAX_ARGC];
-
-static int
-testThread(void)
-{
-    unsigned int i, repeat;
-    status_t ret;
-    int res = 0;
-
-    xmlInitParser();
-    for (repeat = 0; repeat < 500; repeat++) {
-        xmlLoadCatalog(catalog);
-        for (i = 0; i < num_threads; i++) {
-            tid[i] = (thread_id) - 1;
-        }
-        for (i = 0; i < num_threads; i++) {
-            tid[i] =
-                spawn_thread(thread_specific_data, "xmlTestThread",
-                             B_NORMAL_PRIORITY, (void *) &threadParams[i]);
-            if (tid[i] < B_OK) {
-                fprintf(stderr, "beos_thread_create failed\n");
-                return (1);
-            }
-            printf("beos_thread_create %d -> %d\n", i, tid[i]);
-        }
-        for (i = 0; i < num_threads; i++) {
-            void *result;
-            ret = wait_for_thread(tid[i], &result);
-            printf("beos_thread_wait %d -> %d\n", i, ret);
-            if (ret != B_OK) {
-                fprintf(stderr, "beos_thread_wait failed\n");
-                return (1);
-            }
-        }
-
-        xmlCatalogCleanup();
-        ret = B_OK;
-        for (i = 0; i < num_threads; i++)
-            if (threadParams[i].okay == 0) {
-                printf("Thread %d handling %s failed\n", i,
-                       threadParams[i].filename);
-                ret = B_ERROR;
-            }
-    }
-    if (ret != B_OK)
-        return(1);
-    return (0);
-}
-
 #elif defined HAVE_PTHREAD_H
 #include <pthread.h>
 
diff --git a/testThreads.c b/testThreads.c
index bef65377..01dc5883 100644
--- a/testThreads.c
+++ b/testThreads.c
@@ -12,8 +12,6 @@
 #include <pthread.h>
 #elif defined HAVE_WIN32_THREADS
 #include <windows.h>
-#elif defined HAVE_BEOS_THREADS
-#include <OS.h>
 #endif
 #include <string.h>
 #if !defined(_MSC_VER)
@@ -27,8 +25,6 @@
 static pthread_t tid[MAX_ARGC];
 #elif defined HAVE_WIN32_THREADS
 static HANDLE tid[MAX_ARGC];
-#elif defined HAVE_BEOS_THREADS
-static thread_id tid[MAX_ARGC];
 #endif
 
 typedef struct {
@@ -209,61 +205,7 @@ main(void)
 
     return (0);
 }
-#elif defined HAVE_BEOS_THREADS
-int
-main(void)
-{
-    unsigned int i, repeat;
-    status_t ret;
-
-    xmlInitParser();
-    printf("Parser initialized\n");
-    for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) {
-    printf("repeat: %d\n",repeat);
-       xmlLoadCatalog(catalog);
-       printf("loaded catalog: %s\n", catalog);
-       for (i = 0; i < num_threads; i++) {
-           tid[i] = (thread_id) -1;
-       }
-       printf("cleaned threads\n");
-       for (i = 0; i < num_threads; i++) {
-               tid[i] = spawn_thread(thread_specific_data, "xmlTestThread", B_NORMAL_PRIORITY, (void *) 
&threadParams[i]);
-               if (tid[i] < B_OK) {
-                       perror("beos_thread_create");
-                       exit(1);
-               }
-               printf("beos_thread_create %d -> %d\n", i, tid[i]);
-       }
-       for (i = 0; i < num_threads; i++) {
-            void *result;
-           ret = wait_for_thread(tid[i], &result);
-           printf("beos_thread_wait %d -> %d\n", i, ret);
-           if (ret != B_OK) {
-                       perror("beos_thread_wait");
-                       exit(1);
-           }
-       }
-
-       xmlCatalogCleanup();
-       ret = B_OK;
-       for (i = 0; i < num_threads; i++)
-           if (threadParams[i].okay == 0) {
-                       printf("Thread %d handling %s failed\n", i,
-                               threadParams[i].filename);
-                       ret = B_ERROR;
-               }
-    }
-    xmlCleanupParser();
-    xmlMemoryDump();
-
-       if (ret == B_OK)
-               printf("testThread : BeOS : SUCCESS!\n");
-       else
-               printf("testThread : BeOS : FAILED!\n");
-
-    return (0);
-}
-#endif /* pthreads or BeOS threads */
+#endif /* pthreads */
 
 #else /* !LIBXML_THREADS_ENABLED */
 int
diff --git a/threads.c b/threads.c
index 6a856608..ab91f5f3 100644
--- a/threads.c
+++ b/threads.c
@@ -26,11 +26,6 @@
 #endif
 #endif
 
-#ifdef HAVE_BEOS_THREADS
-#include <OS.h>
-#include <TLS.h>
-#endif
-
 #if defined(SOLARIS)
 #include <note.h>
 #endif
@@ -88,9 +83,6 @@ struct _xmlMutex {
     pthread_mutex_t lock;
 #elif defined HAVE_WIN32_THREADS
     CRITICAL_SECTION cs;
-#elif defined HAVE_BEOS_THREADS
-    sem_id sem;
-    thread_id tid;
 #else
     int empty;
 #endif
@@ -108,10 +100,6 @@ struct _xmlRMutex {
     pthread_cond_t cv;
 #elif defined HAVE_WIN32_THREADS
     CRITICAL_SECTION cs;
-#elif defined HAVE_BEOS_THREADS
-    xmlMutexPtr lock;
-    thread_id tid;
-    int32 count;
 #else
     int empty;
 #endif
@@ -142,14 +130,6 @@ static struct {
     LONG control;
 } run_once = { 0, 0};
 static volatile LPCRITICAL_SECTION global_init_lock = NULL;
-
-/* endif HAVE_WIN32_THREADS */
-#elif defined HAVE_BEOS_THREADS
-int32 globalkey = 0;
-thread_id mainthread = 0;
-int32 run_once_init = 0;
-static int32 global_init_lock = -1;
-static vint32 global_init_count = 0;
 #endif
 
 static xmlRMutexPtr xmlLibraryLock = NULL;
@@ -178,12 +158,6 @@ xmlNewMutex(void)
         pthread_mutex_init(&tok->lock, NULL);
 #elif defined HAVE_WIN32_THREADS
     InitializeCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
-        free(tok);
-        return NULL;
-    }
-    tok->tid = -1;
 #endif
     return (tok);
 }
@@ -206,8 +180,6 @@ xmlFreeMutex(xmlMutexPtr tok)
         pthread_mutex_destroy(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     DeleteCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    delete_sem(tok->sem);
 #endif
     free(tok);
 }
@@ -228,14 +200,6 @@ xmlMutexLock(xmlMutexPtr tok)
         pthread_mutex_lock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (acquire_sem(tok->sem) != B_NO_ERROR) {
-#ifdef DEBUG_THREADS
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlMutexLock():BeOS:Couldn't acquire semaphore\n");
-#endif
-    }
-    tok->tid = find_thread(NULL);
 #endif
 
 }
@@ -256,11 +220,6 @@ xmlMutexUnlock(xmlMutexPtr tok)
         pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     LeaveCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (tok->tid == find_thread(NULL)) {
-        tok->tid = -1;
-        release_sem(tok->sem);
-    }
 #endif
 }
 
@@ -290,12 +249,6 @@ xmlNewRMutex(void)
     }
 #elif defined HAVE_WIN32_THREADS
     InitializeCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if ((tok->lock = xmlNewMutex()) == NULL) {
-        free(tok);
-        return NULL;
-    }
-    tok->count = 0;
 #endif
     return (tok);
 }
@@ -319,8 +272,6 @@ xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
     }
 #elif defined HAVE_WIN32_THREADS
     DeleteCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    xmlFreeMutex(tok->lock);
 #endif
     free(tok);
 }
@@ -358,14 +309,6 @@ xmlRMutexLock(xmlRMutexPtr tok)
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     EnterCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (tok->lock->tid == find_thread(NULL)) {
-        tok->count++;
-        return;
-    } else {
-        xmlMutexLock(tok->lock);
-        tok->count = 1;
-    }
 #endif
 }
 
@@ -394,14 +337,6 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
     pthread_mutex_unlock(&tok->lock);
 #elif defined HAVE_WIN32_THREADS
     LeaveCriticalSection(&tok->cs);
-#elif defined HAVE_BEOS_THREADS
-    if (tok->lock->tid == find_thread(NULL)) {
-        tok->count--;
-        if (tok->count == 0) {
-            xmlMutexUnlock(tok->lock);
-        }
-        return;
-    }
 #endif
 }
 
@@ -455,34 +390,6 @@ __xmlGlobalInitMutexLock(void)
 
     /* Lock the chosen critical section */
     EnterCriticalSection(global_init_lock);
-#elif defined HAVE_BEOS_THREADS
-    int32 sem;
-
-    /* Allocate a new semaphore */
-    sem = create_sem(1, "xmlGlobalinitMutex");
-
-    while (global_init_lock == -1) {
-        if (atomic_add(&global_init_count, 1) == 0) {
-            global_init_lock = sem;
-        } else {
-            snooze(1);
-            atomic_add(&global_init_count, -1);
-        }
-    }
-
-    /* If another thread successfully recorded its critical
-     * section in the global_init_lock then discard the one
-     * allocated by this thread. */
-    if (global_init_lock != sem)
-        delete_sem(sem);
-
-    /* Acquire the chosen semaphore */
-    if (acquire_sem(global_init_lock) != B_NO_ERROR) {
-#ifdef DEBUG_THREADS
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n");
-#endif
-    }
 #endif
 }
 
@@ -499,8 +406,6 @@ __xmlGlobalInitMutexUnlock(void)
     if (global_init_lock != NULL) {
        LeaveCriticalSection(global_init_lock);
     }
-#elif defined HAVE_BEOS_THREADS
-    release_sem(global_init_lock);
 #endif
 }
 
@@ -613,24 +518,6 @@ static CRITICAL_SECTION cleanup_helpers_cs;
 #endif /* HAVE_COMPILER_TLS */
 #endif /* HAVE_WIN32_THREADS */
 
-#if defined HAVE_BEOS_THREADS
-
-/**
- * xmlGlobalStateCleanup:
- * @data: unused parameter
- *
- * Used for Beos only
- */
-void
-xmlGlobalStateCleanup(void *data)
-{
-    void *globalval = tls_get(globalkey);
-
-    if (globalval != NULL)
-        xmlFreeGlobalState(globalval);
-}
-#endif
-
 /**
  * xmlGetGlobalState:
  *
@@ -713,21 +600,6 @@ xmlGetGlobalState(void)
     }
     return (globalval);
 #endif /* HAVE_COMPILER_TLS */
-#elif defined HAVE_BEOS_THREADS
-    xmlGlobalState *globalval;
-
-    xmlOnceInit();
-
-    if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) {
-        xmlGlobalState *tsd = xmlNewGlobalState();
-       if (tsd == NULL)
-           return (NULL);
-
-        tls_set(globalkey, tsd);
-        on_exit_thread(xmlGlobalStateCleanup, NULL);
-        return (tsd);
-    }
-    return (globalval);
 #else
     return (NULL);
 #endif
@@ -763,8 +635,6 @@ xmlGetThreadId(void)
     return (ret);
 #elif defined HAVE_WIN32_THREADS
     return GetCurrentThreadId();
-#elif defined HAVE_BEOS_THREADS
-    return find_thread(NULL);
 #else
     return ((int) 0);
 #endif
@@ -788,8 +658,6 @@ xmlIsMainThread(void)
     pthread_once(&once_control, xmlOnceInit);
 #elif defined HAVE_WIN32_THREADS
     xmlOnceInit();
-#elif defined HAVE_BEOS_THREADS
-    xmlOnceInit();
 #endif
 
 #ifdef DEBUG_THREADS
@@ -799,8 +667,6 @@ xmlIsMainThread(void)
     return (pthread_equal(mainthread,pthread_self()));
 #elif defined HAVE_WIN32_THREADS
     return (mainthread == GetCurrentThreadId());
-#elif defined HAVE_BEOS_THREADS
-    return (mainthread == find_thread(NULL));
 #else
     return (1);
 #endif
@@ -975,14 +841,6 @@ xmlOnceInit(void)
                 Sleep(0);
         }
     }
-#elif defined HAVE_BEOS_THREADS
-    if (atomic_add(&run_once_init, 1) == 0) {
-        globalkey = tls_allocate();
-        tls_set(globalkey, NULL);
-        mainthread = find_thread(NULL);
-       __xmlInitializeDict();
-    } else
-        atomic_add(&run_once_init, -1);
 #endif
 }
 #endif
diff --git a/xmlmodule.c b/xmlmodule.c
index 8d6ea8dc..af47514b 100644
--- a/xmlmodule.c
+++ b/xmlmodule.c
@@ -350,112 +350,4 @@ XML_POP_WARNINGS
 
 #endif /* _WIN32 */
 
-#ifdef HAVE_BEOS
-
-#include <kernel/image.h>
-
-/*
- * xmlModulePlatformOpen:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns a handle on success, and zero on error.
- */
-
-static void *
-xmlModulePlatformOpen(const char *name)
-{
-    return (void *) load_add_on(name);
-}
-
-/*
- * xmlModulePlatformClose:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns 0 on success, and non-zero on error.
- */
-
-static int
-xmlModulePlatformClose(void *handle)
-{
-    status_t rc;
-
-    rc = unload_add_on((image_id) handle);
-
-    if (rc == B_OK)
-        return 0;
-    else
-        return -1;
-}
-
-/*
- * xmlModulePlatformSymbol:
- * beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
- * returns 0 on success and the loaded symbol in result, and -1 on error.
- */
-
-static int
-xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
-{
-    status_t rc;
-
-    rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY, symbol);
-
-    return (rc == B_OK) ? 0 : -1;
-}
-
-#endif /* HAVE_BEOS */
-
-#ifdef HAVE_OS2
-
-#include <os2.h>
-
-/*
- * xmlModulePlatformOpen:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosLoadModule.html
- * returns a handle on success, and zero on error.
- */
-
-static void *
-xmlModulePlatformOpen(const char *name)
-{
-    char errbuf[256];
-    void *handle;
-    int rc;
-
-    rc = DosLoadModule(errbuf, sizeof(errbuf) - 1, name, &handle);
-
-    if (rc)
-        return 0;
-    else
-        return (handle);
-}
-
-/*
- * xmlModulePlatformClose:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosFreeModule.html
- * returns 0 on success, and non-zero on error.
- */
-
-static int
-xmlModulePlatformClose(void *handle)
-{
-    return DosFreeModule(handle);
-}
-
-/*
- * xmlModulePlatformSymbol:
- * os2 api info: http://www.edm2.com/os2api/Dos/DosQueryProcAddr.html
- * returns 0 on success and the loaded symbol in result, and -1 on error.
- */
-
-static int
-xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
-{
-    int rc;
-
-    rc = DosQueryProcAddr(handle, 0, name, symbol);
-
-    return (rc == NO_ERROR) ? 0 : -1;
-}
-
-#endif /* HAVE_OS2 */
-
 #endif /* LIBXML_MODULES_ENABLED */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]