Skip to content

Commit 7efd762

Browse files
ammarfaizi2paulmckrcu
authored andcommitted
nolibc/sys: Implement getpagesize(2) function
This function returns the page size used by the running kernel. The page size value is taken from the auxiliary vector at 'AT_PAGESZ' key. 'getpagesize(2)' is assumed as a syscall becuase the manpage placement of this function is in entry 2 ('man 2 getpagesize') despite there is no real 'getpagesize(2)' syscall in the Linux syscall table. Define this function in 'sys.h'. Signed-off-by: Ammar Faizi <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent c61a078 commit 7efd762

File tree

1 file changed

+21
-0
lines changed
  • tools/include/nolibc

1 file changed

+21
-0
lines changed

tools/include/nolibc/sys.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/fs.h>
2020
#include <linux/loop.h>
2121
#include <linux/time.h>
22+
#include <linux/auxvec.h>
2223

2324
#include "arch.h"
2425
#include "errno.h"
@@ -499,6 +500,26 @@ pid_t gettid(void)
499500
return sys_gettid();
500501
}
501502

503+
static unsigned long getauxval(unsigned long key);
504+
505+
/*
506+
* long getpagesize(void);
507+
*/
508+
509+
static __attribute__((unused))
510+
long getpagesize(void)
511+
{
512+
long ret;
513+
514+
ret = getauxval(AT_PAGESZ);
515+
if (!ret) {
516+
SET_ERRNO(ENOENT);
517+
return -1;
518+
}
519+
520+
return ret;
521+
}
522+
502523

503524
/*
504525
* int gettimeofday(struct timeval *tv, struct timezone *tz);

0 commit comments

Comments
 (0)