diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-12-17 22:16:06 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-12-17 22:16:06 +0000 |
commit | ff2a5847b9898b99f9c513a73232b6b9f9a8212b (patch) | |
tree | d901624912d51a3aca8153c51b5de305be4613f4 /wsutil | |
parent | e6d09c163454627e8caedc8b58836f9071073c6e (diff) | |
download | wireshark-ff2a5847b9898b99f9c513a73232b6b9f9a8212b.tar.gz |
sign_ext.h: use G_GINT64_CONSTANT(), add sample for alternative method of sign extension.
Alternative method looks much nicer in dissasembly.
svn path=/trunk/; revision=54202
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/sign_ext.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/wsutil/sign_ext.h b/wsutil/sign_ext.h index ef911829ae..00f84e0188 100644 --- a/wsutil/sign_ext.h +++ b/wsutil/sign_ext.h @@ -41,10 +41,20 @@ ws_sign_ext32(guint32 val, int no_of_bits) static inline guint64 ws_sign_ext64(guint64 val, int no_of_bits) { - if (val & (1LL << (no_of_bits-1))) - val |= (-1 << no_of_bits); + if (val & (G_GINT64_CONSTANT(1) << (no_of_bits-1))) + val |= (G_GINT64_CONSTANT(-1) << no_of_bits); return val; } _U_ +/* +static inline guint64 +ws_sign_ext64(guint64 val, int no_of_bits) +{ + gint64 sval = (val << (64 - no_of_bits)); + + return (guint64) (sval >> (64 - no_of_bits)); +} +*/ + #endif /* __WSUTIL_SIGN_EXT_H__ */ |