153812Salfred/*
253812Salfred * David Leonard <d@openbsd.org>, 1999. Public Domain.
353812Salfred *
453812Salfred * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
553812Salfred *
653812Salfred * $FreeBSD$
753812Salfred */
853812Salfred
9174112Sdeischen#include "namespace.h"
1053812Salfred#include <sys/types.h>
1153812Salfred#include <sys/mman.h>
1253812Salfred#include <pthread.h>
13174112Sdeischen#include "un-namespace.h"
14103388Smini#include "thr_private.h"
1553812Salfred
16174112Sdeischenint __msync(void *addr, size_t len, int flags);
17174112Sdeischen
1875369Sdeischen__weak_reference(__msync, msync);
1971581Sdeischen
2053812Salfredint
2171581Sdeischen__msync(void *addr, size_t len, int flags)
2256698Sjasone{
23113658Sdeischen	struct pthread *curthread = _get_curthread();
2456698Sjasone	int	ret;
2556698Sjasone
2653812Salfred	/*
2753812Salfred	 * XXX This is quite pointless unless we know how to get the
2853812Salfred	 * file descriptor associated with the memory, and lock it for
2953812Salfred	 * write. The only real use of this wrapper is to guarantee
3053812Salfred	 * a cancellation point, as per the standard. sigh.
3153812Salfred	 */
32123312Sdavidxu	_thr_cancel_enter(curthread);
33103419Smini	ret = __sys_msync(addr, len, flags);
34123312Sdavidxu	_thr_cancel_leave(curthread, 1);
3553812Salfred
36174112Sdeischen	return (ret);
3753812Salfred}
38