gerwitz@eastman.UUCP (Paul Gerwitz) (03/20/89)
*********************************************************** SORRY IF THIS IS A REPOST, MAILER BOUNCED AT THE LOCAL SITE *********************************************************** I am trying to install packages (rrn, TeX etc) on my HP/9000 Model 835 with HP-UX version 2.1. I keep comming up with undefined externals like 'index' 'bcopy', 'bzero' that must be from the BSD version but for some reason cannot be resolved through the HP supplied libraries. I realize that I could recode some of these packages to use the SYS V equivilants (strcpy etc) but I would like to keep this as clean and painless as possible to maintain. Any ideas ??? Paul Gerwitz gerwitz@kodak.com ..rochester!kodak!eastman!gerwitz
spirit@uxe.cso.uiuc.edu (03/22/89)
Hello, If you look at a BSD machines man pages you will find out that the functions missing on the HP are relatively simple to replace. You can use the alternative routines below which have similar functions, or write your own. Examples of some of the stuff I have used are below: ................................................................ To use replacemnts for bcopy, index, and rindex ................................................................ #include <memory.h> #include <strings.h> #define bcopy(source,dest,count) memcpy(dest,source,count) #define index(string,ch) strchr(string,ch) #define rindex(string,ch) strrchr(string,ch) ................................................................ Easy code to rewrite though (please check for errors) ................................................................ /* * bcmp -- cmp b1 and b2, return 0 if identical, non-zero otherwise */ bcmp(b1,b2,length) char *b1,*b2; int length; { int i; for (i=0;i<length;i++) if (b2[i] != b1[i]) return(1); return(0); } /* * bcopy -- copy "length" bytes from b1 to b2 */ bcopy(b1,b2,length) char *b1,*b2; int length; { int i; for (i=0;i<length;i++) b2[i] = b1[i]; } /* * bzero -- copy "length" 0 bytes into b1 */ bzero(b1,length) char *b1; int length; { int i; for (i=0;i<length;i++) b1[i] = 0; } Have fun porting whatever code your working on... John Kemp -------------------------------------- University of Illinois Department of Atmospheric Sciences spirit@uxe.cso.uiuc.edu kemp%atmos.uiuc.edu@uxc.cso.uiuc.edu --------------------------------------
kmont@hpindda.HP.COM (Kevin Montgomery) (03/22/89)
/ hpindda:comp.sys.hp / gerwitz@eastman.UUCP (Paul Gerwitz) / 7:06 am Mar 20, 1989 /
> externals like 'index' 'bcopy', 'bzero' that must be from the BSD
Paul-
you could either change the source (I usually will #ifdef the
offending function then will only have to change it once when porting
in the future), or make a library with those offending, virtual functions
mapping to the real functions, or (if you don't want to touch the source,
per se) you could 'sed' the original source to convert things...
kev
chan@hpfcmr.HP.COM (Chan Benson) (03/22/89)
Try adding -lBSD to your link path.
burdick@hpindda.HP.COM (Matt Burdick) (03/23/89)
> I am trying to install packages (rrn, TeX etc) on my HP/9000 Model 835 > with HP-UX version 2.1. I keep comming up with undefined externals like > 'index' 'bcopy', 'bzero' that must be from the BSD version but for some > reason cannot be resolved through the HP supplied libraries. I'm not sure about 2.1 on a series 800, but /usr/lib/libBSD.a on my 6.2 series 300 has 'index' 'bcopy', 'bzero'. Try compiling with the '-lBSD' flag, if you haven't already. -matt -- Matt Burdick | Hewlett-Packard burdick%hpda@hplabs.hp.com | Technical Communications Lab
troyb@hpdml93.HP.COM (Troy Bergstrand) (03/23/89)
Using the -D cc(1) option is a good way to change strings in C code. So -Dindex=strchr -Dbcopy=memcpy ,etc. (-D is actually a cpp option).
shankar@hpclscu.HP.COM (Shankar Unni) (03/23/89)
> > externals like 'index' 'bcopy', 'bzero' that must be from the BSD
Try linking /usr/lib/libBSD.a (specify -lBSD in the link command line). An
"nm" dump of this library shows the following symbols (for HP-UX 6.2):
0x00000000 T _bcmp
0x00000000 T _bcopy
0x00000000 T _bzero
0x00000000 T _index
0x0000001C T _rindex
0x00000000 T _getwd
0x00000000 T _killpg
0x00000000 T _sigvec
0x00000000 T _signal
---
Shankar Unni.
jarmo@tut.FI (Jarmo Sorvari) (03/23/89)
I have a related problem which I ran across when compiling the CAP software library (Appletalk <--> UNIX machines) on our 9000/840. In the aufs part, a function called "flock" was required, if we want to use shared volumes using the file server. HP-UX has "lockf", but it is different from "flock". Has anybody else had the same problem and programmed a replacement for "flock" for the 800 series? BTW, applications based on CAP (LaserWriter printer spooler, Apple Unix File Server etc.) are running fine otherwise on our machine. -- ----------------------------------------------------------------------------- ! Jarmo Sorvari Control Engineering Laboratory ! ! jarmo@tut.fi Tampere University of Technology ! --------------------------------------- BOX 527, 33101 Tampere, Finland -----
burzio@mmlai.UUCP (Tony Burzio) (03/25/89)
In article <169@karhu.tut.FI>, jarmo@tut.FI (Jarmo Sorvari) writes: > I have a related problem which I ran across when compiling the CAP > software library (Appletalk <--> UNIX machines) on our 9000/840. In > the aufs part, a function called "flock" was required, if we want to > use shared volumes using the file server. HP-UX has "lockf", but it > is different from "flock". > > Has anybody else had the same problem and programmed a replacement for > "flock" for the 800 series? > > BTW, applications based on CAP (LaserWriter printer spooler, Apple > Unix File Server etc.) are running fine otherwise on our machine. What is CAP? Where can I get it? Does anyone else know of a way to connect Apple Macs to HP machines? Is there a way to print from UNIX to an Apple laser printer? We currently are file serving MACs to a uVAXII, and find it terribly slow :-). I sure would like another HP capability to add to the DECstation3100 vs HP835 war... ********************************************************************* Tony Burzio * If you can't ski, Martin Marietta Labs * it may as well be warm! mmlai!burzio@uunet.uu.net * *********************************************************************
wunder@hp-ses.SDE.HP.COM (Walter Underwood) (03/28/89)
In the aufs part, a function called "flock" was required, if we want
to use shared volumes using the file server. HP-UX has "lockf", but
it is different from "flock".
Here is an flock() emulation. flock() handles shared locks plus
exclusive locks. This only does exclusive locks. The locking
available from fcntl() is equivalent to flock(), so this really should
be rewritten to use fcntl().
Someone else suggested replacing bcopy() with memcpy(). This is not
always safe. bcopy() handles overlapping strings correctly, memcpy()
does not (it may be optimized for speed, using word moves).
wunder
-----------------
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Walter Underwood <wunder@hp-ses> on Mon Mar 27 11:26:10 1989
#
# This archive contains:
# bsd1.h flock.c
#
unset LANG
echo x - bsd1.h
cat >bsd1.h <<'@EOF'
/*
* Berkeley to HP-UX library functionality mappings
* These routines are not supported by HP.
*
* To use these, also include <sys/param.h>
*/
/* signal(2) mapping */
#define SIGCHLD SIGCLD
/* Helpful macros with select(2) */
#define NFDBITS (sizeof(int) * NBBY)
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p) (memset((char *)(p), 0, sizeof(*(p))))
/* These definitions are in <sys/file.h> on BSD 4.3 */
/*
* Flock call.
*/
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
#define LOCK_NB 4 /* don't block when locking */
#define LOCK_UN 8 /* unlock */
@EOF
chmod 644 bsd1.h
echo x - flock.c
cat >flock.c <<'@EOF'
#include <unistd.h>
#include <sys/file.h>
#include "bsd1.h" /* defines normally in <sys/file.h> */
flock(fd, operation)
int fd, operation;
{
int UN,NB,SH,EX;
int newop = 0;
UN = LOCK_UN & operation;
NB = LOCK_NB & operation;
SH = LOCK_SH & operation;
EX = LOCK_EX & operation;
if (UN)
newop = F_ULOCK;
else
if (NB)
newop = F_TLOCK;
else
if (SH || EX)
newop = F_LOCK;
else
return(-1); /* no operations set */
return(lockf(fd, newop, 0));
}
@EOF
chmod 644 flock.c
exit 0
rml@hpfcdc.HP.COM (Bob Lenk) (04/05/89)
> Here is an flock() emulation. flock() handles shared locks plus > exclusive locks. This only does exclusive locks. The locking > available from fcntl() is equivalent to flock(), so this really should > be rewritten to use fcntl(). BSD flock() cannot be completely emulated by either lockf() or fcntl(). While such emulations are likely to work for many (perhaps even most) applications, the semantics of interactions among related processes or multiple opens of the same file from the same process are quite different. flock() locks a file to an open instance (a kernel file structure, shared across dup() and fork()), while lockf()/fcntl() lock a file to a process. I have no idea how many applications would be affected by the differences, but users need to beware. Bob Lenk hplabs!hpfcla!rml rml%hpfcla@hplabs.hp.com