Skip to contentSkip to conversation

remove PAGE_SIZE from headers_install

PATCH In review Olaf Hering 4 participants 11 messages Jul 14, 2007 – Aug 4, 2007 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove PAGE_SIZE from headers_install

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

define PAGE_SIZE in asm-generic/page.h
guard get_order() with _ARCH_HAS_GET_ORDER for ia64 and xtensa include asm-generic/page.h in asm/page.h
make asm/page.h nearly empty by moving the #ifdef guards up remove unneeded page.h export from frv

---
 include/asm-alpha/page.h     |    3 ++-
 include/asm-arm/page.h       |    4 ++--
 include/asm-arm26/page.h     |    2 --
 include/asm-avr32/page.h     |    2 ++
 include/asm-blackfin/page.h  |    6 +++---
 include/asm-cris/page.h      |    3 ++-
 include/asm-frv/Kbuild       |    1 -
 include/asm-frv/page.h       |    3 ++-
 include/asm-generic/Kbuild   |    1 +
 include/asm-generic/page.h   |    6 ++++++
 include/asm-h8300/page.h     |    3 ++-
 include/asm-i386/page.h      |    5 +++--
 include/asm-ia64/page.h      |    6 +++++-
 include/asm-m32r/page.h      |    6 ++++--
 include/asm-m68k/page.h      |    4 ++--
 include/asm-m68knommu/page.h |    4 ++--
 include/asm-mips/page.h      |    3 ++-
 include/asm-parisc/page.h    |    3 ++-
 include/asm-powerpc/page.h   |    4 +++-
 include/asm-ppc/page.h       |    2 +-
 include/asm-s390/page.h      |   10 +++++-----
 include/asm-sh/page.h        |    8 +++++---
 include/asm-sh64/page.h      |    7 ++++---
 include/asm-sparc/page.h     |   13 +++++++------
 include/asm-sparc64/page.h   |    3 ++-
 include/asm-v850/page.h      |   13 +++++++------
 include/asm-x86_64/page.h    |    5 +++--
 include/asm-xtensa/page.h    |   15 +++++++++------
 28 files changed, 88 insertions(+), 57 deletions(-)
include/asm-alpha/page.h +2 -1
@@ -94,7 +94,8 @@ typedef unsigned long pgprot_t;
 					 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
+#endif /* __KERNEL__ */
+
 #include <asm-generic/page.h>
 
-#endif /* __KERNEL__ */
 #endif /* _ALPHA_PAGE_H */
include/asm-arm/page.h +2 -2
@@ -190,8 +190,8 @@ typedef unsigned long pgprot_t;
 #define ARCH_SLAB_MINALIGN 8
 #endif
 
-#include <asm-generic/page.h>
-
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif
include/asm-arm26/page.h +0 -2
@@ -68,7 +68,6 @@ typedef unsigned long pgprot_t;
 
 #endif /* STRICT_MM_TYPECHECKS */
 #endif /* !__ASSEMBLY__ */
-#endif /* __KERNEL__ */
 
 /* PAGE_SHIFT determines the page size.  This is configurable. */
 #if defined(CONFIG_PAGESIZE_16)
@@ -85,7 +84,6 @@ typedef unsigned long pgprot_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 #include <asm/memory.h>
include/asm-avr32/page.h +2 -0
@@ -109,4 +109,6 @@ static inline int get_order(unsigned lon
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* __ASM_AVR32_PAGE_H */
include/asm-blackfin/page.h +3 -3
@@ -1,5 +1,6 @@
 #ifndef _BLACKFIN_PAGE_H
 #define _BLACKFIN_PAGE_H
+#ifdef __KERNEL__
 
 /* PAGE_SHIFT determines the page size */
 
@@ -11,7 +12,6 @@
 #endif
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
-#ifdef __KERNEL__
 
 #include <asm/setup.h>
 
@@ -85,9 +85,9 @@ extern unsigned long memory_end;
 #define	virt_addr_valid(kaddr)	(((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
 				((void *)(kaddr) < (void *)memory_end))
 
-#include <asm-generic/page.h>
-
 #endif				/* __ASSEMBLY__ */
 #endif				/* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif				/* _BLACKFIN_PAGE_H */
include/asm-cris/page.h +2 -1
@@ -74,9 +74,10 @@ typedef struct { unsigned long pgprot; }
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _CRIS_PAGE_H */
 
include/asm-frv/Kbuild +0 -1
@@ -4,4 +4,3 @@ header-y += registers.h
 
 unifdef-y += termios.h
 unifdef-y += ptrace.h
-unifdef-y += page.h
include/asm-frv/page.h +2 -1
@@ -81,8 +81,9 @@ extern unsigned long max_pfn;
 #endif
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_PAGE_H */
include/asm-generic/Kbuild +1 -0
@@ -8,5 +8,6 @@ header-y += poll.h
 header-y += signal.h
 header-y += statfs.h
 
+unifdef-y += page.h
 unifdef-y += resource.h
 unifdef-y += siginfo.h
include/asm-generic/page.h +6 -0
@@ -6,6 +6,7 @@
 
 #include <linux/compiler.h>
 
+#ifndef _ARCH_HAS_GET_ORDER
 /* Pure 2^n version of get_order */
 static __inline__ __attribute_const__ int get_order(unsigned long size)
 {
@@ -19,8 +20,13 @@ static __inline__ __attribute_const__ in
 	} while (size);
 	return order;
 }
+#endif
 
 #endif	/* __ASSEMBLY__ */
+#else
+
+#define PAGE_SIZE (getpagesize())
+
 #endif	/* __KERNEL__ */
 
 #endif	/* _ASM_GENERIC_PAGE_H */
include/asm-h8300/page.h +2 -1
@@ -76,8 +76,9 @@ extern unsigned long memory_end;
 #endif /* __ASSEMBLY__ */
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _H8300_PAGE_H */
include/asm-i386/page.h +3 -2
@@ -1,6 +1,7 @@
 #ifndef _I386_PAGE_H
 #define _I386_PAGE_H
 
+#ifdef __KERNEL__
 /* PAGE_SHIFT determines the page size */
 #define PAGE_SHIFT	12
 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
@@ -9,7 +10,6 @@
 #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
 #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
 
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 #ifdef CONFIG_X86_USE_3DNOW
@@ -198,9 +198,10 @@ extern int page_is_ram(unsigned long pag
 		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #define __HAVE_ARCH_GATE_AREA 1
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _I386_PAGE_H */
include/asm-ia64/page.h +5 -1
@@ -1,5 +1,6 @@
 #ifndef _ASM_IA64_PAGE_H
 #define _ASM_IA64_PAGE_H
+# ifdef __KERNEL__
 /*
  * Pagetable related stuff.
  *
@@ -7,7 +8,6 @@
  *	David Mosberger-Tang <[email protected]>
  */
 
-# ifdef __KERNEL__
 
 #include <asm/intrinsics.h>
 #include <asm/types.h>
@@ -160,6 +160,7 @@ typedef union ia64_va {
 extern unsigned int hpage_shift;
 #endif
 
+#define _ARCH_HAS_GET_ORDER 1
 static __inline__ int
 get_order (unsigned long size)
 {
@@ -227,4 +228,7 @@ get_order (unsigned long size)
 					  ? VM_EXEC : 0))
 
 # endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* _ASM_IA64_PAGE_H */
include/asm-m32r/page.h +4 -2
@@ -1,12 +1,12 @@
 #ifndef _ASM_M32R_PAGE_H
 #define _ASM_M32R_PAGE_H
+#ifdef __KERNEL__
 
 /* PAGE_SHIFT determines the page size */
 #define PAGE_SHIFT	12
 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 extern void clear_page(void *to);
@@ -84,7 +84,9 @@ typedef struct { unsigned long pgprot; }
 #define devmem_is_allowed(x) 1
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* _ASM_M32R_PAGE_H */
include/asm-m68k/page.h +2 -2
@@ -228,8 +228,8 @@ static inline __attribute_const__ int __
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
-#include <asm-generic/page.h>
-
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _M68K_PAGE_H */
include/asm-m68knommu/page.h +2 -2
@@ -75,8 +75,8 @@ extern unsigned long memory_end;
 
 #endif /* __ASSEMBLY__ */
 
-#include <asm-generic/page.h>
-
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _M68KNOMMU_PAGE_H */
include/asm-mips/page.h +2 -1
@@ -188,8 +188,9 @@ typedef struct { unsigned long pgprot; }
 #define CAC_ADDR(addr)		((addr) - UNCAC_BASE + PAGE_OFFSET)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* defined (__KERNEL__) */
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_PAGE_H */
include/asm-parisc/page.h +2 -1
@@ -171,8 +171,9 @@ extern int npmem_ranges;
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _PARISC_PAGE_H */
include/asm-powerpc/page.h +3 -1
@@ -1,6 +1,7 @@
 #ifndef _ASM_POWERPC_PAGE_H
 #define _ASM_POWERPC_PAGE_H
 
+#ifdef __KERNEL__
 /*
  * Copyright (C) 2001,2005 IBM Corporation.
  *
@@ -10,7 +11,6 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#ifdef __KERNEL__
 #include <asm/asm-compat.h>
 #include <asm/kdump.h>
 
@@ -197,4 +197,6 @@ extern const char *arch_vma_name(struct 
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_POWERPC_PAGE_H */
include/asm-ppc/page.h +1 -1
@@ -1,5 +1,6 @@
 #ifndef _PPC_PAGE_H
 #define _PPC_PAGE_H
+#ifdef __KERNEL__
 
 #include <asm/asm-compat.h>
 
@@ -13,7 +14,6 @@
  */
 #define PAGE_MASK	(~((1 << PAGE_SHIFT) - 1))
 
-#ifdef __KERNEL__
 
 /* This must match what is in arch/ppc/Makefile */
 #define PAGE_OFFSET	CONFIG_KERNEL_START
include/asm-s390/page.h +5 -5
@@ -1,3 +1,6 @@
+#ifndef _S390_PAGE_H
+#define _S390_PAGE_H
+#ifdef __KERNEL__
 /*
  *  include/asm-s390/page.h
  *
@@ -6,9 +9,6 @@
  *    Author(s): Hartmut Penner ([email protected])
  */
 
-#ifndef _S390_PAGE_H
-#define _S390_PAGE_H
-
 #include <asm/types.h>
 
 /* PAGE_SHIFT determines the page size */
@@ -18,7 +18,6 @@
 #define PAGE_DEFAULT_ACC	0
 #define PAGE_DEFAULT_KEY	(PAGE_DEFAULT_ACC << 4)
 
-#ifdef __KERNEL__
 #include <asm/setup.h>
 #ifndef __ASSEMBLY__
 
@@ -164,8 +163,9 @@ static inline int pfn_valid(unsigned lon
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _S390_PAGE_H */
include/asm-sh/page.h +5 -3
@@ -1,6 +1,8 @@
 #ifndef __ASM_SH_PAGE_H
 #define __ASM_SH_PAGE_H
 
+#ifdef __KERNEL__
+
 /*
  * Copyright (C) 1999  Niibe Yutaka
  */
@@ -13,8 +15,6 @@
    [ P4 control   ]		0xE0000000
  */
 
-#ifdef __KERNEL__
-
 /* PAGE_SHIFT determines the page size */
 #if defined(CONFIG_PAGE_SIZE_4KB)
 # define PAGE_SHIFT	12
@@ -141,7 +141,6 @@ typedef struct { unsigned long pgd; } pg
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 /* vDSO support */
 #ifdef CONFIG_VSYSCALL
@@ -149,4 +148,7 @@ typedef struct { unsigned long pgd; } pg
 #endif
 
 #endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* __ASM_SH_PAGE_H */
include/asm-sh64/page.h +4 -3
@@ -1,6 +1,6 @@
 #ifndef __ASM_SH64_PAGE_H
 #define __ASM_SH64_PAGE_H
-
+#ifdef __KERNEL__
 /*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
@@ -43,7 +43,6 @@
 #define ARCH_HAS_SETCLEAR_HUGE_PTE
 #endif
 
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 extern struct page *mem_map;
@@ -113,7 +112,9 @@ typedef struct { unsigned long pgprot; }
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* __ASM_SH64_PAGE_H */
include/asm-sparc/page.h +7 -6
@@ -1,3 +1,8 @@
+#ifndef _SPARC_PAGE_H
+#define _SPARC_PAGE_H
+
+#ifdef __KERNEL__
+
 /* $Id: page.h,v 1.55 2000/10/30 21:01:41 davem Exp $
  * page.h:  Various defines and such for MMU operations on the Sparc for
  *          the Linux kernel.
@@ -5,11 +10,6 @@
  * Copyright (C) 1995 David S. Miller ([email protected])
  */
 
-#ifndef _SPARC_PAGE_H
-#define _SPARC_PAGE_H
-
-#ifdef __KERNEL__
-
 #ifdef CONFIG_SUN4
 #define PAGE_SHIFT   13
 #else
@@ -161,8 +161,9 @@ extern unsigned long pfn_base;
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _SPARC_PAGE_H */
include/asm-sparc64/page.h +2 -1
@@ -141,7 +141,8 @@ typedef unsigned long pgprot_t;
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#endif /* __KERNEL__ */
+
 #include <asm-generic/page.h>
 
-#endif /* __KERNEL__ */
 #endif /* _SPARC64_PAGE_H */
include/asm-v850/page.h +7 -6
@@ -1,3 +1,8 @@
+#ifndef __V850_PAGE_H__
+#define __V850_PAGE_H__
+
+#ifdef __KERNEL__
+
 /*
  * include/asm-v850/page.h -- VM ops
  *
@@ -11,11 +16,6 @@
  * Written by Miles Bader <[email protected]>
  */
 
-#ifndef __V850_PAGE_H__
-#define __V850_PAGE_H__
-
-#ifdef __KERNEL__
-
 #include <asm/machdep.h>
 
 
@@ -124,8 +124,9 @@ typedef unsigned long pgprot_t;
 
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* KERNEL */
 
+#include <asm-generic/page.h>
+
 #endif /* __V850_PAGE_H__ */
include/asm-x86_64/page.h +3 -2
@@ -1,5 +1,6 @@
 #ifndef _X86_64_PAGE_H
 #define _X86_64_PAGE_H
+#ifdef __KERNEL__
 
 #include <linux/const.h>
 
@@ -37,7 +38,6 @@
 #define HPAGE_MASK	(~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
 
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 extern unsigned long end_pfn;
@@ -135,8 +135,9 @@ extern unsigned long __phys_addr(unsigne
 #define __HAVE_ARCH_GATE_AREA 1	
 
 #include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _X86_64_PAGE_H */
include/asm-xtensa/page.h +9 -6
@@ -1,3 +1,8 @@
+#ifndef _XTENSA_PAGE_H
+#define _XTENSA_PAGE_H
+
+#ifdef __KERNEL__
+
 /*
  * linux/include/asm-xtensa/page.h
  *
@@ -8,11 +13,6 @@
  * Copyright (C) 2001 - 2005 Tensilica Inc.
  */
 
-#ifndef _XTENSA_PAGE_H
-#define _XTENSA_PAGE_H
-
-#ifdef __KERNEL__
-
 #include <asm/processor.h>
 
 #define XCHAL_KSEG_CACHED_VADDR 0xd0000000
@@ -59,7 +59,7 @@ typedef struct { unsigned long pgprot; }
 /*
  * Pure 2^n version of get_order
  */
-
+#define _ARCH_HAS_GET_ORDER 1
 static inline int get_order(unsigned long size)
 {
 	int order;
@@ -133,4 +133,7 @@ void copy_user_page(void *to,void* from,
 
 #include <asm-generic/memory_model.h>
 #endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* _XTENSA_PAGE_H */
#1 lore raw
Quoted 8 lines · Olaf Hering

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

define PAGE_SIZE in asm-generic/page.h
guard get_order() with _ARCH_HAS_GET_ORDER for ia64 and xtensa include asm-generic/page.h in asm/page.h
make asm/page.h nearly empty by moving the #ifdef guards up remove unneeded page.h export from frv

imo, asm/page.h should just go away for userspace. the attached patch is what i've been using in Gentoo ... but somethings (like an arch or two in glibc) still assume asm/page.h is OK. in general though, considering asm/page.h has become so unreliable lately (a large number of arches ifdef the whole thing out), most packages out there have updated already to use the userspace interface from unistd.h. -mike

Most arches stub these headers anyways, so lets just plain punt them

include/asm-generic/Kbuild.asm +0 -3
index a37e95f..8731ae4 100644
@@ -27,9 +27,6 @@ unifdef-y += termbits.h
 unifdef-y += termios.h
 unifdef-y += types.h
 unifdef-y += unistd.h
-unifdef-y += user.h
 
 # These probably shouldn't be exported
 unifdef-y += shmparam.h
-unifdef-y += elf.h
-unifdef-y += page.h
include/linux/Kbuild +1 -5
index e81e301..43bc871 100644
@@ -15,7 +15,6 @@ header-y += usb/
 
 header-y += affs_hardblocks.h
 header-y += aio_abi.h
-header-y += a.out.h
 header-y += arcfb.h
 header-y += atmapi.h
 header-y += atmbr2684.h
@@ -54,8 +53,6 @@ header-y += dqblk_v1.h
 header-y += dqblk_v2.h
 header-y += dqblk_xfs.h
 header-y += efs_fs_sb.h
-header-y += elf-fdpic.h
-header-y += elf.h
 header-y += elf-em.h
 header-y += fadvise.h
 header-y += fd.h
@@ -162,6 +159,7 @@ unifdef-y += acct.h
 unifdef-y += adb.h
 unifdef-y += adfs_fs.h
 unifdef-y += agpgart.h
+unifdef-y += a.out.h
 unifdef-y += apm_bios.h
 unifdef-y += atalk.h
 unifdef-y += atmarp.h
@@ -185,7 +183,6 @@ unifdef-y += cyclades.h
 unifdef-y += dccp.h
 unifdef-y += dirent.h
 unifdef-y += dlm.h
-unifdef-y += elfcore.h
 unifdef-y += errno.h
 unifdef-y += errqueue.h
 unifdef-y += ethtool.h
@@ -328,7 +325,6 @@ unifdef-y += uinput.h
 unifdef-y += uio.h
 unifdef-y += unistd.h
 unifdef-y += usbdevice_fs.h
-unifdef-y += user.h
 unifdef-y += utsname.h
 unifdef-y += videodev2.h
 unifdef-y += videodev.h
include/linux/a.out.h +8 -0
index f913cc3..98210e6 100644
@@ -128,12 +128,20 @@ enum machine_type {
 #endif
 
 #ifdef linux
+#ifdef __KERNEL__
 #include <asm/page.h>
+#else
+#include <unistd.h>
+#endif
 #if defined(__i386__) || defined(__mc68000__)
 #define SEGMENT_SIZE	1024
 #else
 #ifndef SEGMENT_SIZE
+#ifdef __KERNEL__
 #define SEGMENT_SIZE	PAGE_SIZE
+#else
+#define SEGMENT_SIZE	getpagesize()
+#endif
 #endif
 #endif
 #endif
include/linux/shm.h +8 -0
index ad2e3af..b95ce87 100644
@@ -3,7 +3,11 @@
 
 #include <linux/ipc.h>
 #include <linux/errno.h>
+#ifdef __KERNEL__
 #include <asm/page.h>
+#else
+#include <unistd.h>
+#endif
 
 /*
  * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can
@@ -13,7 +17,11 @@
 #define SHMMAX 0x2000000		 /* max shared seg size (bytes) */
 #define SHMMIN 1			 /* min shared seg size (bytes) */
 #define SHMMNI 4096			 /* max num of segs system wide */
+#ifdef __KERNEL__
 #define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
+#else
+#define SHMALL (SHMMAX/getpagesize()*(SHMMNI/16))
+#endif
 #define SHMSEG SHMMNI			 /* max shared segs per process */
 
 #include <asm/shmparam.h>
#2 lore raw
Quoted 6 lines · Mike Frysinger

imo, asm/page.h should just go away for userspace. the attached patch is what i've been using in Gentoo ... but somethings (like an arch or two in glibc) still assume asm/page.h is OK. in general though, considering asm/page.h has become so unreliable lately (a large number of arches ifdef the whole thing out), most packages out there have updated already to use the userspace interface from unistd.h.

You need that signed-off thing, and dont forget to send it to [email protected]

#3 lore raw
Quoted 10 lines · Olaf Hering
Quoted 6 lines · Mike Frysinger

imo, asm/page.h should just go away for userspace. the attached patch is what i've been using in Gentoo ... but somethings (like an arch or two in glibc) still assume asm/page.h is OK. in general though, considering asm/page.h has become so unreliable lately (a large number of arches ifdef the whole thing out), most packages out there have updated already to use the userspace interface from unistd.h.

You need that signed-off thing, and dont forget to send it to [email protected]

i honestly didnt think people would consider it for inclusion as it was since i ripped out a lot more headers than just asm/page.h ;)

-mike

#4 lore raw
Quoted 2 lines · Mike Frysinger

i honestly didnt think people would consider it for inclusion as it was since i ripped out a lot more headers than just asm/page.h ;)

So split it up into individual patches. It all looks good to me.

Signature · 1 line
dwmw2
#5 lore raw
In reply to Mike Frysinger
Quoted 9 lines · Mike Frysinger
Quoted 8 lines · Olaf Hering
Quoted 6 lines · Mike Frysinger

imo, asm/page.h should just go away for userspace. the attached patch is what i've been using in Gentoo ... but somethings (like an arch or two in glibc) still assume asm/page.h is OK. in general though, considering asm/page.h has become so unreliable lately (a large number of arches ifdef the whole thing out), most packages out there have updated already to use the userspace interface from unistd.h.

Quoted 5 lines
Quoted 2 lines

You need that signed-off thing, and dont forget to send it to [email protected]

i honestly didnt think people would consider it for inclusion as it was since i ripped out a lot more headers than just asm/page.h ;)

Did you clean it up and submit it already for 2.6.23? Should someone else do it for you?

#6 lore raw
In reply to Mike Frysinger
Quoted 10 lines · Mike Frysinger
Quoted 8 lines · Olaf Hering

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

define PAGE_SIZE in asm-generic/page.h
guard get_order() with _ARCH_HAS_GET_ORDER for ia64 and xtensa include asm-generic/page.h in asm/page.h
make asm/page.h nearly empty by moving the #ifdef guards up remove unneeded page.h export from frv

Quoted 7 lines

imo, asm/page.h should just go away for userspace. the attached patch is what i've been using in Gentoo ... but somethings (like an arch or two in glibc) still assume asm/page.h is OK. in general though, considering asm/page.h has become so unreliable lately (a large number of arches ifdef the whole thing out), most packages out there have updated already to use the userspace interface from unistd.h. -mike

nothing appears to use linux/shm.h and linux/resource.h

strace-4.5.15 uses linux/a.out.h in #ifdef LINUXSPARC

glibc uses asm/elf.h in sys/procfs.h, also in alpha and powerpc.

kexec-tools use linux/elf.h

psmisc and ltrace use linux/user.h
glibc (for sh) and mono-debugger use asm/user.h

And alot of asm/page.h users.

Thats the upstream status today. What you do at home doesnt really matter.

#7 lore raw
In reply to Olaf Hering
Quoted 2 lines · Olaf Hering

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

I would think it would be better to not define it at all. Several architectures already don't have PAGE_SIZE visible to userspace in any way.

-hpa

#8 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Olaf Hering

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

I would think it would be better to not define it at all. Several architectures already don't have PAGE_SIZE visible to userspace in any way.

i386 has it, so everyone uses it.

asm/user.h uses it for NBPG, which appears in gdb configure scripts. Maybe it doesnt trigger there because the sysconf SC_* macros match.

other places where asm/page.h is used:
util-linux configure scripts, strace, xorg-11, and alot more. Have to check if they really need it.

#9 lore raw
Quoted 9 lines · Olaf Hering
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Olaf Hering

Declare PAGE_SIZE as getpagesize() for userspace.
PAGE_SIZE is used in resource.h and shm.h

I would think it would be better to not define it at all. Several architectures already don't have PAGE_SIZE visible to userspace in any way.

i386 has it, so everyone uses it.

not anymore ... it's broken too many other architectures so anything that matters has switched off of it

Quoted 2 lines

asm/user.h uses it for NBPG, which appears in gdb configure scripts. Maybe it doesnt trigger there because the sysconf SC_* macros match.

the sourceware tree (binutils/gdb/etc...) bend over backwards to get a usable definition so not having NBPG available is fine ... there's one thing left which needs fixing and i have a patch that i need to commit for that

Quoted 3 lines

other places where asm/page.h is used:
util-linux configure scripts, strace, xorg-11, and alot more. Have to check if they really need it.

those three packages you quote here i know have been fixed in the latest versions
-mike

#10 lore raw
In reply to Olaf Hering
Quoted 5 lines · Olaf Hering
Quoted 3 lines

I would think it would be better to not define it at all. Several architectures already don't have PAGE_SIZE visible to userspace in any way.

i386 has it, so everyone uses it.

PowerPC lacks it, so nothing we ship in Fedora relies upon it.

Just kill it. Probably by leaving <asm/page.h> empty for now; we can remove it completely later.

Signature · 1 line
dwmw2