summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authormiod <>2025-10-23 18:49:46 +0000
committermiod <>2025-10-23 18:49:46 +0000
commit5a2688fe0c33fbd28683a16e5b2e580a49d6cdf5 (patch)
treed6415ba651265544cd83a24e5a7906557bd1e0a9 /src/lib/libc/stdlib/malloc.c
parent301b8cd8a2821eb7a6a9b89bf1cd766aa845e263 (diff)
downloadopenbsd-5a2688fe0c33fbd28683a16e5b2e580a49d6cdf5.tar.gz
openbsd-5a2688fe0c33fbd28683a16e5b2e580a49d6cdf5.tar.bz2
openbsd-5a2688fe0c33fbd28683a16e5b2e580a49d6cdf5.zip
Revert r1.286 now that all supported platforms have __builtin_clz.
Diffstat (limited to '')
-rw-r--r--src/lib/libc/stdlib/malloc.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index c6261d87c5..f067dd1f37 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.299 2025/06/12 16:07:09 deraadt Exp $ */ 1/* $OpenBSD: malloc.c,v 1.300 2025/10/23 18:49:46 miod Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -1091,24 +1091,6 @@ err:
1091 return NULL; 1091 return NULL;
1092} 1092}
1093 1093
1094#if defined(__GNUC__) && __GNUC__ < 4
1095static inline unsigned int
1096lb(u_int x)
1097{
1098#if defined(__m88k__)
1099 __asm__ __volatile__ ("ff1 %0, %0" : "=r" (x) : "0" (x));
1100 return x;
1101#else
1102 /* portable version */
1103 unsigned int count = 0;
1104 while ((x & (1U << (sizeof(int) * CHAR_BIT - 1))) == 0) {
1105 count++;
1106 x <<= 1;
1107 }
1108 return (sizeof(int) * CHAR_BIT - 1) - count;
1109#endif
1110}
1111#else
1112/* using built-in function version */ 1094/* using built-in function version */
1113static inline unsigned int 1095static inline unsigned int
1114lb(u_int x) 1096lb(u_int x)
@@ -1116,7 +1098,6 @@ lb(u_int x)
1116 /* I need an extension just for integer-length (: */ 1098 /* I need an extension just for integer-length (: */
1117 return (sizeof(int) * CHAR_BIT - 1) - __builtin_clz(x); 1099 return (sizeof(int) * CHAR_BIT - 1) - __builtin_clz(x);
1118} 1100}
1119#endif
1120 1101
1121/* https://pvk.ca/Blog/2015/06/27/linear-log-bucketing-fast-versatile-simple/ 1102/* https://pvk.ca/Blog/2015/06/27/linear-log-bucketing-fast-versatile-simple/
1122 via Tony Finch */ 1103 via Tony Finch */