File: unaligned.h

package info (click to toggle)
twin 0.4.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,804 kB
  • ctags: 23,904
  • sloc: ansic: 61,860; cpp: 1,023; makefile: 777; sh: 552; lex: 302; yacc: 231
file content (26 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _TWIN_UNALIGNED_H
#define _TWIN_UNALIGNED_H

#include "Tw/prefix.h"

#define PushV(s,len,vec)	(Tw(CopyMem)(vec, s, len), (s) += (len))
#define PopV(s,len,lvec)	(Tw(CopyMem)(s, lvec, len), (s) += (len))
#define PopAddr(s,type,len,ptr)	((ptr) = (len) ? (type *)s : (type *)0, s += (len))


#ifdef __i386__

# define TW_CAN_UNALIGNED 1
# define Push(s,type,val)	(*((type *)(s))++ = (val))
# define Pop(s,type,lval)	((lval) = *((type TW(CONST) *)(s))++)

#else /* !__i386__ */

# warning not ix86 arch, using memcpy
# define TW_CAN_UNALIGNED 0
# define Push(s,type,val)	do {type __tmp = (val); PushV(s,sizeof(type),&__tmp); } while(0)
# define Pop(s,type,lval)	PopV(s,sizeof(type),&(lval))

#endif /* __i386__ */

#endif /* _TWIN_UNALIGNED_H */