Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib add {at_, }quick_exit(3) from FreeBSD
details: https://anonhg.NetBSD.org/src/rev/cf5b8c7bcd1d
branches: trunk
changeset: 786332:cf5b8c7bcd1d
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 26 18:29:55 2013 +0000
description:
add {at_,}quick_exit(3) from FreeBSD
diffstat:
lib/libc/stdlib/Makefile.inc | 7 +-
lib/libc/stdlib/at_quick_exit.3 | 63 +++++++++++++++++++++++++++
lib/libc/stdlib/atexit.3 | 4 +-
lib/libc/stdlib/atexit.c | 24 +++++-----
lib/libc/stdlib/exit.3 | 4 +-
lib/libc/stdlib/quick_exit.3 | 59 ++++++++++++++++++++++++++
lib/libc/stdlib/quick_exit.c | 93 +++++++++++++++++++++++++++++++++++++++++
7 files changed, 237 insertions(+), 17 deletions(-)
diffs (truncated from 405 to 300 lines):
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/Makefile.inc
--- a/lib/libc/stdlib/Makefile.inc Fri Apr 26 18:29:06 2013 +0000
+++ b/lib/libc/stdlib/Makefile.inc Fri Apr 26 18:29:55 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.78 2011/09/14 23:33:51 christos Exp $
+# $NetBSD: Makefile.inc,v 1.79 2013/04/26 18:29:55 christos Exp $
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
# stdlib sources
@@ -11,7 +11,7 @@
hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \
nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \
- radixsort.c rand.c rand_r.c random.c remque.c \
+ quick_exit.c radixsort.c rand.c rand_r.c random.c remque.c \
seed48.c setenv.c srand48.c strsuftoll.c \
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
@@ -38,6 +38,7 @@
.include "${ARCHDIR}/stdlib/Makefile.inc"
MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
+ at_quick_exit.3 \
bsearch.3 \
div.3 \
exit.3 \
@@ -48,7 +49,7 @@
lsearch.3 \
malloc.3 memory.3 mi_vector_hash.3 \
posix_memalign.3 posix_openpt.3 ptsname.3 \
- qabs.3 qdiv.3 qsort.3 \
+ qabs.3 qdiv.3 quick_exit.3 qsort.3 \
radixsort.3 rand48.3 rand.3 random.3 \
strfmon.3 strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 \
tsearch.3 \
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/at_quick_exit.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/at_quick_exit.3 Fri Apr 26 18:29:55 2013 +0000
@@ -0,0 +1,63 @@
+.\" $NetBSD: at_quick_exit.3,v 1.1 2013/04/26 18:29:55 christos Exp $
+.\" Copyright (c) 2011 David Chisnall
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/lib/libc/stdlib/at_quick_exit.3,v 1.5 2012/11/17 01:49:41 svnexp Exp $
+.\"
+.Dd December 7, 2011
+.Dt AT_QUICK_EXIT 3
+.Os
+.Sh NAME
+.Nm at_quick_exit
+.Nd registers a cleanup function to run on quick exit
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.Ft int
+.Fn at_quick_exit "void (*func)(void)"
+.Sh DESCRIPTION
+The
+.Fn at_quick_exit
+function registers a cleanup function to be called when the program exits as a
+result of calling
+.Xr quick_exit 3 .
+The cleanup functions are called in the reverse order and will not be called if
+the program exits by calling
+.Xr exit 3 ,
+.Xr _Exit 3 ,
+or
+.Xr abort 3 .
+.Sh RETURN VALUES
+The
+.Fn at_quick_exit
+function returns the value 0 if successful and a non-zero value on failure.
+.Sh SEE ALSO
+.Xr exit 3 ,
+.Xr quick_exit 3
+.Sh STANDARDS
+The
+.Fn at_quick_exit
+function conforms to
+.St -isoC-2011 .
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/atexit.3
--- a/lib/libc/stdlib/atexit.3 Fri Apr 26 18:29:06 2013 +0000
+++ b/lib/libc/stdlib/atexit.3 Fri Apr 26 18:29:55 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: atexit.3,v 1.9 2003/08/07 16:43:38 agc Exp $
+.\" $NetBSD: atexit.3,v 1.10 2013/04/26 18:29:55 christos Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -68,7 +68,9 @@
The existing list of functions is unmodified.
.El
.Sh SEE ALSO
+.Xr at_quick_exit 3
.Xr exit 3
+.Xr quick_exit 3
.Sh STANDARDS
The
.Fn atexit
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/atexit.c
--- a/lib/libc/stdlib/atexit.c Fri Apr 26 18:29:06 2013 +0000
+++ b/lib/libc/stdlib/atexit.c Fri Apr 26 18:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $ */
+/* $NetBSD: atexit.c,v 1.25 2013/04/26 18:29:55 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $");
+__RCSID("$NetBSD: atexit.c,v 1.25 2013/04/26 18:29:55 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
@@ -74,7 +74,7 @@
#ifdef _REENTRANT
/* ..and a mutex to protect it all. */
-static mutex_t atexit_mutex;
+mutex_t __atexit_mutex;
#endif /* _REENTRANT */
void __libc_atexit_init(void) __attribute__ ((visibility("hidden")));
@@ -85,7 +85,7 @@
* if possible. cxa_atexit handlers are never allocated from the static
* pool.
*
- * atexit_mutex must be held.
+ * __atexit_mutex must be held.
*/
static struct atexit_handler *
atexit_handler_alloc(void *dso)
@@ -105,7 +105,7 @@
/*
* Either no static slot was free, or this is a cxa_atexit
- * handler. Allocate a new one. We keep the atexit_mutex
+ * handler. Allocate a new one. We keep the __atexit_mutex
* held to prevent handlers from being run while we (potentially)
* block in malloc().
*/
@@ -114,7 +114,7 @@
}
/*
- * Initialize atexit_mutex with the PTHREAD_MUTEX_RECURSIVE attribute.
+ * Initialize __atexit_mutex with the PTHREAD_MUTEX_RECURSIVE attribute.
* Note that __cxa_finalize may generate calls to __cxa_atexit.
*/
void
@@ -123,7 +123,7 @@
mutexattr_t atexit_mutex_attr;
mutexattr_init(&atexit_mutex_attr);
mutexattr_settype(&atexit_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
- mutex_init(&atexit_mutex, &atexit_mutex_attr);
+ mutex_init(&__atexit_mutex, &atexit_mutex_attr);
}
/*
@@ -140,11 +140,11 @@
_DIAGASSERT(func != NULL);
- mutex_lock(&atexit_mutex);
+ mutex_lock(&__atexit_mutex);
ah = atexit_handler_alloc(dso);
if (ah == NULL) {
- mutex_unlock(&atexit_mutex);
+ mutex_unlock(&__atexit_mutex);
return (-1);
}
@@ -155,7 +155,7 @@
ah->ah_next = atexit_handler_stack;
atexit_handler_stack = ah;
- mutex_unlock(&atexit_mutex);
+ mutex_unlock(&__atexit_mutex);
return (0);
}
@@ -175,7 +175,7 @@
void (*cxa_func)(void *);
void (*atexit_func)(void);
- mutex_lock(&atexit_mutex);
+ mutex_lock(&__atexit_mutex);
call_depth++;
/*
@@ -220,7 +220,7 @@
prevp = &ah->ah_next;
}
call_depth--;
- mutex_unlock(&atexit_mutex);
+ mutex_unlock(&__atexit_mutex);
if (call_depth > 0)
return;
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/exit.3
--- a/lib/libc/stdlib/exit.3 Fri Apr 26 18:29:06 2013 +0000
+++ b/lib/libc/stdlib/exit.3 Fri Apr 26 18:29:55 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: exit.3,v 1.15 2012/01/02 15:55:29 dholland Exp $
+.\" $NetBSD: exit.3,v 1.16 2013/04/26 18:29:55 christos Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -98,8 +98,10 @@
never returns.
.Sh SEE ALSO
.Xr _exit 2 ,
+.Xr at_quick_exit 3 ,
.Xr atexit 3 ,
.Xr intro 3 ,
+.Xr quick_exit 3 ,
.Xr tmpfile 3
.Sh STANDARDS
The
diff -r 917a89772d51 -r cf5b8c7bcd1d lib/libc/stdlib/quick_exit.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/quick_exit.3 Fri Apr 26 18:29:55 2013 +0000
@@ -0,0 +1,59 @@
+.\" $NetBSD: quick_exit.3,v 1.1 2013/04/26 18:29:55 christos Exp $
+.\" Copyright (c) 2011 David Chisnall
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/lib/libc/stdlib/quick_exit.3,v 1.4 2012/11/17 01:49:41 svnexp Exp $
+.\"
+.Dd December 7, 2011
+.Dt QUICK_EXIT 3
+.Os
+.Sh NAME
+.Nm quick_exit
+.Nd exits a program quickly, running minimal cleanup
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.Ft _Noreturn void
+.Fn quick_exit "void"
+.Sh DESCRIPTION
+The
+.Fn quick_exit
+function exits the program quickly calling any cleanup functions registered
+with
+.Xr at_quick_exit 3
+but not any C++ destructors or cleanup code registered with
+.Xr atexit 3 .
+.Sh RETURN VALUES
+The
+.Fn quick_exit
+function does not return.
Home |
Main Index |
Thread Index |
Old Index