]> granicus.if.org Git - postgresql/commitdiff
I haven't tried building postgres with the Watcom compiler for 7.1 because
authorBruce Momjian <bruce@momjian.us>
Thu, 24 May 2001 15:53:34 +0000 (15:53 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 24 May 2001 15:53:34 +0000 (15:53 +0000)
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

doc/FAQ_QNX4
src/backend/Makefile
src/backend/port/qnx4/sem.c
src/backend/port/qnx4/shm.c
src/backend/port/qnx4/tstsem.c
src/bin/ipcclean/ipcclean.sh
src/include/port/qnx4.h
src/include/storage/s_lock.h
src/makefiles/Makefile.qnx4
src/pl/plpgsql/Makefile

index 5880feab8cd2b4f82232cec52171e76ccd79b5c7..53209a8c8f85d08ee78f13b07bec862e835bfddd 100644 (file)
@@ -1,5 +1,9 @@
 PostgresSQL on QNX 4
 --------------------
+last updated:           $Date: 2001/05/24 15:53:31 $
+
+current maintainer:     Bernd Tegge (tegge@repas-aeg.de)
+original author:        Andreas Kardos (kardos@repas-aeg.de)
 
 This port is an important step because PostgreSQL is now the only free
 relational database with full SQL and ODBC support available for QNX 4.
@@ -7,47 +11,66 @@ The only commercial databases available are Empress RDBMS and Velocis
 Database Server (not supported for Digital Unix).
 
 The most effort required the emulation of System V semaphore sets,
-shared memory and IPC and of some IEEE floating-point functionality. For
-the Watcom compiler spinlocks have been implemented using POSIX semaphores.
+shared memory and IPC and of some IEEE floating-point functionality.
 
-It is recomended to use the GNU C compiler instead of the Watcom compiler
+It is recommended to use the GNU C compiler instead of the Watcom compiler
 because the Watcom compiler doesn't support a int8 datatype (long or
-long long int) and it does not have a C++ frontend.
-It could be managed to build postgres using the Watcom compiler but it crashes
-quite early. These problems probably could be solved. The only advantage would
-be support of Tk and pgaccess. For the Watcom compiler some more modifications
-have to be made which are not described here.
+long long int) and it does not have a C++ frontend. The only advantage
+using Watcom C would be support of Tk and pgaccess.
 
 QNX 4 does not offer native support of shared libraries. Therefore the related
 functionality cannot be used. Shared library support could probably be
 implemented in future.
 
-QNX 4 does not support UNIX domain sockets. Connections can only be made
-with TCP/IP sockets. Therefore postmaster must always be started with the
--i option. Furthermore it would be useful to set the PGHOST variable.
+QNX 4 does not support UNIX domain sockets. Clients must use TCP/IP sockets.
+Therefore postmaster must always be started with the -i option. Furthermore
+it would be useful to set the PGHOST variable.
 
 Prerequisites:
 --------------
 
 The following prerequisites have been used:
 
-QNX 4.25
-Watcom C 10.6
-GNU make
+QNX standard:
+QNX 4.25, Watcom C 10.6, GNU make
+
+Available from http://www.teaser.fr/~jcmichot/
 flex-2.5.4a.tar.gz (flex)
-egcs111-qnx4-r20.tar[.gz] (GNU C)
+egcs-112-qnx4-r20.tar[.gz] (GNU C)
+
+Available from ftp://ftp.visi.com/users/hawkeyd/qnx/
+bison-1.2.5.tar.gz
+
+Available from http://quics.qnx.com/cgi-bin/dir_find.cgi?/usr/free/
 perl 5.004_04
+
+from ftp://ftp.freesoftware.com/pub/infozip/zlib/
+zlib 1.1.3
+
 tcl8.0.3.tar.Z (Tcl)
 
+In order to achieve meaningful results for the regression tests, you need
+a different shell. The standard QNX shell is quite broken with regard to
+scripting (even QSSL suggested to use pdksh or bash). Both are available
+in source and binaries at
+http://quics.qnx.com/cgi-bin/dir_find.cgi?/usr/free/
+
 flex can be built without any problems using the Watcom or GNU C compilers.
 
+The current version of bison (1.2.8 at the time of this writing) does not
+build cleanly on QNX4 with gcc installed, but you can download src and
+binary of a previous version from the above mentioned ftp site.
+
+download source
 GNU C can be installed by
-/etc/install -u egcs111-qnx4-r20.tar[.gz]
+/etc/install -u egcs112-qnx4-r20.tar[.gz]
 
 Although Tcl can be built after some slight code changes using the Watcom
 compiler, the GNU C compiler should be used instead. Otherwise it would be
 impossible to link postgres built with GNU C together with libtcl8.0.a built
-with the Watcom compiler.
+with the Watcom compiler. However, if you are going to build a Watcom version
+you must build the tcl and tk libraries with Watcom too.
+
 To make unix/tclUnixTest.c compilable uncomment
 #include <sys/resource.h>
 in it or
@@ -79,17 +102,14 @@ ln -s /usr/src/pgsql/src/backend/port/qnx4/sem.h /usr/include/sys/sem.h
 ln -s /usr/src/pgsql/src/backend/port/qnx4/shm.h /usr/include/sys/shm.h
 
 For ecgs-2.91.60 the file
-/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.60/include/g++/stl_alloc.h
+/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.66/include/g++/stl_alloc.h
 had to be patched (extern "C++" { ... } // extern "C++").
 See attached patch.
 
-If you use another ecpg version the include/g++ path in Makefile.qnx4
-(CXXFLAGS) has to be adopted.
-
 If all prerequisites are available postgres can be built and installed by
 cd pgsql/src
-./configure --with-tcl --with-perl --with-x
-gmake all > make.log 2>&1
+./configure --with-tcl --without-tk --with-perl
+gmake > make.log 2>&1
 gmake install > make.install.log 2>&1
 su
 cd interfaces/perl5
@@ -113,11 +133,15 @@ Currently yacc fails on backend/parser/gram.y and
 interfaces/ecpg/preproc/preproc.y due to exceeded maximum table size. You can
 generate the gram.h, parse.h, preproc.h and preproc.c files on another platform
 and use them. This is only a problem when you use the current source tree since
-parse.h, gram.c, preproc.h and preporc.c are included in official
-distributions.
+parse.h, gram.c, preproc.h and preproc.c are included in official
+distributions. In order to avoid this, install the bison binary mentioned
+above.
 
 Regression tests:
 -----------------
+please don't use the QNX shell for the parallel regression tests. Download
+bash from quics.qnx.com and run 'make SHELL=/usr/local/bin/bash check'
+instead.
 
 The majority of regression tests succeeded. The following tests failed:
 
@@ -136,7 +160,8 @@ if a value of type money is inserted in string representation e.g. as in
 "insert into rtest_emp values ('wiech', '5000.00');"
 Subject of further investigation.
 
-create_function_2, triggers, misc, plpgsql:
+create_function_1, create_function_2, create_type, create_operator,
+create_view, select_views, triggers, misc, plpgsql:
 Error messages due to the lack of shared library support.
 
 numeric, numeric_big, sanity_check:
@@ -147,14 +172,19 @@ Subject of further investigation. Probably because of the missing indices
 these numeric tests take a long time.
 The diffence in sanity_check.out is a consequence of this problem only.
 
-The reached state of this port should be sufficient for lot of applications.
+The current state of this port should be sufficient for lot of applications.
+
+The Watcom version failed additional tests because of the lack of int8
+support.
 
 Have fun!
 
 Andreas Kardos
-kardos@repas-aeg.de
 2000-04-04
 
+Bernd Tegge
+tegge@repas-aeg.de
+2001-03-01
 
 ---------------------------------------------------------------------------
 
index 30ea30f8d750ce2ee239b12fdf68d75f3a0daa90..4db21fe665cc28c4d0bf72483f5c045dcf090a50 100644 (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
 
index f339e16973a7ca6c80d93d17bf9b0286a9b3c380..188a5f0616f8f4ddce542f44fd7021790c8de30f 100644 (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 $
  *
  *-------------------------------------------------------------------------
  */
 #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 );
                }
        }
 
index 14c77f4fc9ce6a4089c2857c11931cbc7e88dca6..b96203f1c2d6a8b64442f328196b4f472ba8ec39 100644 (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 $
  *
  *-------------------------------------------------------------------------
  */
 #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. */
index dc697ceaed5b82954e201d992ae2d21f58a85df7..c58a724f9d0ff161bc9a45f6d50a23fab06a21d2 100644 (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)
 {
index db3f003b0cdcd8a3ded4c0f394d79b3cba57384c..881391e641ebffb6d0ff11ad03aaf0d1edd8ef3d 100644 (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.
 #
index b1069932b743d82d35914344707715c549342841..d1a4bc9af994c2389e2444728c21235a8cc5ef91 100644 (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);
index e8f900a4ef4b52c3274f737c7ffd97d8169d0c63..86fc8e2c869a2d6dcaad35a601ce7c9f8ae0c957 100644 (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 $
  *
  *-------------------------------------------------------------------------
  */
  */
 
 
-#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,
index a7d902ad245e239d96551a11a7a50051649cf385..2fb9d7bd193cdeb6e87b4d9620500a43eece5c75 100644 (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
index 2a6598676bb803018b50b4fd43fb01bfe88c72e6..860416dcdc68f90e2d2a0172dec2cfcc2588c9ef 100644 (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 $@