staging: unisys: remove S8 type
[sfrench/cifs-2.6.git] / drivers / staging / unisys / include / commontypes.h
1 /* Copyright (C) 2010 - 2013 UNISYS CORPORATION
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or (at
7  * your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12  * NON INFRINGEMENT.  See the GNU General Public License for more
13  * details.
14  */
15
16 #ifndef _COMMONTYPES_H_
17 #define _COMMONTYPES_H_
18
19 /* define the following to prevent include nesting in kernel header files of
20  * similar abbreviated content */
21 #define _SUPERVISOR_COMMONTYPES_H_
22
23 #ifdef __KERNEL__
24 #include <linux/types.h>
25 #include <linux/version.h>
26 #include <linux/io.h>
27 #include <linux/uuid.h>
28 #else
29 #include <stdint.h>
30 #include <syslog.h>
31 #endif
32
33 #define S16 int16_t
34 #define S32 int32_t
35 #define S64 int64_t
36
37 #ifdef __KERNEL__
38
39 #ifdef CONFIG_X86_32
40 #define UINTN u32
41 #else
42 #define UINTN u64
43 #endif
44
45 #else
46
47 #include <stdint.h>
48 #if __WORDSIZE == 32
49 #define UINTN u32
50 #elif __WORDSIZE == 64
51 #define UINTN u64
52 #else
53 #error Unsupported __WORDSIZE
54 #endif
55
56 #endif
57
58 typedef u64 GUEST_PHYSICAL_ADDRESS;
59
60 #define MEMSET(ptr, val, len) memset(ptr, val, len)
61 #define MEMCMP(m1, m2, len) memcmp(m1, m2, len)
62 #define MEMCMP_IO(m1, m2, len) memcmp((void __force *)m1, m2, len)
63 #define STRLEN(s) ((UINTN)strlen((const char *)s))
64 #define STRCPY(d, s) (strcpy((char *)d, (const char *)s))
65
66 #define INLINE inline
67 #define OFFSETOF offsetof
68
69 #ifdef __KERNEL__
70 #define MEMORYBARRIER mb()
71 #define MEMCPY(dest, src, len) memcpy(dest, src, len)
72 #define MEMCPY_TOIO(dest, src, len) memcpy_toio(dest, src, len)
73 #define MEMCPY_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
74
75 #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
76                               lin, logCtx)                              \
77         do {                                                            \
78                 pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d\n", \
79                        chName, &chType, field,  \
80                        &expected, &actual, \
81                        fil, lin);                                       \
82         } while (0)
83 #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \
84                              lin, logCtx)                               \
85         do {                                                            \
86                 pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \
87                        chName, &chType, field,  \
88                        (unsigned long)expected, (unsigned long)actual,  \
89                        fil, lin);                                       \
90         } while (0)
91
92 #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \
93                              lin, logCtx)                               \
94         do {                                                            \
95                 pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \
96                        chName, &chType, field,  \
97                        (unsigned long long)expected,                    \
98                        (unsigned long long)actual,                      \
99                        fil, lin);                                       \
100         } while (0)
101
102 #define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \
103                       LineNumber, Str, args...)                         \
104         pr_info(Str, ## args)
105
106 #else
107 #define MEMCPY(dest, src, len) memcpy(dest, src, len)
108
109 #define MEMORYBARRIER mb()
110
111 #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
112                               lin, logCtx)                              \
113         do {                                                            \
114                 syslog(LOG_USER | LOG_ERR,                              \
115                        "Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d", \
116                        chName, &chType, field,  \
117                        &expected, &actual, \
118                        fil, lin);                                       \
119         } while (0)
120
121 #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \
122                              lin, logCtx)                               \
123         do {                                                            \
124                 syslog(LOG_USER | LOG_ERR,                              \
125                        "Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d", \
126                        chName, chType, field,   \
127                        (unsigned long)expected, (unsigned long)actual,  \
128                        fil, lin);                                       \
129         } while (0)
130
131 #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \
132                              lin, logCtx)                               \
133         do {                                                            \
134                 syslog(LOG_USER | LOG_ERR,                              \
135                        "Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d", \
136                        chName, chType, field,   \
137                        (unsigned long long)expected,                    \
138                        (unsigned long long)actual,                      \
139                        fil, lin);                                       \
140         } while (0)
141
142 #define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \
143                       LineNumber, Str, args...)                         \
144         syslog(LOG_USER | LOG_INFO, Str, ## args)
145 #endif
146
147 #define VolatileBarrier() MEMORYBARRIER
148
149 #endif
150