yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * msync() for uClibc |
| 4 | * |
| 5 | * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> |
| 6 | * |
| 7 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 8 | */ |
| 9 | |
| 10 | #include <sys/syscall.h> |
| 11 | #include <unistd.h> |
| 12 | #include <sys/mman.h> |
| 13 | |
| 14 | #ifdef __NR_msync |
| 15 | |
| 16 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 17 | #include <sysdep-cancel.h> |
| 18 | #else |
| 19 | #define SINGLE_THREAD_P 1 |
| 20 | #endif |
| 21 | |
| 22 | #define __NR___syscall_msync __NR_msync |
| 23 | static __always_inline _syscall3(int, __syscall_msync, void *, addr, size_t, length, |
| 24 | int, flags) |
| 25 | |
| 26 | extern __typeof(msync) __libc_msync; |
| 27 | int __libc_msync(void * addr, size_t length, int flags) |
| 28 | { |
| 29 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 30 | int oldtype, result; |
| 31 | #endif |
| 32 | |
| 33 | if (SINGLE_THREAD_P) |
| 34 | return __syscall_msync(addr, length, flags); |
| 35 | |
| 36 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 37 | oldtype = LIBC_CANCEL_ASYNC (); |
| 38 | result = __syscall_msync(addr, length, flags); |
| 39 | LIBC_CANCEL_RESET (oldtype); |
| 40 | return result; |
| 41 | #endif |
| 42 | } |
| 43 | weak_alias(__libc_msync,msync) |
| 44 | |
| 45 | #endif |