diff options
author | raf <none@none> | 2007-03-20 19:30:49 -0700 |
---|---|---|
committer | raf <none@none> | 2007-03-20 19:30:49 -0700 |
commit | 1d53067866b073ea6710000ba4dd448441361988 (patch) | |
tree | fbac45aa59a72e34fdd5e5fccc91c5bb1d0f0df5 /usr/src/lib/libmapmalloc/common | |
parent | 84f43ade33b1b00348bdcdfaca9f71f6a0c786eb (diff) | |
download | illumos-joyent-1d53067866b073ea6710000ba4dd448441361988.tar.gz |
6533630 all malloc interposition libraries need to be made fork-safe
--HG--
rename : usr/src/lib/libmapmalloc/common/malloc_debug.c => deleted_files/usr/src/lib/libmapmalloc/common/malloc_debug.c
Diffstat (limited to 'usr/src/lib/libmapmalloc/common')
-rw-r--r-- | usr/src/lib/libmapmalloc/common/calloc.c | 10 | ||||
-rw-r--r-- | usr/src/lib/libmapmalloc/common/malloc_debug.c | 63 | ||||
-rw-r--r-- | usr/src/lib/libmapmalloc/common/textmem.c | 39 | ||||
-rw-r--r-- | usr/src/lib/libmapmalloc/common/valloc.c | 11 |
4 files changed, 39 insertions, 84 deletions
diff --git a/usr/src/lib/libmapmalloc/common/calloc.c b/usr/src/lib/libmapmalloc/common/calloc.c index 762d03d2b8..d14cac713c 100644 --- a/usr/src/lib/libmapmalloc/common/calloc.c +++ b/usr/src/lib/libmapmalloc/common/calloc.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,14 +18,15 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <sys/types.h> +#include <c_synonyms.h> #include <stdlib.h> #include <string.h> /* diff --git a/usr/src/lib/libmapmalloc/common/malloc_debug.c b/usr/src/lib/libmapmalloc/common/malloc_debug.c deleted file mode 100644 index c8b7e602ef..0000000000 --- a/usr/src/lib/libmapmalloc/common/malloc_debug.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1991, Sun Microsytems, Inc. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <sys/types.h> - - -/* - * malloc_debug(level) - empty routine - */ - -/*ARGSUSED*/ -int -malloc_debug(int level) -{ - return (1); -} - - -/* - * malloc_verify() - empty routine - */ - -int -malloc_verify(void) -{ - return (1); -} - - -/* - * mallocmap() - empty routine - */ - -void -mallocmap(void) -{ - ; -} diff --git a/usr/src/lib/libmapmalloc/common/textmem.c b/usr/src/lib/libmapmalloc/common/textmem.c index eed2ca0478..6a3f04cb1e 100644 --- a/usr/src/lib/libmapmalloc/common/textmem.c +++ b/usr/src/lib/libmapmalloc/common/textmem.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,15 +18,15 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright (c) 1991-1997,2000-2001 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + #pragma ident "%Z%%M% %I% %E% SMI" /* SVR4/MNLS 1.1.2.1 */ /*LINTLIBRARY*/ @@ -49,6 +48,7 @@ * New memory chunks are allocated on a first-fit basis. * Freed blocks are joined in larger blocks. Free pages are unmapped. */ +#include <c_synonyms.h> #include <stdlib.h> #include <sys/types.h> #include <sys/mman.h> @@ -56,13 +56,11 @@ #include <errno.h> #include <unistd.h> #include <thread.h> +#include <pthread.h> #include <synch.h> #include <string.h> - -#ifdef _REENTRANT static mutex_t lock = DEFAULTMUTEX; -#endif /* _REENTRANT */ struct block { size_t size; /* Space available for user */ @@ -280,3 +278,22 @@ defrag(struct page *page) (void) munmap((caddr_t)page, page->size); } } + +static void +malloc_prepare() +{ + (void) mutex_lock(&lock); +} + +static void +malloc_release() +{ + (void) mutex_unlock(&lock); +} + +#pragma init(malloc_init) +static void +malloc_init(void) +{ + (void) pthread_atfork(malloc_prepare, malloc_release, malloc_release); +} diff --git a/usr/src/lib/libmapmalloc/common/valloc.c b/usr/src/lib/libmapmalloc/common/valloc.c index 2b4a443738..5858564a3a 100644 --- a/usr/src/lib/libmapmalloc/common/valloc.c +++ b/usr/src/lib/libmapmalloc/common/valloc.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,14 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1991-1997, Sun Microsytems, Inc. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" /*LINTLIBRARY*/ -#include <sys/types.h> +#include <c_synonyms.h> #include <stdlib.h> #include <errno.h> |