From owner-freebsd-current Wed May 20 00:47:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA09933 for freebsd-current-outgoing; Wed, 20 May 1998 00:47:44 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from ren.dtir.qld.gov.au (firewall-user@ns.dtir.qld.gov.au [203.108.138.66]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA09882 for ; Wed, 20 May 1998 00:47:36 -0700 (PDT) (envelope-from syssgm@dtir.qld.gov.au) Received: by ren.dtir.qld.gov.au; id RAA06193; Wed, 20 May 1998 17:47:20 +1000 (EST) Received: from ogre.dtir.qld.gov.au(167.123.8.3) by ren.dtir.qld.gov.au via smap (3.2) id xma006190; Wed, 20 May 98 17:47:14 +1000 Received: from troll.dtir.qld.gov.au (troll-8.dtir.qld.gov.au [167.123.8.1]) by ogre.dtir.qld.gov.au (8.8.7/8.8.7) with ESMTP id RAA17244; Wed, 20 May 1998 17:47:14 +1000 (EST) Received: from localhost (syssgm@localhost) by troll.dtir.qld.gov.au (8.8.5/8.8.5) with SMTP id RAA09525; Wed, 20 May 1998 17:47:10 +1000 (EST) Message-Id: <199805200747.RAA09525@troll.dtir.qld.gov.au> X-Authentication-Warning: troll.dtir.qld.gov.au: syssgm@localhost didn't use HELO protocol To: Terry Lambert cc: freebsd-current@FreeBSD.ORG, syssgm@dtir.qld.gov.au Subject: Re: Fix for undefined "__error" and discussion of shared object versioning References: <199805200312.UAA26227@usr04.primenet.com> In-Reply-To: <199805200312.UAA26227@usr04.primenet.com> from Terry Lambert at "Wed, 20 May 1998 03:12:25 +0000" Date: Wed, 20 May 1998 17:47:10 +1000 From: Stephen McKay Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wednesday, 20th May 1998, Terry Lambert wrote: >hermes% gcc -v >gcc version 2.7.2.1 Ditto. Tweaking your code slightly: -- errno.h ------------------------------------------------------------------- #ifndef KERNEL #include __BEGIN_DECLS int * __error __P((void)); extern int fake_used; static int *___error(void) { extern int errno; fake_used++; return &errno; } #pragma weak __error = ___error #warning "using a fake errno.h" __END_DECLS #define errno (* __error()) #endif -- terry.c ------------------------------------------------------------------- #include "errno.h" /* use hacked errno.h because of paranoia*/ #include int fake_used; main() { printf("default errno is %d\n", errno); printf("fake_used is %d\n", fake_used); } ------------------------------------------------------------------------------ My non-libc_r linkage does: ------------------------------------------------------------------------------ $ cc -o terry terry.c In file included from terry.c:1: errno.h:8: warning: #warning "using a fake errno.h" $ ./terry default errno is 0 fake_used is 1 ------------------------------------------------------------------------------ My libc_r linkage does: ------------------------------------------------------------------------------ $ cc -o terry terry.c -lc_r In file included from terry.c:1: errno.h:8: warning: #warning "using a fake errno.h" $ ./terry default errno is 2 fake_used is 2 ------------------------------------------------------------------------------ >The difference in the output is because PHK's malloc always fails a >``readlink("/etc/malloc.conf");'' and sets errno = ENOENT (2). This explains the errno of 2. fake_used should be 0. I explain the count of 2 by assuming that one is for the assignment to errno, and the other for the read of errno. Our ___error() should not have been called at all in this example. So, it's not working properly after all. I am keen to make this work, but don't know how. Why don't weak symbols work for this? >> I don't see how your major/minor/subminor is any better than the >> current major/minor, or how it would avoid the current problem. > >It would avoid the problem by letting us bump the minor but not the >subminor when the errno.h change went in. So long as you did not >foolishly replace an existing library of the same major/minor that >you had built on your own, the executable would continue to prefer >the old library to the new library you had built. What you are saying is that we would bump the minor numbers on all libraries with your system, as opposed to bumping the major numbers on all libraries with the current system. This gains nothing as far as I can see. >> The lesson here is to have no global variables! > >Tell POSIX/ANSI about it. Call me if they actually listen to you, since >I want some things fixed. 8-). It's all happening with the Open Group now, isn't it? Aren't they about to release Unix 98 to match Windoze 98? Misfeature for misfeature I expect. :-) Stephen. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message