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/linux_util.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 /*
    2  * Copyright (c) 1994 Christos Zoulas
    3  * Copyright (c) 1995 Frank van der Linden
    4  * Copyright (c) 1995 Scott Bartram
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. The name of the author may not be used to endorse or promote products
   16  *    derived from this software without specific prior written permission
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  *
   29  * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
   30  * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
   31  * $FreeBSD: releng/5.0/sys/compat/linux/linux_util.h 102803 2002-09-01 21:15:37Z iedowse $
   32  */
   33 
   34 /*
   35  * This file is pretty much the same as Christos' svr4_util.h
   36  * (for now).
   37  */
   38 
   39 #ifndef _LINUX_UTIL_H_
   40 #define _LINUX_UTIL_H_
   41 
   42 #include <vm/vm.h>
   43 #include <vm/vm_param.h>
   44 #include <vm/pmap.h>
   45 #include <machine/vmparam.h>
   46 #include <sys/exec.h>
   47 #include <sys/sysent.h>
   48 #include <sys/cdefs.h>
   49 #include <sys/uio.h>
   50 
   51 static __inline caddr_t stackgap_init(void);
   52 static __inline void *stackgap_alloc(caddr_t *, size_t);
   53 
   54 #define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode))
   55 
   56 static __inline caddr_t
   57 stackgap_init()
   58 {
   59         return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE);
   60 }
   61 
   62 static __inline void *
   63 stackgap_alloc(sgp, sz)
   64         caddr_t *sgp;
   65         size_t   sz;
   66 {
   67         void *p = (void *) *sgp;
   68 
   69         sz = ALIGN(sz);
   70         if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode))
   71                 return NULL;
   72         *sgp += sz;
   73         return p;
   74 }
   75 
   76 extern const char linux_emul_path[];
   77 
   78 int linux_emul_convpath(struct thread *, char *, enum uio_seg, char **, int);
   79 int linux_emul_find(struct thread *, caddr_t *, char *, char **, int);
   80 
   81 #define CHECKALT(p, sgp, path, i)                                       \
   82         do {                                                            \
   83                 int _error;                                             \
   84                                                                         \
   85                 _error = linux_emul_find(p, sgp, path, &path, i);       \
   86                 if (_error == EFAULT)                                   \
   87                         return (_error);                                \
   88         } while (0)
   89 
   90 #define CHECKALTEXIST(p, sgp, path) CHECKALT(p, sgp, path, 0)
   91 #define CHECKALTCREAT(p, sgp, path) CHECKALT(p, sgp, path, 1)
   92 
   93 #define LCONVPATH(td, upath, pathp, i)                                  \
   94         do {                                                            \
   95                 int _error;                                             \
   96                                                                         \
   97                 _error = linux_emul_convpath(td, upath, UIO_USERSPACE,  \
   98                     pathp, i);                                          \
   99                 if (*(pathp) == NULL)                                   \
  100                         return (_error);                                \
  101         } while (0)
  102 
  103 #define LCONVPATHEXIST(td, upath, pathp) LCONVPATH(td, upath, pathp, 0)
  104 #define LCONVPATHCREAT(td, upath, pathp) LCONVPATH(td, upath, pathp, 1)
  105 #define LFREEPATH(path) free(path, M_TEMP)
  106 
  107 #define DUMMY(s)                                                        \
  108 int                                                                     \
  109 linux_ ## s(struct thread *p, struct linux_ ## s ## _args *args)        \
  110 {                                                                       \
  111         return (unsupported_msg(p, #s));                                \
  112 }                                                                       \
  113 struct __hack
  114 
  115 static __inline int
  116 unsupported_msg(struct thread *td, const char *fname)
  117 {
  118 
  119         printf("linux: syscall %s is obsoleted or not implemented (pid=%ld)\n",
  120             fname, (long)td->td_proc->p_pid);
  121         return (ENOSYS);
  122 }
  123 
  124 #endif /* !_LINUX_UTIL_H_ */

Cache object: 2f4610f70e367a46a9405ffe88805e24


[ 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.