public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Thorsten Kukuk <kukuk@suse.de>
Cc: libc-hacker@sources.redhat.com
Subject: Re: bits/libc-lock.h and _LIBC
Date: Fri, 08 Nov 2002 09:57:00 -0000	[thread overview]
Message-ID: <200211081757.gA8HvoJ05389@magilla.sf.frob.com> (raw)
In-Reply-To: Thorsten Kukuk's message of  Monday, 21 October 2002 11:27:36 +0200 <20021021112734.A25309@suse.de>

I don't think that bits/libc-lock.h should be useful outside of libc.
In fact, I think we should stop installing it.

The original intent of bits/libc-lock.h was to be used in user-visible
headers such as using __libc_lock_{lock,unlock} in the getc macro in
stdio.h.  (This was before the pthreads spec, and its interfaces for
locked/unlocked stdio streams, existed.)  For that use, the opaque types
are necessary to respect the ANSI C name space.  The other types and macros
for things that are not locks, and the unconditional inclusion of
pthread.h, were added to libc-lock.h when I was not involved and people
were not as anal about permitting this potential kind of use while meeting
the name space requirements.  It's now the case that we're sure no
user-visible header needs to use these macros.  Now we would probably avoid
introducing any such thing, and if such a need came up we would just use
the pthreads interfaces directly.

libio's data structure already has an indirection precisely to avoid the
user-visible header needing to know the lock type's layout.  libio-using
code can already just use the flockfile or _IO_flockfile interfaces.

The only installed header that in any way involves bits/libc-lock.h now is
libio.h.  So my plan is to stop installing it, and address libio.h and
bits/stdio-lock.h as follows.

Aside from compiling libc itself, there are two cases that matter.

1. code written for libio on a native glibc system, i.e. your own stream
   flavors with your own jump table, that would like to interact nicely
   with pthreads-enabled uses of stdio, so user defines _IO_MTSAFE_IO.

   For this, a bits/stdio-lock.h written in terms of pthreads interfaces
   directly would be fine.  pthread_cleanup_push/pop can't be referenced
   weakly (there're macros); but if you define _IO_MTSAFE_IO, you probably
   are linking with libpthread anyway.  (In the medium-term future, those
   will be done by try/finally and not have any link-time dependency, so
   using those and _IO_flockfile will make _IO_MTSAFE_IO users
   pthreads-aware but not pthreads-requiring.)

2. What you are talking about is sharing this libio source code for
   unrelated private uses in other packages.  (That is fine, but do
   remember that the primary role of the glibc sources is to build the
   whole libc as the system library for free operating systems.  The
   maintenance burden for supporting other uses of the sources needs to be
   kept minimal on us and the future us, unless it's required for other
   official GNU packages, as is the case with getopt and the various other
   shared sources.)  For that, you can supply whatever bits/stdio-lock.h
   header you want, it doesn't have to be the one in the libc sources.
   The pthreads-using version I am considering making glibc install now
   might well be just what you want, but it doesn't matter that glibc
   change for you to use a header that works for the way you are using the
   libio sources.

For compiling libc, things are already as they should be.  The current
sysdeps/generic/bits/stdio-lock.h can become include/bits/stdio-lock.h and
a pthreads-using version in sysdeps/pthread/bits/stdio-lock.h will be the
one installed.

I'm not sure what problem you might have that isn't solved by just using
your own bits/stdio-lock.h in the package where you've copied the libio
sources from glibc.  But is there any problem you have that isn't solved by
the header changes I described above?

Does anyone else see a problem with those changes?  I think case #1 is
reasonable enough to support, and I guess it's actually broken now.  But
more importantly I want to stop installing bits/libc-lock.h since it really
is an internal-only header, and having it there clearly confuses people.


Thanks,
Roland

      parent reply	other threads:[~2002-11-08 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-22  6:51 Thorsten Kukuk
2002-11-04  1:29 ` Ulrich Drepper
2002-11-04  1:32   ` Thorsten Kukuk
2002-11-04  1:46     ` Ulrich Drepper
2002-11-08  9:57 ` Roland McGrath [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211081757.gA8HvoJ05389@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=kukuk@suse.de \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).