From owner-freebsd-hackers Fri Sep 13 9:30:24 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11B0037B401 for ; Fri, 13 Sep 2002 09:30:16 -0700 (PDT) Received: from swan.mail.pas.earthlink.net (swan.mail.pas.earthlink.net [207.217.120.123]) by mx1.FreeBSD.org (Postfix) with ESMTP id A6FEF43E72 for ; Fri, 13 Sep 2002 09:30:15 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0275.cvx22-bradley.dialup.earthlink.net ([209.179.199.20] helo=mindspring.com) by swan.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17ptKf-00000P-00; Fri, 13 Sep 2002 09:30:14 -0700 Message-ID: <3D821238.38BAF06D@mindspring.com> Date: Fri, 13 Sep 2002 09:28:40 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Jev , freebsd-hackers@freebsd.org Subject: Re: gethostbyname_r() fbsd equiv? References: <20020913145830.GB41842@ecad.org> <3D820700.DB53B0F9@mindspring.com> <3D820BE9.7E69C57E@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Terry Lambert wrote: > Terry Lambert wrote: > > Jev wrote: > > > Im trying to build some software on freebsd, which wants to use > > > the thread safe gethostbyname_r(). Despite having very bad C skills im > > > going to attempt to patch it. What would I use in place of > > > gethostbyname_r() on freebsd? > > > > Do you need the real gethostbyname_r(), or do you need the > > bastardized Linux version? The real version has the prototype: > > In case anyone cares, it's the pre-knowing the buffer size, with > no ability to return partial results and at the same time indicate > the buffer is to short, and the h_errno pointer and the return > of the hostent structure whose address was passed, rather than an > int, that I object to in the Linux interface. > > And yes, I know it matches the Solaris interface. Cool. In current versions of AIX and HP/UX, the _r versions of the interfaces don't exist, and the calls use thread local storage, as I had suggested previously for some of the other _r versions of itnerfaces in FreeBSD to make them thread reentrant. There's actually a crt0 modification that's needed to make this work in that case; it requires passing the address of the arg pointer down to the init constructors, so that it's available (right now, they take void arguments). This would also let us create a static "libdlopen", as a side effect, if anyone is interested (you would lose the program symbols from the ligage set, but that's not really a big loss, compared to what you get from having it, IMO). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message