]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/sysdep.h
Include file splits and namespace cleanups.
[thirdparty/pciutils.git] / lib / sysdep.h
CommitLineData
489233b4
MM
1/*
2 * The PCI Library -- System-Dependent Stuff
3 *
4 * Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9#ifdef __GNUC__
10#define UNUSED __attribute__((unused))
11#define NONRET __attribute__((noreturn))
12#else
13#define UNUSED
14#define NONRET
15#define inline
16#endif
17
18#ifdef PCI_HAVE_LINUX_BYTEORDER_H
19
20#include <asm/byteorder.h>
21#define cpu_to_le16 __cpu_to_le16
22#define cpu_to_le32 __cpu_to_le32
23#define le16_to_cpu __le16_to_cpu
24#define le32_to_cpu __le32_to_cpu
25
26#else
27
28#ifdef PCI_OS_LINUX
29#include <endian.h>
30#define BYTE_ORDER __BYTE_ORDER
31#define BIG_ENDIAN __BIG_ENDIAN
32#endif
33
34#ifdef PCI_OS_SUNOS
35#include <sys/byteorder.h>
36#define BIG_ENDIAN 4321
37#ifdef _LITTLE_ENDIAN
38#define BYTE_ORDER 1234
39#else
40#define BYTE_ORDER 4321
41#endif
42#endif
43
44#ifdef PCI_OS_WINDOWS
45#include <sys/param.h>
46#endif
47
48#if BYTE_ORDER == BIG_ENDIAN
49#define cpu_to_le16 swab16
50#define cpu_to_le32 swab32
51#define le16_to_cpu swab16
52#define le32_to_cpu swab32
53
54static inline word swab16(word w)
55{
56 return (w << 8) | ((w >> 8) & 0xff);
57}
58
59static inline u32 swab32(u32 w)
60{
61 return ((w & 0xff000000) >> 24) |
62 ((w & 0x00ff0000) >> 8) |
63 ((w & 0x0000ff00) << 8) |
64 ((w & 0x000000ff) << 24);
65}
66#else
67#define cpu_to_le16(x) (x)
68#define cpu_to_le32(x) (x)
69#define le16_to_cpu(x) (x)
70#define le32_to_cpu(x) (x)
71#endif
72
73#endif