1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

I haven't tried building postgres with the Watcom compiler for 7.1 because

it does not support 64bit integers. AFAIK that's the default data type for
OIDs, so I am not surprised that this does not work. Use gcc instead.
BTW., 7.1 does not compile as is with gcc either, I believed the
required patches made it into the 7.1.1 release but obviously I missed
the deadline.
Since the ports mailing list does not seem to be archived I have attached
a copy of the patch (for 7.1 and 7.1.1).

I've just performed a build of a Watcom compiled version and found a couple
of bugs in the watcom specific part of that patch. Please use the attached
version instead.

Tegge, Bernd
This commit is contained in:
Bruce Momjian
2001-05-24 15:53:34 +00:00
parent 6f101c806b
commit f36fc7bb63
10 changed files with 191 additions and 73 deletions

View File

@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.71 2001/04/23 20:27:55 petere Exp $
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.72 2001/05/24 15:53:32 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -25,7 +25,8 @@ OBJS := $(DIRS:%=%/SUBSYS.o)
ifeq ($(PORTNAME), qnx4)
# This file crashes qnx4's wlink and is therefore not in
# bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
# necessary?)
# necessary?) [ Yes, until the Watcom compiler goes open source it's
# effectively unsupported ]
OBJS+= bootstrap/bootstrap.o
endif

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.4 2001/02/02 18:21:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.5 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,14 +23,16 @@
#include "storage/ipc.h"
#include "storage/proc.h"
#include <sys/sem.h>
#include <sys/mman.h>
#include <sys/stat.h>
#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET)
#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET + 1) / PROC_NSEMS_PER_SET)
#define SEMMAX (PROC_NSEMS_PER_SET+1)
#define OPMAX 8
#define MODE 0700
#define SHM_INFO_NAME "SysV_Sem_Info"
#define SHM_INFO_NAME "PgSysV_Sem_Info"
struct pending_ops
@@ -56,6 +58,17 @@ struct sem_info
static struct sem_info *SemInfo = (struct sem_info *) - 1;
/* ----------------------------------------------------------------
* semclean - remove the shared memory file on exit
* only called by the process which created the shm file
* ----------------------------------------------------------------
*/
static void
semclean( void )
{
remove( "/dev/shmem/" SHM_INFO_NAME );
}
int
semctl(int semid, int semnum, int cmd, /* ... */ union semun arg)
@@ -132,6 +145,7 @@ semget(key_t key, int nsems, int semflg)
semid,
semnum /* , semnum1 */ ;
int exist = 0;
struct stat statbuf;
if (nsems < 0 || nsems > SEMMAX)
{
@@ -153,6 +167,26 @@ semget(key_t key, int nsems, int semflg)
return fd;
/* The size may only be set once. Ignore errors. */
ltrunc(fd, sizeof(struct sem_info), SEEK_SET);
if ( fstat( fd, &statbuf ) ) /* would be strange : the only doc'ed */
{ /* error is EBADF */
close( fd );
return -1;
}
/*
* size is rounded by proc to the next __PAGESIZE
*/
if ( statbuf.st_size !=
((( sizeof(struct sem_info) /__PAGESIZE)+1) * __PAGESIZE) )
{
fprintf( stderr,
"Found a pre-existing shared memory block for the semaphore memory\n"
"of a different size (%ld instead %ld). Make sure that all executables\n"
"are from the same release or remove the file \"/dev/shmem/%s\"\n"
"left by a previous version.\n", statbuf.st_size,
sizeof(struct sem_info), SHM_INFO_NAME);
errno = EACCES;
return -1;
}
SemInfo = mmap(NULL, sizeof(struct sem_info),
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (SemInfo == MAP_FAILED)
@@ -167,6 +201,7 @@ semget(key_t key, int nsems, int semflg)
for (semid = 0; semid < SETMAX; semid++)
SemInfo->set[semid].key = -1;
sem_post(&SemInfo->sem);
on_proc_exit( semclean, NULL );
}
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.4 2001/03/22 03:59:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.5 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,9 +15,11 @@
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/stat.h>
#define MODE 0777
@@ -41,6 +43,12 @@ static int shm_updinfo(int i, struct shm_info * info);
static int shm_getinfo(int shmid, struct shm_info * info);
static int shm_getinfobyaddr(const void *addr, struct shm_info * info);
static char *
keytoname(key_t key, char *name)
{
sprintf( name,"PgShm%x", key );
return name;
}
static int
shm_putinfo(struct shm_info * info)
@@ -172,25 +180,51 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf)
{
struct shm_info info;
char name[NAME_MAX + 1];
int result;
int fd;
struct stat statbuf;
if (cmd == IPC_RMID)
switch( cmd )
{
case IPC_RMID :
if (shm_getinfo(shmid, &info) == -1)
{
errno = EACCES;
return -1;
}
return shm_unlink(itoa(info.key, name, 16));
close( info.shmid );
keytoname(info.key, name);
return shm_unlink( name );
case IPC_STAT :
/*
* we have to open it first. stat() does no prefix tracking
* -> the call would go to fsys instead of proc
*/
keytoname(shmid, name);
fd = shm_open( name, 0, MODE );
if ( fd >= 0 )
{
result = fstat( fd, &statbuf );
/*
* if the file exists, subtract 2 from linkcount :
* one for our own open and one for the dir entry
*/
if ( ! result )
buf->shm_nattch = statbuf.st_nlink-2;
close( fd );
return result;
}
if (cmd == IPC_STAT)
else
{
/*
* Can we support IPC_STAT? We only need shm_nattch ... For now,
* punt and assume the shm seg does not exist.
* if there's no entry for this key it doesn't matter
* the next shmget() would get a different shm anyway
*/
errno = EINVAL;
return -1;
buf->shm_nattch = 0;
return 0;
}
}
errno = EINVAL;
return -1;
@@ -214,7 +248,7 @@ shmget(key_t key, size_t size, int flags)
else
oflag |= O_RDONLY;
}
info.shmid = shm_open(itoa(key, name, 16), oflag, MODE);
info.shmid = shm_open(keytoname(key, name), oflag, MODE);
/* store shared memory information */
if (info.shmid != -1)
@@ -222,8 +256,13 @@ shmget(key_t key, size_t size, int flags)
info.key = key;
info.size = size;
info.addr = NULL;
if (shm_putinfo(&info) == -1)
if (shm_putinfo(&info) == -1) {
close( info.shmid );
if ( (oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) ) {
shm_unlink( name );
}
return -1;
}
}
/* The size may only be set once. Ignore errors. */

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.4 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,6 +40,10 @@ sig_handler(int sig_no)
printf("semval = %d\n", i);
}
void on_proc_exit( void (*function)(), Datum arg )
{
atexit( function );
}
int
main(int argc, char **argv)
{

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.10 2001/02/10 10:27:28 petere Exp $
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.11 2001/05/24 15:53:33 momjian Exp $
#
CMDNAME=`basename $0`
@@ -33,7 +33,17 @@ EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
# List of platform-specific hacks
# Feel free to add yours here.
#-----------------------------------
#
# This is QNX 4.25
#
if [ `uname` = 'QNX' ]; then
if ps -eA | grep -s '[p]ostmaster' >/dev/null 2>&1 ; then
echo "$CMDNAME: You still have a postmaster running." 1>&2
exit 1
fi
rm -f /dev/shmem/PgS*
exit $?
fi
#
# This is based on RedHat 5.2.
#

View File

@@ -4,12 +4,8 @@
#include <ioctl.h> /* for unix.h */
#include <unix.h>
#include <sys/select.h> /* for select */
#if !defined(__GNUC__)
#include <semaphore.h> /* for sem_t */
#endif
#define HAS_TEST_AND_SET
#define HAVE_STRING_H
#undef HAVE_GETRUSAGE
@@ -26,14 +22,8 @@ extern unsigned char __nan[8];
typedef u_short ushort;
#if defined(__GNUC__)
typedef unsigned char slock_t;
#else
typedef sem_t slock_t;
#endif
extern int isnan(double dsrc);
extern double rint(double x);

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.92 2001/04/13 23:32:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.93 2001/05/24 15:53:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,7 +106,7 @@
*/
#if defined(__i386__) && !defined(__QNX__)
#if defined(__i386__)
#define TAS(lock) tas(lock)
static __inline__ int
@@ -396,18 +396,19 @@ tas(volatile slock_t *lock)
#endif /* __hpux */
#if defined(__QNX__)
#if defined(__QNX__) && defined(__WATCOMC__)
/*
* QNX 4
*
* Note that slock_t under QNX is sem_t instead of char
* QNX 4 using WATCOM C
*/
#define TAS(lock) (sem_trywait((lock)) < 0)
#define S_UNLOCK(lock) sem_post((lock))
#define S_INIT_LOCK(lock) sem_init((lock), 1, 1)
#define S_LOCK_FREE(lock) ((lock)->value)
#endif /* __QNX__ */
#define TAS(lock) wc_tas(lock)
extern slock_t wc_tas(volatile slock_t *lock);
#pragma aux wc_tas =\
" mov al,1 " \
" lock xchg al,[esi]" \
parm [esi] \
value [al];
#endif /* __QNX__ and __WATCOMC__*/
#if defined(__sgi)
@@ -544,7 +545,6 @@ extern int tas(volatile slock_t *lock); /* in port/.../tas.s, or
/****************************************************************************
* Platform-independent out-of-line support routines
*/
extern void s_lock(volatile slock_t *lock,
const char *file, const int line);
extern void s_lock_sleep(unsigned spins, int timeout, int microsec,

View File

@@ -13,5 +13,5 @@ CFLAGS_SL =
%$(DLSUFFIX): %.o
@echo 'cannot make shared object $@ from $<'
# Hack alert! Fix your compiler installation...
override CXXFLAGS +=-I/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.60/include/g++
override CXXFLAGS +=-I/usr/local/include/g++
override CFLAGS +=-I/usr/local/include

View File

@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.5 2000/08/31 16:12:15 petere Exp $
# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.6 2001/05/24 15:53:34 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -12,8 +12,17 @@ subdir = src/pl/plpgsql
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
ifneq ($(PORTNAME), qnx4)
all install installdirs uninstall distprep:
$(MAKE) -C src $@
else #qnx4
all install installdirs uninstall distprep:
echo plpgsql not supported with QNX due to lack of shared library support
endif # qnx4
clean distclean maintainer-clean:
-$(MAKE) -C src $@