mailing list of musl libc
 help / color / mirror / code / Atom feed
* Why musl define PAGE_SIZE
@ 2015-09-11 19:28 Yuxin Ren
  2015-09-11 19:44 ` Isaac Dunham
  2015-09-11 20:01 ` Rich Felker
  0 siblings, 2 replies; 5+ messages in thread
From: Yuxin Ren @ 2015-09-11 19:28 UTC (permalink / raw)
  To: musl

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

Hi ,

I found in the bits/limits.h file, musl defines PAGE_SIZE macro .
I think this macro is always defined by operating system, not libc.

Why does musl define this marco?

Thanks a lot.
Yuxin

[-- Attachment #2: Type: text/html, Size: 309 bytes --]

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

* Re: Why musl define PAGE_SIZE
  2015-09-11 19:28 Why musl define PAGE_SIZE Yuxin Ren
@ 2015-09-11 19:44 ` Isaac Dunham
  2015-09-11 19:53   ` Yuxin Ren
  2015-09-11 20:10   ` Rich Felker
  2015-09-11 20:01 ` Rich Felker
  1 sibling, 2 replies; 5+ messages in thread
From: Isaac Dunham @ 2015-09-11 19:44 UTC (permalink / raw)
  To: musl

On Fri, Sep 11, 2015 at 03:28:52PM -0400, Yuxin Ren wrote:
> Hi,
> 
> I found in the bits/limits.h file, musl defines PAGE_SIZE macro .
> I think this macro is always defined by operating system, not libc.
> 
> Why does musl define this marco?

It's required to be in limits.h, which has to be provided by libc for a
full implementation.
Hypothetically, we could get it from the Linux headers.
But the Linux headers can and sometimes do introduce definitions and
structs that violate the header namespaces, resulting in collisions
(ie, kernel header defines struct foo, application defines struct foo
without including any headers that *should* define it, application fails
to compile.)

HTH,
Isaac Dunham


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

* Re: Why musl define PAGE_SIZE
  2015-09-11 19:44 ` Isaac Dunham
@ 2015-09-11 19:53   ` Yuxin Ren
  2015-09-11 20:10   ` Rich Felker
  1 sibling, 0 replies; 5+ messages in thread
From: Yuxin Ren @ 2015-09-11 19:53 UTC (permalink / raw)
  To: musl

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

But I do not think other libcs define PAGE_SIZE, such as glibc or diet-libc.
Is that true?

Thanks

On Fri, Sep 11, 2015 at 3:44 PM, Isaac Dunham <ibid.ag@gmail.com> wrote:

> On Fri, Sep 11, 2015 at 03:28:52PM -0400, Yuxin Ren wrote:
> > Hi,
> >
> > I found in the bits/limits.h file, musl defines PAGE_SIZE macro .
> > I think this macro is always defined by operating system, not libc.
> >
> > Why does musl define this marco?
>
> It's required to be in limits.h, which has to be provided by libc for a
> full implementation.
> Hypothetically, we could get it from the Linux headers.
> But the Linux headers can and sometimes do introduce definitions and
> structs that violate the header namespaces, resulting in collisions
> (ie, kernel header defines struct foo, application defines struct foo
> without including any headers that *should* define it, application fails
> to compile.)
>
> HTH,
> Isaac Dunham
>

[-- Attachment #2: Type: text/html, Size: 1343 bytes --]

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

* Re: Why musl define PAGE_SIZE
  2015-09-11 19:28 Why musl define PAGE_SIZE Yuxin Ren
  2015-09-11 19:44 ` Isaac Dunham
@ 2015-09-11 20:01 ` Rich Felker
  1 sibling, 0 replies; 5+ messages in thread
From: Rich Felker @ 2015-09-11 20:01 UTC (permalink / raw)
  To: musl

On Fri, Sep 11, 2015 at 03:28:52PM -0400, Yuxin Ren wrote:
> Hi ,
> 
> I found in the bits/limits.h file, musl defines PAGE_SIZE macro .
> I think this macro is always defined by operating system, not libc.
> 
> Why does musl define this marco?

The page size, and whether it's a constant or variable, is part of the
target ABI. musl provides the PAGE_SIZE macro on targets where it's
constant because it may be useful to applications that want to
optimize for the case where a fixed page size is known. This is no
different from providing definitions reflecting other parts of the ABI
like type definitions or macro constants for communicating with system
interfaces.

Rich


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

* Re: Why musl define PAGE_SIZE
  2015-09-11 19:44 ` Isaac Dunham
  2015-09-11 19:53   ` Yuxin Ren
@ 2015-09-11 20:10   ` Rich Felker
  1 sibling, 0 replies; 5+ messages in thread
From: Rich Felker @ 2015-09-11 20:10 UTC (permalink / raw)
  To: musl

On Fri, Sep 11, 2015 at 12:44:02PM -0700, Isaac Dunham wrote:
> On Fri, Sep 11, 2015 at 03:28:52PM -0400, Yuxin Ren wrote:
> > Hi,
> > 
> > I found in the bits/limits.h file, musl defines PAGE_SIZE macro .
> > I think this macro is always defined by operating system, not libc.
> > 
> > Why does musl define this marco?
> 
> It's required to be in limits.h, which has to be provided by libc for a
> full implementation.

It's not required. Lack of a definition means you have to query the
value at runtime with sysconf(_SC_PAGESIZE). But failure to provide a
value on platforms where it is constant just gratuitously pessimizes
programs that need to know page size.

Rich


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

end of thread, other threads:[~2015-09-11 20:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11 19:28 Why musl define PAGE_SIZE Yuxin Ren
2015-09-11 19:44 ` Isaac Dunham
2015-09-11 19:53   ` Yuxin Ren
2015-09-11 20:10   ` Rich Felker
2015-09-11 20:01 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).