aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2000-10-03 03:11:26 +0000
committerBruce Momjian <bruce@momjian.us>2000-10-03 03:11:26 +0000
commit87c0e623ba14c2de376ca9af06fb21da7b2c2215 (patch)
treee67887aaff9248f2e0c866566ed0b2967cabaae2 /src
parentde1af06287dd0b169385b0756074a0b24feb123c (diff)
downloadpostgresql-87c0e623ba14c2de376ca9af06fb21da7b2c2215.tar.gz
postgresql-87c0e623ba14c2de376ca9af06fb21da7b2c2215.zip
New diff that now covers the entire tree. Applying this gets postgresql
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/async.c3
-rw-r--r--src/backend/libpq/pqcomm.c20
-rw-r--r--src/backend/libpq/pqpacket.c11
-rw-r--r--src/backend/main/main.c11
-rw-r--r--src/backend/port/dynloader/beos.c2
-rw-r--r--src/backend/port/dynloader/beos.h2
-rw-r--r--src/backend/postmaster/postmaster.c6
-rw-r--r--src/backend/storage/ipc/ipc.c164
-rw-r--r--src/backend/storage/lmgr/proc.c37
-rw-r--r--src/backend/tcop/postgres.c7
-rw-r--r--src/backend/utils/adt/pg_lzcompress.c4
-rw-r--r--src/backend/utils/error/elog.c7
-rw-r--r--src/backend/utils/error/exc.c6
-rw-r--r--src/include/c.h23
-rw-r--r--src/include/config.h.in21
-rw-r--r--src/include/port/beos.h3
-rw-r--r--src/include/storage/ipc.h11
-rw-r--r--src/interfaces/libpq/fe-connect.c9
-rw-r--r--src/template/beos2
19 files changed, 290 insertions, 59 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 94eb1bb1224..6611f134727 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -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
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 8417cd475ab..68ee5a03bde 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -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);
diff --git a/src/backend/libpq/pqpacket.c b/src/backend/libpq/pqpacket.c
index defc57f69af..8e51a97f225 100644
--- a/src/backend/libpq/pqpacket.c
+++ b/src/backend/libpq/pqpacket.c
@@ -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;
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index a20b39886d5..7625bf7626a 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -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));
diff --git a/src/backend/port/dynloader/beos.c b/src/backend/port/dynloader/beos.c
index c2a6b788457..f1ed5281b6d 100644
--- a/src/backend/port/dynloader/beos.c
+++ b/src/backend/port/dynloader/beos.c
@@ -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 $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/port/dynloader/beos.h b/src/backend/port/dynloader/beos.h
index 3765ff06296..9cc37430342 100644
--- a/src/backend/port/dynloader/beos.h
+++ b/src/backend/port/dynloader/beos.h
@@ -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 $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index ba5ec51648c..99ae61b2b5b 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -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;
}
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index d0e98cf48b4..f6e045a2cdc 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -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
*
@@ -34,8 +34,15 @@
#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
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index fb5d06fd8b8..1ade4950bec 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -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");
/* ----------------
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 150423faafa..bddad9e4f6e 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -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,
diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c
index 9360c60dad7..fc93031b521 100644
--- a/src/backend/utils/adt/pg_lzcompress.c
+++ b/src/backend/utils/adt/pg_lzcompress.c
@@ -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;
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 60307ff2b57..4aeefacb824 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -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)
diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c
index 21a1008f8cb..0f1d834f92a 100644
--- a/src/backend/utils/error/exc.c
+++ b/src/backend/utils/error/exc.c
@@ -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);
diff --git a/src/include/c.h b/src/include/c.h
index fcef4a0ff30..b38f2b96e1e 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -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
@@ -69,7 +69,11 @@
* 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
diff --git a/src/include/config.h.in b/src/include/config.h.in
index 86b9623995e..bb53769b004 100644
--- a/src/include/config.h.in
+++ b/src/include/config.h.in
@@ -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
@@ -342,15 +342,30 @@
/* 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
diff --git a/src/include/port/beos.h b/src/include/port/beos.h
index c7b33efecb9..401426c5f22 100644
--- a/src/include/port/beos.h
+++ b/src/include/port/beos.h
@@ -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 */
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index 85dfe03ceb1..04cd86d3cb4 100644
--- a/src/include/storage/ipc.h
+++ b/src/include/storage/ipc.h
@@ -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
@@ -27,7 +27,14 @@
#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
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 2296a2db6ce..663ec7cb668 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -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;
diff --git a/src/template/beos b/src/template/beos
index 0a62b51a1e4..d93a6c1e4f3 100644
--- a/src/template/beos
+++ b/src/template/beos
@@ -1,6 +1,6 @@
AROPT:crs
SHARED_LIB:-fpic -DPIC
-CFLAGS:-O2 -DBEOS
+CFLAGS:-O2
SRCH_INC:
SRCH_LIB:
USE_LOCALE:no