This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ports/16191] New: PAGE_SIZE defined constant on MIPS, but size is configurable


https://sourceware.org/bugzilla/show_bug.cgi?id=16191

            Bug ID: 16191
           Summary: PAGE_SIZE defined constant on MIPS, but size is
                    configurable
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ports
          Assignee: unassigned at sourceware dot org
          Reporter: ams at sourceware dot org
                CC: carlos at redhat dot com, roland at gnu dot org

The sys/user.h header defines PAGE_SIZE to a constant (4096), but that figure
is not always accurate; the page size is a kernel configuration option.

  #define PAGE_SHIFT              12
  #define PAGE_SIZE               (1UL << PAGE_SHIFT)
  #define PAGE_MASK               (~(PAGE_SIZE-1))
  #define NBPG                    PAGE_SIZE
  #define UPAGES                  1
  #define HOST_TEXT_START_ADDR    (u.start_code)
  #define HOST_DATA_START_ADDR    (u.start_data)
  #define HOST_STACK_END_ADDR     (u.start_stack + u.u_ssize * NBPG)

A knock-on effect of this bug is that sysdeps/unix/sysv/linux/ifaddrs.c uses an
"optimization" when PAGE_SIZE is constant that means getifaddrs will always
fail when the real page size does not match PAGE_SIZE.

  #ifdef PAGE_SIZE
    /* Help the compiler optimize out the malloc call if PAGE_SIZE
       is constant and smaller or equal to PTHREAD_STACK_MIN/4.  */
    const size_t buf_size = PAGE_SIZE;
  #else
    const size_t buf_size = __getpagesize ();
  #endif

According to Andrew Pinski, the constant PAGE_SIZE is not appropriate on any
MIPS variant, so at least some of the above macros can be removed. Other
architectures appear to remove all of them, but it's not clear that that's
correct on MIPS.

This issue probably applied to other architectures also. Joseph Myers has
mentioned MicroBlaze.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]