23#ifndef _ASTERISK_UNALIGNED_H
24#define _ASTERISK_UNALIGNED_H
26#if defined(__cplusplus) || defined(c_plusplus)
34 const struct { uint64_t
d; } __attribute__((packed)) *pp = p;
40 const struct {
unsigned int d; } __attribute__((packed)) *pp = p;
46 const struct {
unsigned short d; } __attribute__((packed)) *pp = p;
53 struct { uint64_t
d; } __attribute__((packed,may_alias)) *pp = p;
60 struct {
unsigned int d; } __attribute__((packed)) *pp = p;
67 struct {
unsigned short d; } __attribute__((packed)) *pp = p;
71#elif defined(SOLARIS) && defined(__sparc__)
74 const unsigned char *cp = p;
77 (((uint64_t) cp[0]) << 56) |
78 (((uint64_t) cp[1]) << 48) |
79 (((uint64_t) cp[2]) << 40) |
80 (((uint64_t) cp[3]) << 32) |
81 (((uint64_t) cp[4]) << 24) |
82 (((uint64_t) cp[5]) << 16) |
83 (((uint64_t) cp[6]) << 8) |
84 (((uint64_t) cp[7]) << 0);
89 const unsigned char *cp = p;
91 return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3];
96 const unsigned char *cp = p;
98 return (cp[0] << 8) | cp[1] ;
103 unsigned char *cp = p;
105 cp[0] = (
datum >> 56) & 0xff;
106 cp[1] = (
datum >> 48) & 0xff;
107 cp[2] = (
datum >> 40) & 0xff;
108 cp[3] = (
datum >> 32) & 0xff;
109 cp[4] = (
datum >> 24) & 0xff;
110 cp[5] = (
datum >> 16) & 0xff;
111 cp[6] = (
datum >> 8) & 0xff;
112 cp[7] = (
datum >> 0) & 0xff;
117 unsigned char *cp = p;
127 unsigned char *cp = p;
133#define get_unaligned_uint64(p) (*((uint64_t *)(p)))
134#define get_unaligned_uint32(p) (*((unsigned int *)(p)))
135#define get_unaligned_uint16(p) (*((unsigned short *)(p)))
136#define put_unaligned_uint64(p,d) do { uint64_t *__P = (p); *__P = d; } while(0)
137#define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0)
138#define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0)
141#if defined(__cplusplus) || defined(c_plusplus)
static unsigned int get_unaligned_uint32(const void *p)
static void put_unaligned_uint16(void *p, unsigned short datum)
static unsigned short get_unaligned_uint16(const void *p)
static void put_unaligned_uint64(void *p, uint64_t datum)
static void put_unaligned_uint32(void *p, unsigned int datum)
static uint64_t get_unaligned_uint64(const void *p)