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/ufs/ufs/ufs_bswap.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: ufs_bswap.h,v 1.13 2003/10/05 17:48:50 bouyer Exp $    */
    2 
    3 /*
    4  * Copyright (c) 1998 Manuel Bouyer.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Manuel Bouyer.
   17  * 4. The name of the author may not be used to endorse or promote products
   18  *    derived from this software without specific prior written permission.
   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  */
   32 
   33 #ifndef _UFS_UFS_BSWAP_H_
   34 #define _UFS_UFS_BSWAP_H_
   35 
   36 #if defined(_KERNEL_OPT)
   37 #include "opt_ffs.h"
   38 #endif
   39 
   40 #include <machine/bswap.h>
   41 
   42 /* Macros to access UFS flags */
   43 #ifdef FFS_EI
   44 #define UFS_MPNEEDSWAP(mp)      (VFSTOUFS(mp)->um_flags & UFS_NEEDSWAP)
   45 #define UFS_FSNEEDSWAP(fs)      ((fs)->fs_flags & FS_SWAPPED)
   46 #define UFS_IPNEEDSWAP(ip)      UFS_MPNEEDSWAP(ITOV(ip)->v_mount)
   47 #else
   48 #define UFS_MPNEEDSWAP(mp) (0)
   49 #define UFS_FSNEEDSWAP(fs) (0)
   50 #define UFS_IPNEEDSWAP(ip) (0)
   51 #endif
   52 
   53 #if !defined(_KERNEL) || defined(FFS_EI)
   54 /* inlines for access to swapped data */
   55 static __inline u_int16_t ufs_rw16 __P((u_int16_t, int));
   56 static __inline u_int32_t ufs_rw32 __P((u_int32_t, int));
   57 static __inline u_int64_t ufs_rw64 __P((u_int64_t, int));
   58 
   59 static __inline u_int16_t
   60 ufs_rw16(a, ns)
   61         u_int16_t a;
   62         int ns;
   63 {
   64         return ((ns) ?  bswap16(a) : (a));
   65 }
   66 static __inline u_int32_t
   67 ufs_rw32(a, ns)
   68         u_int32_t a;
   69         int ns;
   70 {
   71         return ((ns) ?  bswap32(a) : (a));
   72 }
   73 static __inline u_int64_t
   74 ufs_rw64(a, ns)
   75         u_int64_t a;
   76         int ns;
   77 {
   78         return ((ns) ?  bswap64(a) : (a));
   79 }
   80 #else
   81 #define ufs_rw16(a, ns) ((uint16_t)(a))
   82 #define ufs_rw32(a, ns) ((uint32_t)(a))
   83 #define ufs_rw64(a, ns) ((uint64_t)(a))
   84 #endif
   85 
   86 #define ufs_add16(a, b, ns) \
   87         (a) = ufs_rw16(ufs_rw16((a), (ns)) + (b), (ns))
   88 #define ufs_add32(a, b, ns) \
   89         (a) = ufs_rw32(ufs_rw32((a), (ns)) + (b), (ns))
   90 #define ufs_add64(a, b, ns) \
   91         (a) = ufs_rw64(ufs_rw64((a), (ns)) + (b), (ns))
   92 
   93 #endif /* !_UFS_UFS_BSWAP_H_ */

Cache object: a37d3a193116ef5aa8b6523ca9be9cf6


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