~psusi/ubuntu/precise/dmraid/fix-gpt

« back to all changes in this revision

Viewing changes to 1.0.0.rc16/lib/datastruct/byteorder.h

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2010-02-04 21:34:22 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100204213422-tdag8lcxpr7ahmg4
Tags: 1.0.0.rc16-3ubuntu1
* Merge from debian testing. (LP: #503136)  Remaining changes:
  - debian/dmraid-activate: Remove the special-casing of the root
    device which breaks in many situations and leaves the raw devices
    exposed. This was introduced in Debian to accommodate some broken
    configurations which wanted to access "partitions" on the raid
    raw devices. In Ubuntu, broken configurations has not been supported.
  - debian/dmraid.postinst: Comment out "udevadm trigger" call in postinst
    for now as it has severeconsequences when mountall is installed
    (clears /tmp).  If dmraid is installed, then presumably the important
    system devices are up and one canbe bothered with a reboot to take 
    the change into account. Let update-initramfs flag the system
    as needing a reboot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004,2005  Heinz Mauelshagen, Red Hat GmbH.
 
3
 *                          All rights reserved.
 
4
 *
 
5
 * See file LICENSE at the top of this source tree for license information.
 
6
 */
 
7
 
 
8
/* Cheers utils.h */
 
9
 
 
10
#ifndef _BYTEORDER_H
 
11
#define _BYTEORDER_H
 
12
 
 
13
#ifdef __KLIBC__
 
14
#include <endian.h>
 
15
#endif
 
16
 
 
17
#ifdef  DM_BYTEORDER_SWAB
 
18
 
 
19
static inline uint64_t
 
20
le64_to_cpu(uint64_t x)
 
21
{
 
22
        return ((((uint64_t) x & 0x00000000000000ffULL) << 56) |
 
23
                (((uint64_t) x & 0x000000000000ff00ULL) << 40) |
 
24
                (((uint64_t) x & 0x0000000000ff0000ULL) << 24) |
 
25
                (((uint64_t) x & 0x00000000ff000000ULL) << 8) |
 
26
                (((uint64_t) x & 0x000000ff00000000ULL) >> 8) |
 
27
                (((uint64_t) x & 0x0000ff0000000000ULL) >> 24) |
 
28
                (((uint64_t) x & 0x00ff000000000000ULL) >> 40) |
 
29
                (((uint64_t) x & 0xff00000000000000ULL) >> 56));
 
30
}
 
31
 
 
32
static inline int32_t
 
33
le32_to_cpu(int32_t x)
 
34
{
 
35
        return ((((u_int32_t) x & 0x000000ffU) << 24) |
 
36
                (((u_int32_t) x & 0x0000ff00U) << 8) |
 
37
                (((u_int32_t) x & 0x00ff0000U) >> 8) |
 
38
                (((u_int32_t) x & 0xff000000U) >> 24));
 
39
}
 
40
 
 
41
static inline int16_t
 
42
le16_to_cpu(int16_t x)
 
43
{
 
44
        return ((((u_int16_t) x & 0x00ff) << 8) |
 
45
                (((u_int16_t) x & 0xff00) >> 8));
 
46
}
 
47
 
 
48
#define CVT64(x)        do { x = le64_to_cpu(x); } while(0)
 
49
#define CVT32(x)        do { x = le32_to_cpu(x); } while(0)
 
50
#define CVT16(x)        do { x = le16_to_cpu(x); } while(0)
 
51
 
 
52
#else
 
53
 
 
54
#define CVT64(x)
 
55
#define CVT32(x)
 
56
#define CVT16(x)
 
57
 
 
58
#undef  DM_BYTEORDER_SWAB
 
59
 
 
60
#endif /* #ifdef DM_BYTEORDER_SWAB */
 
61
 
 
62
#endif