VirtualBox

Changeset 46408 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 6, 2013 1:28:44 PM (11 years ago)
Author:
vboxsync
Message:

Use iprt/formats/hfs.h. Also use IPRT for endian conversion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxFsDxe/fsw_hfs.h

    r29125 r46408  
    2323
    2424#include "fsw_core.h"
     25#include "iprt/formats/hfs.h"
     26#include "iprt/asm.h"           /* endian conversion */
    2527
    2628
     
    3133#define HFS_SUPERBLOCK_BLOCKNO   2
    3234
    33 /* Make world look Applish enough for the system header describing HFS layout  */
    34 #define __APPLE_API_PRIVATE
    35 #define __APPLE_API_UNSTABLE
    36 
    37 #define u_int8_t  fsw_u8
    38 #define u_int16_t fsw_u16
    39 #define u_int32_t fsw_u32
    40 #define u_int64_t fsw_u64
    41 #define int8_t    fsw_s8
    42 #define int16_t   fsw_s16
    43 #define int32_t   fsw_s32
    44 #define int64_t   fsw_s64
    45 
    46 #include "hfs_format.h"
    47 
    48 #undef u_int8_t
    49 #undef u_int16_t
    50 #undef u_int32_t
    51 #undef u_int64_t
    52 #undef int8_t
    53 #undef int16_t
    54 #undef int32_t
    55 #undef int64_t
    56 
    57 #pragma pack(1)
    5835#ifdef _MSC_VER
    5936/* vasily: disable warning for non-standard anonymous struct/union
     
    6138 */
    6239# pragma warning (disable:4201)
    63 # define inline __inline
    6440#endif
    6541
     
    6844};
    6945
     46#pragma pack(1)
    7047struct fsw_hfs_key
    7148{
     
    7754  };
    7855};
    79 
    8056#pragma pack()
    8157
     
    9268 * HFS: Dnode structure with HFS-specific data.
    9369 */
    94 
    9570struct fsw_hfs_dnode
    9671{
     
    131106};
    132107
    133 /* Endianess swappers */
    134 static inline fsw_u16
    135 swab16(fsw_u16 x)
     108/* Endianess swappers. */
     109DECLINLINE(fsw_u16)
     110be16_to_cpu(fsw_u16 x)
    136111{
    137     return x<<8 | x>>8;
     112    return RT_BE2H_U16(x);
    138113}
    139114
    140 static inline fsw_u32
    141 swab32(fsw_u32 x)
     115DECLINLINE(fsw_u16)
     116cpu_to_be16(fsw_u16 x)
    142117{
    143     return x<<24 | x>>24 |
    144             (x & (fsw_u32)0x0000ff00UL)<<8 |
    145             (x & (fsw_u32)0x00ff0000UL)>>8;
     118    return RT_H2BE_U16(x);
    146119}
    147120
    148121
    149 static inline fsw_u64
    150 swab64(fsw_u64 x)
     122DECLINLINE(fsw_u32)
     123cpu_to_be32(fsw_u32 x)
    151124{
    152     return x<<56 | x>>56 |
    153             (x & (fsw_u64)0x000000000000ff00ULL)<<40 |
    154             (x & (fsw_u64)0x0000000000ff0000ULL)<<24 |
    155             (x & (fsw_u64)0x00000000ff000000ULL)<< 8 |
    156             (x & (fsw_u64)0x000000ff00000000ULL)>> 8 |
    157             (x & (fsw_u64)0x0000ff0000000000ULL)>>24 |
    158             (x & (fsw_u64)0x00ff000000000000ULL)>>40;
     125    return RT_H2BE_U32(x);
    159126}
    160127
    161 static inline fsw_u16
    162 be16_to_cpu(fsw_u16 x)
     128DECLINLINE(fsw_u32)
     129be32_to_cpu(fsw_u32 x)
    163130{
    164     return swab16(x);
     131    return RT_BE2H_U32(x);
    165132}
    166133
    167 static inline fsw_u16
    168 cpu_to_be16(fsw_u16 x)
    169 {
    170     return swab16(x);
    171 }
    172 
    173 
    174 static inline fsw_u32
    175 cpu_to_be32(fsw_u32 x)
    176 {
    177     return swab32(x);
    178 }
    179 
    180 static inline fsw_u32
    181 be32_to_cpu(fsw_u32 x)
    182 {
    183     return swab32(x);
    184 }
    185 
    186 static inline fsw_u64
     134DECLINLINE(fsw_u64)
    187135be64_to_cpu(fsw_u64 x)
    188136{
    189     return swab64(x);
     137    return RT_BE2H_U64(x);
    190138}
    191139
    192140#endif
     141
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette