/*
- * Copyright (C) 2012, 2013
+ * Copyright (C) 2012, 2013, 2014
* Dale Weiler
* Wolfgang Bumiller
*
* SOFTWARE.
*/
#define GMQCC_PLATFORM_HEADER
+#include <stdlib.h>
#include "gmqcc.h"
#include "platform.h"
switch (typesize) {
case 1: return;
case 2:
- util_swap16((uint16_t*)_data, length>>1);
+ util_swap16((uint16_t*)_data, length);
return;
case 4:
- util_swap32((uint32_t*)_data, length>>2);
+ util_swap32((uint32_t*)_data, length);
return;
case 8:
- util_swap64((uint32_t*)_data, length>>3);
+ util_swap64((uint32_t*)_data, length<<1); /* swap64 operates on 32 bit words, thus scale to that length. */
return;
- default: exit(EXIT_FAILURE); /* please blow the fuck up! */
+ default:
+ con_err ("util_endianswap: I don't know how to swap a %u byte structure!\n", typesize);
+ exit(EXIT_FAILURE); /* please blow the fuck up! */
}
# endif
#endif
}};
/* Non - Reflected */
-uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
+uint16_t util_crc16(uint16_t current, const char *GMQCC_RESTRICT k, size_t len) {
register uint16_t h = current;
/* don't load twice */
SELECT_DATA(1) ^
SELECT_DATA(0);
data += 8;
+ len -= 8;
}
+ #undef SELECT_BULK
+ #undef SELECT_DATA
+
/* deal with the rest with the byte method */
for (n = len & 7; n; --n)
h = (uint16_t)(h << 8) ^ (*util_crc16_table)[(h >> 8) ^ *data++];
* modifier is the match to make and the transposition from it, while add is the upper-value that determines the
* transposition from uppercase to lower case.
*/
-static GMQCC_INLINE size_t util_strtransform(const char *in, char *out, size_t outsz, const char *mod, int add) {
+static size_t util_strtransform(const char *in, char *out, size_t outsz, const char *mod, int add) {
size_t sz = 1;
for (; *in && sz < outsz; ++in, ++out, ++sz) {
*out = (*in == mod[0])