summaryrefslogtreecommitdiffstats
path: root/lib/libcxx/include/support/ibm/support.h
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2016-09-03 18:39:32 +0000
committerpatrick <patrick@openbsd.org>2016-09-03 18:39:32 +0000
commitfe1ccca2776129541f1c4f645e4d1de89a22a031 (patch)
tree8e4fd7a09a5a15a9498fd2d88dcddbd40e999c79 /lib/libcxx/include/support/ibm/support.h
parentFixed missing null check in switchctl.c (diff)
downloadwireguard-openbsd-fe1ccca2776129541f1c4f645e4d1de89a22a031.tar.xz
wireguard-openbsd-fe1ccca2776129541f1c4f645e4d1de89a22a031.zip
Import libc++ 3.9.0
Diffstat (limited to 'lib/libcxx/include/support/ibm/support.h')
-rw-r--r--lib/libcxx/include/support/ibm/support.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/libcxx/include/support/ibm/support.h b/lib/libcxx/include/support/ibm/support.h
new file mode 100644
index 00000000000..0abfa7f95a6
--- /dev/null
+++ b/lib/libcxx/include/support/ibm/support.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------- support/ibm/support.h ----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H
+#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
+
+extern "builtin" int __popcnt4(unsigned int);
+extern "builtin" int __popcnt8(unsigned long long);
+extern "builtin" unsigned int __cnttz4(unsigned int);
+extern "builtin" unsigned int __cnttz8(unsigned long long);
+extern "builtin" unsigned int __cntlz4(unsigned int);
+extern "builtin" unsigned int __cntlz8(unsigned long long);
+
+// Builtin functions for counting population
+#define __builtin_popcount(x) __popcnt4(x)
+#define __builtin_popcountll(x) __popcnt8(x)
+#if defined(__64BIT__)
+#define __builtin_popcountl(x) __builtin_popcountll(x)
+#else
+#define __builtin_popcountl(x) __builtin_popcount(x)
+#endif
+
+// Builtin functions for counting trailing zeros
+#define __builtin_ctz(x) __cnttz4(x)
+#define __builtin_ctzll(x) __cnttz8(x)
+#if defined(__64BIT__)
+#define __builtin_ctzl(x) __builtin_ctzll(x)
+#else
+#define __builtin_ctzl(x) __builtin_ctz(x)
+#endif
+
+// Builtin functions for counting leading zeros
+#define __builtin_clz(x) __cntlz4(x)
+#define __builtin_clzll(x) __cntlz8(x)
+#if defined(__64BIT__)
+#define __builtin_clzl(x) __builtin_clzll(x)
+#else
+#define __builtin_clzl(x) __builtin_clz(x)
+#endif
+
+#if defined(__64BIT__)
+#define __SIZE_WIDTH__ 64
+#else
+#define __SIZE_WIDTH__ 32
+#endif
+
+#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H