Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug-607243.c
1 /* bad shift right 12 */
2
3 #include <testfwk.h>
4
5 typedef unsigned int u16_t;
6
7 struct myhdr { u16_t x; } h, *p;
8
9 #define NTOHS(n) (((((u16_t)(n) & 0xff)) << 8) | (((u16_t)(n) & 0xff00) >> 8))
10 #define IPH_V(hdr) ((u16_t)NTOHS((hdr)->x) >> 12)
11
12 void testBug(void) {
13   p = &h;
14   p->x = 0x45;
15   ASSERT(IPH_V(p)==4);
16 }