ldb speed test - needs free block dev
[tridge/junkcode.git] / ival.c
1 #include <stdio.h>
2 #include <string.h>
3
4 typedef unsigned short uint16;
5 typedef unsigned int uint32;
6
7 #ifndef X86
8 #define PVAL(buf,pos) ((((const unsigned char *)(buf))[pos]))
9 #define SVAL(buf,pos) ((PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8))
10 #define IVAL(buf,pos) ((SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16))
11 #else
12 #define SVAL(buf,pos) (*(const uint16 *)((const char *)(buf) + (pos)))
13 #define IVAL(buf,pos) (*(const uint32 *)((const char *)(buf) + (pos)))
14 #endif
15
16 #define SMB_BIG_UINT unsigned long long
17
18 static char buf[4];
19
20 int main(void)
21 {
22         SMB_BIG_UINT x;
23         
24         memset(buf, 0xFF, 4);
25         buf[3] = 0x7F;
26
27         x = IVAL(buf, 0);
28
29         printf("%.0f\n", (double)x);
30         return 0;
31 }