Digi XBee(R) ANSI C Host Library
zcl64.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012 Digi International Inc.,
3  * All rights not expressly granted are reserved.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
7  * You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
10  * =======================================================================
11  */
12 
33 #ifndef ZIGBEE_ZCL64_H
34 #define ZIGBEE_ZCL64_H
35 
36 #include "xbee/platform.h"
37 
42 typedef JSUint64 zcl64_t;
43 
57 #define ZCL64_INIT(hi, lo) JSLL_INIT(hi, lo)
58 
67 #ifdef XBEE_NATIVE_64BIT
68  #define ZCL64_LOAD(r, hi32, lo32) r = (((uint64_t)(hi32) << 32) + lo32)
69 #else
70  #define ZCL64_LOAD(r, hi32, lo32) ((r).hi = (hi32), (r).lo = (lo32))
71 #endif
72 
81 #define ZCL64_IS_ZERO(a) JSLL_IS_ZERO(a)
82 
92 #define ZCL64_EQ(a, b) JSLL_EQ(a, b)
93 
103 #define ZCL64_NE(a, b) JSLL_NE(a, b)
104 
113 #define ZCL64_GE_ZERO(a) JSLL_GE_ZERO(a)
114 
123 #define ZCL64_LT(a, b) JSLL_REAL_CMP(a, <, b)
124 
133 #define ZCL64_LTU(a, b) JSLL_REAL_UCMP(a, <, b)
134 
142 #define ZCL64_AND(r, a, b) JSLL_AND(r, a, b)
143 
151 #define ZCL64_OR(r, a, b) JSLL_OR(r, a, b)
152 
160 #define ZCL64_XOR(r, a, b) JSLL_XOR(r, a, b)
161 
168 #define ZCL64_NOT(r, a) JSLL_NOT(r, a)
169 
176 #define ZCL64_NEG(r, a) JSLL_NEG(r, a)
177 
185 #define ZCL64_ADD(r, a, b) JSLL_ADD(r, a, b)
186 
194 #define ZCL64_SUB(r, a, b) JSLL_SUB(r, a, b)
195 
203 #define ZCL64_MUL(r, a, b) JSLL_MUL(r, a, b)
204 
214 #define ZCL64_MUL32(r, a, b) JSLL_MUL32(r, a, b)
215 
228 #define ZCL64_UDIVMOD(qp, rp, a, b) JSLL_UDIVMOD(qp, rp, a, b)
229 
230 // Is there a need for a signed divmod, based on JSLL_DIV and JSLL_MOD?
231 // Would need to store two negate flags, one for quotient and one for
232 // remainder. Remainder only negative if a is negative, quotient is negative
233 // if sign of a and b differ
234 
243 #define ZCL64_DIV(r, a, b) JSLL_DIV(r, a, b)
244 
253 #define ZCL64_MOD(r, a, b) JSLL_MOD(r, a, b)
254 
264 #define ZCL64_ASL(r, a, b) JSLL_SHL(r, a, b)
265 
275 #define ZCL64_LSL(r, a, b) ZCL64_SLA(r, a, b)
276 
286 #define ZCL64_ASR(r, a, b) JSLL_SHR(r, a, b)
287 
297 #define ZCL64_LSR(r, a, b) JSLL_USHR(r, a, b)
298 
299 /* a is an JSInt32, b is JSInt32, r is JSInt64 */
300 //#define JSLL_ISHL(r, a, b)
301 
309 #define ZCL64_TO_INT32(i32, i64) JSLL_L2I(i32, i64)
310 
318 #define ZCL64_TO_UINT32(u32, u64) JSLL_L2UI(u32, u64)
319 
324 #ifdef XBEE_NATIVE_64BIT
325  #define ZCL64_LOW32(u64) ((uint32_t)(u64))
326 #else
327  #define ZCL64_LOW32(u64) ((u64).lo)
328 #endif
329 
334 #ifdef XBEE_NATIVE_64BIT
335  #define ZCL64_HIGH32(u64) ((uint32_t)(u64 >> 32))
336 #else
337  #define ZCL64_HIGH32(u64) ((u64).hi)
338 #endif
339 
347 #define ZCL64_TO_FLOAT(f, i64) JSLL_L2F(f, i64)
348 
356 #define ZCL64_TO_DOUBLE(d, i64) JSLL_L2D(d, i64)
357 
358 
366 #define ZCL64_FROM_INT32(i64, i32) JSLL_I2L(i64, i32)
367 
375 #define ZCL64_FROM_UINT32(u64, u32) JSLL_UI2L(u64, u32)
376 
384 #define ZCL64_FROM_FLOAT(i64, f) JSLL_F2L(i64, f)
385 
393 #define ZCL64_FROM_DOUBLE(i64, d) JSLL_D2L(i64, d)
394 
395 
408 #define ZCL64_TO_HEXSTR(buffer, var) JSLL_HEXSTR(buffer, var)
409 
421 #define ZCL64_TO_DECSTR(buffer, var) JSLL_DECSTR(buffer, var)
422 
434 #define ZCL64_TO_UDECSTR(buffer, var) JSLL_UDECSTR(buffer, var)
435 
436 #endif
437 
JSUint64 zcl64_t
64-bit integer in host-byte-order Use for 56-bit values as well – ZCL layer will make sure top byte ...
Definition: zcl64.h:42
Common header for Hardware Abstraction Layer.
Definition: jslong_glue.h:30