The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/linux/common/linux_limit.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: linux_limit.h,v 1.3.10.1 2009/04/01 00:25:22 snj Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    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.
   10  *
   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.
   19  *
   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.
   31  */
   32 
   33 #ifndef _LINUX_LIMIT_H_
   34 #define _LINUX_LIMIT_H_
   35 
   36 static int linux_to_bsd_limit(int);
   37 
   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)
   52 
   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)
   58 
   59 static int
   60 linux_to_bsd_limit(lim)
   61         int lim;
   62 {      
   63         switch (lim) {
   64         case LINUX_RLIMIT_CPU:
   65                 return RLIMIT_CPU;
   66         case LINUX_RLIMIT_FSIZE:
   67                 return RLIMIT_FSIZE;
   68         case LINUX_RLIMIT_DATA:
   69                 return RLIMIT_DATA;
   70         case LINUX_RLIMIT_STACK:
   71                 return RLIMIT_STACK;
   72         case LINUX_RLIMIT_CORE:
   73                 return RLIMIT_CORE;
   74         case LINUX_RLIMIT_RSS:
   75                 return RLIMIT_RSS;
   76         case LINUX_RLIMIT_NPROC:
   77                 return RLIMIT_NPROC;
   78         case LINUX_RLIMIT_NOFILE:
   79                 return RLIMIT_NOFILE;
   80         case LINUX_RLIMIT_MEMLOCK:
   81                 return RLIMIT_MEMLOCK;
   82         case LINUX_RLIMIT_AS:
   83                 return RLIMIT_AS;
   84         case LINUX_RLIMIT_LOCKS:
   85                 return -EOPNOTSUPP;
   86         default:
   87                 return -EINVAL;
   88         }
   89 }      
   90 
   91 
   92 #endif /* _LINUX_LIMIT_H_ */

Cache object: be8cba5b93af513acd17046eb06b7dc7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.