This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] For RTEMS-LIBBSD support, add bitcount routines
On 16/05/17 21:04, Craig Howland wrote:
On 05/16/2017 02:23 PM, Kevin Kirspel wrote:
---
newlib/libc/include/sys/types.h | 66
++++++++++++++++++++++++++++++++++++++---
1 file changed, 62 insertions(+), 4 deletions(-)
diff --git a/newlib/libc/include/sys/types.h
b/newlib/libc/include/sys/types.h
index 65ff520..83f891e 100644
...
+#ifdef __LP64__
+static __inline __uint64_t
+__bitcount64(__uint64_t _x)
+{
...
+}
+
+#define __bitcountl(x) __bitcount64((unsigned long)(x))
+#else /* __LP64__ */
+static __inline __uint64_t
+__bitcount64(__uint64_t _x)
+{
+ return (__bitcount32(_x >> 32) + __bitcount32(_x));
+}
+
+#define __bitcountl(x) __bitcount32((unsigned long)(x))
+#endif /* __LP64__ */
+#define __bitcount(x) __bitcount32((unsigned int)(x))
+#endif /* __POPCNT__ */
+
Depending only upon LP64 is not sufficient in general to get all the
sizes right. (ARM Cortex A53, for example, has 64-bit int,
too--ILP64. So A53 would probably end up with two problems, bitcountl
and bitcount.)
RTEMS doesn't support an __ILP64__ ABI at the moment, so it should be
sufficient. However, maybe we should use the __SIZEOF_INT__ and
__SIZEOF_LONG__ builtin defines instead of __LP64.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.