Giter Site home page Giter Site logo

getpagesize() about wasi-libc HOT 4 CLOSED

paravoid avatar paravoid commented on August 14, 2024
getpagesize()

from wasi-libc.

Comments (4)

sbc100 avatar sbc100 commented on August 14, 2024

I don't see any reason not to include this.

from wasi-libc.

sunfishcode avatar sunfishcode commented on August 14, 2024

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.

paravoid avatar paravoid commented on August 14, 2024

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.

sunfishcode avatar sunfishcode commented on August 14, 2024

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.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.