]> git.proxmox.com Git - wasi-libc.git/commitdiff
Add a `getpagesize` function. (#300)
authorDan Gohman <dev@sunfishcode.online>
Mon, 11 Jul 2022 15:27:39 +0000 (08:27 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Jul 2022 15:27:39 +0000 (08:27 -0700)
* Add a `getpagesize` function.

This adds a `getpagesize` function. This interface is deprecated in POSIX,
but it's sufficiently widely used and not problematic in practice.

* Use musl's `getpagesize`.

* Enable the `getpagesize` declaration in unistd.h.

Makefile
expected/wasm32-wasi/defined-symbols.txt
libc-bottom-half/headers/public/__macro_PAGESIZE.h
libc-top-half/musl/include/unistd.h

index 4341980f4faa483ac2ae5c92934e36a4f816c20c..6eaf094790157b12029f842d558241b66317062c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -145,6 +145,7 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
         env/unsetenv.c \
         unistd/posix_close.c \
         stat/futimesat.c \
+        legacy/getpagesize.c \
     ) \
     $(filter-out %/procfdname.c %/syscall.c %/syscall_ret.c %/vdso.c %/version.c, \
                  $(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/*.c)) \
index 69242c75dd5b36fd43bcecef0822b19bc72fa6fe..40023d96d0771be1a619fac727aea77ec738c65b 100644 (file)
@@ -681,6 +681,7 @@ getline
 getopt
 getopt_long
 getopt_long_only
+getpagesize
 getpid
 getrusage
 getsockopt
index 0243c98c9a1f685c2fe5edf5281d12f4e1b33e76..d89222050ca697d23026839a5a02cec6d2a3bacb 100644 (file)
@@ -5,6 +5,11 @@
  * The page size in WebAssembly is fixed at 64 KiB. If this ever changes,
  * it's expected that applications will need to opt in, so we can change
  * this.
+ *
+ * If this ever needs to be a value outside the range of an `int`, the
+ * `getpagesize` function which returns this value will need special
+ * consideration. POSIX has deprecated `getpagesize` in favor of
+ * `sysconf(_SC_PAGESIZE)` which does not have this problem.
  */
 #define PAGESIZE (0x10000)
 
index 9231d605c4cf6a0e6950c672a7182f9a725ceac8..b5cb5c6630169415c4e155c6d57cc7b943910d16 100644 (file)
@@ -244,7 +244,9 @@ void *sbrk(intptr_t);
 pid_t vfork(void);
 int vhangup(void);
 int chroot(const char *);
+#endif
 int getpagesize(void);
+#ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
 int getdtablesize(void);
 int sethostname(const char *, size_t);
 int getdomainname(char *, size_t);