summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/main/main.c8
-rw-r--r--src/backend/port/Makefile.in8
-rw-r--r--src/backend/port/dynloader/beos.c80
-rw-r--r--src/backend/port/dynloader/beos.h17
-rw-r--r--src/backend/storage/ipc/ipc.c139
-rw-r--r--src/backend/storage/lmgr/proc.c6
-rw-r--r--src/backend/tcop/postgres.c9
-rw-r--r--src/backend/utils/error/elog.c8
8 files changed, 75 insertions, 200 deletions
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index 7625bf7626..1ead86f4c3 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.31 2000/10/03 03:11:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.32 2000/10/07 14:39:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -98,6 +98,12 @@ if (!geteuid())
}
#endif /* __BEOS__ */
+#ifdef __BEOS__
+ /* Specific beos actions on startup */
+ beos_startup(argc,argv);
+#endif
+
+
if (len >= 10 && !strcmp(argv[0] + len - 10, "postmaster"))
exit(PostmasterMain(argc, argv));
diff --git a/src/backend/port/Makefile.in b/src/backend/port/Makefile.in
index eb7214cb36..eb976af02a 100644
--- a/src/backend/port/Makefile.in
+++ b/src/backend/port/Makefile.in
@@ -13,7 +13,7 @@
# be converted to Method 2.
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.24 2000/08/31 16:10:16 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.25 2000/10/07 14:39:10 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -27,6 +27,9 @@ OBJS+= @STRTOL@ @STRTOUL@ @SNPRINTF@
ifeq ($(PORTNAME), qnx4)
OBJS += getrusage.o qnx4/SUBSYS.o
endif
+ifeq ($(PORTNAME), beos)
+OBJS += beos/SUBSYS.o
+endif
all: SUBSYS.o
SUBSYS.o: $(OBJS)
@@ -37,6 +40,9 @@ qnx4/SUBSYS.o: qnx4.dir
qnx4.dir:
$(MAKE) -C qnx4 all
+beos/SUBSYS.o:
+ $(MAKE) -C beos all
+
tas.o: tas.s
$(CC) $(CFLAGS) -c tas.s
diff --git a/src/backend/port/dynloader/beos.c b/src/backend/port/dynloader/beos.c
index f1ed5281b6..ea97057e62 100644
--- a/src/backend/port/dynloader/beos.c
+++ b/src/backend/port/dynloader/beos.c
@@ -8,53 +8,65 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.2 2000/10/03 03:11:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.3 2000/10/07 14:39:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#include <kernel/OS.h>
-#include <image.h>
-#include <errno.h>
+#include "utils/dynamic_loader.h"
+#include "utils/elog.h"
-#include "dynloader.h"
-extern char pg_pathname[];
-
-void *
-beos_dlopen(const char *filename)
+void *
+pg_dlopen(char *filename)
{
- image_id id = -1;
+ image_id* im;
+
+ /* Handle memory allocation to store the Id of the shared object*/
+ im=(image_id*)(malloc(sizeof(image_id)));
+
+ /* Add-on loading */
+ *im=beos_dl_open(filename);
+
+ return im;
+}
- if ((id = load_add_on(filename)) < 0)
- return NULL;
- return (void *) id;
+char *
+pg_dlerror()
+{
+ static char errmsg[] = "Load Add-On failed";
+ return errmsg;
}
-void
-beos_dlclose(void *handle)
+PGFunction
+pg_dlsym(void *handle, char *funcname)
{
- image_id id = (image_id) handle;
- unload_add_on(id);
- return;
+ PGFunction fpt;
+
+ /* Checking that "Handle" is valid */
+ if ((handle) && ((*(int*)(handle))>=0))
+ {
+ /* Loading symbol */
+ if(get_image_symbol(*((int*)(handle)),funcname,B_SYMBOL_TYPE_TEXT,(void**)&fpt)==B_OK);
+ {
+ return fpt;
+ }
+ elog(NOTICE, "loading symbol '%s' failed ",funcname);
+ }
+ elog(NOTICE, "add-on not loaded correctly");
+ return NULL;
}
-void *
-beos_dlsym(void *handle, const char *name)
-{
- image_id id = (image_id)handle;
- void *addr;
-
- if (get_image_symbol(id, name, B_SYMBOL_TYPE_ANY, &addr) != B_OK)
- return NULL;
-
- return addr;
-}
-
-char *
-beos_dlerror()
+void
+pg_dlclose(void *handle)
{
- return (char *)strerror(errno);
-}
+ /* Checking that "Handle" is valid */
+ if ((handle) && ((*(int*)(handle))>=0))
+ {
+ if (beos_dl_close(*(image_id*)handle)!=B_OK)
+ elog(NOTICE, "error while unloading add-on");
+ free(handle);
+ }
+} \ No newline at end of file
diff --git a/src/backend/port/dynloader/beos.h b/src/backend/port/dynloader/beos.h
index 9cc3743034..7ef1677e5e 100644
--- a/src/backend/port/dynloader/beos.h
+++ b/src/backend/port/dynloader/beos.h
@@ -7,27 +7,12 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: beos.h,v 1.2 2000/10/03 03:11:15 momjian Exp $
+ * $Id: beos.h,v 1.3 2000/10/07 14:39:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "postgres.h"
-
-#include "fmgr.h"
-#include "utils/dynamic_loader.h"
-
-char *beos_dlerror(void);
-void *beos_dlopen(const char *filename);
-void *beos_dlsym(void *handle, const char *name);
-void beos_dlclose(void *handle);
-
-#define pg_dlopen(f) beos_dlopen(f)
-#define pg_dlsym beos_dlsym
-#define pg_dlclose beos_dlclose
-#define pg_dlerror beos_dlerror
-
#endif /* PORT_PROTOS_H */
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index f6e045a2cd..2ea5ccfeda 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.51 2000/10/03 03:11:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.52 2000/10/07 14:39:12 momjian Exp $
*
* NOTES
*
@@ -243,17 +243,12 @@ 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__ */
}
@@ -270,18 +265,11 @@ IPCPrivateMemoryKill(int status, int shmId)
}
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__ */
}
}
@@ -304,7 +292,6 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
int removeOnExit)
{
int semId;
-#ifndef __BEOS__
int i;
int errStatus;
u_short array[IPC_NMAXSEM];
@@ -366,21 +353,6 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
}
-#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);
@@ -424,7 +396,6 @@ void
IpcSemaphoreKill(IpcSemaphoreKey key)
{
int semId;
-#ifndef __BEOS__
union semun semun;
semun.val = 0; /* unused */
@@ -433,23 +404,6 @@ 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
}
/****************************************************************************/
@@ -462,7 +416,6 @@ static int IpcSemaphoreLock_return;
void
IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
{
-#ifndef __BEOS__
extern int errno;
int errStatus;
struct sembuf sops;
@@ -495,13 +448,6 @@ 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
}
/****************************************************************************/
@@ -514,7 +460,6 @@ static int IpcSemaphoreUnlock_return;
void
IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
{
-#ifndef __BEOS__
extern int errno;
int errStatus;
struct sembuf sops;
@@ -548,49 +493,28 @@ 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__ */
}
/****************************************************************************/
@@ -611,7 +535,6 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
shmid = PrivateMemoryCreate(memKey, size);
}
else
-#ifndef __BEOS__
shmid = shmget(memKey, size, IPC_CREAT | permission);
@@ -649,24 +572,6 @@ 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);
@@ -683,7 +588,6 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
{
IpcMemoryId shmid;
-#ifndef __BEOS__
shmid = shmget(memKey, size, 0);
if (shmid < 0)
@@ -692,17 +596,6 @@ 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;
}
@@ -715,10 +608,8 @@ 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
}
/****************************************************************************/
@@ -733,7 +624,6 @@ IpcMemoryAttach(IpcMemoryId memId)
{
char *memAddress;
-#ifndef __BEOS__
if (UsePrivateMemory)
memAddress = (char *) PrivateMemoryAttach(memId);
else
@@ -746,23 +636,6 @@ 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));
@@ -780,7 +653,6 @@ 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)
@@ -789,15 +661,6 @@ 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 1ade4950be..2da1495cd3 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.82 2000/10/03 03:11:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.83 2000/10/07 14:39:13 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.82 2000/10/03 03:11:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.83 2000/10/07 14:39:13 momjian Exp $
*/
#include "postgres.h"
@@ -266,10 +266,8 @@ 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;
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index e276083788..04a7abb002 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.179 2000/10/07 04:00:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.180 2000/10/07 14:39:14 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -1462,6 +1462,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
if (IsUnderPostmaster)
{
+#ifdef __BEOS__
+ /* Specific beos backend stratup actions */
+ beos_backend_startup(argv[0]);
+#endif
+
/* noninteractive case: nothing should be left after switches */
if (errs || argc != optind || DBName == NULL)
{
@@ -1613,7 +1618,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.179 $ $Date: 2000/10/07 04:00:41 $\n");
+ puts("$Revision: 1.180 $ $Date: 2000/10/07 14:39:14 $\n");
}
/*
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 4aeefacb82..a4cea6af75 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.63 2000/10/03 03:11:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.64 2000/10/07 14:39:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -144,6 +144,9 @@ elog(int lev, const char *fmt, ...)
sprintf(errorstr_buf, "error %d", errno);
errorstr = errorstr_buf;
}
+#else
+ errorstr = strerror(errno);
+#endif /* __BEOS__ */
if (lev == ERROR || lev == FATAL)
{
@@ -182,9 +185,6 @@ elog(int lev, const char *fmt, ...)
prefix = prefix_buf;
break;
}
-#else
- errorstr = strerror(errno);
-#endif /* __BEOS__ */
timestamp_size = 0;
if (Log_timestamp)