Patches for QNX

Sam Roberts sam at cogent.ca
Wed Mar 1 14:19:33 CET 2000




Here's some tiny patches for gpg under QNX. With
these patches (and if gcc is installed) it configures, builds, and the
test target reports it passes all (23) tests.


Here are the diffs (in the unified format). If they are not
accptable due to content or format just let me know. Otherwise, can
they be integrated?


- sam at cogent.ca


-- a question --

  In util/secmem.c:

  QNX doesn't have the capability of paging *any* memory to disk, so
  it's safe to make lock_pool() a null op, *all* memory is locked in RAM.
  Should I do this, or do I misunderstand what mlock() does (I don't
  think I do)?

--


  There's a dozen ways to get the time, QNX uses the POSIX clock_gettime(),
  I think it exists under HPUX and LynxOS as well so I added the test
  to the configure stuff, see below, so systems that have it will use it.


diff -ur gnupg-1.0.1/config.h.in gnupg-1.0.1-qnx/config.h.in
--- gnupg-1.0.1/config.h.in Sat Dec  4 06:35:59 1999
+++ gnupg-1.0.1-qnx/config.h.in Tue Feb 29 12:14:26 2000
@@ -194,6 +194,9 @@
 /* Define if you have the gettimeofday function.  */
 #undef HAVE_GETTIMEOFDAY

+/* Define if you have the clock_gettime function.  */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define if you have the memicmp function.  */
 #undef HAVE_MEMICMP



diff -ur gnupg-1.0.1/configure.in gnupg-1.0.1-qnx/configure.in
--- gnupg-1.0.1/configure.in    Thu Dec 16 04:10:38 1999
+++ gnupg-1.0.1-qnx/configure.in    Tue Feb 29 12:17:21 2000
@@ -386,7 +386,7 @@
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS(strerror stpcpy strlwr stricmp tcgetattr rand strtoul mmap)
-AC_CHECK_FUNCS(memmove gettimeofday getrusage gethrtime setrlimit)
+AC_CHECK_FUNCS(memmove gettimeofday getrusage gethrtime setrlimit clock_gettime)
 AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo)

 GNUPG_CHECK_MLOCK





  cipher/random.c uses the clock_gettime() in the same way the old
  gettimeofday() does.


diff -ur gnupg-1.0.1/cipher/random.c gnupg-1.0.1-qnx/cipher/random.c
--- gnupg-1.0.1/cipher/random.c Tue Oct 26 13:36:58 1999
+++ gnupg-1.0.1-qnx/cipher/random.c Tue Feb 29 11:26:27 2000
@@ -45,6 +45,9 @@
 #ifdef HAVE_GETRUSAGE
   #include <sys/resource.h>
 #endif
+#ifdef HAVE_CLOCK_GETTIME
+  #include <time.h>
+#endif
 #include "util.h"
 #include "rmd.h"
 #include "ttyio.h"
@@ -398,6 +401,13 @@
        BUG();
    add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
    add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), 1 );
+    }
+  #elif HAVE_CLOCK_GETTIME
+    {   struct timespec tv;
+    if( clock_gettime( CLOCK_REALTIME, &tv ) == -1 )
+       BUG();
+   add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
+   add_randomness( &tv.tv_nsec, sizeof(tv.tv_nsec), 1 );
     }
   #else /* use times */
     #ifndef HAVE_DOSISH_SYSTEM





  Interestingly, there are already QNX ifdefs in this file, but it's
  not complete. This is.

diff -ur gnupg-1.0.1/cipher/rndunix.c gnupg-1.0.1-qnx/cipher/rndunix.c
--- gnupg-1.0.1/cipher/rndunix.c    Sat Oct  9 09:43:12 1999
+++ gnupg-1.0.1-qnx/cipher/rndunix.c    Tue Feb 29 11:31:39 2000
@@ -75,9 +75,9 @@
 #ifndef __QNX__
 #include <sys/resource.h>
 #endif             /* __QNX__ */
-#ifdef _AIX
+#if defined(_AIX) || defined(__QNX__)
 #include <sys/select.h>
-#endif             /* _AIX */
+#endif             /* _AIX || __QNX__ */
 #ifndef __QNX__
 #include <sys/shm.h>
 #include <sys/signal.h>
@@ -90,6 +90,10 @@
 #include <sys/wait.h>
 /* #include <kitchensink.h> */
 #include <errno.h>
+#ifdef __QNX__
+#include <process.h>
+#include <signal.h>
+#endif             /* __QNX__ */

 #include "types.h"  /* for byte and u32 typedefs */
 #ifndef IS_MODULE





  For some reason, after close to 20 years, QNX still hasn't made it
  into these "standard" GNU autoconf scripts.


diff -ur gnupg-1.0.1/scripts/config.guess gnupg-1.0.1-qnx/scripts/config.guess
--- gnupg-1.0.1/scripts/config.guess    Wed Aug  4 04:45:24 1999
+++ gnupg-1.0.1-qnx/scripts/config.guess    Tue Feb 29 10:34:06 2000
@@ -68,6 +68,9 @@
 # Note: order is significant - the case branches are not exclusive.

 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+   *:QNX:*:*)
+   echo i386-pc-qnx
+   exit 0 ;;
     alpha:OSF1:*:*)
    if test $UNAME_RELEASE = "V4.0"; then
        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`



diff -ur gnupg-1.0.1/scripts/config.sub gnupg-1.0.1-qnx/scripts/config.sub
--- gnupg-1.0.1/scripts/config.sub  Wed Aug  4 04:45:25 1999
+++ gnupg-1.0.1-qnx/scripts/config.sub  Tue Feb 29 11:07:42 2000
@@ -881,6 +881,9 @@
    -solaris)
        os=-solaris2
        ;;
+   -qnx)
+       os=-qnx
+       ;;
    -svr4*)
        os=-sysv4
        ;;


--
Sam Roberts (sam at cogent.ca), Cogent Real-Time Systems (www.cogent.ca)
"News is very popular among its readers." - RFC 977 (NNTP)



More information about the Gnupg-devel mailing list