summaryrefslogtreecommitdiff
path: root/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc')
-rw-r--r--src/lib/libc/include/thread_private.h66
-rw-r--r--src/lib/libc/net/ether_aton.36
-rw-r--r--src/lib/libc/net/ethers.c4
-rw-r--r--src/lib/libc/net/gai_strerror.36
-rw-r--r--src/lib/libc/net/if_indextoname.312
-rw-r--r--src/lib/libc/net/inet6_opt_init.318
-rw-r--r--src/lib/libc/net/inet6_rth_space.38
-rw-r--r--src/lib/libc/stdlib/exit.311
-rw-r--r--src/lib/libc/stdlib/malloc.328
-rw-r--r--src/lib/libc/stdlib/malloc.c9
-rw-r--r--src/lib/libc/stdlib/mkstemp.c5
-rw-r--r--src/lib/libc/stdlib/mktemp.342
-rw-r--r--src/lib/libc/stdlib/ptsname.36
-rw-r--r--src/lib/libc/stdlib/rand48.38
-rw-r--r--src/lib/libc/stdlib/realpath.36
-rw-r--r--src/lib/libc/string/memmem.36
16 files changed, 153 insertions, 88 deletions
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
index 1ec1071161..3e1dbcdf6e 100644
--- a/src/lib/libc/include/thread_private.h
+++ b/src/lib/libc/include/thread_private.h
@@ -1,10 +1,13 @@
1/* $OpenBSD: thread_private.h,v 1.37 2024/08/18 02:25:51 guenther Exp $ */ 1/* $OpenBSD: thread_private.h,v 1.40 2025/08/04 01:44:33 dlg Exp $ */
2 2
3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ 3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
4 4
5#ifndef _THREAD_PRIVATE_H_ 5#ifndef _THREAD_PRIVATE_H_
6#define _THREAD_PRIVATE_H_ 6#define _THREAD_PRIVATE_H_
7 7
8#include <sys/types.h>
9#include <sys/gmon.h>
10
8extern int __isthreaded; 11extern int __isthreaded;
9 12
10#define _MALLOC_MUTEXES 32 13#define _MALLOC_MUTEXES 32
@@ -292,6 +295,12 @@ TAILQ_HEAD(pthread_queue, pthread);
292 295
293#ifdef FUTEX 296#ifdef FUTEX
294 297
298/*
299 * CAS based implementations
300 */
301
302#define __CMTX_CAS
303
295struct pthread_mutex { 304struct pthread_mutex {
296 volatile unsigned int lock; 305 volatile unsigned int lock;
297 int type; 306 int type;
@@ -312,6 +321,10 @@ struct pthread_rwlock {
312 321
313#else 322#else
314 323
324/*
325 * spinlock based implementations
326 */
327
315struct pthread_mutex { 328struct pthread_mutex {
316 _atomic_lock_t lock; 329 _atomic_lock_t lock;
317 struct pthread_queue lockers; 330 struct pthread_queue lockers;
@@ -336,6 +349,46 @@ struct pthread_rwlock {
336}; 349};
337#endif /* FUTEX */ 350#endif /* FUTEX */
338 351
352/* libc mutex */
353
354#define __CMTX_UNLOCKED 0
355#define __CMTX_LOCKED 1
356#define __CMTX_CONTENDED 2
357
358#ifdef __CMTX_CAS
359struct __cmtx {
360 volatile unsigned int lock;
361};
362
363#define __CMTX_INITIALIZER() { \
364 .lock = __CMTX_UNLOCKED, \
365}
366#else /* __CMTX_CAS */
367struct __cmtx {
368 _atomic_lock_t spin;
369 volatile unsigned int lock;
370};
371
372#define __CMTX_INITIALIZER() { \
373 .spin = _SPINLOCK_UNLOCKED, \
374 .lock = __CMTX_UNLOCKED, \
375}
376#endif /* __CMTX_CAS */
377
378/* libc recursive mutex */
379
380struct __rcmtx {
381 volatile pthread_t owner;
382 struct __cmtx mtx;
383 unsigned int depth;
384};
385
386#define __RCMTX_INITIALIZER() { \
387 .owner = NULL, \
388 .mtx = __CMTX_INITIALIZER(), \
389 .depth = 0, \
390}
391
339struct pthread_mutex_attr { 392struct pthread_mutex_attr {
340 int ma_type; 393 int ma_type;
341 int ma_protocol; 394 int ma_protocol;
@@ -390,6 +443,7 @@ struct pthread {
390 443
391 /* cancel received in a delayed cancel block? */ 444 /* cancel received in a delayed cancel block? */
392 int delayed_cancel; 445 int delayed_cancel;
446 struct gmonparam *gmonparam;
393}; 447};
394/* flags in pthread->flags */ 448/* flags in pthread->flags */
395#define THREAD_DONE 0x001 449#define THREAD_DONE 0x001
@@ -410,6 +464,16 @@ void _spinlock(volatile _atomic_lock_t *);
410int _spinlocktry(volatile _atomic_lock_t *); 464int _spinlocktry(volatile _atomic_lock_t *);
411void _spinunlock(volatile _atomic_lock_t *); 465void _spinunlock(volatile _atomic_lock_t *);
412 466
467void __cmtx_init(struct __cmtx *);
468int __cmtx_enter_try(struct __cmtx *);
469void __cmtx_enter(struct __cmtx *);
470void __cmtx_leave(struct __cmtx *);
471
472void __rcmtx_init(struct __rcmtx *);
473int __rcmtx_enter_try(struct __rcmtx *);
474void __rcmtx_enter(struct __rcmtx *);
475void __rcmtx_leave(struct __rcmtx *);
476
413void _rthread_debug(int, const char *, ...) 477void _rthread_debug(int, const char *, ...)
414 __attribute__((__format__ (printf, 2, 3))); 478 __attribute__((__format__ (printf, 2, 3)));
415pid_t _thread_dofork(pid_t (*_sys_fork)(void)); 479pid_t _thread_dofork(pid_t (*_sys_fork)(void));
diff --git a/src/lib/libc/net/ether_aton.3 b/src/lib/libc/net/ether_aton.3
index 98562dc44c..83fe98880c 100644
--- a/src/lib/libc/net/ether_aton.3
+++ b/src/lib/libc/net/ether_aton.3
@@ -1,8 +1,8 @@
1.\" $OpenBSD: ether_aton.3,v 1.3 2022/09/11 06:38:10 jmc Exp $ 1.\" $OpenBSD: ether_aton.3,v 1.4 2025/06/29 00:33:46 dlg Exp $
2.\" 2.\"
3.\" Written by roland@frob.com. Public domain. 3.\" Written by roland@frob.com. Public domain.
4.\" 4.\"
5.Dd $Mdocdate: September 11 2022 $ 5.Dd $Mdocdate: June 29 2025 $
6.Dt ETHER_ATON 3 6.Dt ETHER_ATON 3
7.Os 7.Os
8.Sh NAME 8.Sh NAME
@@ -19,7 +19,7 @@
19.In netinet/in.h 19.In netinet/in.h
20.In netinet/if_ether.h 20.In netinet/if_ether.h
21.Ft char * 21.Ft char *
22.Fn ether_ntoa "struct ether_addr *e" 22.Fn ether_ntoa "const struct ether_addr *e"
23.Ft struct ether_addr * 23.Ft struct ether_addr *
24.Fn ether_aton "const char *s" 24.Fn ether_aton "const char *s"
25.Ft int 25.Ft int
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c
index d62be1ca71..6edad5c5e5 100644
--- a/src/lib/libc/net/ethers.c
+++ b/src/lib/libc/net/ethers.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ethers.c,v 1.27 2019/01/25 00:19:25 millert Exp $ */ 1/* $OpenBSD: ethers.c,v 1.28 2025/06/29 00:33:46 dlg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Todd C. Miller <millert@openbsd.org> 4 * Copyright (c) 1998 Todd C. Miller <millert@openbsd.org>
@@ -42,7 +42,7 @@
42static char * _ether_aton(const char *, struct ether_addr *); 42static char * _ether_aton(const char *, struct ether_addr *);
43 43
44char * 44char *
45ether_ntoa(struct ether_addr *e) 45ether_ntoa(const struct ether_addr *e)
46{ 46{
47 static char a[] = "xx:xx:xx:xx:xx:xx"; 47 static char a[] = "xx:xx:xx:xx:xx:xx";
48 48
diff --git a/src/lib/libc/net/gai_strerror.3 b/src/lib/libc/net/gai_strerror.3
index d271f492c5..93d11aad09 100644
--- a/src/lib/libc/net/gai_strerror.3
+++ b/src/lib/libc/net/gai_strerror.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: gai_strerror.3,v 1.10 2017/05/03 01:58:33 deraadt Exp $ 1.\" $OpenBSD: gai_strerror.3,v 1.11 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $ 2.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 4.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
@@ -16,7 +16,7 @@
16.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17.\" PERFORMANCE OF THIS SOFTWARE. 17.\" PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: May 3 2017 $ 19.Dd $Mdocdate: June 13 2025 $
20.Dt GAI_STRERROR 3 20.Dt GAI_STRERROR 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,7 +26,7 @@
26.In sys/types.h 26.In sys/types.h
27.In sys/socket.h 27.In sys/socket.h
28.In netdb.h 28.In netdb.h
29.Ft "const char *" 29.Ft const char *
30.Fn gai_strerror "int ecode" 30.Fn gai_strerror "int ecode"
31.Sh DESCRIPTION 31.Sh DESCRIPTION
32The 32The
diff --git a/src/lib/libc/net/if_indextoname.3 b/src/lib/libc/net/if_indextoname.3
index 25d2a2722f..9d00d66bd5 100644
--- a/src/lib/libc/net/if_indextoname.3
+++ b/src/lib/libc/net/if_indextoname.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: if_indextoname.3,v 1.16 2015/11/21 07:48:10 jmc Exp $ 1.\" $OpenBSD: if_indextoname.3,v 1.17 2025/06/13 18:34:00 schwarze Exp $
2.\" Copyright (c) 1983, 1991, 1993 2.\" Copyright (c) 1983, 1991, 1993
3.\" The Regents of the University of California. All rights reserved. 3.\" The Regents of the University of California. All rights reserved.
4.\" 4.\"
@@ -28,7 +28,7 @@
28.\" 28.\"
29.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 29.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
30.\" 30.\"
31.Dd $Mdocdate: November 21 2015 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt IF_NAMETOINDEX 3 32.Dt IF_NAMETOINDEX 3
33.Os 33.Os
34.Sh NAME 34.Sh NAME
@@ -41,13 +41,13 @@
41.In sys/types.h 41.In sys/types.h
42.In sys/socket.h 42.In sys/socket.h
43.In net/if.h 43.In net/if.h
44.Ft "unsigned int" 44.Ft unsigned int
45.Fn if_nametoindex "const char *ifname" 45.Fn if_nametoindex "const char *ifname"
46.Ft "char *" 46.Ft char *
47.Fn if_indextoname "unsigned int ifindex" "char *ifname" 47.Fn if_indextoname "unsigned int ifindex" "char *ifname"
48.Ft "struct if_nameindex *" 48.Ft struct if_nameindex *
49.Fn if_nameindex "void" 49.Fn if_nameindex "void"
50.Ft "void" 50.Ft void
51.Fn if_freenameindex "struct if_nameindex *ptr" 51.Fn if_freenameindex "struct if_nameindex *ptr"
52.Sh DESCRIPTION 52.Sh DESCRIPTION
53These functions map interface indexes to interface names (such as 53These functions map interface indexes to interface names (such as
diff --git a/src/lib/libc/net/inet6_opt_init.3 b/src/lib/libc/net/inet6_opt_init.3
index 41ba842166..87244507a9 100644
--- a/src/lib/libc/net/inet6_opt_init.3
+++ b/src/lib/libc/net/inet6_opt_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: inet6_opt_init.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: inet6_opt_init.3,v 1.9 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $ 2.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 WIDE Project. 4.\" Copyright (C) 2004 WIDE Project.
@@ -28,7 +28,7 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.Dd $Mdocdate: March 31 2022 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt INET6_OPT_INIT 3 32.Dt INET6_OPT_INIT 3
33.Os 33.Os
34.\" 34.\"
@@ -44,19 +44,19 @@
44.\" 44.\"
45.Sh SYNOPSIS 45.Sh SYNOPSIS
46.In netinet/in.h 46.In netinet/in.h
47.Ft "int" 47.Ft int
48.Fn inet6_opt_init "void *extbuf" "socklen_t extlen" 48.Fn inet6_opt_init "void *extbuf" "socklen_t extlen"
49.Ft "int" 49.Ft int
50.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp" 50.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp"
51.Ft "int" 51.Ft int
52.Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset" 52.Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset"
53.Ft "int" 53.Ft int
54.Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen" 54.Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen"
55.Ft "int" 55.Ft int
56.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp" 56.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp"
57.Ft "int" 57.Ft int
58.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp" 58.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp"
59.Ft "int" 59.Ft int
60.Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen" 60.Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen"
61.\" 61.\"
62.Sh DESCRIPTION 62.Sh DESCRIPTION
diff --git a/src/lib/libc/net/inet6_rth_space.3 b/src/lib/libc/net/inet6_rth_space.3
index c40b45057e..7304266fe1 100644
--- a/src/lib/libc/net/inet6_rth_space.3
+++ b/src/lib/libc/net/inet6_rth_space.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: inet6_rth_space.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: inet6_rth_space.3,v 1.9 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $ 2.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 WIDE Project. 4.\" Copyright (C) 2004 WIDE Project.
@@ -28,7 +28,7 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.Dd $Mdocdate: March 31 2022 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt INET6_RTH_SPACE 3 32.Dt INET6_RTH_SPACE 3
33.Os 33.Os
34.\" 34.\"
@@ -45,7 +45,7 @@
45.In netinet/in.h 45.In netinet/in.h
46.Ft socklen_t 46.Ft socklen_t
47.Fn inet6_rth_space "int" "int" 47.Fn inet6_rth_space "int" "int"
48.Ft "void *" 48.Ft void *
49.Fn inet6_rth_init "void *" "socklen_t" "int" "int" 49.Fn inet6_rth_init "void *" "socklen_t" "int" "int"
50.Ft int 50.Ft int
51.Fn inet6_rth_add "void *" "const struct in6_addr *" 51.Fn inet6_rth_add "void *" "const struct in6_addr *"
@@ -53,7 +53,7 @@
53.Fn inet6_rth_reverse "const void *" "void *" 53.Fn inet6_rth_reverse "const void *" "void *"
54.Ft int 54.Ft int
55.Fn inet6_rth_segments "const void *" 55.Fn inet6_rth_segments "const void *"
56.Ft "struct in6_addr *" 56.Ft struct in6_addr *
57.Fn inet6_rth_getaddr "const void *" "int" 57.Fn inet6_rth_getaddr "const void *" "int"
58.\" 58.\"
59.Sh DESCRIPTION 59.Sh DESCRIPTION
diff --git a/src/lib/libc/stdlib/exit.3 b/src/lib/libc/stdlib/exit.3
index 22acade86c..ccb416ee82 100644
--- a/src/lib/libc/stdlib/exit.3
+++ b/src/lib/libc/stdlib/exit.3
@@ -29,9 +29,9 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: exit.3,v 1.18 2024/08/30 03:44:48 guenther Exp $ 32.\" $OpenBSD: exit.3,v 1.19 2025/06/03 14:15:53 yasuoka Exp $
33.\" 33.\"
34.Dd $Mdocdate: August 30 2024 $ 34.Dd $Mdocdate: June 3 2025 $
35.Dt EXIT 3 35.Dt EXIT 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
@@ -54,9 +54,7 @@ Call the functions registered with the
54.Xr atexit 3 54.Xr atexit 3
55function, in the reverse order of their registration. 55function, in the reverse order of their registration.
56.It 56.It
57Flush all open output streams. 57Flush and close all open streams.
58.It
59Close all open streams.
60.It 58.It
61Unlink all files created with the 59Unlink all files created with the
62.Xr tmpfile 3 60.Xr tmpfile 3
@@ -79,6 +77,7 @@ function never returns.
79.Sh SEE ALSO 77.Sh SEE ALSO
80.Xr _exit 2 , 78.Xr _exit 2 ,
81.Xr atexit 3 , 79.Xr atexit 3 ,
80.Xr fflush 3 ,
82.Xr intro 3 , 81.Xr intro 3 ,
83.Xr sysexits 3 , 82.Xr sysexits 3 ,
84.Xr tmpfile 3 83.Xr tmpfile 3
@@ -86,7 +85,7 @@ function never returns.
86The 85The
87.Fn exit 86.Fn exit
88function conforms to 87function conforms to
89.St -isoC-99 . 88.St -p1003.1-2024 .
90.Sh HISTORY 89.Sh HISTORY
91An 90An
92.Fn exit 91.Fn exit
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index bea5575bf8..ee13b01bd4 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -30,9 +30,9 @@
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" $OpenBSD: malloc.3,v 1.142 2024/08/03 20:09:24 guenther Exp $ 33.\" $OpenBSD: malloc.3,v 1.147 2025/06/04 00:38:01 yasuoka Exp $
34.\" 34.\"
35.Dd $Mdocdate: August 3 2024 $ 35.Dd $Mdocdate: June 4 2025 $
36.Dt MALLOC 3 36.Dt MALLOC 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -69,7 +69,8 @@
69.Fn malloc_conceal "size_t size" 69.Fn malloc_conceal "size_t size"
70.Ft void * 70.Ft void *
71.Fn calloc_conceal "size_t nmemb" "size_t size" 71.Fn calloc_conceal "size_t nmemb" "size_t size"
72.Vt char *malloc_options ; 72.Vt const char * const
73.Va malloc_options ;
73.Sh DESCRIPTION 74.Sh DESCRIPTION
74The standard functions 75The standard functions
75.Fn malloc , 76.Fn malloc ,
@@ -268,7 +269,15 @@ next checks the environment for a variable called
268and finally looks at the global variable 269and finally looks at the global variable
269.Va malloc_options 270.Va malloc_options
270in the program. 271in the program.
271Each is scanned for the flags documented below. 272Since
273.Fn malloc
274might already get called before the beginning of
275.Fn main ,
276either initialize
277.Va malloc_options
278to a string literal at file scope or do not declare it at all.
279.Pp
280Each of the three strings is scanned for the flags documented below.
272Unless otherwise noted uppercase means on, lowercase means off. 281Unless otherwise noted uppercase means on, lowercase means off.
273During initialization, flags occurring later modify the behaviour 282During initialization, flags occurring later modify the behaviour
274that was requested by flags processed earlier. 283that was requested by flags processed earlier.
@@ -363,18 +372,9 @@ Use with
363to get a verbose dump of malloc's internal state. 372to get a verbose dump of malloc's internal state.
364.It Cm X 373.It Cm X
365.Dq xmalloc . 374.Dq xmalloc .
366Rather than return failure, 375Rather than return failure to handle out-of-memory conditions gracefully,
367.Xr abort 3 376.Xr abort 3
368the program with a diagnostic message on stderr. 377the program with a diagnostic message on stderr.
369It is the intention that this option be set at compile time by
370including in the source:
371.Bd -literal -offset indent
372extern char *malloc_options;
373malloc_options = "X";
374.Ed
375.Pp
376Note that this will cause code that is supposed to handle
377out-of-memory conditions gracefully to abort instead.
378.It Cm < 378.It Cm <
379.Dq Halve the cache size . 379.Dq Halve the cache size .
380Decrease the size of the free page cache by a factor of two. 380Decrease the size of the free page cache by a factor of two.
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index cad8e5d6a1..c6261d87c5 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.299 2025/06/12 16:07:09 deraadt 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
267char *malloc_options; /* compile-time options */ 266/* compile-time options */
267const char *const malloc_options __attribute__((weak));
268 268
269static __dead void wrterror(struct dir_info *d, char *msg, ...) 269static __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)
501static void 501static void
502omalloc_init(void) 502omalloc_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;
diff --git a/src/lib/libc/stdlib/mkstemp.c b/src/lib/libc/stdlib/mkstemp.c
index 75a9d27d1a..760575005f 100644
--- a/src/lib/libc/stdlib/mkstemp.c
+++ b/src/lib/libc/stdlib/mkstemp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mkstemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */ 1/* $OpenBSD: mkstemp.c,v 1.2 2025/08/04 04:59:31 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Todd C. Miller 3 * Copyright (c) 2024 Todd C. Miller
4 * 4 *
@@ -20,7 +20,8 @@
20#include <fcntl.h> 20#include <fcntl.h>
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#define MKOSTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC) 23#define MKOSTEMP_FLAGS \
24 (O_APPEND | O_CLOEXEC | O_CLOFORK | O_DSYNC | O_RSYNC | O_SYNC)
24 25
25static int 26static int
26mkstemp_cb(const char *path, int flags) 27mkstemp_cb(const char *path, int flags)
diff --git a/src/lib/libc/stdlib/mktemp.3 b/src/lib/libc/stdlib/mktemp.3
index 83b7c9eb30..a967358164 100644
--- a/src/lib/libc/stdlib/mktemp.3
+++ b/src/lib/libc/stdlib/mktemp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: mktemp.3,v 1.2 2024/03/01 21:30:40 millert Exp $ 1.\" $OpenBSD: mktemp.3,v 1.4 2025/08/04 14:11:37 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 1989, 1991, 1993 3.\" Copyright (c) 1989, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -27,17 +27,17 @@
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.Dd $Mdocdate: March 1 2024 $ 30.Dd $Mdocdate: August 4 2025 $
31.Dt MKTEMP 3 31.Dt MKTEMP 3
32.Os 32.Os
33.Sh NAME 33.Sh NAME
34.Nm mktemp , 34.Nm mktemp ,
35.Nm mkstemp , 35.Nm mkstemp ,
36.Nm mkostemp ,
37.Nm mkstemps , 36.Nm mkstemps ,
38.Nm mkostemps ,
39.Nm mkdtemp , 37.Nm mkdtemp ,
40.Nm mkdtemps 38.Nm mkdtemps ,
39.Nm mkostemp ,
40.Nm mkostemps
41.Nd make temporary file name (unique) 41.Nd make temporary file name (unique)
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.In stdlib.h 43.In stdlib.h
@@ -119,6 +119,8 @@ system call:
119Append on each write. 119Append on each write.
120.It Dv O_CLOEXEC 120.It Dv O_CLOEXEC
121Set the close-on-exec flag on the new file descriptor. 121Set the close-on-exec flag on the new file descriptor.
122.It Dv O_CLOFORK
123Set the close-on-fork flag on the new file descriptor.
122.It Dv O_SYNC 124.It Dv O_SYNC
123Perform synchronous I/O operations. 125Perform synchronous I/O operations.
124.El 126.El
@@ -163,8 +165,8 @@ functions return a pointer to the template on success and
163on failure. 165on failure.
164The 166The
165.Fn mkstemp , 167.Fn mkstemp ,
166.Fn mkostemp ,
167.Fn mkstemps , 168.Fn mkstemps ,
169.Fn mkostemp ,
168and 170and
169.Fn mkostemps 171.Fn mkostemps
170functions return \-1 if no suitable file could be created. 172functions return \-1 if no suitable file could be created.
@@ -253,9 +255,9 @@ of
253The 255The
254.Fn mktemp , 256.Fn mktemp ,
255.Fn mkstemp , 257.Fn mkstemp ,
256.Fn mkostemp , 258.Fn mkdtemp ,
257and 259and
258.Fn mkdtemp 260.Fn mkostemp
259functions may set 261functions may set
260.Va errno 262.Va errno
261to one of the following values: 263to one of the following values:
@@ -318,8 +320,8 @@ function.
318.Pp 320.Pp
319The 321The
320.Fn mkstemp , 322.Fn mkstemp ,
321.Fn mkostemp ,
322.Fn mkstemps , 323.Fn mkstemps ,
324.Fn mkostemp ,
323and 325and
324.Fn mkostemps 326.Fn mkostemps
325functions may also set 327functions may also set
@@ -345,18 +347,16 @@ function.
345.Xr tmpnam 3 347.Xr tmpnam 3
346.Sh STANDARDS 348.Sh STANDARDS
347The 349The
348.Fn mkdtemp 350.Fn mkstemp ,
351.Fn mkdtemp ,
349and 352and
350.Fn mkstemp 353.Fn mkostemp
351functions conform to the 354functions conform to the
352.St -p1003.1-2008 355.St -p1003.1-2024
353specification. 356specification.
354The ability to specify more than six 357The ability to specify more than six
355.Em X Ns s 358.Em X Ns s
356is an extension to that standard. 359is an extension to that standard.
357The
358.Fn mkostemp
359function is expected to conform to a future revision of that standard.
360.Pp 360.Pp
361The 361The
362.Fn mktemp 362.Fn mktemp
@@ -368,9 +368,9 @@ it is no longer a part of the standard.
368.Pp 368.Pp
369The 369The
370.Fn mkstemps , 370.Fn mkstemps ,
371.Fn mkostemps , 371.Fn mkdtemps ,
372and 372and
373.Fn mkdtemps 373.Fn mkostemps
374functions are non-standard and should not be used if portability is required. 374functions are non-standard and should not be used if portability is required.
375.Sh HISTORY 375.Sh HISTORY
376A 376A
@@ -378,14 +378,14 @@ A
378function appeared in 378function appeared in
379.At v7 . 379.At v7 .
380The 380The
381.Fn mkdtemp
382function appeared in
383.Ox 2.2 .
384The
385.Fn mkstemp 381.Fn mkstemp
386function appeared in 382function appeared in
387.Bx 4.3 . 383.Bx 4.3 .
388The 384The
385.Fn mkdtemp
386function appeared in
387.Ox 2.2 .
388The
389.Fn mkstemps 389.Fn mkstemps
390function appeared in 390function appeared in
391.Ox 2.3 . 391.Ox 2.3 .
diff --git a/src/lib/libc/stdlib/ptsname.3 b/src/lib/libc/stdlib/ptsname.3
index 98705528f5..eea36a5a02 100644
--- a/src/lib/libc/stdlib/ptsname.3
+++ b/src/lib/libc/stdlib/ptsname.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ptsname.3,v 1.2 2012/12/04 18:42:16 millert Exp $ 1.\" $OpenBSD: ptsname.3,v 1.3 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2002 The FreeBSD Project, Inc. 3.\" Copyright (c) 2002 The FreeBSD Project, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
@@ -32,7 +32,7 @@
32.\" 32.\"
33.\" $FreeBSD: head/lib/libc/stdlib/ptsname.3 240412 2012-09-12 17:54:09Z emaste $ 33.\" $FreeBSD: head/lib/libc/stdlib/ptsname.3 240412 2012-09-12 17:54:09Z emaste $
34.\" 34.\"
35.Dd $Mdocdate: December 4 2012 $ 35.Dd $Mdocdate: June 13 2025 $
36.Dt PTSNAME 3 36.Dt PTSNAME 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -44,7 +44,7 @@
44.In stdlib.h 44.In stdlib.h
45.Ft int 45.Ft int
46.Fn grantpt "int fildes" 46.Fn grantpt "int fildes"
47.Ft "char *" 47.Ft char *
48.Fn ptsname "int fildes" 48.Fn ptsname "int fildes"
49.Ft int 49.Ft int
50.Fn unlockpt "int fildes" 50.Fn unlockpt "int fildes"
diff --git a/src/lib/libc/stdlib/rand48.3 b/src/lib/libc/stdlib/rand48.3
index fa7a7179bc..02e1999db9 100644
--- a/src/lib/libc/stdlib/rand48.3
+++ b/src/lib/libc/stdlib/rand48.3
@@ -9,9 +9,9 @@
9.\" of any kind. I shall in no event be liable for anything that happens 9.\" of any kind. I shall in no event be liable for anything that happens
10.\" to anyone/anything when using this software. 10.\" to anyone/anything when using this software.
11.\" 11.\"
12.\" $OpenBSD: rand48.3,v 1.21 2019/12/20 19:16:40 tb Exp $ 12.\" $OpenBSD: rand48.3,v 1.22 2025/06/13 18:34:00 schwarze Exp $
13.\" 13.\"
14.Dd $Mdocdate: December 20 2019 $ 14.Dd $Mdocdate: June 13 2025 $
15.Dt DRAND48 3 15.Dt DRAND48 3
16.Os 16.Os
17.Sh NAME 17.Sh NAME
@@ -46,9 +46,9 @@
46.Fn srand48 "long seed" 46.Fn srand48 "long seed"
47.Ft void 47.Ft void
48.Fn srand48_deterministic "long seed" 48.Fn srand48_deterministic "long seed"
49.Ft "unsigned short *" 49.Ft unsigned short *
50.Fn seed48 "unsigned short xseed[3]" 50.Fn seed48 "unsigned short xseed[3]"
51.Ft "unsigned short *" 51.Ft unsigned short *
52.Fn seed48_deterministic "unsigned short xseed[3]" 52.Fn seed48_deterministic "unsigned short xseed[3]"
53.Ft void 53.Ft void
54.Fn lcong48 "unsigned short p[7]" 54.Fn lcong48 "unsigned short p[7]"
diff --git a/src/lib/libc/stdlib/realpath.3 b/src/lib/libc/stdlib/realpath.3
index 1dec10fef4..1f932e3bb5 100644
--- a/src/lib/libc/stdlib/realpath.3
+++ b/src/lib/libc/stdlib/realpath.3
@@ -28,9 +28,9 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.\" $OpenBSD: realpath.3,v 1.26 2021/10/13 15:04:53 kn Exp $ 31.\" $OpenBSD: realpath.3,v 1.27 2025/06/13 18:34:00 schwarze Exp $
32.\" 32.\"
33.Dd $Mdocdate: October 13 2021 $ 33.Dd $Mdocdate: June 13 2025 $
34.Dt REALPATH 3 34.Dt REALPATH 3
35.Os 35.Os
36.Sh NAME 36.Sh NAME
@@ -39,7 +39,7 @@
39.Sh SYNOPSIS 39.Sh SYNOPSIS
40.In limits.h 40.In limits.h
41.In stdlib.h 41.In stdlib.h
42.Ft "char *" 42.Ft char *
43.Fn realpath "const char *pathname" "char *resolved" 43.Fn realpath "const char *pathname" "char *resolved"
44.Sh DESCRIPTION 44.Sh DESCRIPTION
45The 45The
diff --git a/src/lib/libc/string/memmem.3 b/src/lib/libc/string/memmem.3
index de62d738de..eeb621f8f6 100644
--- a/src/lib/libc/string/memmem.3
+++ b/src/lib/libc/string/memmem.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: memmem.3,v 1.4 2024/08/03 20:13:23 guenther Exp $ 1.\" $OpenBSD: memmem.3,v 1.5 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com> 3.\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com>
4.\" 4.\"
@@ -26,7 +26,7 @@
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE. 27.\" SUCH DAMAGE.
28.\" 28.\"
29.Dd $Mdocdate: August 3 2024 $ 29.Dd $Mdocdate: June 13 2025 $
30.Dt MEMMEM 3 30.Dt MEMMEM 3
31.Os 31.Os
32.Sh NAME 32.Sh NAME
@@ -34,7 +34,7 @@
34.Nd locate a byte substring in a byte string 34.Nd locate a byte substring in a byte string
35.Sh SYNOPSIS 35.Sh SYNOPSIS
36.In string.h 36.In string.h
37.Ft "void *" 37.Ft void *
38.Fo memmem 38.Fo memmem
39.Fa "const void *big" "size_t big_len" 39.Fa "const void *big" "size_t big_len"
40.Fa "const void *little" "size_t little_len" 40.Fa "const void *little" "size_t little_len"