VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/swab.h@ 33016

Last change on this file since 33016 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/** @file
2 *
3 * VBox storage devices:
4 * C++-safe replacements for some Linux byte order macros
5 *
6 * On Linux, DrvHostDVD.cpp includes <linux/cdrom.h>, which in turn
7 * includes <linux/byteorder/swab.h>. Unfortunately, that file is not very
8 * C++ friendly, and our C++ compiler refuses to look at it. The solution
9 * is to define _LINUX_BYTEORDER_SWAB_H, which prevents that file's contents
10 * from getting included at all, and to provide, in this file, our own
11 * C++-proof versions of the macros which are needed by <linux/cdrom.h>
12 * before we include that file. We actually provide them as inline
13 * functions, due to the way they get resolved in the original.
14 */
15
16/*
17 * Copyright (C) 2006-2007 Oracle Corporation
18 *
19 * This file is part of VirtualBox Open Source Edition (OSE), as
20 * available from http://www.virtualbox.org. This file is free software;
21 * you can redistribute it and/or modify it under the terms of the GNU
22 * General Public License (GPL) as published by the Free Software
23 * Foundation, in version 2 as it comes in the "COPYING" file of the
24 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
25 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
26 */
27
28#ifndef _VBOX_LINUX_SWAB_H
29#define _VBOX_LINUX_SWAB_H
30
31#define _LINUX_BYTEORDER_SWAB_H
32#define _LINUX_BYTEORDER_SWABB_H
33
34#include <asm/types.h>
35
36/* Sorry for the unnecessary brackets here, but I really think
37 readability requires them */
38static __inline__ __u16 __swab16p(const __u16 *px)
39{
40 __u16 x = *px;
41 return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
42}
43
44static __inline__ __u32 __swab32p(const __u32 *px)
45{
46 __u32 x = *px;
47 return ((x & 0xff) << 24) | ((x & 0xff00) << 8)
48 | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff);
49}
50
51static __inline__ __u64 __swab64p(const __u64 *px)
52{
53 __u64 x = *px;
54 return ((x & 0xff) << 56) | ((x & 0xff00) << 40)
55 | ((x & 0xff0000) << 24) | ((x & 0xff000000) << 8)
56 | ((x >> 8) & 0xff000000) | ((x >> 24) & 0xff0000)
57 | ((x >> 40) & 0xff00) | ((x >> 56) & 0xff);
58}
59
60#endif /* _VBOX_LINUX_SWAB_H */
Note: See TracBrowser for help on using the repository browser.

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