New diff that now covers the entire tree. Applying this gets postgresql
authorBruce Momjian <bruce@momjian.us>
Tue, 3 Oct 2000 03:11:26 +0000 (03:11 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 3 Oct 2000 03:11:26 +0000 (03:11 +0000)
working on the VERY latest version of BeOS.  I'm sure there will be
alot of comments, but then if there weren't I'd be disappointed!

Thanks for your continuing efforts to get this into your tree.

Haven't bothered with the new files as they haven't changed.

BTW Peter, the compiler is "broken" about the bool define and so on.
I'm filing a bug report to try and get it addressed.  Hopefully then we
can tidy up the code a bit.

I await the replies with interest :)

David Reid

18 files changed:
configure.in
src/backend/commands/async.c
src/backend/libpq/pqcomm.c
src/backend/libpq/pqpacket.c
src/backend/main/main.c
src/backend/postmaster/postmaster.c
src/backend/storage/ipc/ipc.c
src/backend/storage/lmgr/proc.c
src/backend/tcop/postgres.c
src/backend/utils/adt/pg_lzcompress.c
src/backend/utils/error/elog.c
src/backend/utils/error/exc.c
src/include/c.h
src/include/config.h.in
src/include/port/beos.h
src/include/storage/ipc.h
src/interfaces/libpq/fe-connect.c
src/template/beos

index 798f6728a62bd24c056a389b67f35f2c7b91c5f7..51230d9e22062318af60b053be56074be94fee5c 100644 (file)
@@ -660,7 +660,7 @@ fi
 ## Header files
 ##
 dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
-AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h netinet/tcp.h pwd.h sys/ipc.h sys/pstat.h sys/select.h sys/socket.h sys/types.h sys/un.h termios.h])
+AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h netinet/tcp.h pwd.h sys/pstat.h sys/select.h sys/socket.h sys/types.h sys/un.h termios.h])
 
 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
 AC_CHECK_HEADERS([readline/history.h history.h], [break])
index 10e3d3f560dcd4692a86608d42df464bafb1ba64..10991ff97ce0a4843862122088eb4ce9932b22e8 100644 (file)
@@ -496,7 +496,6 @@ AtCommit_Notify()
                                 */
                                if (kill(listenerPID, SIGUSR2) < 0)
                                {
-
                                        /*
                                         * Get rid of pg_listener entry if it refers to a PID
                                         * that no longer exists.  Presumably, that backend
index b616f704552d0ecdf49fb38767ddfb1934f2461f..ba154204d7b06568fac598a9be48b07c55bfe78d 100644 (file)
@@ -208,11 +208,16 @@ StreamServerPort(int family, unsigned short portName, int *fdP)
 
        MemSet((char *) &saddr, 0, sizeof(saddr));
        saddr.sa.sa_family = family;
+
+/* I know this isn't a good way of testing, but until we have a 
+ * define for this it'll do!
+ * we have Unix sockets... 
+ */
+#ifdef HAVE_SYS_UN_H 
        if (family == AF_UNIX)
        {
                len = UNIXSOCK_PATH(saddr.un, portName);
                strcpy(sock_path, saddr.un.sun_path);
-
                /*
                 * If the socket exists but nobody has an advisory lock on it we
                 * can safely delete the file.
@@ -231,13 +236,16 @@ StreamServerPort(int family, unsigned short portName, int *fdP)
                }
 #endif  /* HAVE_FCNTL_SETLK */
        }
-       else
-       {
+#endif /* HAVE_SYS_UN_H */
+
+    if (family == AF_INET) 
+    {
                saddr.in.sin_addr.s_addr = htonl(INADDR_ANY);
                saddr.in.sin_port = htons(portName);
                len = sizeof(struct sockaddr_in);
        }
-       err = bind(fd, &saddr.sa, len);
+
+       err = bind(fd, (struct sockaddr *)&saddr.sa, len);
        if (err < 0)
        {
                snprintf(PQerrormsg, PQERRORMSG_LENGTH,
@@ -258,6 +266,7 @@ StreamServerPort(int family, unsigned short portName, int *fdP)
                return STATUS_ERROR;
        }
 
+#ifdef HAVE_SYS_UN_H /* yeah I know... */
        if (family == AF_UNIX)
        {
                on_proc_exit(StreamDoUnlink, 0);
@@ -279,6 +288,7 @@ StreamServerPort(int family, unsigned short portName, int *fdP)
                }
 #endif  /* HAVE_FCNTL_SETLK */
        }
+#endif /* HAVE_SYS_UN_H */
 
        listen(fd, SOMAXCONN);
 
index ee6cdd00264bce865fbb3b0e11b6b3f188ca644d..e04839d7eedd795e87053e7d26a6e58c2eac19db 100644 (file)
@@ -61,7 +61,11 @@ PacketReceiveFragment(Port *port)
                got = SSL_read(port->ssl, pkt->ptr, pkt->nrtodo);
        else
 #endif
+#ifndef __BEOS__
                got = read(port->sock, pkt->ptr, pkt->nrtodo);
+#else
+        got = recv(port->sock, pkt->ptr, pkt->nrtodo, 0);
+#endif /* __BEOS__ */
        if (got > 0)
        {
                pkt->nrtodo -= got;
@@ -150,8 +154,11 @@ PacketSendFragment(Port *port)
                done = SSL_write(port->ssl, pkt->ptr, pkt->nrtodo);
        else
 #endif
+#ifndef __BEOS__
                done = write(port->sock, pkt->ptr, pkt->nrtodo);
-
+#else
+               done = send(port->sock, pkt->ptr, pkt->nrtodo, 0);
+#endif
        if (done > 0)
        {
                pkt->nrtodo -= done;
index 89fcf3258b4e1cf336065cfe8302fe4b32270e4c..174d079f3fdfdecc0ff45688e76775f09ab7ac0b 100644 (file)
@@ -85,11 +85,18 @@ main(int argc, char *argv[])
         */
        len = strlen(argv[0]);
 
-       if (!geteuid())
+/* OK this is going to seem weird, but BeOS is presently basically
+ * a single user system.  There is work going on, but at present it'll
+ * say that every user is uid 0, i.e. root.  We'll inhibit this check
+ * until Be get the system working with multiple users!!
+ */
+#ifndef __BEOS__
+if (!geteuid())
        {
                fprintf(stderr, "%s", NOROOTEXEC);
                exit(1);
        }
+#endif /* __BEOS__ */
 
        if (len >= 10 && !strcmp(argv[0] + len - 10, "postmaster"))
                exit(PostmasterMain(argc, argv));
index bbe840287939df8fb026d0aa5ff7ba5381e5a4ae..d01eaded1c07da2b0e75a6c01fd097f88e522327 100644 (file)
@@ -818,13 +818,12 @@ ServerLoop(void)
                if (select(nSockets, &rmask, &wmask, (fd_set *) NULL,
                                   (struct timeval *) NULL) < 0)
                {
-                       if (errno == EINTR)
+                       if (errno == EINTR || errno == EWOULDBLOCK)
                                continue;
                        fprintf(stderr, "%s: ServerLoop: select failed: %s\n",
                                        progname, strerror(errno));
                        return STATUS_ERROR;
                }
-
                /*
                 * Select a random seed at the time of first receiving a request.
                 */
@@ -1021,7 +1020,6 @@ initMasks(fd_set *rmask, fd_set *wmask)
        if (ServerSock_INET != INVALID_SOCK)
        {
                FD_SET(ServerSock_INET, rmask);
-
                if (ServerSock_INET > nsocks)
                        nsocks = ServerSock_INET;
        }
index eb8c35861e077bed462a5a0391951aec461046fa..5a1fc62a0d446200ec01975530ce32e3febccafc 100644 (file)
 #include "storage/ipc.h"
 #include "storage/s_lock.h"
 /* In Ultrix, sem.h and shm.h must be included AFTER ipc.h */
+#ifdef HAVE_SYS_SEM_H
 #include <sys/sem.h>
+#endif
+#ifdef HAVE_SYS_SHM_H
 #include <sys/shm.h>
+#endif
+#ifdef HAVE_KERNEL_OS_H
+#include <kernel/OS.h>
+#endif
 #include "miscadmin.h"
 #include "utils/memutils.h"
 #include "libpq/libpq.h"
@@ -236,12 +243,17 @@ on_exit_reset(void)
 static void
 IPCPrivateSemaphoreKill(int status, int semId)
 {
+/* BeOS has a native sempahore type... */
+#ifndef __BEOS__
        union semun semun;
        semun.val = 0;          /* unused */
 
        if (semctl(semId, 0, IPC_RMID, semun) == -1)
                elog(NOTICE, "IPCPrivateSemaphoreKill: semctl(%d, 0, IPC_RMID, ...) failed: %s",
                         semId, strerror(errno));
+#else  /* __BEOS__ */
+    delete_sem(semId);
+#endif /* __BEOS__ */
 }
 
 
@@ -258,12 +270,19 @@ IPCPrivateMemoryKill(int status, int shmId)
        }
        else
        {
+#ifndef __BEOS__
                if (shmctl(shmId, IPC_RMID, (struct shmid_ds *) NULL) < 0)
-               {
-                       elog(NOTICE, "IPCPrivateMemoryKill: shmctl(id=%d, IPC_RMID, NULL) failed: %m",
-                                shmId);
-               }
-       }
+               {
+                       elog(NOTICE, "IPCPrivateMemoryKill: shmctl(%d, %d, 0) failed: %m",
+                                shmId, IPC_RMID);
+               }
+#else
+        if (delete_area(shmId) != B_OK)
+        {
+            elog(NOTICE, "IPCPrivateMemoryKill: delete_area(%d) failed", shmId);
+        }
+#endif /* __BEOS__ */
+    }
 }
 
 /*
@@ -284,9 +303,10 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
                                   int semStartValue,
                                   int removeOnExit)
 {
+       int                     semId;
+#ifndef __BEOS__
        int                     i;
        int                     errStatus;
-       int                     semId;
        u_short         array[IPC_NMAXSEM];
        union semun semun;
 
@@ -302,6 +322,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
                fprintf(stderr, "calling semget(%d, %d, 0%o)\n",
                        semKey, semNum, (unsigned)(IPC_CREAT|permission));
 #endif
+
                semId = semget(semKey, semNum, IPC_CREAT | permission);
 
                if (semId < 0)
@@ -341,9 +362,25 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
                }
 
                if (removeOnExit)
-                       on_shmem_exit(IPCPrivateSemaphoreKill, (Datum)semId);
+                       on_shmem_exit(IPCPrivateSemaphoreKill, (Datum) semId);
+       }
+
+
+#else /* BeOS implementation */
+    char semname[32];
+    sprintf (semname, "pgsql_ipc:%ld", semKey);
+    semId = create_sem(1, semname);
+    if (semId < 0) {
+                       fprintf(stderr, "IpcSemaphoreCreate: create_sem(1, %s) failed: %s\n",
+                                       semname, strerror(errno));
+                       return (-1);
        }
 
+       if (removeOnExit)
+               on_shmem_exit(IPCPrivateSemaphoreKill, (caddr_t) semId);
+
+#endif
+
 #ifdef DEBUG_IPC
        fprintf(stderr, "IpcSemaphoreCreate returns %d\n", semId);
        fflush(stdout);
@@ -387,6 +424,7 @@ void
 IpcSemaphoreKill(IpcSemaphoreKey key)
 {
        int                     semId;
+#ifndef __BEOS__ 
        union semun semun;
        semun.val = 0;          /* unused */
 
@@ -395,6 +433,23 @@ IpcSemaphoreKill(IpcSemaphoreKey key)
        semId = semget(key, 0, 0);
        if (semId != -1)
                semctl(semId, 0, IPC_RMID, semun);
+#else
+/* first find the semId by looking at sempahore names... */
+    sem_info si;
+    int32 cookie = 0;
+    char semname[32];
+    sprintf(semname, "pgsql_ipc:%ld", key);
+    
+    semId = -1;
+    while (get_next_sem_info(0, &cookie, &si) == B_OK) {
+        if (strcmp(si.name, semname) == 0){
+            semId = si.sem;
+            break;
+        }
+    }
+    if (semId != -1)
+        delete_sem(semId);
+#endif
 }
 
 /****************************************************************************/
@@ -407,6 +462,7 @@ static int  IpcSemaphoreLock_return;
 void
 IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
 {
+#ifndef __BEOS__
        extern int      errno;
        int                     errStatus;
        struct sembuf sops;
@@ -439,6 +495,13 @@ IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
                                semId, strerror(errno));
                proc_exit(255);
        }
+#else
+    if ((IpcSemaphoreLock_return = acquire_sem(semId)) != B_NO_ERROR) {
+        fprintf(stderr, "IpcSempahoreLock: acquire_sem failed on sem_id %d: %s\n",
+            semId, strerror(errno));
+        proc_exit(255);
+    }
+#endif
 }
 
 /****************************************************************************/
@@ -451,6 +514,7 @@ static int  IpcSemaphoreUnlock_return;
 void
 IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
 {
+#ifndef __BEOS__
        extern int      errno;
        int                     errStatus;
        struct sembuf sops;
@@ -484,28 +548,49 @@ IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
                                semId, strerror(errno));
                proc_exit(255);
        }
+#else
+    if ((IpcSemaphoreUnlock_return = release_sem(semId)) != B_NO_ERROR) {
+        fprintf(stderr, "IpcSempahoreUnlock: release_sem failed on sem_id %d: %s\n",
+            semId, strerror(errno));
+        proc_exit(255);
+    }
+#endif
 }
 
 int
 IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem)
 {
+#ifndef __BEOS__
        int                     semncnt;
        union semun dummy;                      /* for Solaris */
        dummy.val = 0;          /* unused */
 
        semncnt = semctl(semId, sem, GETNCNT, dummy);
        return semncnt;
+#else
+    sem_info si;
+    
+    get_sem_info(semId, &si);
+    return si.count;
+#endif /* __BEOS__ */
 }
 
 int
 IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem)
 {
+#ifndef __BEOS__
        int                     semval;
        union semun dummy;                      /* for Solaris */
        dummy.val = 0;          /* unused */
 
        semval = semctl(semId, sem, GETVAL, dummy);
        return semval;
+#else
+    sem_info si;
+    
+    get_sem_info(semId, &si);
+    return si.count;
+#endif /* __BEOS__ */
 }
 
 /****************************************************************************/
@@ -526,6 +611,8 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
                shmid = PrivateMemoryCreate(memKey, size);
        }
        else
+#ifndef __BEOS__
+
                shmid = shmget(memKey, size, IPC_CREAT | permission);
 
        if (shmid < 0)
@@ -562,6 +649,25 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
                return IpcMemCreationFailed;
        }
 
+#else
+
+    {
+        char *addr;
+        uint32 pages = ((size - 1) / B_PAGE_SIZE) +1;
+        char areaname[32];
+        sprintf (areaname, "pgsql_ipc%ld", memKey);
+        
+        shmid = create_area(areaname, (void*)&addr, B_ANY_ADDRESS, pages * B_PAGE_SIZE,
+            B_NO_LOCK, B_READ_AREA|B_WRITE_AREA);   
+    }
+
+    if (shmid < 0) {
+        fprintf(stderr, "IpcMemoryCreate: failed: %s\n",
+            strerror(errno));
+        return IpcMemCreationFailed;
+    }
+#endif /* __BEOS__ */
+
        /* if (memKey == PrivateIPCKey) */
        on_shmem_exit(IPCPrivateMemoryKill, (Datum) shmid);
 
@@ -577,6 +683,7 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
 {
        IpcMemoryId shmid;
 
+#ifndef __BEOS__
        shmid = shmget(memKey, size, 0);
 
        if (shmid < 0)
@@ -585,6 +692,17 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
                                memKey, size, strerror(errno));
                return IpcMemIdGetFailed;
        }
+#else
+    char areaname[32];
+    sprintf(areaname, "pgsql_ipc%ld", memKey);
+    shmid = find_area(areaname);
+    
+    if (shmid == B_NAME_NOT_FOUND){
+        fprintf(stderr, "IpcMemoryIdGet: find_area(%s) failed: %s\n",
+            areaname, strerror(errno));
+        return IpcMemIdGetFailed;
+    }
+#endif /* __BEOS__ */
 
        return shmid;
 }
@@ -597,8 +715,10 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
 static void
 IpcMemoryDetach(int status, char *shmaddr)
 {
+#ifndef __BEOS__
        if (shmdt(shmaddr) < 0)
                elog(NOTICE, "IpcMemoryDetach: shmdt(0x%p) failed: %m", shmaddr);
+#endif
 }
 
 /****************************************************************************/
@@ -613,6 +733,7 @@ IpcMemoryAttach(IpcMemoryId memId)
 {
        char       *memAddress;
 
+#ifndef __BEOS__
        if (UsePrivateMemory)
                memAddress = (char *) PrivateMemoryAttach(memId);
        else
@@ -625,6 +746,23 @@ IpcMemoryAttach(IpcMemoryId memId)
                                memId, strerror(errno));
                return IpcMemAttachFailed;
        }
+#else
+    
+       if (UsePrivateMemory)
+               memAddress = (char *) PrivateMemoryAttach(memId);
+       else
+    {
+        area_info ai;
+        get_area_info(memId, &ai);
+        memAddress = (char *)ai.address;
+    }
+    
+    if (memAddress == (char *)-1) {
+        fprintf(stderr,"IpcMemoryAttach: failed to get area address (%d): %s\n",
+            memId, strerror(errno));
+        return IpcMemAttachFailed;
+    }
+#endif /* __BEOS__ */
 
        if (!UsePrivateMemory)
                on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddress));
@@ -642,6 +780,7 @@ IpcMemoryKill(IpcMemoryKey memKey)
 {
        IpcMemoryId shmid;
 
+#ifndef __BEOS__
        if (!UsePrivateMemory && (shmid = shmget(memKey, 0, 0)) >= 0)
        {
                if (shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL) < 0)
@@ -650,6 +789,15 @@ IpcMemoryKill(IpcMemoryKey memKey)
                                 shmid, IPC_RMID);
                }
        }
+#else
+    char areaname[32];
+    sprintf(areaname, "pgsql_ipc%ld", memKey);
+    shmid = find_area(areaname);
+    if (!UsePrivateMemory && shmid > 0) {
+        if (delete_area(shmid) != B_OK)
+            elog(NOTICE, "IpcMemoryKill: deleta_area(%d) failed!", shmid);
+    }
+#endif /* __BEOS__ */
 }
 
 #ifdef HAS_TEST_AND_SET
index c931c37648ae9e5f84ac7331cfb6012d6a218bb4..1fd0cc357435e75c0c125175a3524eb138d5aa4a 100644 (file)
@@ -65,7 +65,9 @@
 
 
 /* In Ultrix and QNX, sem.h must be included after ipc.h */
+#ifdef HAVE_SYS_SEM_H
 #include <sys/sem.h>
+#endif
 
 #include "storage/proc.h"
 
@@ -264,8 +266,10 @@ InitProcess(IPCKey key)
                 * we might be reusing a semaphore that belongs to a dead backend.
                 * So be careful and reinitialize its value here.
                 */
+#ifndef __BEOS__
                semun.val = IpcSemaphoreDefaultStartValue;
                semctl(semId, semNum, SETVAL, semun);
+#endif
 
                IpcSemaphoreLock(semId, semNum, IpcExclusiveLock);
                MyProc->sem.semId = semId;
@@ -515,7 +519,9 @@ SetWaitingForLock(bool waiting)
 void
 LockWaitCancel(void)
 {
-       struct itimerval timeval,
+/* BeOS doesn't have setitimer, but has set_alarm */
+#ifndef __BEOS__       
+struct itimerval timeval,
                                dummy;
 
        if (!lockWaiting)
@@ -524,6 +530,14 @@ LockWaitCancel(void)
        /* Deadlock timer off */
        MemSet(&timeval, 0, sizeof(struct itimerval));
        setitimer(ITIMER_REAL, &timeval, &dummy);
+#else
+       if (!lockWaiting)
+               return;
+       lockWaiting = false;
+       /* Deadlock timer off */
+    set_alarm(B_INFINITE_TIMEOUT, B_PERIODIC_ALARM);
+#endif /* __BEOS__ */
+        
        if (GetOffWaitqueue(MyProc))
                elog(ERROR, "Query cancel requested while waiting lock");
 }
@@ -555,8 +569,12 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
        bool            selfConflict = (lockctl->conflictTab[token] & myMask),
                                prevSame = false;
        bool            deadlock_checked = false;
+#ifndef __BEOS__
        struct itimerval timeval,
                                dummy;
+#else
+    bigtime_t time_interval;
+#endif
 
        MyProc->token = token;
        MyProc->waitLock = lock;
@@ -635,9 +653,14 @@ ins:;
         * to 0.
         * --------------
         */
+#ifndef __BEOS__
        MemSet(&timeval, 0, sizeof(struct itimerval));
        timeval.it_value.tv_sec = DeadlockTimeout / 1000;
        timeval.it_value.tv_usec = (DeadlockTimeout % 1000) * 1000;
+#else
+    /* usecs */
+    time_interval = DeadlockTimeout * 1000000;
+#endif
 
        SetWaitingForLock(true);
        do
@@ -645,7 +668,11 @@ ins:;
                MyProc->errType = NO_ERROR;             /* reset flag after deadlock check */
 
                if (!deadlock_checked)
+#ifndef __BEOS__
                        if (setitimer(ITIMER_REAL, &timeval, &dummy))
+#else
+            if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
+#endif
                                elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
                deadlock_checked = true;
 
@@ -665,9 +692,13 @@ ins:;
         * We were awoken before a timeout - now disable the timer
         * ---------------
         */
+#ifndef __BEOS__
        timeval.it_value.tv_sec = 0;
        timeval.it_value.tv_usec = 0;
        if (setitimer(ITIMER_REAL, &timeval, &dummy))
+#else
+    if (set_alarm(B_INFINITE_TIMEOUT, B_PERIODIC_ALARM) < 0)
+#endif
                elog(FATAL, "ProcSleep: Unable to diable timer for process wakeup");
 
        /* ----------------
index 5e06521bba764a5b48510421dc132baab8bfed29..62def952b795632624704f1d58b8d3b90bee8c03 100644 (file)
@@ -1397,7 +1397,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
        if (!IsUnderPostmaster)
        {
                puts("\nPOSTGRES backend interactive interface ");
-               puts("$Revision: 1.176 $ $Date: 2000/10/02 19:42:53 $\n");
+               puts("$Revision: 1.177 $ $Date: 2000/10/03 03:11:19 $\n");
        }
 
        /*
@@ -1730,7 +1730,8 @@ ShowUsage(void)
                        (long int) user.tv_usec,
                        (long int) sys.tv_sec,
                        (long int) sys.tv_usec);
-#ifdef HAVE_GETRUSAGE
+/* BeOS has rusage but only has some fields, and not these... */
+#if defined(HAVE_GETRUSAGE) && !defined(__BEOS__)
        fprintf(StatFp,
                        "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
                        r.ru_inblock - Save_r.ru_inblock,
index 69d037b7e843dc59989e1567b6bd87de0da13ef6..82ef958a35857016c82d72b7e48462c9a8815c96 100644 (file)
@@ -474,7 +474,7 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
  * ----------
  */
 int
-pglz_compress(char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
+pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
 {
        int            hist_next = 0;
 
index c30471d74cd15d47f8bece10d3ff670d1181cf0a..2e78e57862ca9320f9710c0b14bc44cc2ff25e61 100644 (file)
@@ -134,6 +134,8 @@ elog(int lev, const char *fmt, ...)
        if (lev <= DEBUG && Debugfile < 0)
                return;                                 /* ignore debug msgs if noplace to send */
 
+/* BeOS doesn't have sys_nerr and should be able to use strerror()... */
+#ifndef __BEOS__
        /* save errno string for %m */
        if (errno < sys_nerr && errno >= 0)
                errorstr = strerror(errno);
@@ -180,6 +182,9 @@ elog(int lev, const char *fmt, ...)
                        prefix = prefix_buf;
                        break;
        }
+#else
+    errorstr = strerror(errno);
+#endif /* __BEOS__ */
 
        timestamp_size = 0;
        if (Log_timestamp)
index 0ee8e1e9cef406e9793ff526acf84d7dc5b80d34..8d4eb8dd9aa3725f936e485bf8f8387093c5c361 100644 (file)
@@ -131,7 +131,11 @@ ExcPrint(Exception *excP,
 
        fprintf(stderr, " (%ld)", detail);
 
+#ifndef __BEOS__
        if (errno > 0 && errno < sys_nerr)
+#else
+    if (errno > 0)
+#endif
                fprintf(stderr, " [%s]", strerror(errno));
        else if (errno != 0)
                fprintf(stderr, " [Error %d]", errno);
index 571142065560d444f2645ed4502cd99d3a43735a..9f4b49dfe025bc5474294f90b2b9d85c98d786cb 100644 (file)
@@ -56,7 +56,7 @@
 #include <errno.h>
 #include <sys/fcntl.h>         /* ensure O_BINARY is available */
 #endif
-#ifdef __BEOS__
+#ifdef HAVE_SUPPORTDEFS_H
 #include <SupportDefs.h>
 #endif
 
  *             Boolean value, either true or false.
  *
  */
-#ifndef __BEOS__
+
+/* BeOS defines bool already, but the compiler chokes on the
+ * #ifndef unless we wrap it in this check.
+ */
+#ifndef __BEOS__ 
 #ifndef __cplusplus
 #ifndef bool
 typedef char bool;
@@ -170,24 +174,22 @@ typedef char *Pointer;
  *             used for numerical computations and the
  *             frontend/backend protocol.
  */
-#ifndef __BEOS__
+#ifndef __BEOS__ /* this shouldn't be required, but is is! */
 typedef signed char int8;              /* == 8 bits */
 typedef signed short int16;            /* == 16 bits */
 typedef signed int int32;              /* == 32 bits */
 #endif /* __BEOS__ */
-
 /*
  * uintN
  *             Unsigned integer, EXACTLY N BITS IN SIZE,
  *             used for numerical computations and the
  *             frontend/backend protocol.
  */
-#ifndef __BEOS__
+#ifndef __BEOS__ /* this shouldn't be required, but is is! */
 typedef unsigned char uint8;   /* == 8 bits */
 typedef unsigned short uint16; /* == 16 bits */
 typedef unsigned int uint32;   /* == 32 bits */
 #endif /* __BEOS__ */
-
 /*
  * floatN
  *             Floating point number, AT LEAST N BITS IN SIZE,
@@ -268,8 +270,7 @@ typedef int32 int4;
 typedef float float4;
 typedef double float8;
 
-/* BeOS already has int64 defined, so skip these... */
-#ifndef BEOS
+#ifndef __BEOS__ /* this is already defined on BeOS */
 #ifdef HAVE_LONG_INT_64
 /* Plain "long int" fits, use it */
 typedef long int int64;
@@ -283,9 +284,7 @@ typedef long int int64;
 #define INT64_IS_BUSTED
 #endif
 #endif
-#else /* Add BeOS support */
-#include <SupportDefs.h>
-#endif /* BEOS */
+#endif /* __BEOS__ */
 
 /* ----------------------------------------------------------------
  *                             Section 4:      datum type + support macros
index 3c0c20ed08c85b9716304cdfb1260cf8438dbbc2..ceedc9cb6962deb22a1f06f5988652857966ae7f 100644 (file)
 /* Set to 1 if you have <readline/readline.h> */
 #undef HAVE_READLINE_READLINE_H
 
-/* Define if you have <sys/ipc.h> */
+/* Set to 1 if you have <sys/ipc.h> */
 #undef HAVE_SYS_IPC_H
 
 /* Set to 1 if  you have <sys/select.h> */
 #undef HAVE_SYS_SELECT_H
 
-/* Set to 1 if  you have <sys/un.h> */
+/* Set to 1 if you have <sys/un.h> */
 #undef HAVE_SYS_UN_H
 
+/* Set to 1 if you have <sys/sem.h> */
+#undef HAVE_SYS_SEM_H
+
+/* Set to 1 if you have <sys/shm.h> */
+#undef HAVE_SYS_SHM_H
+
+/* Set to 1 if you have <kernel/OS.h> */
+#undef HAVE_KERNEL_OS_H
+
+/* Set to 1 if you have <SupportDefs.h> */
+#undef HAVE_SUPPORTDEFS_H
+
+/* Set to 1 if you have <kernel/image.h> */
+#undef HAVE_KERNEL_IMAGE_H
+
 /* Set to 1 if you have <termios.h> */
 #undef HAVE_TERMIOS_H
 
index c7b33efecb9dc2b72d9903d72ac51cae79f5b6a7..401426c5f22d275580ab0d38082c88db0137339a 100644 (file)
@@ -4,7 +4,6 @@
 
 typedef unsigned char slock_t;
 
-#define AF_UNIX     1
-#define IPPROTO_IP  0
+#define AF_UNIX     1 /* no domain sockets on BeOS */
 
 
index f6f9f17b82bfaee9129fae31db31328cb6ca351d..15759e459d8c8e1d6fb9c01b95b14160eef72085 100644 (file)
 #include <sys/types.h>
 #ifdef HAVE_SYS_IPC_H
 #include <sys/ipc.h>                   /* For IPC_PRIVATE */
-#endif
+#else
+/* BeOS doesn't have IPC_PRIVATE so we'll use the value that is set by
+ * FreeBSD (1)
+ */
+#define IPC_PRIVATE 1
+#endif /* HAVE_SYS_IPC_H */
+
+#include "config.h"
 
 #ifndef HAVE_UNION_SEMUN
 union semun
index 68905baaa30413adeb6988d28930a7317eb8e692..0c580cb395d7e299f40d4d1b204995bf997d60a9 100644 (file)
@@ -619,8 +619,11 @@ update_db_info(PGconn *conn)
 static int
 connectMakeNonblocking(PGconn *conn)
 {
-#ifndef WIN32
+#ifdef WIN32
        if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0)
+#elif defined(__BEOS__)
+       int                     on = 1;
+    if (ioctl(conn->sock, FIONBIO, &on) != 0)
 #else
        int                     on = 1;
 
@@ -959,7 +962,6 @@ static int
 connectDBComplete(PGconn *conn)
 {
        PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
-
        if (conn == NULL || conn->status == CONNECTION_BAD)
                return 0;
 
@@ -1039,7 +1041,6 @@ PostgresPollingStatusType
 PQconnectPoll(PGconn *conn)
 {
        PGresult   *res;
-
        if (conn == NULL)
                return PGRES_POLLING_FAILED;
 
index 0a62b51a1e4c9979170d04d46cd356bb0042ccee..d93a6c1e4f390ea82be0b266eb7af33819f66ea5 100644 (file)
@@ -1,6 +1,6 @@
 AROPT:crs
 SHARED_LIB:-fpic -DPIC
-CFLAGS:-O2 -DBEOS
+CFLAGS:-O2
 SRCH_INC:
 SRCH_LIB:
 USE_LOCALE:no