From: Roland McGrath <roland@redhat.com>
To: Andreas Schwab <schwab@suse.de>
Cc: libc-hacker@sources.redhat.com
Subject: Re: Cyclic dependency between <sys/ucontext.h> and <ucontext.h>
Date: Mon, 17 Feb 2003 15:06:00 -0000 [thread overview]
Message-ID: <200302170441.h1H4f2529446@magilla.sf.frob.com> (raw)
In-Reply-To: Andreas Schwab's message of Friday, 14 February 2003 22:31:29 +0100 <jeof5esg5q.fsf@sykes.suse.de>
> There is a cyclic dependency between the headers <sys/ucontext.h> and
> <ucontext.h> when _XOPEN_SOURCE is defined to 500 or 600: <sys/ucontext.h>
> includes <signal.h> which includes <ucontext.h> which includes
> <sys/ucontext.h>. The effect is that you'll get a compiler error when
> including <sys/ucontext.h> due to ucontext_t begin undefined. I don't
> know how to fix that properly, a workaround is to include <ucontext.h>
> instead.
For the record, this is easily reproduced by:
echo '#include <sys/ucontext.h>' | gcc -c -x c - -D_XOPEN_SOURCE=600
Moving #include <signal.h> outside of #ifndef _SYS_UCONTEXT_H gets around this.
That way, it winds up getting the <signal.h> definitions it needs at the
first inclusion depth, and then the circularity back to <sys/ucontext.h>
does the definitions <ucontext.h> needs, leaving nothing left in the
outermost inclusion depth (_SYS_UCONTEXT_H is already defined).
I believe <ucontext.h> in <signal.h> is only because <signal.h> is supposed
to define the ucontext_t and mcontext_t types. 1003.1-2001 doesn't say it
should declare makecontext et al as well. That being the case, <signal.h>
can just include <sys/ucontext.h> instead of <ucontext.h> and we won't have
this problem (or the unrequested declarations of makecontext et al).
The following patch does that, and makes the <sys/ucontext.h> test case
compile ok for me.
2003-02-16 Roland McGrath <roland@redhat.com>
* signal/signal.h: Include <sys/ucontext.h>, not <ucontext.h>.
--- signal/signal.h.~1.66.~ Wed Oct 23 14:05:37 2002
+++ signal/signal.h Sun Feb 16 20:40:19 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999,2000,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -327,7 +327,8 @@ extern int siginterrupt (int __sig, int
# include <bits/sigstack.h>
# ifdef __USE_XOPEN
-# include <ucontext.h>
+/* This will define `ucontext_t' and `mcontext_t'. */
+# include <sys/ucontext.h>
# endif
/* Run signals handlers on the stack specified by SS (if not NULL).
prev parent reply other threads:[~2003-02-17 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-14 21:31 Andreas Schwab
2003-02-17 15:06 ` 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=200302170441.h1H4f2529446@magilla.sf.frob.com \
--to=roland@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=schwab@suse.de \
/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).