summaryrefslogtreecommitdiff
path: root/gcc/hwint.h
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-16 19:59:56 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-16 19:59:56 +0000
commita2b340f29b83bb9b928e8b97126e54d41fc607e9 (patch)
tree7517b4a73e11c8c28d9049721a6ee6d367b9c7ba /gcc/hwint.h
parenteb106fafe36111527e8d60e7762b9704223bca9e (diff)
downloadgcc-a2b340f29b83bb9b928e8b97126e54d41fc607e9.tar.gz
* hwint.c (abs_hwi, absu_hwi): Move to ...
* hwint.h (abs_hwi, absu_hwi): ... here; make inline. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218791 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/hwint.h')
-rw-r--r--gcc/hwint.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/hwint.h b/gcc/hwint.h
index fd961fd91da..8e1c8f5ae77 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -264,4 +264,21 @@ zext_hwi (unsigned HOST_WIDE_INT src, unsigned int prec)
}
}
+/* Compute the absolute value of X. */
+
+inline HOST_WIDE_INT
+abs_hwi (HOST_WIDE_INT x)
+{
+ gcc_checking_assert (x != HOST_WIDE_INT_MIN);
+ return x >= 0 ? x : -x;
+}
+
+/* Compute the absolute value of X as an unsigned type. */
+
+inline unsigned HOST_WIDE_INT
+absu_hwi (HOST_WIDE_INT x)
+{
+ return x >= 0 ? (unsigned HOST_WIDE_INT)x : -(unsigned HOST_WIDE_INT)x;
+}
+
#endif /* ! GCC_HWINT_H */