ia64/xen-unstable

view xen/include/acm/acm_endian.h @ 8614:bd606783c6bf

remove unnecessary macro bdev_put which is an alias to blkdev_put.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vhanquez@kneesa.uk.xensource.com
date Mon Jan 16 21:13:29 2006 +0000 (2006-01-16)
parents 1e40bed176d4
children 699656fb1d0b
line source
1 /****************************************************************
2 * acm_endian.h
3 *
4 * Copyright (C) 2005 IBM Corporation
5 *
6 * Author:
7 * Stefan Berger <stefanb@watson.ibm.com>
8 *
9 * Contributions:
10 * Reiner Sailer <sailer@watson.ibm.com>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation, version 2 of the
15 * License.
16 *
17 * sHype header file defining endian-dependent functions for the
18 * big-endian policy interface
19 *
20 */
22 #ifndef _ACM_ENDIAN_H
23 #define _ACM_ENDIAN_H
25 /* don't use these functions in performance critical sections! */
27 /* set during initialization by testing */
28 extern u8 little_endian;
30 static inline u32 ntohl(u32 x)
31 {
32 if (little_endian)
33 return
34 ( (((x) >> 24) & 0xff )|
35 (((x) >> 8) & 0xff00 )|
36 (((x) << 8) & 0xff0000 )|
37 (((x) << 24) & 0xff000000) );
38 else
39 return x;
40 }
42 static inline u16 ntohs(u16 x)
43 {
44 if (little_endian)
45 return
46 ( (((x) >> 8) & 0xff )|
47 (((x) << 8) & 0xff00 ) );
48 else
49 return x;
50 }
52 #define htonl(x) ntohl(x)
53 #define htons(x) ntohs(x)
55 static inline void arrcpy16(u16 *dest, const u16 *src, size_t n)
56 {
57 unsigned int i = 0;
58 while (i < n) {
59 dest[i] = htons(src[i]);
60 i++;
61 }
62 }
64 static inline void arrcpy32(u32 *dest, const u32 *src, size_t n)
65 {
66 unsigned int i = 0;
67 while (i < n) {
68 dest[i] = htonl(src[i]);
69 i++;
70 }
71 }
73 static inline void arrcpy(void *dest, const void *src, unsigned int elsize, size_t n)
74 {
75 switch (elsize) {
76 case sizeof(u16):
77 arrcpy16((u16 *)dest, (u16 *)src, n);
78 break;
80 case sizeof(u32):
81 arrcpy32((u32 *)dest, (u32 *)src, n);
82 break;
84 default:
85 memcpy(dest, src, elsize*n);
86 }
87 }
89 #endif
91 /*
92 * Local variables:
93 * mode: C
94 * c-set-style: "BSD"
95 * c-basic-offset: 4
96 * tab-width: 4
97 * indent-tabs-mode: nil
98 * End:
99 */