summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-02-19 17:56:59 +0100
committerJakub Jelinek <jakub@redhat.com>2013-02-19 17:56:59 +0100
commit2389741abb70e282c39125e1017191a985a2cfea (patch)
tree49dbca16aa3ae5a9d6876352e8329d7e3dd4577b /stdlib
parent55e4107b2c70b222b5ceb88d9c0ca68f9699b9ce (diff)
downloadglibc-2389741abb70e282c39125e1017191a985a2cfea.tar.gz
glibc-2389741abb70e282c39125e1017191a985a2cfea.tar.xz
glibc-2389741abb70e282c39125e1017191a985a2cfea.zip
* stdlib/strtod_l.c (__mpn_lshift_1): Rewritten as function-like
	macro.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/strtod_l.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index 5959354ecc..47247b548c 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -444,28 +444,30 @@ str_to_mpn (const STRING_TYPE *str, int digcnt, mp_limb_t *n, mp_size_t *nsize,
 /* Shift {PTR, SIZE} COUNT bits to the left, and fill the vacated bits
    with the COUNT most significant bits of LIMB.
 
-   Tege doesn't like this function so I have to write it here myself. :)
+   Implemented as a macro, so that __builtin_constant_p works even at -O0.
+
+   Tege doesn't like this macro so I have to write it here myself. :)
    --drepper */
-static inline void
-__attribute ((always_inline))
-__mpn_lshift_1 (mp_limb_t *ptr, mp_size_t size, unsigned int count,
-		mp_limb_t limb)
-{
-  if (__builtin_constant_p (count) && count == BITS_PER_MP_LIMB)
-    {
-      /* Optimize the case of shifting by exactly a word:
-	 just copy words, with no actual bit-shifting.  */
-      mp_size_t i;
-      for (i = size - 1; i > 0; --i)
-	ptr[i] = ptr[i - 1];
-      ptr[0] = limb;
-    }
-  else
-    {
-      (void) __mpn_lshift (ptr, ptr, size, count);
-      ptr[0] |= limb >> (BITS_PER_MP_LIMB - count);
-    }
-}
+#define __mpn_lshift_1(ptr, size, count, limb) \
+  do									\
+    {									\
+      mp_limb_t *__ptr = (ptr);						\
+      if (__builtin_constant_p (count) && count == BITS_PER_MP_LIMB)	\
+	{								\
+	  mp_size_t i;							\
+	  for (i = (size) - 1; i > 0; --i)				\
+	    __ptr[i] = __ptr[i - 1];					\
+	  __ptr[0] = (limb);						\
+	}								\
+      else								\
+	{								\
+	  /* We assume count > 0 && count < BITS_PER_MP_LIMB here.  */	\
+	  unsigned int __count = (count);				\
+	  (void) __mpn_lshift (__ptr, __ptr, size, __count);		\
+	  __ptr[0] |= (limb) >> (BITS_PER_MP_LIMB - __count);		\
+	}								\
+    }									\
+  while (0)
 
 
 #define INTERNAL(x) INTERNAL1(x)