From owner-freebsd-current Tue May 19 20:12:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA27116 for freebsd-current-outgoing; Tue, 19 May 1998 20:12:34 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp02.primenet.com (daemon@smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA27111 for ; Tue, 19 May 1998 20:12:33 -0700 (PDT) (envelope-from tlambert@usr04.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id UAA28171; Tue, 19 May 1998 20:12:32 -0700 (MST) Received: from usr04.primenet.com(206.165.6.204) via SMTP by smtp02.primenet.com, id smtpd028156; Tue May 19 20:12:30 1998 Received: (from tlambert@localhost) by usr04.primenet.com (8.8.5/8.8.5) id UAA26227; Tue, 19 May 1998 20:12:25 -0700 (MST) From: Terry Lambert Message-Id: <199805200312.UAA26227@usr04.primenet.com> Subject: Re: Fix for undefined "__error" and discussion of shared object versioning To: syssgm@dtir.qld.gov.au (Stephen McKay) Date: Wed, 20 May 1998 03:12:25 +0000 (GMT) Cc: tlambert@primenet.com, freebsd-current@FreeBSD.ORG, syssgm@dtir.qld.gov.au In-Reply-To: <199805190928.TAA10958@troll.dtir.qld.gov.au> from "Stephen McKay" at May 19, 98 07:28:50 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I still don't think this works. I'm not testing this live, I'm faking up > test cases. Assume I changed #ifndef __GNUC__ to #ifdef __GNUC__ already. > > I've renamed stuff to show the principle not working more easily: I dunno. I didn't protect with __GNUC__ in my test cases, and I used a live build tree with the real libc_r, linked shared. Your mileage may vary, but mine didn't. My gcc -v returns: ------------------------------------------------------------------------------ hermes% gcc -v gcc version 2.7.2.1 ------------------------------------------------------------------------------ It works the same on gcc 2.8.0, which I use for ACAP and C++ threads safe exceptions and the Standard Template Library. My errno.h code looks like this: -- errno.h ------------------------------------------------------------------- #ifndef KERNEL #include __BEGIN_DECLS int * __error __P((void)); static int *___error(void) { extern int errno; return &errno; } #pragma weak __error = ___error #warning "using a fake errno.h" __END_DECLS #define errno (* __error()) #endif ------------------------------------------------------------------------------ My test case looks like: -- foo.c --------------------------------------------------------------------- #include "errno.h" /* use hacked errno.h because of paranoia*/ #include main() { printf( "default errno is %d\n", errno); } ------------------------------------------------------------------------------ My non-libc_r linkage does: ------------------------------------------------------------------------------ hermes% cc -o foo foo.c In file included from foo.c:2: errno.h:51: warning: #warning "using a fake errno.h" hermes% ./foo default errno is 0 ------------------------------------------------------------------------------ My libc_r linkage does: ------------------------------------------------------------------------------ hermes% cc -o foo foo.c -lc_r In file included from foo.c:2: errno.h:51: warning: #warning "using a fake errno.h" hermes% ./foo default errno is 2 ------------------------------------------------------------------------------ The difference in the output is because PHK's malloc always fails a ``readlink("/etc/malloc.conf");'' and sets errno = ENOENT (2). Are you sure you are running a futzed up compiler, like egcs? > >It is, however, the correct one, I've decided, working on getting > >this hack to actually work. > > It would be a big pain though. Could we wait for ELF instead? > > >The versioning needs major, minor, and subminor. > > 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. The old library doesn't reference __error() via use of errno. > The current problem is due to replacing a global integer with a function. > Replacing one function with another would have been simple. 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-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message