Subject: bug#6811: [PATCH] emacs-23.2 on hpux

From: "Peter O'Gorman" <[email-masked]>
Date: Fri, 6 Aug 2010 11:16:27 -0500

Hi,

Attached is a patch that allows us to build emacs-23.2 on our HP-UX
systems (10.20, 11.00 and 11.11 PA-RISC and 11.23, 11.31 both PA and
IA64).

Older hpux systems do not have setegid(), so I instead #defined it using
setregid. I must admit to being a little worried about this, simply
because the setegid() usage was introduced to fix a security flaw.

ORDINARY_LINK works. All of our hpux systems have termios.

We had problems both on HPUX and AIX crashing running temacs during the
build with a memory fault, turns out to be due to the fact that
DATA_SEG_BITS was not being added back in. This may not be the best fix
for the problem, but works for us.

Other notes:
Please restore the OSF/1 files etc. we still build on an OSF/1 system.
We also build on solaris 6, please don't remove it.

Peter
-- 
Peter O'Gorman
[email-masked]
Index: configure.in
===================================================================
--- configure.in.orig	2010-08-02 22:49:24.298009472 +0000
+++ configure.in	2010-08-06 16:01:20.204304769 +0000
@@ -504,6 +504,10 @@
     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
   ;;
 
+  ia64*-hp-hpux1[1-9]* )
+    machine=hp800 opsys=hpux11
+  ;;
+
   hppa*-*-linux-gnu* )
     machine=hp800 opsys=gnu-linux
   ;;
@@ -2333,7 +2337,7 @@
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
 gai_strerror mkstemp getline getdelim mremap memmove fsync sync bzero \
 memset memcmp difftime memcpy mempcpy mblen mbrlen posix_memalign \
-cfmakeraw cfsetspeed)
+setregid setegid cfmakeraw cfsetspeed)
 
 AC_CHECK_HEADERS(sys/un.h)
 
Index: src/s/hpux10-20.h
===================================================================
--- src/s/hpux10-20.h.orig	2010-08-02 22:49:24.309919775 +0000
+++ src/s/hpux10-20.h	2010-08-06 15:37:50.432830578 +0000
@@ -31,6 +31,8 @@
 
 #define HPUX
 
+#define ORDINARY_LINK
+
 /* SYSTEM_TYPE should indicate the kind of system you are using.
  It sets the Lisp variable system-type.  */
 
@@ -46,7 +48,8 @@
  *	for terminal control.
  */
 
-#define HAVE_TERMIO
+#define NO_TERMIO
+#define HAVE_TERMIOS
 
 /*
  *	Define HAVE_PTYS if the system supports pty devices.
@@ -116,7 +119,9 @@
 #define NO_EDITRES
 
 /* Tested in getloadavg.c.  */
+#ifndef HAVE_PSTAT_GETDYNAMIC
 #define HAVE_PSTAT_GETDYNAMIC
+#endif
 
 /* Eric Backus <[email-masked]> says, HP-UX 9.x on HP 700 machines
    has a broken `rint' in some library versions including math library
Index: src/s/hpux11.h
===================================================================
--- src/s/hpux11.h.orig	2010-08-02 22:49:24.302598951 +0000
+++ src/s/hpux11.h	2010-08-03 04:21:16.274466073 +0000
@@ -12,5 +12,9 @@
    then close and reopen it in the child.  */
 #define USG_SUBTTY_WORKS
 
+#if __ia64
+#define CANNOT_DUMP 1
+#endif
+
 /* arch-tag: f5a3d780-82cd-4a9a-832e-a4031aab788b
    (do not change this comment) */
Index: lib-src/movemail.c
===================================================================
--- lib-src/movemail.c.orig	2010-08-06 15:44:45.000000000 +0000
+++ lib-src/movemail.c	2010-08-06 15:46:51.732281428 +0000
@@ -151,6 +151,14 @@
 extern char *rindex __P((const char *, int));
 #endif
 
+#ifndef HAVE_SETEGID
+# ifdef HAVE_SETREGID
+#  define setegid(x) setregid(-1,x)
+# else
+#  error This system has neither setegid nor setregid
+# endif
+#endif
+
 void fatal ();
 void error ();
 void pfatal_with_name ();
Index: src/lisp.h
===================================================================
--- src/lisp.h.orig	2010-08-06 15:41:41.000000000 +0000
+++ src/lisp.h	2010-08-06 15:41:54.344492292 +0000
@@ -431,9 +431,12 @@
 
 #define XSET(var, type, ptr) \
    ((var) = ((EMACS_INT)(type) << VALBITS) + ((EMACS_INT) (ptr) & VALMASK))
+#ifdef DATA_SEG_BITS
 
+#define XPNTR(a) ((EMACS_UINT) (((a) & VALMASK) | DATA_SEG_BITS))
+#else
 #define XPNTR(a) ((EMACS_UINT) ((a) & VALMASK))
-
+#endif
 #endif /* not USE_LSB_TAG */
 
 #else /* USE_LISP_UNION_TYPE */