uaccess.h revision 289624
1/* $FreeBSD: head/sys/ofed/include/linux/uaccess.h 289624 2015-10-20 11:40:04Z hselasky $ */
2/*-
3 * Copyright (c) 2010 Isilon Systems, Inc.
4 * Copyright (c) 2010 iX Systems, Inc.
5 * Copyright (c) 2010 Panasas, Inc.
6 * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
7 * Copyright (c) 2015 Fran��ois Tigeot
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice unmodified, this list of conditions, and the following
15 *    disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31#ifndef	_LINUX_UACCESS_H_
32#define	_LINUX_UACCESS_H_
33
34#include <linux/compiler.h>
35
36#define	get_user(_x, _p)	-copyin((_p), &(_x), sizeof(*(_p)))
37#define	put_user(_x, _p)	-copyout(&(_x), (_p), sizeof(*(_p)))
38
39/*
40 * NOTE: The returned value from pagefault_disable() must be stored
41 * and passed to pagefault_enable(). Else possible recursion on the
42 * state can be lost.
43 */
44static inline int __must_check
45pagefault_disable(void)
46{
47	return (vm_fault_disable_pagefaults());
48}
49
50static inline void
51pagefault_enable(int save)
52{
53	vm_fault_enable_pagefaults(save);
54}
55
56#endif	/* _LINUX_UACCESS_H_ */
57