util.h File Reference

Macros for dealing with unaligned numbers. More...

#include <isc/util.h>
#include <string.h>

Go to the source code of this file.

Defines

#define ISCCC_UTIL_H   1
#define GET8(v, w)
#define GET16(v, w)
#define GET24(v, w)
#define GET32(v, w)
#define GET64(v, w)
#define GETC16(v, w, d)
#define GETC32(v, w)
#define GET_OFFSET(v, w)   GET32(v, w)
#define GET_MEM(v, c, w)
#define GET_TYPE(v, w)
#define PUT8(v, w)
#define PUT16(v, w)
#define PUT24(v, w)
#define PUT32(v, w)
#define PUT64(v, w)
#define PUTC16(v, w)
#define PUTC32(v, w)
#define PUT_OFFSET(v, w)   PUT32(v, w)
#define PUT_MEM(s, c, w)
#define REGION_SIZE(r)   ((unsigned int)((r).rend - (r).rstart))
#define REGION_EMPTY(r)   ((r).rstart == (r).rend)
#define REGION_FROMSTRING(r, s)
#define DE_CONST(konst, var)
 Use this to remove the const qualifier of a variable to assign it to a non-const variable or pass it as a non-const function argument ... but only when you are sure it won't then be changed! This is necessary to sometimes shut up some compilers (as with gcc -Wcast-qual) when there is just no other good way to avoid the situation.


Detailed Description

Macros for dealing with unaligned numbers.

Note:
no side effects are allowed when invoking these macros!

Definition in file util.h.


Define Documentation

#define ISCCC_UTIL_H   1

Definition at line 35 of file util.h.

#define GET8 ( v,
 ) 

Value:

do { \
                v = *w; \
                w++; \
        } while (0)

Definition at line 46 of file util.h.

Referenced by table_fromwire(), value_fromwire(), and verify().

#define GET16 ( v,
 ) 

Value:

do { \
                v = (unsigned int)w[0] << 8; \
                v |= (unsigned int)w[1]; \
                w += 2; \
        } while (0)

Definition at line 52 of file util.h.

#define GET24 ( v,
 ) 

Value:

do { \
                v = (unsigned int)w[0] << 16; \
                v |= (unsigned int)w[1] << 8; \
                v |= (unsigned int)w[2]; \
                w += 3; \
        } while (0)

Definition at line 59 of file util.h.

#define GET32 ( v,
 ) 

Value:

do { \
                v = (unsigned int)w[0] << 24; \
                v |= (unsigned int)w[1] << 16; \
                v |= (unsigned int)w[2] << 8; \
                v |= (unsigned int)w[3]; \
                w += 4; \
        } while (0)

Definition at line 67 of file util.h.

Referenced by isccc_cc_fromwire(), and value_fromwire().

#define GET64 ( v,
 ) 

Value:

do { \
                v = (isc_uint64_t)w[0] << 56; \
                v |= (isc_uint64_t)w[1] << 48; \
                v |= (isc_uint64_t)w[2] << 40; \
                v |= (isc_uint64_t)w[3] << 32; \
                v |= (isc_uint64_t)w[4] << 24; \
                v |= (isc_uint64_t)w[5] << 16; \
                v |= (isc_uint64_t)w[6] << 8; \
                v |= (isc_uint64_t)w[7]; \
                w += 8; \
        } while (0)

Definition at line 76 of file util.h.

#define GETC16 ( v,
w,
 ) 

Value:

do { \
                GET8(v, w); \
                if (v == 0) \
                        d = ISCCC_TRUE; \
                else { \
                        d = ISCCC_FALSE; \
                        if (v == 255) \
                                GET16(v, w); \
                } \
        } while (0)

Definition at line 89 of file util.h.

#define GETC32 ( v,
 ) 

Value:

do { \
                GET24(v, w); \
                if (v == 0xffffffu) \
                        GET32(v, w); \
        } while (0)

Definition at line 101 of file util.h.

#define GET_OFFSET ( v,
 )     GET32(v, w)

Definition at line 108 of file util.h.

#define GET_MEM ( v,
c,
 ) 

Value:

do { \
                memmove(v, w, c); \
                w += c; \
        } while (0)

Definition at line 110 of file util.h.

Referenced by table_fromwire().

#define GET_TYPE ( v,
 ) 

Value:

do { \
                GET8(v, w); \
                if (v > 127) { \
                        if (v < 255) \
                                v = ((v & 0x7f) << 16) | ISCCC_RDATATYPE_SIG; \
                        else \
                                GET32(v, w); \
                } \
        } while (0)

Definition at line 116 of file util.h.

#define PUT8 ( v,
 ) 

Value:

do { \
                *w = (v & 0x000000ffU); \
                w++; \
        } while (0)

Definition at line 127 of file util.h.

#define PUT16 ( v,
 ) 

Value:

do { \
                w[0] = (v & 0x0000ff00U) >> 8; \
                w[1] = (v & 0x000000ffU); \
                w += 2; \
        } while (0)

Definition at line 133 of file util.h.

#define PUT24 ( v,
 ) 

Value:

do { \
                w[0] = (v & 0x00ff0000U) >> 16; \
                w[1] = (v & 0x0000ff00U) >> 8; \
                w[2] = (v & 0x000000ffU); \
                w += 3; \
        } while (0)

Definition at line 140 of file util.h.

#define PUT32 ( v,
 ) 

Value:

do { \
                w[0] = (v & 0xff000000U) >> 24; \
                w[1] = (v & 0x00ff0000U) >> 16; \
                w[2] = (v & 0x0000ff00U) >> 8; \
                w[3] = (v & 0x000000ffU); \
                w += 4; \
        } while (0)

Definition at line 148 of file util.h.

#define PUT64 ( v,
 ) 

Value:

do { \
                w[0] = (v & 0xff00000000000000ULL) >> 56; \
                w[1] = (v & 0x00ff000000000000ULL) >> 48; \
                w[2] = (v & 0x0000ff0000000000ULL) >> 40; \
                w[3] = (v & 0x000000ff00000000ULL) >> 32; \
                w[4] = (v & 0x00000000ff000000ULL) >> 24; \
                w[5] = (v & 0x0000000000ff0000ULL) >> 16; \
                w[6] = (v & 0x000000000000ff00ULL) >> 8; \
                w[7] = (v & 0x00000000000000ffULL); \
                w += 8; \
        } while (0)

Definition at line 157 of file util.h.

#define PUTC16 ( v,
 ) 

Value:

do { \
                if (v > 0 && v < 255) \
                        PUT8(v, w); \
                else { \
                        PUT8(255, w); \
                        PUT16(v, w); \
                } \
        } while (0)

Definition at line 170 of file util.h.

#define PUTC32 ( v,
 ) 

Value:

do { \
                if (v < 0xffffffU) \
                        PUT24(v, w); \
                else { \
                        PUT24(0xffffffU, w); \
                        PUT32(v, w); \
                } \
        } while (0)

Definition at line 180 of file util.h.

#define PUT_OFFSET ( v,
 )     PUT32(v, w)

Definition at line 190 of file util.h.

#define PUT_MEM ( s,
c,
 ) 

Value:

do { \
                memmove(w, s, c); \
                w += c; \
        } while (0)

Definition at line 194 of file util.h.

Referenced by sign().

#define REGION_SIZE ( r   )     ((unsigned int)((r).rend - (r).rstart))

Definition at line 203 of file util.h.

Referenced by control_recvmessage(), isccc_cc_fromwire(), isccc_sexpr_frombinary(), isccc_sexpr_print(), sign(), table_fromwire(), value_fromwire(), value_towire(), and verify().

#define REGION_EMPTY ( r   )     ((r).rstart == (r).rend)

Definition at line 204 of file util.h.

Referenced by list_fromwire(), and table_fromwire().

#define REGION_FROMSTRING ( r,
s   ) 

Value:

do { \
        (r).rstart = (unsigned char *)s; \
        (r).rend = (r).rstart + strlen(s); \
} while (0)

Definition at line 205 of file util.h.

#define DE_CONST ( konst,
var   ) 

Value:

do { \
                union { const void *k; void *v; } _u; \
                _u.k = konst; \
                var = _u.v; \
        } while (0)
Use this to remove the const qualifier of a variable to assign it to a non-const variable or pass it as a non-const function argument ... but only when you are sure it won't then be changed! This is necessary to sometimes shut up some compilers (as with gcc -Wcast-qual) when there is just no other good way to avoid the situation.

Definition at line 218 of file util.h.


Generated on Tue Apr 28 17:41:18 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha