Changeset 11207 in vbox for trunk/include
- Timestamp:
- Aug 7, 2008 3:36:08 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cdefs.h
r11198 r11207 1057 1057 * Reverses the byte order of an uint64_t value. */ 1058 1058 #if 0 1059 # define RT_BSWAP_U64(u64) RT_MAKE_U64(RT_H2BE_U32((u64) >> 32), RT_H2BE_U32((u64) & 0xffffffff)) 1060 #else 1059 # define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64) 1060 #elif defined(__GNUC__) 1061 /** @todo use __builtin_constant_p? */ 1061 1062 # define RT_BSWAP_U64(u64) ASMByteSwapU64(u64) 1063 #else 1064 # define RT_BSWAP_U64(u64) ASMByteSwapU64(u64) 1062 1065 #endif 1063 1066 1064 1067 /** @def RT_BSWAP_U32 1065 * Converts uint32_t value from host to big endian byte order. */1068 * Reverses the byte order of an uint32_t value. */ 1066 1069 #if 0 1067 # define RT_BSWAP_U32(u32) (RT_BYTE4(u32) | (RT_BYTE3(u32) << 8) | (RT_BYTE2(u32) << 16) | (RT_BYTE1(u32) << 24)) 1068 #else 1070 # define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32) 1071 #elif defined(__GNUC__) 1072 /** @todo use __builtin_constant_p? */ 1069 1073 # define RT_BSWAP_U32(u32) ASMByteSwapU32(u32) 1074 #else 1075 # define RT_BSWAP_U32(u32) ASMByteSwapU32(u32) 1070 1076 #endif 1071 1077 1072 1078 /** @def RT_BSWAP_U16 1073 * Converts uint16_t value from host to big endian byte order. */1079 * Reverses the byte order of an uint16_t value. */ 1074 1080 #if 0 1075 # define RT_BSWAP_U16(u16) (RT_HIBYTE(u16) | (RT_LOBYTE(u16) << 8)) 1076 #else 1081 # define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16) 1082 #elif defined(__GNUC__) 1083 /** @todo use __builtin_constant_p? */ 1077 1084 # define RT_BSWAP_U16(u16) ASMByteSwapU16(u16) 1078 #endif 1085 #else 1086 # define RT_BSWAP_U16(u16) ASMByteSwapU16(u16) 1087 #endif 1088 1089 1090 /** @def RT_BSWAP_U64_C 1091 * Reverses the byte order of an uint64_t constant. */ 1092 #define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff)) 1093 1094 /** @def RT_BSWAP_U32_C 1095 * Reverses the byte order of an uint32_t constant. */ 1096 #define RT_BSWAP_U32_C(u32) (RT_BYTE4(u32) | (RT_BYTE3(u32) << 8) | (RT_BYTE2(u32) << 16) | (RT_BYTE1(u32) << 24)) 1097 1098 /** @def RT_BSWAP_U16_C 1099 * Reverses the byte order of an uint16_t constant. */ 1100 #define RT_BSWAP_U16_C(u16) (RT_HIBYTE(u16) | (RT_LOBYTE(u16) << 8)) 1079 1101 1080 1102 … … 1087 1109 #endif 1088 1110 1111 /** @def RT_H2LE_U64_C 1112 * Converts an uint64_t constant from host to little endian byte order. */ 1113 #ifdef RT_BIG_ENDIAN 1114 # define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64) 1115 #else 1116 # define RT_H2LE_U64_C(u64) (u64) 1117 #endif 1118 1089 1119 /** @def RT_H2LE_U32 1090 1120 * Converts an uint32_t value from host to little endian byte order. */ … … 1095 1125 #endif 1096 1126 1127 /** @def RT_H2LE_U32_C 1128 * Converts an uint32_t constant from host to little endian byte order. */ 1129 #ifdef RT_BIG_ENDIAN 1130 # define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32) 1131 #else 1132 # define RT_H2LE_U32_C(u32) (u32) 1133 #endif 1134 1097 1135 /** @def RT_H2LE_U16 1098 1136 * Converts an uint16_t value from host to little endian byte order. */ … … 1103 1141 #endif 1104 1142 1143 /** @def RT_H2LE_U16_C 1144 * Converts an uint16_t constant from host to little endian byte order. */ 1145 #ifdef RT_BIG_ENDIAN 1146 # define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16) 1147 #else 1148 # define RT_H2LE_U16_C(u16) (u16) 1149 #endif 1150 1151 1105 1152 /** @def RT_LE2H_U64 1106 1153 * Converts an uint64_t value from little endian to host byte order. */ … … 1111 1158 #endif 1112 1159 1160 /** @def RT_LE2H_U64_C 1161 * Converts an uint64_t constant from little endian to host byte order. */ 1162 #ifdef RT_BIG_ENDIAN 1163 # define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64) 1164 #else 1165 # define RT_LE2H_U64_C(u64) (u64) 1166 #endif 1167 1113 1168 /** @def RT_LE2H_U32 1114 1169 * Converts an uint32_t value from little endian to host byte order. */ … … 1119 1174 #endif 1120 1175 1176 /** @def RT_LE2H_U32_C 1177 * Converts an uint32_t constant from little endian to host byte order. */ 1178 #ifdef RT_BIG_ENDIAN 1179 # define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32) 1180 #else 1181 # define RT_LE2H_U32_C(u32) (u32) 1182 #endif 1183 1121 1184 /** @def RT_LE2H_U16 1122 1185 * Converts an uint16_t value from little endian to host byte order. */ … … 1127 1190 #endif 1128 1191 1192 /** @def RT_LE2H_U16_C 1193 * Converts an uint16_t constant from little endian to host byte order. */ 1194 #ifdef RT_BIG_ENDIAN 1195 # define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16) 1196 #else 1197 # define RT_LE2H_U16_C(u16) (u16) 1198 #endif 1199 1129 1200 1130 1201 /** @def RT_H2BE_U64 … … 1136 1207 #endif 1137 1208 1209 /** @def RT_H2BE_U64_C 1210 * Converts an uint64_t constant from host to big endian byte order. */ 1211 #ifdef RT_BIG_ENDIAN 1212 # define RT_H2BE_U64_C(u64) (u64) 1213 #else 1214 # define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64) 1215 #endif 1216 1138 1217 /** @def RT_H2BE_U32 1139 1218 * Converts an uint32_t value from host to big endian byte order. */ … … 1144 1223 #endif 1145 1224 1225 /** @def RT_H2BE_U32_C 1226 * Converts an uint32_t constant from host to big endian byte order. */ 1227 #ifdef RT_BIG_ENDIAN 1228 # define RT_H2BE_U32_C(u32) (u32) 1229 #else 1230 # define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32) 1231 #endif 1232 1146 1233 /** @def RT_H2BE_U16 1147 1234 * Converts an uint16_t value from host to big endian byte order. */ … … 1152 1239 #endif 1153 1240 1241 /** @def RT_H2BE_U16_C 1242 * Converts an uint16_t constant from host to big endian byte order. */ 1243 #ifdef RT_BIG_ENDIAN 1244 # define RT_H2BE_U16_C(u16) (u16) 1245 #else 1246 # define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16) 1247 #endif 1248 1154 1249 /** @def RT_BE2H_U64 1155 1250 * Converts an uint64_t value from big endian to host byte order. */ … … 1160 1255 #endif 1161 1256 1257 /** @def RT_BE2H_U64 1258 * Converts an uint64_t constant from big endian to host byte order. */ 1259 #ifdef RT_BIG_ENDIAN 1260 # define RT_BE2H_U64_C(u64) (u64) 1261 #else 1262 # define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64) 1263 #endif 1264 1162 1265 /** @def RT_BE2H_U32 1163 1266 * Converts an uint32_t value from big endian to host byte order. */ … … 1168 1271 #endif 1169 1272 1273 /** @def RT_BE2H_U32_C 1274 * Converts an uint32_t value from big endian to host byte order. */ 1275 #ifdef RT_BIG_ENDIAN 1276 # define RT_BE2H_U32_C(u32) (u32) 1277 #else 1278 # define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32) 1279 #endif 1280 1170 1281 /** @def RT_BE2H_U16 1171 1282 * Converts an uint16_t value from big endian to host byte order. */ … … 1174 1285 #else 1175 1286 # define RT_BE2H_U16(u16) RT_BSWAP_U16(u16) 1287 #endif 1288 1289 /** @def RT_BE2H_U16_C 1290 * Converts an uint16_t constant from big endian to host byte order. */ 1291 #ifdef RT_BIG_ENDIAN 1292 # define RT_BE2H_U16_C(u16) (u16) 1293 #else 1294 # define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16) 1176 1295 #endif 1177 1296 … … 1181 1300 #define RT_H2N_U64(u64) RT_H2BE_U64(u64) 1182 1301 1302 /** @def RT_H2N_U64_C 1303 * Converts an uint64_t constant from host to network byte order. */ 1304 #define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64) 1305 1183 1306 /** @def RT_H2N_U32 1184 1307 * Converts an uint32_t value from host to network byte order. */ 1185 1308 #define RT_H2N_U32(u32) RT_H2BE_U32(u32) 1186 1309 1310 /** @def RT_H2N_U32_C 1311 * Converts an uint32_t constant from host to network byte order. */ 1312 #define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32) 1313 1187 1314 /** @def RT_H2N_U16 1188 1315 * Converts an uint16_t value from host to network byte order. */ 1189 1316 #define RT_H2N_U16(u16) RT_H2BE_U16(u16) 1190 1317 1318 /** @def RT_H2N_U16_C 1319 * Converts an uint16_t constant from host to network byte order. */ 1320 #define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16) 1321 1191 1322 /** @def RT_N2H_U64 1192 1323 * Converts an uint64_t value from network to host byte order. */ 1193 1324 #define RT_N2H_U64(u64) RT_BE2H_U64(u64) 1194 1325 1326 /** @def RT_N2H_U64_C 1327 * Converts an uint64_t constant from network to host byte order. */ 1328 #define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64) 1329 1195 1330 /** @def RT_N2H_U32 1196 1331 * Converts an uint32_t value from network to host byte order. */ 1197 1332 #define RT_N2H_U32(u32) RT_BE2H_U32(u32) 1198 1333 1334 /** @def RT_N2H_U32_C 1335 * Converts an uint32_t constant from network to host byte order. */ 1336 #define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32) 1337 1199 1338 /** @def RT_N2H_U16 1200 1339 * Converts an uint16_t value from network to host byte order. */ 1201 1340 #define RT_N2H_U16(u16) RT_BE2H_U16(u16) 1341 1342 /** @def RT_N2H_U16_C 1343 * Converts an uint16_t value from network to host byte order. */ 1344 #define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16) 1202 1345 1203 1346
Note:
See TracChangeset
for help on using the changeset viewer.