From: Bruce Momjian Date: Tue, 3 Oct 2000 03:11:26 +0000 (+0000) Subject: New diff that now covers the entire tree. Applying this gets postgresql X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=7007241103042fe74012e83fe43221e07753a3d2;p=users%2Fbernd%2Fpostgres.git 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 --- diff --git a/configure.in b/configure.in index 798f6728a6..51230d9e22 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 10e3d3f560..10991ff97c 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -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 b616f70455..ba154204d7 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -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 ee6cdd0026..e04839d7ee 100644 --- a/src/backend/libpq/pqpacket.c +++ b/src/backend/libpq/pqpacket.c @@ -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 89fcf3258b..174d079f3f 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -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/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index bbe8402879..d01eaded1c 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -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 eb8c35861e..5a1fc62a0d 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -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 +#endif +#ifdef HAVE_SYS_SHM_H #include +#endif +#ifdef HAVE_KERNEL_OS_H +#include +#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 c931c37648..1fd0cc3574 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -65,7 +65,9 @@ /* In Ultrix and QNX, sem.h must be included after ipc.h */ +#ifdef HAVE_SYS_SEM_H #include +#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 5e06521bba..62def952b7 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -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 69d037b7e8..82ef958a35 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -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 c30471d74c..2e78e57862 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -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 0ee8e1e9ce..8d4eb8dd9a 100644 --- a/src/backend/utils/error/exc.c +++ b/src/backend/utils/error/exc.c @@ -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 5711420655..9f4b49dfe0 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -56,7 +56,7 @@ #include #include /* ensure O_BINARY is available */ #endif -#ifdef __BEOS__ +#ifdef HAVE_SUPPORTDEFS_H #include #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 -#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 3c0c20ed08..ceedc9cb69 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -342,15 +342,30 @@ /* Set to 1 if you have */ #undef HAVE_READLINE_READLINE_H -/* Define if you have */ +/* Set to 1 if you have */ #undef HAVE_SYS_IPC_H /* Set to 1 if you have */ #undef HAVE_SYS_SELECT_H -/* Set to 1 if you have */ +/* Set to 1 if you have */ #undef HAVE_SYS_UN_H +/* Set to 1 if you have */ +#undef HAVE_SYS_SEM_H + +/* Set to 1 if you have */ +#undef HAVE_SYS_SHM_H + +/* Set to 1 if you have */ +#undef HAVE_KERNEL_OS_H + +/* Set to 1 if you have */ +#undef HAVE_SUPPORTDEFS_H + +/* Set to 1 if you have */ +#undef HAVE_KERNEL_IMAGE_H + /* Set to 1 if you have */ #undef HAVE_TERMIOS_H diff --git a/src/include/port/beos.h b/src/include/port/beos.h index c7b33efecb..401426c5f2 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 f6f9f17b82..15759e459d 100644 --- a/src/include/storage/ipc.h +++ b/src/include/storage/ipc.h @@ -27,7 +27,14 @@ #include #ifdef HAVE_SYS_IPC_H #include /* 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 68905baaa3..0c580cb395 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -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 0a62b51a1e..d93a6c1e4f 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