[v3,29/29] Optimize various ways to obtain the page size using <bits/pagesize.h>
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
redhat-pt-bot/TryBot-32bit |
fail
|
Patch caused testsuite regressions
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
fail
|
Test failed
|
Commit Message
Create inline definitions of getpagesize and __getpagesize if they
are constant. Expand sysconf (_SC_PAGE_SIZE) inline if possible.
---
bits/shm.h | 9 +++++++++
posix/unistd.h | 21 +++++++++++++++++++++
2 files changed, 30 insertions(+)
@@ -20,6 +20,7 @@
#endif
#include <bits/types.h>
+#include <bits/pagesize.h>
/* Flags for `shmat'. */
#define SHM_RDONLY 010000 /* attach read-only else read-write */
@@ -35,6 +36,14 @@ __BEGIN_DECLS
/* Segment low boundary address multiple. */
#define SHMLBA (__getpagesize ())
extern int __getpagesize (void) __THROW __attribute__ ((__const__));
+#if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \
+ && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX
+__extern_inline int
+__NTH (__getpagesize (void))
+{
+ return 1 << __GLIBC_PAGE_SHIFT_MIN;
+}
+#endif
/* Type to count number of attaches. */
@@ -639,6 +639,19 @@ extern long int fpathconf (int __fd, int __name) __THROW;
/* Get the value of the system variable NAME. */
extern long int sysconf (int __name) __THROW;
+#include <bits/pagesize.h>
+#if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \
+ && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX
+__extern_inline long int
+__NTH (sysconf (int __name))
+{
+ if (__builtin_constant_p (__name) && __name == _SC_PAGESIZE)
+ return 1L << __GLIBC_PAGE_SHIFT_MIN;
+ extern long int __REDIRECT_NTH (__sysconf_alias, (int), sysconf);
+ return __sysconf_alias (__name);
+}
+#endif /* __USE_EXTERN_INLINES */
+
#ifdef __USE_POSIX2
/* Get the value of the string-valued system variable NAME. */
extern size_t confstr (int __name, char *__buf, size_t __len) __THROW
@@ -1010,6 +1023,14 @@ extern void sync (void) __THROW;
which is not necessarily the same as the hardware page size. */
extern int getpagesize (void) __THROW __attribute__ ((__const__));
+# if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \
+ && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX
+__extern_inline int
+__NTH (getpagesize (void))
+{
+ return 1 << __GLIBC_PAGE_SHIFT_MIN;
+}
+# endif
/* Return the maximum number of file descriptors
the current process could possibly have. */