diff -cr -x configure pgsql/configure.in pgsql_beos/configure.in *** pgsql/configure.in Wed Jun 7 16:26:36 2000 --- pgsql_beos/configure.in Fri Jun 9 12:36:07 2000 *************** *** 697,702 **** --- 697,707 ---- AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(values.h) AC_CHECK_HEADERS(sys/exec.h sys/pstat.h machine/vmparam.h) + AC_CHECK_HEADERS(sys/ipc.h) + AC_CHECK_HEADERS(sys/un.h) + AC_CHECK_HEADERS(sys/sem.h sys/shm.h) + AC_CHECK_HEADERS(kernel/OS.h kernel/image.h) + AC_CHECK_HEADERS(SupportDefs.h) dnl ODBC headers... AC_CHECK_HEADERS(sys/param.h pwd.h) dnl diff -cr -x configure pgsql/src/backend/libpq/pqcomm.c pgsql_beos/src/backend/libpq/pqcomm.c *** pgsql/src/backend/libpq/pqcomm.c Tue Jun 6 16:04:29 2000 --- pgsql_beos/src/backend/libpq/pqcomm.c Sun Jun 11 01:04:11 2000 *************** *** 210,220 **** MemSet((char *) &saddr, 0, sizeof(saddr)); saddr.sa.sa_family = family; 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. --- 210,225 ---- 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. *************** *** 233,245 **** } #endif /* HAVE_FCNTL_SETLK */ } ! else ! { 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); if (err < 0) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, --- 238,253 ---- } #endif /* HAVE_FCNTL_SETLK */ } ! #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, (struct sockaddr *)&saddr.sa, len); if (err < 0) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, *************** *** 260,265 **** --- 268,274 ---- return STATUS_ERROR; } + #ifdef HAVE_SYS_UN_H /* yeah I know... */ if (family == AF_UNIX) { on_proc_exit(StreamDoUnlink, NULL); *************** *** 281,286 **** --- 290,296 ---- } #endif /* HAVE_FCNTL_SETLK */ } + #endif /* HAVE_SYS_UN_H */ listen(fd, SOMAXCONN); diff -cr -x configure pgsql/src/backend/libpq/pqpacket.c pgsql_beos/src/backend/libpq/pqpacket.c *** pgsql/src/backend/libpq/pqpacket.c Wed Apr 12 17:15:14 2000 --- pgsql_beos/src/backend/libpq/pqpacket.c Sat Jun 10 19:26:01 2000 *************** *** 61,67 **** --- 61,71 ---- 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,157 **** done = SSL_write(port->ssl, pkt->ptr, pkt->nrtodo); else #endif done = write(port->sock, pkt->ptr, pkt->nrtodo); ! if (done > 0) { pkt->nrtodo -= done; --- 154,164 ---- 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 -cr -x configure pgsql/src/backend/main/main.c pgsql_beos/src/backend/main/main.c *** pgsql/src/backend/main/main.c Wed Jan 26 05:56:30 2000 --- pgsql_beos/src/backend/main/main.c Sat Jun 10 01:00:23 2000 *************** *** 83,93 **** */ len = strlen(argv[0]); ! if (!geteuid()) { fprintf(stderr, "%s", NOROOTEXEC); exit(1); } if (len >= 10 && !strcmp(argv[0] + len - 10, "postmaster")) exit(PostmasterMain(argc, argv)); --- 83,100 ---- */ len = strlen(argv[0]); ! /* 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)); Only in pgsql_beos/src/backend/port/dynloader: beos.c Only in pgsql_beos/src/backend/port/dynloader: beos.h diff -cr -x configure pgsql/src/backend/postmaster/postmaster.c pgsql_beos/src/backend/postmaster/postmaster.c *** pgsql/src/backend/postmaster/postmaster.c Tue Jun 6 16:04:29 2000 --- pgsql_beos/src/backend/postmaster/postmaster.c Sun Jun 11 01:03:50 2000 *************** *** 186,192 **** */ static int ServerSock_INET = INVALID_SOCK; /* stream socket server */ ! #if !defined(__CYGWIN32__) && !defined(__QNX__) static int ServerSock_UNIX = INVALID_SOCK; /* stream socket server */ #endif --- 186,192 ---- */ static int ServerSock_INET = INVALID_SOCK; /* stream socket server */ ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) static int ServerSock_UNIX = INVALID_SOCK; /* stream socket server */ #endif *************** *** 583,589 **** } } ! #if !defined(__CYGWIN32__) && !defined(__QNX__) status = StreamServerPort(AF_UNIX, (unsigned short)PostPortName, &ServerSock_UNIX); if (status != STATUS_OK) { --- 583,589 ---- } } ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) status = StreamServerPort(AF_UNIX, (unsigned short)PostPortName, &ServerSock_UNIX); if (status != STATUS_OK) { *************** *** 845,857 **** if (select(nSockets, &rmask, &wmask, (fd_set *) NULL, (struct timeval *) NULL) < 0) { ! if (errno == EINTR) 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. */ --- 845,856 ---- if (select(nSockets, &rmask, &wmask, (fd_set *) NULL, (struct timeval *) NULL) < 0) { ! 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. */ *************** *** 876,882 **** /* new connection pending on our well-known port's socket */ ! #if !defined(__CYGWIN32__) && !defined(__QNX__) if (ServerSock_UNIX != INVALID_SOCK && FD_ISSET(ServerSock_UNIX, &rmask) && (port = ConnCreate(ServerSock_UNIX)) != NULL) --- 875,881 ---- /* new connection pending on our well-known port's socket */ ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) if (ServerSock_UNIX != INVALID_SOCK && FD_ISSET(ServerSock_UNIX, &rmask) && (port = ConnCreate(ServerSock_UNIX)) != NULL) *************** *** 1035,1041 **** FD_ZERO(rmask); FD_ZERO(wmask); ! #if !defined(__CYGWIN32__) && !defined(__QNX__) if (ServerSock_UNIX != INVALID_SOCK) { FD_SET(ServerSock_UNIX, rmask); --- 1034,1040 ---- FD_ZERO(rmask); FD_ZERO(wmask); ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) if (ServerSock_UNIX != INVALID_SOCK) { FD_SET(ServerSock_UNIX, rmask); *************** *** 1048,1054 **** if (ServerSock_INET != INVALID_SOCK) { FD_SET(ServerSock_INET, rmask); - if (ServerSock_INET > nsocks) nsocks = ServerSock_INET; } --- 1047,1052 ---- *************** *** 1849,1858 **** */ /* Close the postmaster sockets */ if (NetServer) StreamClose(ServerSock_INET); ServerSock_INET = INVALID_SOCK; ! #if !defined(__CYGWIN32__) && !defined(__QNX__) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; #endif --- 1847,1858 ---- */ /* Close the postmaster sockets */ + if (NetServer) StreamClose(ServerSock_INET); ServerSock_INET = INVALID_SOCK; ! ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; #endif *************** *** 1968,1974 **** if (ServerSock_INET != INVALID_SOCK) StreamClose(ServerSock_INET); ServerSock_INET = INVALID_SOCK; ! #if !defined(__CYGWIN32__) && !defined(__QNX__) if (ServerSock_UNIX != INVALID_SOCK) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; --- 1968,1974 ---- if (ServerSock_INET != INVALID_SOCK) StreamClose(ServerSock_INET); ServerSock_INET = INVALID_SOCK; ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) if (ServerSock_UNIX != INVALID_SOCK) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; *************** *** 2138,2147 **** /* Lose the postmaster's on-exit routines and port connections */ on_exit_reset(); if (NetServer) StreamClose(ServerSock_INET); ServerSock_INET = INVALID_SOCK; ! #if !defined(__CYGWIN32__) && !defined(__QNX__) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; #endif --- 2138,2151 ---- /* Lose the postmaster's on-exit routines and port connections */ on_exit_reset(); + /* BeOS has global sockets, so don't close it here... */ + #ifndef __BEOS__ if (NetServer) StreamClose(ServerSock_INET); + #endif ServerSock_INET = INVALID_SOCK; ! ! #if !defined(__CYGWIN32__) && !defined(__QNX__) && !defined(__BEOS__) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; #endif diff -cr -x configure pgsql/src/backend/storage/ipc/ipc.c pgsql_beos/src/backend/storage/ipc/ipc.c *** pgsql/src/backend/storage/ipc/ipc.c Wed May 31 00:28:29 2000 --- pgsql_beos/src/backend/storage/ipc/ipc.c Fri Jun 9 23:37:30 2000 *************** *** 34,41 **** --- 34,48 ---- #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" *************** *** 238,247 **** --- 245,259 ---- IPCPrivateSemaphoreKill(int status, int semId) /* caddr_t */ { + /* BeOS has a native sempahore type... */ + #ifndef __BEOS__ union semun semun; semun.val = 0; /* unused */ semctl(semId, 0, IPC_RMID, semun); + #else /* __BEOS__ */ + delete_sem(semId); + #endif /* __BEOS__ */ } *************** *** 259,270 **** } else { if (shmctl(shmId, IPC_RMID, (struct shmid_ds *) NULL) < 0) { elog(NOTICE, "IPCPrivateMemoryKill: shmctl(%d, %d, 0) failed: %m", shmId, IPC_RMID); } ! } } /* --- 271,289 ---- } else { + #ifndef __BEOS__ if (shmctl(shmId, IPC_RMID, (struct shmid_ds *) NULL) < 0) { 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__ */ ! } } /* *************** *** 285,293 **** int semStartValue, int removeOnExit) { int i; int errStatus; - int semId; u_short array[IPC_NMAXSEM]; union semun semun; --- 304,313 ---- int semStartValue, int removeOnExit) { + int semId; + #ifndef __BEOS__ int i; int errStatus; u_short array[IPC_NMAXSEM]; union semun semun; *************** *** 303,308 **** --- 323,329 ---- 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) *************** *** 330,335 **** --- 351,372 ---- on_shmem_exit(IPCPrivateSemaphoreKill, (caddr_t) 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); *************** *** 373,378 **** --- 410,416 ---- IpcSemaphoreKill(IpcSemaphoreKey key) { int semId; + #ifndef __BEOS__ union semun semun; semun.val = 0; /* unused */ *************** *** 381,386 **** --- 419,441 ---- 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 } /****************************************************************************/ *************** *** 393,398 **** --- 448,454 ---- void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock) { + #ifndef __BEOS__ extern int errno; int errStatus; struct sembuf sops; *************** *** 425,430 **** --- 481,493 ---- 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 } /****************************************************************************/ *************** *** 437,442 **** --- 500,506 ---- void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock) { + #ifndef __BEOS__ extern int errno; int errStatus; struct sembuf sops; *************** *** 470,497 **** --- 534,582 ---- 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__ */ } /****************************************************************************/ *************** *** 512,517 **** --- 597,604 ---- shmid = PrivateMemoryCreate(memKey, size); } else + #ifndef __BEOS__ + shmid = shmget(memKey, size, IPC_CREAT | permission); if (shmid < 0) *************** *** 522,527 **** --- 609,633 ---- 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, (caddr_t) shmid); *************** *** 537,542 **** --- 643,649 ---- { IpcMemoryId shmid; + #ifndef __BEOS__ shmid = shmget(memKey, size, 0); if (shmid < 0) *************** *** 545,550 **** --- 652,668 ---- 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; } *************** *** 557,564 **** --- 675,684 ---- static void IpcMemoryDetach(int status, char *shmaddr) { + #ifndef __BEOS__ if (shmdt(shmaddr) < 0) elog(NOTICE, "IpcMemoryDetach: shmdt(0x%p): %m", shmaddr); + #endif } /****************************************************************************/ *************** *** 573,578 **** --- 693,699 ---- { char *memAddress; + #ifndef __BEOS__ if (UsePrivateMemory) memAddress = (char *) PrivateMemoryAttach(memId); else *************** *** 585,590 **** --- 706,728 ---- 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, (caddr_t) memAddress); *************** *** 602,607 **** --- 740,746 ---- { IpcMemoryId shmid; + #ifndef __BEOS__ if (!UsePrivateMemory && (shmid = shmget(memKey, 0, 0)) >= 0) { if (shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL) < 0) *************** *** 610,615 **** --- 749,763 ---- 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 -cr -x configure pgsql/src/backend/storage/lmgr/proc.c pgsql_beos/src/backend/storage/lmgr/proc.c *** pgsql/src/backend/storage/lmgr/proc.c Wed May 31 00:28:30 2000 --- pgsql_beos/src/backend/storage/lmgr/proc.c Fri Jun 9 23:50:58 2000 *************** *** 64,70 **** --- 64,72 ---- /* In Ultrix and QNX, sem.h must be included after ipc.h */ + #ifdef HAVE_SYS_SEM_H #include + #endif #include "storage/lock.h" #include "storage/proc.h" *************** *** 264,271 **** --- 266,275 ---- * 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; *************** *** 513,519 **** void LockWaitCancel(void) { ! struct itimerval timeval, dummy; if (!lockWaiting) --- 517,525 ---- void LockWaitCancel(void) { ! /* BeOS doesn't have setitimer, but has set_alarm */ ! #ifndef __BEOS__ ! struct itimerval timeval, dummy; if (!lockWaiting) *************** *** 522,527 **** --- 528,541 ---- /* 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"); } *************** *** 553,560 **** --- 567,578 ---- 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; *************** *** 633,641 **** --- 651,664 ---- * 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 *************** *** 643,649 **** --- 666,676 ---- 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; *************** *** 663,671 **** --- 690,702 ---- * 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 -cr -x configure pgsql/src/backend/tcop/postgres.c pgsql_beos/src/backend/tcop/postgres.c *** pgsql/src/backend/tcop/postgres.c Thu Jun 8 22:37:26 2000 --- pgsql_beos/src/backend/tcop/postgres.c Fri Jun 9 23:53:17 2000 *************** *** 1668,1674 **** (long int) user.tv_usec, (long int) sys.tv_sec, (long int) sys.tv_usec); ! #ifdef HAVE_GETRUSAGE fprintf(StatFp, "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n", r.ru_inblock - Save_r.ru_inblock, --- 1668,1675 ---- (long int) user.tv_usec, (long int) sys.tv_sec, (long int) sys.tv_usec); ! /* 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 -cr -x configure pgsql/src/backend/utils/adt/pg_lzcompress.c pgsql_beos/src/backend/utils/adt/pg_lzcompress.c *** pgsql/src/backend/utils/adt/pg_lzcompress.c Tue May 30 00:49:53 2000 --- pgsql_beos/src/backend/utils/adt/pg_lzcompress.c Sat Jun 10 00:00:03 2000 *************** *** 398,404 **** * ---------- */ int ! pglz_compress(char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy) { PGLZ_HistEntry *hist_start[PGLZ_HISTORY_SIZE]; PGLZ_HistEntry *hist_alloc; --- 398,404 ---- * ---------- */ int ! pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strategy) { PGLZ_HistEntry *hist_start[PGLZ_HISTORY_SIZE]; PGLZ_HistEntry *hist_alloc; diff -cr -x configure pgsql/src/backend/utils/error/elog.c pgsql_beos/src/backend/utils/error/elog.c *** pgsql/src/backend/utils/error/elog.c Sun Jun 4 15:06:29 2000 --- pgsql_beos/src/backend/utils/error/elog.c Sat Jun 10 00:22:47 2000 *************** *** 162,167 **** --- 162,169 ---- break; } + /* BeOS doesn't have sys_nerr and should be able to use strerror()... */ + #ifndef __BEOS__ /* get errno string for %m */ if (errno < sys_nerr && errno >= 0) errorstr = strerror(errno); *************** *** 170,175 **** --- 172,180 ---- sprintf(errorstr_buf, "error %d", errno); errorstr = errorstr_buf; } + #else + errorstr = strerror(errno); + #endif /* __BEOS__ */ timestamp_size = 0; if (Log_timestamp) diff -cr -x configure pgsql/src/backend/utils/error/exc.c pgsql_beos/src/backend/utils/error/exc.c *** pgsql/src/backend/utils/error/exc.c Wed Jan 26 05:57:20 2000 --- pgsql_beos/src/backend/utils/error/exc.c Sat Jun 10 00:27:40 2000 *************** *** 127,133 **** --- 127,137 ---- 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 -cr -x configure pgsql/src/include/c.h pgsql_beos/src/include/c.h *** pgsql/src/include/c.h Thu Jun 8 22:37:35 2000 --- pgsql_beos/src/include/c.h Fri Jun 9 11:58:12 2000 *************** *** 59,64 **** --- 59,67 ---- #ifdef __CYGWIN32__ #include #endif + #ifdef HAVE_SUPPORTDEFS_H + #include + #endif /* ---------------------------------------------------------------- * Section 1: bool, true, false, TRUE, FALSE, NULL *************** *** 69,74 **** --- 72,82 ---- * Boolean value, either true or false. * */ + + /* 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; *************** *** 81,86 **** --- 89,95 ---- #ifndef false #define false ((bool) 0) #endif + #endif /* __BEOS__ */ typedef bool *BoolPtr; #ifndef TRUE *************** *** 168,187 **** * used for numerical computations and the * frontend/backend protocol. */ typedef signed char int8; /* == 8 bits */ typedef signed short int16; /* == 16 bits */ typedef signed int int32; /* == 32 bits */ ! /* * uintN * Unsigned integer, EXACTLY N BITS IN SIZE, * used for numerical computations and the * frontend/backend protocol. */ typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ ! /* * floatN * Floating point number, AT LEAST N BITS IN SIZE, --- 177,198 ---- * used for numerical computations and the * frontend/backend protocol. */ + #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__ /* 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, *************** *** 259,264 **** --- 270,276 ---- typedef float float4; typedef double float8; + #ifndef __BEOS__ /* this is already defined on BeOS */ #ifdef HAVE_LONG_INT_64 /* Plain "long int" fits, use it */ typedef long int int64; *************** *** 272,277 **** --- 284,290 ---- #define INT64_IS_BUSTED #endif #endif + #endif /* __BEOS__ */ /* ---------------------------------------------------------------- * Section 4: datum type + support macros diff -cr -x configure pgsql/src/include/config.h.in pgsql_beos/src/include/config.h.in *** pgsql/src/include/config.h.in Sun Jun 4 15:06:32 2000 --- pgsql_beos/src/include/config.h.in Fri Jun 9 12:44:12 2000 *************** *** 280,285 **** --- 280,306 ---- /* Set to 1 if you have */ #undef HAVE_MACHINE_VMPARAM_H + /* Set to 1 if you have */ + #undef HAVE_SYS_IPC_H + + /* 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 + /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS diff -cr -x configure pgsql/src/include/libpq/pqcomm.h pgsql_beos/src/include/libpq/pqcomm.h *** pgsql/src/include/libpq/pqcomm.h Wed Jan 26 05:58:12 2000 --- pgsql_beos/src/include/libpq/pqcomm.h Fri Jun 9 12:15:52 2000 *************** *** 23,29 **** --- 23,31 ---- #include "winsock.h" #else #include + #ifdef HAVE_SYS_UN_H #include + #endif #include #endif *************** *** 33,39 **** { struct sockaddr sa; struct sockaddr_in in; ! #ifndef WIN32 struct sockaddr_un un; #endif } SockAddr; --- 35,41 ---- { struct sockaddr sa; struct sockaddr_in in; ! #if !defined(WIN32) && !defined(__BEOS__) struct sockaddr_un un; #endif } SockAddr; Only in pgsql_beos/src/include/port: beos.h diff -cr -x configure pgsql/src/include/storage/ipc.h pgsql_beos/src/include/storage/ipc.h *** pgsql/src/include/storage/ipc.h Wed Jan 26 05:58:32 2000 --- pgsql_beos/src/include/storage/ipc.h Fri Jun 9 23:24:53 2000 *************** *** 23,29 **** --- 23,36 ---- #define IPC_H #include + #ifdef HAVE_SYS_IPC_H #include /* For IPC_PRIVATE */ + #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" diff -cr -x configure pgsql/src/interfaces/libpq/fe-connect.c pgsql_beos/src/interfaces/libpq/fe-connect.c *** pgsql/src/interfaces/libpq/fe-connect.c Wed May 31 00:28:41 2000 --- pgsql_beos/src/interfaces/libpq/fe-connect.c Sun Jun 11 00:28:52 2000 *************** *** 600,607 **** static int connectMakeNonblocking(PGconn *conn) { ! #ifndef WIN32 if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0) #else int on = 1; --- 600,610 ---- static int connectMakeNonblocking(PGconn *conn) { ! #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; *************** *** 741,747 **** conn->raddr.in.sin_port = htons((unsigned short) (portno)); conn->raddr_len = sizeof(struct sockaddr_in); } ! #if !defined(WIN32) && !defined(__CYGWIN32__) else conn->raddr_len = UNIXSOCK_PATH(conn->raddr.un, portno); #endif --- 744,750 ---- conn->raddr.in.sin_port = htons((unsigned short) (portno)); conn->raddr_len = sizeof(struct sockaddr_in); } ! #if !defined(WIN32) && !defined(__CYGWIN32__) && !defined(__BEOS__) else conn->raddr_len = UNIXSOCK_PATH(conn->raddr.un, portno); #endif *************** *** 941,947 **** connectDBComplete(PGconn *conn) { PostgresPollingStatusType flag = PGRES_POLLING_WRITING; - if (conn == NULL || conn->status == CONNECTION_BAD) return 0; --- 944,949 ---- *************** *** 1021,1027 **** PQconnectPoll(PGconn *conn) { PGresult *res; - if (conn == NULL) return PGRES_POLLING_FAILED; --- 1023,1028 ---- Only in pgsql_beos/src/makefiles: Makefile.beos Only in pgsql_beos/src/template: beos