public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Fwd: Why are there multiple ucontext.h headers for the same architeture?
       [not found] <CAL+bK4MjSmtjMrqOxpWnvn91=DuA8wb7RduRq2RMKjab7f-SyQ@mail.gmail.com>
@ 2020-01-20  9:44 ` Neven Sajko
  2020-01-20 15:03   ` Carlos O'Donell
  0 siblings, 1 reply; 6+ messages in thread
From: Neven Sajko @ 2020-01-20  9:44 UTC (permalink / raw)
  To: libc-help

Hello,

I was browsing through the Glibc source tree when I noticed a weird
thing: this two files are similar:

sysdeps/unix/sysv/linux/arm/sys/ucontext.h
sysdeps/arm/sys/ucontext.h

I am thinking that one may be for Linux and the other for Hurd?

In what cases is the first header used/packaged/installed, and when
the other header?

Also, it is strange that the files are not more similar, for example,
in one header the ARM registers are in an array, and in the other they
are struct fields. Why the difference? Could this not be more unified?

Thanks,
Neven

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why are there multiple ucontext.h headers for the same architeture?
  2020-01-20  9:44 ` Fwd: Why are there multiple ucontext.h headers for the same architeture? Neven Sajko
@ 2020-01-20 15:03   ` Carlos O'Donell
  2020-01-20 15:34     ` Lukasz Majewski
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos O'Donell @ 2020-01-20 15:03 UTC (permalink / raw)
  To: Neven Sajko; +Cc: libc-help

On Mon, Jan 20, 2020 at 4:44 AM Neven Sajko <nsajko@gmail.com> wrote:
>
> Hello,
>
> I was browsing through the Glibc source tree when I noticed a weird
> thing: this two files are similar:
>
> sysdeps/unix/sysv/linux/arm/sys/ucontext.h
> sysdeps/arm/sys/ucontext.h
>
> I am thinking that one may be for Linux and the other for Hurd?
>
> In what cases is the first header used/packaged/installed, and when
> the other header?
>
> Also, it is strange that the files are not more similar, for example,
> in one header the ARM registers are in an array, and in the other they
> are struct fields. Why the difference? Could this not be more unified?

The glibc build system searches system dependency directories in a
particular order and resolves them with a specific set of rules.

This ordering and rules allows architectures to define their own
copies of certain headers.

Where possible we try to refactor things to avoid duplicate headers,
but it does happen sometimes.

You can see the sysdep ordering during the glibc build:

config_sysdirs='sysdeps/unix/sysv/linux/x86_64/64
sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86
sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64
sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl
sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv
sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64
sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu
sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86
sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96
sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64
sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754
sysdeps/generic'

Does that answer your questions?

Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why are there multiple ucontext.h headers for the same architeture?
  2020-01-20 15:03   ` Carlos O'Donell
@ 2020-01-20 15:34     ` Lukasz Majewski
  2020-01-20 23:27       ` Neven Sajko
  2020-01-21  4:04       ` Carlos O'Donell
  0 siblings, 2 replies; 6+ messages in thread
From: Lukasz Majewski @ 2020-01-20 15:34 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: Neven Sajko, libc-help

[-- Attachment #1: Type: text/plain, Size: 2375 bytes --]

Hi Carlos,

> On Mon, Jan 20, 2020 at 4:44 AM Neven Sajko <nsajko@gmail.com> wrote:
> >
> > Hello,
> >
> > I was browsing through the Glibc source tree when I noticed a weird
> > thing: this two files are similar:
> >
> > sysdeps/unix/sysv/linux/arm/sys/ucontext.h
> > sysdeps/arm/sys/ucontext.h
> >
> > I am thinking that one may be for Linux and the other for Hurd?
> >
> > In what cases is the first header used/packaged/installed, and when
> > the other header?
> >
> > Also, it is strange that the files are not more similar, for
> > example, in one header the ARM registers are in an array, and in
> > the other they are struct fields. Why the difference? Could this
> > not be more unified?  
> 
> The glibc build system searches system dependency directories in a
> particular order and resolves them with a specific set of rules.

Sorry to jump in ... but this puzzles me from some time.

Is there any Makefile facility (other than standard --debug[=FLAGS]
switch) to facilitate debugging?

Or maybe there is any other way to inspect this?

> 
> This ordering and rules allows architectures to define their own
> copies of certain headers.
> 
> Where possible we try to refactor things to avoid duplicate headers,
> but it does happen sometimes.
> 
> You can see the sysdep ordering during the glibc build:
> 
> config_sysdirs='sysdeps/unix/sysv/linux/x86_64/64
> sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86
> sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64
> sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl
> sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv
> sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64
> sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu
> sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86
> sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96
> sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64
> sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754
> sysdeps/generic'
> 
> Does that answer your questions?
> 
> Cheers,
> Carlos.




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why are there multiple ucontext.h headers for the same architeture?
  2020-01-20 15:34     ` Lukasz Majewski
@ 2020-01-20 23:27       ` Neven Sajko
  2020-01-21  4:02         ` Carlos O'Donell
  2020-01-21  4:04       ` Carlos O'Donell
  1 sibling, 1 reply; 6+ messages in thread
From: Neven Sajko @ 2020-01-20 23:27 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Carlos O'Donell, libc-help

I still do not understand this: when would sysdeps/arm/sys/ucontext.h
be used/installed instead of
sysdeps/unix/sysv/linux/arm/sys/ucontext.h?

Or, more generally, these seem to be all the ucontext.h headers in glibc:

sysdeps/unix/sysv/linux/x86/sys/ucontext.h
sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
sysdeps/unix/sysv/linux/sh/sys/ucontext.h
sysdeps/unix/sysv/linux/s390/sys/ucontext.h
sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
sysdeps/unix/sysv/linux/mips/sys/ucontext.h
sysdeps/unix/sysv/linux/microblaze/sys/ucontext.h
sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
sysdeps/unix/sysv/linux/csky/sys/ucontext.h
sysdeps/unix/sysv/linux/arm/sys/ucontext.h
sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
sysdeps/mips/sys/ucontext.h
sysdeps/m68k/sys/ucontext.h
sysdeps/i386/sys/ucontext.h
sysdeps/generic/sys/ucontext.h
sysdeps/arm/sys/ucontext.h
stdlib/ucontext.h
include/ucontext.h

So the same question I asked for ARM could also be asked for i386,
m68k, or mips.

Thanks,
Neven

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why are there multiple ucontext.h headers for the same architeture?
  2020-01-20 23:27       ` Neven Sajko
@ 2020-01-21  4:02         ` Carlos O'Donell
  0 siblings, 0 replies; 6+ messages in thread
From: Carlos O'Donell @ 2020-01-21  4:02 UTC (permalink / raw)
  To: Neven Sajko; +Cc: Lukasz Majewski, libc-help

On Mon, Jan 20, 2020 at 6:27 PM Neven Sajko <nsajko@gmail.com> wrote:
>
> I still do not understand this: when would sysdeps/arm/sys/ucontext.h
> be used/installed instead of
> sysdeps/unix/sysv/linux/arm/sys/ucontext.h?

The search directories for system dependencies are ordered and
searched in their order.

On a normal x86_64 build the search order is:
sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64
sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl
sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl
sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu
sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64 sysdeps/unix
sysdeps/posix sysdeps/x86_64/64 sysdeps/x86_64/fpu/multiarch
sysdeps/x86_64/fpu sysdeps/x86/fpu sysdeps/x86_64/multiarch
sysdeps/x86_64 sysdeps/x86 sysdeps/ieee754/float128
sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64/wordsize-64
sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/wordsize-64
sysdeps/ieee754 sysdeps/generic

Which means that sysdeps/unix/sysv/linux/x86 comes *before*
sysdeps/generic (last on the list).

Therefore sysdeps/unix/sysv/linux/x86/sys/ucontext.h is the installed header.

The sysdep dirs are used via make's vpath directive.

> Or, more generally, these seem to be all the ucontext.h headers in glibc:

Right, there is one per viable configuration.

> sysdeps/unix/sysv/linux/x86/sys/ucontext.h
> sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
> sysdeps/unix/sysv/linux/sh/sys/ucontext.h
> sysdeps/unix/sysv/linux/s390/sys/ucontext.h
> sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
> sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
> sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
> sysdeps/unix/sysv/linux/mips/sys/ucontext.h
> sysdeps/unix/sysv/linux/microblaze/sys/ucontext.h
> sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
> sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
> sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
> sysdeps/unix/sysv/linux/csky/sys/ucontext.h
> sysdeps/unix/sysv/linux/arm/sys/ucontext.h
> sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
> sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
> sysdeps/mips/sys/ucontext.h
> sysdeps/m68k/sys/ucontext.h
> sysdeps/i386/sys/ucontext.h
> sysdeps/generic/sys/ucontext.h
> sysdeps/arm/sys/ucontext.h
> stdlib/ucontext.h
> include/ucontext.h
>
> So the same question I asked for ARM could also be asked for i386,
> m68k, or mips.

I hope that I have answered your question with my response above.

Cheers,
Carlos.

> Or, more generally, these seem to be all the ucontext.h headers in glibc:

Right, there is one per viable configuration.

> sysdeps/unix/sysv/linux/x86/sys/ucontext.h
> sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
> sysdeps/unix/sysv/linux/sh/sys/ucontext.h
> sysdeps/unix/sysv/linux/s390/sys/ucontext.h
> sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
> sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
> sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
> sysdeps/unix/sysv/linux/mips/sys/ucontext.h
> sysdeps/unix/sysv/linux/microblaze/sys/ucontext.h
> sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
> sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
> sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
> sysdeps/unix/sysv/linux/csky/sys/ucontext.h
> sysdeps/unix/sysv/linux/arm/sys/ucontext.h
> sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
> sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
> sysdeps/mips/sys/ucontext.h
> sysdeps/m68k/sys/ucontext.h
> sysdeps/i386/sys/ucontext.h
> sysdeps/generic/sys/ucontext.h
> sysdeps/arm/sys/ucontext.h
> stdlib/ucontext.h
> include/ucontext.h
>
> So the same question I asked for ARM could also be asked for i386,
> m68k, or mips.

I hope that I have answered your question with my response above.

Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why are there multiple ucontext.h headers for the same architeture?
  2020-01-20 15:34     ` Lukasz Majewski
  2020-01-20 23:27       ` Neven Sajko
@ 2020-01-21  4:04       ` Carlos O'Donell
  1 sibling, 0 replies; 6+ messages in thread
From: Carlos O'Donell @ 2020-01-21  4:04 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Neven Sajko, libc-help

On Mon, Jan 20, 2020 at 10:34 AM Lukasz Majewski <lukma@denx.de> wrote:
> Sorry to jump in ... but this puzzles me from some time.
>
> Is there any Makefile facility (other than standard --debug[=FLAGS]
> switch) to facilitate debugging?

Only the standard Makefile debugging facilities are available.

I am open to adding more debugging output like the whole sysdep list
in order if that helps?

> Or maybe there is any other way to inspect this?

The build log contains the sysdep list.

e.g.
LC_ALL=C gawk -f scripts/sysd-rules.awk > /home/carlos/build/glibc/sysd-rulesT \
                -v all_object_suffixes='.o .os .oS' \
                -v inhibit_sysdep_asm='' \
                -v sysd_rules_patterns='%:% rtld-%:rtld-% rtld-%:% m_%:s_%' \
                -v config_sysdirs='sysdeps/unix/sysv/linux/x86_64/64
sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86
sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64
sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl
sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv
sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64
sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu
sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86
sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96
sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64
sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754
sysdeps/generic'

Then you can see the list in order generated from sysd-rules.awk.

Does that answer your question?

Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-21  4:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAL+bK4MjSmtjMrqOxpWnvn91=DuA8wb7RduRq2RMKjab7f-SyQ@mail.gmail.com>
2020-01-20  9:44 ` Fwd: Why are there multiple ucontext.h headers for the same architeture? Neven Sajko
2020-01-20 15:03   ` Carlos O'Donell
2020-01-20 15:34     ` Lukasz Majewski
2020-01-20 23:27       ` Neven Sajko
2020-01-21  4:02         ` Carlos O'Donell
2020-01-21  4:04       ` Carlos O'Donell

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).