piet@cs.ruu.nl (Piet van Oostrum) (11/29/89)
From: darrylo@HPSRDMO.HP.COM (Darryl Okahata) Newsgroups: gnu.g++.lib.bug Subject: libg++ for HP-UX Message-ID: <8911060634.AA06969@hpsrdmo.HP.COM> Date: 6 Nov 89 06:34:41 GMT Here are some patches to help libg++ (V1.36 -- the latest officially-released version available from labrea) get up and running on HP machines. These patches were made for a g++ configured for "hp9k320g", but will probably work for other HP configurations. Problems fixed: 1. In ctype.h, the ctype classification array is called "_ctype", and not "_ctype_". It is, however, still an array of unsigned char; it is NOT an array of short. --------------- I tried to compile G++/LIBG++ (1.36.1) on HP-UX 6.5, with Darryl's patches. The ctype patch didn't work out on my system for two reasons: 1. The name is not _ctype, but __ctype on my system. 2. In contrast to other Unix systems the table has the first (superfluous) element missing, so all (_ctype_+1)'s should be __ctype. I don't know why this is different on my system, but the following works: I got the whole system running with the native assembler and loader. (Just another question: Is there a G++ for the HP9000/800 series?) ------------------------------------------------------------------------ // Here's a ctype.h for SunOS-3 and vax 4.3BSD. // It will probably work on most BSD derived systems. // Just compare it to the C version to verify. // No big deal, but it will save you some typing. #ifndef _ctype_h #pragma once #define _ctype_h #include <stdio.h> /* sorry, but needed for USG stuff */ static const int _U = 01; static const int _L = 02; static const int _N = 04; static const int _S = 010; static const int _P = 020; static const int _C = 040; #ifdef USG static const int _B = 0100; /* different from BSD */ static const int _X = 0200; /* different from BSD */ #else static const int _X = 0100; static const int _B = 0200; #endif #ifdef DGUX #define CTYPE_TYPE short #else #define CTYPE_TYPE char #endif #if defined(USG) && !defined(hpux) #define _ctype_ _ctype #endif extern "C" { #ifndef hpux extern CTYPE_TYPE _ctype_[]; } inline int isalpha(char c) { return ((_ctype_+1)[c]&(_U|_L)); } inline int isupper(char c) { return ((_ctype_+1)[c]&_U); } inline int islower(char c) { return ((_ctype_+1)[c]&_L); } inline int isdigit(char c) { return ((_ctype_+1)[c]&_N); } inline int isxdigit(char c) { return ((_ctype_+1)[c]&_X); } inline int isspace(char c) { return ((_ctype_+1)[c]&_S); } inline int ispunct(char c) { return ((_ctype_+1)[c]&_P); } inline int isalnum(char c) { return ((_ctype_+1)[c]&(_U|_L|_N)); } inline int isprint(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N|_B)); } inline int isgraph(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N)); } inline int iscntrl(char c) { return ((_ctype_+1)[c]&_C); } #else extern unsigned char *__ctype; } inline int isalpha(char c) { return ((__ctype)[c]&(_U|_L)); } inline int isupper(char c) { return ((__ctype)[c]&_U); } inline int islower(char c) { return ((__ctype)[c]&_L); } inline int isdigit(char c) { return ((__ctype)[c]&_N); } inline int isxdigit(char c) { return ((__ctype)[c]&_X); } inline int isspace(char c) { return ((__ctype)[c]&_S); } inline int ispunct(char c) { return ((__ctype)[c]&_P); } inline int isalnum(char c) { return ((__ctype)[c]&(_U|_L|_N)); } inline int isprint(char c) { return ((__ctype)[c]&(_P|_U|_L|_N|_B)); } inline int isgraph(char c) { return ((__ctype)[c]&(_P|_U|_L|_N)); } inline int iscntrl(char c) { return ((__ctype)[c]&_C); } #endif inline int isascii(char c) { return ((unsigned)(c)<=0177); } inline int toupper(char c) { return islower(c)? (c-'a'+'A') : c; } inline int tolower(char c) { return isupper(c)? (c-'A'+'a') : c; } inline int toascii(char c) { return ((c)&0177); } #ifdef _ctype_ #undef _ctype_ #endif #ifdef CTYPE_TYPE #undef CTYPE_TYPE #endif #endif _ctype_h ------------------------------------------------------------------------ -- Piet* van Oostrum, Dept of Computer Science, University of Utrecht Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31-30-531806 Uucp: uunet!mcsun!hp4nl!ruuinf!piet Telefax: +31-30-513791 Internet: piet@cs.ruu.nl (*`Pete')
darrylo@HPSRDMO.HP.COM (Darryl Okahata) (11/30/89)
Piet van Oostrum writes: > I tried to compile G++/LIBG++ (1.36.1) on HP-UX 6.5, with Darryl's patches. > The ctype patch didn't work out on my system for two reasons: > > 1. The name is not _ctype, but __ctype on my system. > 2. In contrast to other Unix systems the table has the first (superfluous) > element missing, so all (_ctype_+1)'s should be __ctype. > > I don't know why this is different on my system, but the following works: > I got the whole system running with the native assembler and loader. [ Note: the following was originally determined by examination of include and object (binary) files. It was not "determined" through the use of any documentation or un*x source. ] 1. On HP-UX, "__ctype" is declared as: extern unsigned char *__ctype; This is a *POINTER* to the actual ctype array "_ctype" (and this pointer also seems to point to the *second* element in the ctype array, and not the first element). 2. Because the pointer "__ctype" points to the second element of the array (index "1"), you do not, as you have discovered, need the "(_ctype_+1)". However, as the patch that was originally distributed uses the "_ctype" array and not the "__ctype" pointer, you do need the "(_ctype_+1)". I recommend using the original patch, as it does not require that all the "(_ctype_+1)"s be changed to "__ctype". Also, referring to the "_ctype" array is slightly faster than using an indirect pointer. When you tried the original patch, why did it not work? -- Darryl Okahata UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo Internet: darrylo%hpnmd@hpcea.HP.COM DISCLAIMER: this message is the author's personal opinion and does not constitute the support, opinion or policy of Hewlett-Packard or of the little green men that have been following him all day.