Comments (4)
I don't see any reason not to include this.
from wasi-libc.
From a quick search, code embedding OpenBSD's reallocarray looks like this, which doesn't have a getpagesize
call. Is the code you're using embedding OpenBSD's entire malloc
implementation? If so, getpagesize
may not be the only problem, as that would also need a real mmap
. The underlying WebAssembly platform doesn't support mmap
, so wasi-libc's mmap
is emulated; it calls malloc
to do the actual allocation, but that won't work if you're using mmap
to implement malloc
:-).
wasi-libc does support reallocarray
, so one option would be to change the code to just use that rather than using its own bundled version.
Beyond that, C code calling functions which have been deprecated since the 1990's isn't an automatic priority for me, but getpagesize
is sufficiently widely used and harmless that it'd be ok to support. I posted #300 with an implementation.
from wasi-libc.
This is about recallocarray()
, not reallocarray()
. See https://github.com/openbsd/src/blob/master/lib/libc/stdlib/recallocarray.c for the OpenBSD implementation. It's much more trivial and a wrapper on top of calloc
, so no mmap
required etc. I've confirmed that if one replaces getpagesize()
there with PAGE_SIZE
or sysconf(_SC_PAGESIZE)
it builds and works just fine.
Thanks so much for the quick response & PR! I wonder, does this needs a reimplementation in the bottom half, given this is already present in the top-half and already in wasi-libc's source tree? cf.
https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/src/legacy/getpagesize.c
from wasi-libc.
This is about
recallocarray()
, notreallocarray()
. See https://github.com/openbsd/src/blob/master/lib/libc/stdlib/recallocarray.c for the OpenBSD implementation. It's much more trivial and a wrapper on top ofcalloc
, so nommap
required etc. I've confirmed that if one replacesgetpagesize()
there withPAGE_SIZE
orsysconf(_SC_PAGESIZE)
it builds and works just fine.
Ah, I misread that.
Thanks so much for the quick response & PR! I wonder, does this needs a reimplementation in the bottom half, given this is already present in the top-half and already in wasi-libc's source tree? cf. https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/src/legacy/getpagesize.c
I updated to PR to use the musl version.
from wasi-libc.
Related Issues (20)
- Please tag wasi-sdk-21 HOT 2
- is there any plan to support mqueue/rwlock api? HOT 1
- Support sigaction (for LLVM) HOT 1
- how does preview2 deal with wasm64? HOT 2
- locking issues in chdir.c
- O_RESOLVE_BENEATH is forced HOT 4
- both `/` and `.` preopens "normlaize" to empty string meaning it is not possible to preopen root and current dir simultaneously HOT 6
- main in a library regression HOT 2
- Enhancement request: interface to get the wasi-libc version at runtime HOT 2
- Support `mprotect` in wasi-emulated-mman HOT 6
- Consider including a pthread.h for all targets HOT 5
- httpclient module for API request HOT 1
- Dereferencing nullptr in __sec_to_zone function HOT 2
- wasi-libc should probably not define `_POSIX_CPUTIME` and `_POSIX_THREAD_CPUTIME`...
- Command line length limits are easily exceeded on Windows HOT 1
- Keep/separate out a list of symbols that are only stubs
- sysroot for wasm64
- FTS Support HOT 1
- Support WASIp2 sockets in `read` and `write`
- [msys2] AR is set as gcc in UCRT64 and MINGW64 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasi-libc.