]> granicus.if.org Git - icu/commitdiff
ICU-9008 version of RES_GET_INT(res) for when >> does not sign-extend
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 15 Dec 2011 00:43:16 +0000 (00:43 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Thu, 15 Dec 2011 00:43:16 +0000 (00:43 +0000)
X-SVN-Rev: 31119

icu4c/source/common/uresdata.h

index 2bedf00426a326c82416db0742f966e2b06d25b1..3e63db917d9730f68be2b694b6c2d25b71bce449 100644 (file)
@@ -66,7 +66,12 @@ typedef uint32_t Resource;
 #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res))
 
 /* get signed and unsigned integer values directly from the Resource handle */
-#define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L)
+#if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC
+#   define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L)
+#else
+#   define RES_GET_INT(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff)
+#endif
+
 #define RES_GET_UINT(res) ((res)&0x0fffffff)
 
 #define URES_IS_ARRAY(type) ((int32_t)(type)==URES_ARRAY || (int32_t)(type)==URES_ARRAY16)