Can you please remind me why we need both OSV_LIBC_API and putting the
function name in 5 different files?
Isn't there a big risk that later when all this export stuff is less fresh
in our mind, we forget one of these 6 places and create a mess?

--
Nadav Har'El
[email protected]


On Tue, Dec 21, 2021 at 8:26 PM Waldemar Kozaczuk <[email protected]>
wrote:

> Some apps/runtimes like dotnet call posix_madvise
> which we do not implement. This patch adds a simple
> implementation of it based on madvise with a difference
> that only POSIX_MADV_DONTNEED is supported. On top of
> this as required posix_madvise() returns an error without
> setting errno.
>
> Signed-off-by: Waldemar Kozaczuk <[email protected]>
> ---
>  .../aarch64/osv_ld-musl-aarch64.so.1.symbols       |  1 +
>  exported_symbols/aarch64/osv_libc.so.6.symbols     |  1 +
>  .../x64/osv_ld-musl-x86_64.so.1.symbols            |  1 +
>  exported_symbols/x64/osv_libc.so.6.symbols         |  1 +
>  libc/mman.cc                                       | 14 ++++++++++++++
>  5 files changed, 18 insertions(+)
>
> diff --git a/exported_symbols/aarch64/osv_ld-musl-aarch64.so.1.symbols
> b/exported_symbols/aarch64/osv_ld-musl-aarch64.so.1.symbols
> index c463131a..4c284fba 100644
> --- a/exported_symbols/aarch64/osv_ld-musl-aarch64.so.1.symbols
> +++ b/exported_symbols/aarch64/osv_ld-musl-aarch64.so.1.symbols
> @@ -739,6 +739,7 @@ posix_fadvise
>  posix_fadvise64
>  posix_fallocate
>  posix_fallocate64
> +posix_madvise
>  posix_memalign
>  pow
>  pow10
> diff --git a/exported_symbols/aarch64/osv_libc.so.6.symbols
> b/exported_symbols/aarch64/osv_libc.so.6.symbols
> index 000191b7..ea0bfcdc 100644
> --- a/exported_symbols/aarch64/osv_libc.so.6.symbols
> +++ b/exported_symbols/aarch64/osv_libc.so.6.symbols
> @@ -667,6 +667,7 @@ posix_fadvise
>  posix_fadvise64
>  posix_fallocate
>  posix_fallocate64
> +posix_madvise
>  posix_memalign
>  ppoll
>  prctl
> diff --git a/exported_symbols/x64/osv_ld-musl-x86_64.so.1.symbols
> b/exported_symbols/x64/osv_ld-musl-x86_64.so.1.symbols
> index b3f87859..d88e98ed 100644
> --- a/exported_symbols/x64/osv_ld-musl-x86_64.so.1.symbols
> +++ b/exported_symbols/x64/osv_ld-musl-x86_64.so.1.symbols
> @@ -721,6 +721,7 @@ posix_fadvise
>  posix_fadvise64
>  posix_fallocate
>  posix_fallocate64
> +posix_madvise
>  __posix_getopt
>  posix_memalign
>  pow
> diff --git a/exported_symbols/x64/osv_libc.so.6.symbols
> b/exported_symbols/x64/osv_libc.so.6.symbols
> index 6635cabb..07b5368b 100644
> --- a/exported_symbols/x64/osv_libc.so.6.symbols
> +++ b/exported_symbols/x64/osv_libc.so.6.symbols
> @@ -596,6 +596,7 @@ posix_fadvise
>  posix_fadvise64
>  posix_fallocate
>  posix_fallocate64
> +posix_madvise
>  __posix_getopt
>  posix_memalign
>  ppoll
> diff --git a/libc/mman.cc b/libc/mman.cc
> index 9dd6429a..75a94eb0 100644
> --- a/libc/mman.cc
> +++ b/libc/mman.cc
> @@ -257,3 +257,17 @@ void *sbrk(intptr_t increment)
>      errno = ENOMEM;
>      return (void *)-1;
>  }
> +
> +static unsigned posix_madvise_to_advise(int advice)
> +{
> +    if (advice == POSIX_MADV_DONTNEED) {
> +        return mmu::advise_dontneed;
> +    }
> +    return 0;
> +}
> +
> +OSV_LIBC_API
> +int posix_madvise(void *addr, size_t len, int advice) {
> +    auto err = mmu::advise(addr, len, posix_madvise_to_advise(advice));
> +    return err.get();
> +}
> --
> 2.31.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20211221182614.242226-1-jwkozaczuk%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjsy2qaz-LRX4ZjMuRFa848e2rjAbsTs239HObzYiF5Ueg%40mail.gmail.com.

Reply via email to