Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / compat / linux / common / linux_limit.h
blob2fde3def76d958628a589ced9e619331bef0fb3e
1 /* $NetBSD: linux_limit.h,v 1.4 2009/03/15 15:55:51 cegger Exp $ */
3 /*-
4 * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following 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.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _LINUX_LIMIT_H_
34 #define _LINUX_LIMIT_H_
36 static int linux_to_bsd_limit(int);
38 #ifdef LINUX_LARGEFILE64
39 #define bsd_to_linux_rlimit1(l, b, f) \
40 (l)->f = ((b)->f == RLIM_INFINITY || \
41 ((b)->f & 0x8000000000000000UL) != 0) ? \
42 LINUX_RLIM_INFINITY : (b)->f
43 #else
44 #define bsd_to_linux_rlimit1(l, b, f) \
45 (l)->f = ((b)->f == RLIM_INFINITY || \
46 ((b)->f & 0xffffffff00000000ULL) != 0) ? \
47 LINUX_RLIM_INFINITY : (int32_t)(b)->f
48 #endif
49 #define bsd_to_linux_rlimit(l, b) \
50 bsd_to_linux_rlimit1(l, b, rlim_cur); \
51 bsd_to_linux_rlimit1(l, b, rlim_max)
53 #define linux_to_bsd_rlimit1(b, l, f) \
54 (b)->f = (l)->f == LINUX_RLIM_INFINITY ? RLIM_INFINITY : (l)->f
55 #define linux_to_bsd_rlimit(b, l) \
56 linux_to_bsd_rlimit1(b, l, rlim_cur); \
57 linux_to_bsd_rlimit1(b, l, rlim_max)
59 static int
60 linux_to_bsd_limit(int lim)
62 switch (lim) {
63 case LINUX_RLIMIT_CPU:
64 return RLIMIT_CPU;
65 case LINUX_RLIMIT_FSIZE:
66 return RLIMIT_FSIZE;
67 case LINUX_RLIMIT_DATA:
68 return RLIMIT_DATA;
69 case LINUX_RLIMIT_STACK:
70 return RLIMIT_STACK;
71 case LINUX_RLIMIT_CORE:
72 return RLIMIT_CORE;
73 case LINUX_RLIMIT_RSS:
74 return RLIMIT_RSS;
75 case LINUX_RLIMIT_NPROC:
76 return RLIMIT_NPROC;
77 case LINUX_RLIMIT_NOFILE:
78 return RLIMIT_NOFILE;
79 case LINUX_RLIMIT_MEMLOCK:
80 return RLIMIT_MEMLOCK;
81 case LINUX_RLIMIT_AS:
82 return RLIMIT_AS;
83 case LINUX_RLIMIT_LOCKS:
84 return -EOPNOTSUPP;
85 default:
86 return -EINVAL;
91 #endif /* _LINUX_LIMIT_H_ */