From 8f4a5048eea6536ee85c0f2670adbb97d71e427d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 27 Mar 2010 06:19:50 -0700 Subject: [PATCH] Optimize __getpagesize a bit. --- ChangeLog | 3 +++ sysdeps/unix/sysv/linux/getpagesize.c | 27 +++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index d06b956810..4587248b6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-03-27 Ulrich Drepper + * sysdeps/unix/sysv/linux/getpagesize.c (__getpagesize): If + __ASSUME_AT_PAGESIZE we can rely on the value being set. + * include/wchar.h: Undefine __need_mbstate_t and __need_wint_t unconditionally in the end. diff --git a/sysdeps/unix/sysv/linux/getpagesize.c b/sysdeps/unix/sysv/linux/getpagesize.c index 6d03b3bbf2..0866079511 100644 --- a/sysdeps/unix/sysv/linux/getpagesize.c +++ b/sysdeps/unix/sysv/linux/getpagesize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1995-1997,2000,2002,2004 +/* Copyright (C) 1991,1992,1995-1997,2000,2002,2004,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,30 +17,37 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include #include +#include /* Return the system page size. */ int __getpagesize () { +#ifdef __ASSUME_AT_PAGESIZE + assert (GLRO(dl_pagesize) != 0); + return GLRO(dl_pagesize); +#else if (GLRO(dl_pagesize) != 0) return GLRO(dl_pagesize); -#ifdef EXEC_PAGESIZE +# ifdef EXEC_PAGESIZE return EXEC_PAGESIZE; -#else /* No EXEC_PAGESIZE. */ -#ifdef NBPG -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* No CLSIZE. */ +# else /* No EXEC_PAGESIZE. */ +# ifdef NBPG +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* No CLSIZE. */ return NBPG * CLSIZE; -#else /* No NBPG. */ +# else /* No NBPG. */ return NBPC; -#endif /* NBPG. */ -#endif /* EXEC_PAGESIZE. */ +# endif /* NBPG. */ +# endif /* EXEC_PAGESIZE. */ +#endif } libc_hidden_def (__getpagesize) weak_alias (__getpagesize, getpagesize) -- 2.11.4.GIT