]> granicus.if.org Git - postgresql/commitdiff
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

20 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/port/dynloader/beos.c
src/backend/port/dynloader/beos.h
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 94eb1bb12247d4500e82a943b41e56b0459d35c9..6611f134727b97fb62e1bd2a79ca1f0f4908e94f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.69 2000/10/02 19:42:45 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.70 2000/10/03 03:11:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 8417cd475abd279a0bddebd648d90b96cf138b00..68ee5a03bdef6ec97cf6cf163bb9ef0fae639986 100644 (file)
@@ -29,7 +29,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Id: pqcomm.c,v 1.103 2000/10/02 21:45:31 petere Exp $
+ *     $Id: pqcomm.c,v 1.104 2000/10/03 03:11:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 defc57f69af278b3e890851076182221bafee499..8e51a97f2254dc447fd652a7842f7bc9cc9ddf50 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.26 2000/04/12 17:15:14 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.27 2000/10/03 03:11:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 a20b39886d52cf8435c5708a63f636f5622e5633..7625bf7626ad6f97ed4d859873afe318f66b14c0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.30 2000/09/06 14:15:19 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.31 2000/10/03 03:11:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 c2a6b78845752e458ef75a2c3ccb99cb2af4a505..f1ed5281b6d860cf194180d2ced3fcc0f395ad96 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.1 2000/10/02 17:15:53 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.2 2000/10/03 03:11:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
index 3765ff0629688c692aee861d7a8ad0451fa8a45b..9cc374303420da30ef0a3d773da12921e48426c8 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: beos.h,v 1.1 2000/10/02 17:15:53 momjian Exp $
+ * $Id: beos.h,v 1.2 2000/10/03 03:11:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
index ba5ec51648c67f0df710b01818d2bd7e791bfcbd..99ae61b2b5bb6572c967535ea4d1adf2f2bf6edb 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.167 2000/10/02 19:42:46 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.168 2000/10/03 03:11:16 momjian Exp $
  *
  * NOTES
  *
@@ -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 d0e98cf48b4787ab21f61ed2e7541f684f0700d6..f6e045a2cdc3d584fc2d24cc669d04317e593e87 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.50 2000/10/02 19:42:48 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.51 2000/10/03 03:11:17 momjian Exp $
  *
  * NOTES
  *
 #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 fb5d06fd8b8995feedd0b215ba71d744063d9ac4..1ade4950bec9875692ed6dbabcee57a474526e59 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.81 2000/10/02 21:45:32 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.82 2000/10/03 03:11:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@
  *             This is so that we can support more backends. (system-wide semaphore
  *             sets run out pretty fast.)                                -ay 4/95
  *
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.81 2000/10/02 21:45:32 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.82 2000/10/03 03:11:18 momjian Exp $
  */
 #include "postgres.h"
 
@@ -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 150423faafac97411475cda738e6418fd311d9e7..bddad9e4f6ed754c18cb39fe33b0aec783cdb19e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.176 2000/10/02 19:42:53 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.177 2000/10/03 03:11:19 momjian Exp $
  *
  * NOTES
  *       this is the "main" module of the postgres backend and
@@ -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 9360c60dad777d10e1072c65cb39ad62df6db001..fc93031b521eb0ee7a5d373ceedd55804fecaecd 100644 (file)
@@ -1,7 +1,7 @@
 /* ----------
  * pg_lzcompress.c -
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.8 2000/07/20 14:23:28 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.9 2000/10/03 03:11:20 momjian Exp $
  *
  *             This is an implementation of LZ compression for PostgreSQL.
  *             It uses a simple history table and generates 2-3 byte tags
@@ -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 60307ff2b5711add072c9ae6e21d8f81935be8ad..4aeefacb824b8527c2ddac00215ff9ec4caab0ed 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.62 2000/09/29 13:35:26 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.63 2000/10/03 03:11:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 21a1008f8cb196ac5d85ad59ff2f5cc4daf956f0..0f1d834f92acf709cb5445a45161f28d0ceff12c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.30 2000/09/29 13:35:26 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.31 2000/10/03 03:11:22 momjian Exp $
  *
  * NOTE
  *       XXX this code needs improvement--check for state violations and
@@ -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 fcef4a0ff301f621ffc4935de5b2ad14307a430c..b38f2b96e1e59128d093a2d7a6cd19729d93bf77 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.83 2000/10/02 17:15:55 momjian Exp $
+ * $Id: c.h,v 1.84 2000/10/03 03:11:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 86b9623995e0fbca5d552080f0545dc28f402ac7..bb53769b0049cc0cabb5107f7f8867142dfaf722 100644 (file)
@@ -8,7 +8,7 @@
  * or in config.h afterwards.  Of course, if you edit config.h, then your
  * changes will be overwritten the next time you run configure.
  *
- * $Id: config.h.in,v 1.138 2000/10/02 17:15:55 momjian Exp $
+ * $Id: config.h.in,v 1.139 2000/10/03 03:11:23 momjian Exp $
  */
 
 #ifndef CONFIG_H
 /* 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 85dfe03ceb1488cca1b244783a18db27c467320e..04cd86d3cb48ca61cfc45a07e34fd80d1c970e49 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: ipc.h,v 1.40 2000/10/02 19:42:56 petere Exp $
+ * $Id: ipc.h,v 1.41 2000/10/03 03:11:24 momjian Exp $
  *
  * NOTES
  *       This file is very architecture-specific.      This stuff should actually
 #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 2296a2db6ceb79e615072b062050afd29dae895c..663ec7cb6680ba18ba0392c63d49a2266cb52a1f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.134 2000/09/27 15:17:56 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.135 2000/10/03 03:11:25 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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