summaryrefslogtreecommitdiff
path: root/msgpack
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@users.sourceforge.jp>2010-01-20 14:46:54 +0900
committerfrsyuki <frsyuki@users.sourceforge.jp>2010-01-20 14:46:54 +0900
commitd8212ad6200db16ca49c5c8198ba0955272763c8 (patch)
treecef2bcca39582f143879e4ca616e0f49be51528f /msgpack
parent1066bb38a87df13e89d891682e39df2ef9a08d7c (diff)
downloadmsgpack-python-d8212ad6200db16ca49c5c8198ba0955272763c8.tar.gz
strict-aliasing rule
Diffstat (limited to 'msgpack')
-rw-r--r--msgpack/pack_template.h12
-rw-r--r--msgpack/unpack_template.h12
2 files changed, 12 insertions, 12 deletions
diff --git a/msgpack/pack_template.h b/msgpack/pack_template.h
index de148bf..b314d6d 100644
--- a/msgpack/pack_template.h
+++ b/msgpack/pack_template.h
@@ -554,19 +554,19 @@ if(sizeof(unsigned long long) == 2) {
msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
{
- union { char buf[4]; uint32_t num; } f;
- *((float*)&f.buf) = d; // FIXME
+ union { float f; uint32_t i; } mem;
+ mem.f = d;
unsigned char buf[5];
- buf[0] = 0xca; *(uint32_t*)&buf[1] = _msgpack_be32(f.num);
+ buf[0] = 0xca; *(uint32_t*)&buf[1] = _msgpack_be32(mem.i);
msgpack_pack_append_buffer(x, buf, 5);
}
msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
{
- union { char buf[8]; uint64_t num; } f;
- *((double*)&f.buf) = d; // FIXME
+ union { double f; uint64_t i; } mem;
+ mem.f = d;
unsigned char buf[9];
- buf[0] = 0xcb; *(uint64_t*)&buf[1] = _msgpack_be64(f.num);
+ buf[0] = 0xcb; *(uint64_t*)&buf[1] = _msgpack_be64(mem.i);
msgpack_pack_append_buffer(x, buf, 9);
}
diff --git a/msgpack/unpack_template.h b/msgpack/unpack_template.h
index 3328ea3..cf2e74c 100644
--- a/msgpack/unpack_template.h
+++ b/msgpack/unpack_template.h
@@ -222,13 +222,13 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
//case CS_
//case CS_
case CS_FLOAT: {
- union { uint32_t num; char buf[4]; } f;
- f.num = PTR_CAST_32(n); // FIXME
- push_fixed_value(_float, *((float*)f.buf)); }
+ union { uint32_t i; float f; } mem;
+ mem.i = PTR_CAST_32(n);
+ push_fixed_value(_float, mem.f); }
case CS_DOUBLE: {
- union { uint64_t num; char buf[8]; } f;
- f.num = PTR_CAST_64(n); // FIXME
- push_fixed_value(_double, *((double*)f.buf)); }
+ union { uint64_t i; double f; } mem;
+ mem.i = PTR_CAST_64(n);
+ push_fixed_value(_double, mem.f); }
case CS_UINT_8:
push_fixed_value(_uint8, (uint8_t)PTR_CAST_8(n));
case CS_UINT_16: