diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index cad8e5d6a1..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.297 2024/09/20 02:00:46 jsg 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> |
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <sys/queue.h> | 31 | #include <sys/queue.h> |
| 32 | #include <sys/mman.h> | 32 | #include <sys/mman.h> |
| 33 | #include <sys/sysctl.h> | 33 | #include <sys/sysctl.h> |
| 34 | #include <uvm/uvmexp.h> | ||
| 35 | #include <errno.h> | 34 | #include <errno.h> |
| 36 | #include <stdarg.h> | 35 | #include <stdarg.h> |
| 37 | #include <stdint.h> | 36 | #include <stdint.h> |
| @@ -264,7 +263,8 @@ static union { | |||
| 264 | __attribute__((section(".openbsd.mutable"))); | 263 | __attribute__((section(".openbsd.mutable"))); |
| 265 | #define mopts malloc_readonly.mopts | 264 | #define mopts malloc_readonly.mopts |
| 266 | 265 | ||
| 267 | char *malloc_options; /* compile-time options */ | 266 | /* compile-time options */ |
| 267 | const char *const malloc_options __attribute__((weak)); | ||
| 268 | 268 | ||
| 269 | static __dead void wrterror(struct dir_info *d, char *msg, ...) | 269 | static __dead void wrterror(struct dir_info *d, char *msg, ...) |
| 270 | __attribute__((__format__ (printf, 2, 3))); | 270 | __attribute__((__format__ (printf, 2, 3))); |
| @@ -501,7 +501,8 @@ omalloc_parseopt(char opt) | |||
| 501 | static void | 501 | static void |
| 502 | omalloc_init(void) | 502 | omalloc_init(void) |
| 503 | { | 503 | { |
| 504 | char *p, *q, b[16]; | 504 | const char *p; |
| 505 | char *q, b[16]; | ||
| 505 | int i, j; | 506 | int i, j; |
| 506 | const int mib[2] = { CTL_VM, VM_MALLOC_CONF }; | 507 | const int mib[2] = { CTL_VM, VM_MALLOC_CONF }; |
| 507 | size_t sb; | 508 | size_t sb; |
| @@ -1090,24 +1091,6 @@ err: | |||
| 1090 | return NULL; | 1091 | return NULL; |
| 1091 | } | 1092 | } |
| 1092 | 1093 | ||
| 1093 | #if defined(__GNUC__) && __GNUC__ < 4 | ||
| 1094 | static inline unsigned int | ||
| 1095 | lb(u_int x) | ||
| 1096 | { | ||
| 1097 | #if defined(__m88k__) | ||
| 1098 | __asm__ __volatile__ ("ff1 %0, %0" : "=r" (x) : "0" (x)); | ||
| 1099 | return x; | ||
| 1100 | #else | ||
| 1101 | /* portable version */ | ||
| 1102 | unsigned int count = 0; | ||
| 1103 | while ((x & (1U << (sizeof(int) * CHAR_BIT - 1))) == 0) { | ||
| 1104 | count++; | ||
| 1105 | x <<= 1; | ||
| 1106 | } | ||
| 1107 | return (sizeof(int) * CHAR_BIT - 1) - count; | ||
| 1108 | #endif | ||
| 1109 | } | ||
| 1110 | #else | ||
| 1111 | /* using built-in function version */ | 1094 | /* using built-in function version */ |
| 1112 | static inline unsigned int | 1095 | static inline unsigned int |
| 1113 | lb(u_int x) | 1096 | lb(u_int x) |
| @@ -1115,7 +1098,6 @@ lb(u_int x) | |||
| 1115 | /* I need an extension just for integer-length (: */ | 1098 | /* I need an extension just for integer-length (: */ |
| 1116 | return (sizeof(int) * CHAR_BIT - 1) - __builtin_clz(x); | 1099 | return (sizeof(int) * CHAR_BIT - 1) - __builtin_clz(x); |
| 1117 | } | 1100 | } |
| 1118 | #endif | ||
| 1119 | 1101 | ||
| 1120 | /* 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/ |
| 1121 | via Tony Finch */ | 1103 | via Tony Finch */ |
