thr_msync.c revision 174689
1184610Salfred/*
2184610Salfred * David Leonard <d@openbsd.org>, 1999. Public Domain.
3184610Salfred *
4184610Salfred * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
5184610Salfred *
6184610Salfred * $FreeBSD: head/lib/libkse/thread/thr_msync.c 174689 2007-12-16 23:29:57Z deischen $
7184610Salfred */
8184610Salfred
9184610Salfred#include "namespace.h"
10184610Salfred#include <sys/types.h>
11184610Salfred#include <sys/mman.h>
12184610Salfred#include <pthread.h>
13184610Salfred#include "un-namespace.h"
14184610Salfred#include "thr_private.h"
15184610Salfred
16184610Salfredint __msync(void *addr, size_t len, int flags);
17184610Salfred
18184610Salfred__weak_reference(__msync, msync);
19184610Salfred
20184610Salfredint
21184610Salfred__msync(void *addr, size_t len, int flags)
22184610Salfred{
23184610Salfred	struct pthread *curthread = _get_curthread();
24184610Salfred	int	ret;
25184610Salfred
26184610Salfred	/*
27184610Salfred	 * XXX This is quite pointless unless we know how to get the
28184610Salfred	 * file descriptor associated with the memory, and lock it for
29184610Salfred	 * write. The only real use of this wrapper is to guarantee
30184610Salfred	 * a cancellation point, as per the standard. sigh.
31184610Salfred	 */
32184610Salfred	_thr_cancel_enter(curthread);
33246122Shselasky	ret = __sys_msync(addr, len, flags);
34246122Shselasky	_thr_cancel_leave(curthread, 1);
35246122Shselasky
36194677Sthompsa	return (ret);
37194677Sthompsa}
38194677Sthompsa