CVS commit: [netbsd-5] src/lib/libc/stdlib

2010-11-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Nov 22 00:20:27 UTC 2010

Modified Files:
src/lib/libc/stdlib [netbsd-5]: getenv.c

Log Message:
Pull up following revision(s) (requested by tron in ticket #1474):
lib/libc/stdlib/getenv.c: revision 1.33 via patch
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
  results e.g. for  getenv(A=3DB)  if an environment variable A
  with value B=3DC exists.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.26.1 src/lib/libc/stdlib/getenv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/getenv.c
diff -u src/lib/libc/stdlib/getenv.c:1.18 src/lib/libc/stdlib/getenv.c:1.18.26.1
--- src/lib/libc/stdlib/getenv.c:1.18	Sun Sep 25 20:08:01 2005
+++ src/lib/libc/stdlib/getenv.c	Mon Nov 22 00:20:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: getenv.c,v 1.18 2005/09/25 20:08:01 christos Exp $	*/
+/*	$NetBSD: getenv.c,v 1.18.26.1 2010/11/22 00:20:27 riz Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)getenv.c	8.1 (Berkeley) 6/4/93;
 #else
-__RCSID($NetBSD: getenv.c,v 1.18 2005/09/25 20:08:01 christos Exp $);
+__RCSID($NetBSD: getenv.c,v 1.18.26.1 2010/11/22 00:20:27 riz Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -67,6 +67,8 @@
 	char *result;
 
 	_DIAGASSERT(name != NULL);
+	if (strchr(name, '=') != NULL)
+		return NULL;
 
 	rwlock_rdlock(__environ_lock);
 	result = __findenv(name, offset);
@@ -83,6 +85,11 @@
 
 	_DIAGASSERT(name != NULL);
 
+	if (strchr(name, '=') != NULL) {
+		errno = ENOENT;
+		return -1;
+	}
+
 	rwlock_rdlock(__environ_lock);
 	result = __findenv(name, offset);
 	if (result == NULL) {



CVS commit: [netbsd-5] src/lib/libc/stdlib

2010-09-11 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Sep 12 04:52:45 UTC 2010

Modified Files:
src/lib/libc/stdlib [netbsd-5]: exit.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1451):
lib/libc/stdlib/exit.c: revision 1.13
Only do the __libc_init hack in libc, i.e. remove it from ld.elf_so.
This fixes hppa ld.elf_so by reducing the number of PLABELs required to
the number before the hack was applied.


To generate a diff of this commit:
cvs rdiff -u -r1.11.12.1 -r1.11.12.2 src/lib/libc/stdlib/exit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/exit.c
diff -u src/lib/libc/stdlib/exit.c:1.11.12.1 src/lib/libc/stdlib/exit.c:1.11.12.2
--- src/lib/libc/stdlib/exit.c:1.11.12.1	Fri Jul 16 18:34:08 2010
+++ src/lib/libc/stdlib/exit.c	Sun Sep 12 04:52:45 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: exit.c,v 1.11.12.1 2010/07/16 18:34:08 riz Exp $	*/
+/*	$NetBSD: exit.c,v 1.11.12.2 2010/09/12 04:52:45 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)exit.c	8.1 (Berkeley) 6/4/93;
 #else
-__RCSID($NetBSD: exit.c,v 1.11.12.1 2010/07/16 18:34:08 riz Exp $);
+__RCSID($NetBSD: exit.c,v 1.11.12.2 2010/09/12 04:52:45 snj Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -45,10 +45,12 @@
 #include atexit.h
 #endif
 
+#ifdef _LIBC
 extern void __libc_init(void);
 #ifndef __lint
 static void (*force_ref)(void) __used = __libc_init;
 #endif
+#endif
 
 void (*__cleanup) __P((void));
 



CVS commit: [netbsd-5] src/lib/libc/stdlib

2010-03-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Mar 13 00:53:33 UTC 2010

Modified Files:
src/lib/libc/stdlib [netbsd-5]: jemalloc.c

Log Message:
Pull up following revision(s) (requested by enami in ticket #1327):
lib/libc/stdlib/jemalloc.c: revision 1.21
Fix race condition on reallocation of huge category.
We need to remove the old region before mremap() since if it relesae the
old region, other thread may map it for the same huge category allocation
and insert it to the tree before we acquire a lock after mremap().
Fixes PR/42876.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/lib/libc/stdlib/jemalloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/jemalloc.c
diff -u src/lib/libc/stdlib/jemalloc.c:1.19 src/lib/libc/stdlib/jemalloc.c:1.19.4.1
--- src/lib/libc/stdlib/jemalloc.c:1.19	Mon Jun 23 10:46:25 2008
+++ src/lib/libc/stdlib/jemalloc.c	Sat Mar 13 00:53:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: jemalloc.c,v 1.19 2008/06/23 10:46:25 ad Exp $	*/
+/*	$NetBSD: jemalloc.c,v 1.19.4.1 2010/03/13 00:53:32 riz Exp $	*/
 
 /*-
  * Copyright (C) 2006,2007 Jason Evans jas...@freebsd.org.
@@ -118,7 +118,7 @@
 
 #include sys/cdefs.h
 /* __FBSDID($FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $); */ 
-__RCSID($NetBSD: jemalloc.c,v 1.19 2008/06/23 10:46:25 ad Exp $);
+__RCSID($NetBSD: jemalloc.c,v 1.19.4.1 2010/03/13 00:53:32 riz Exp $);
 
 #ifdef __FreeBSD__
 #include libc_private.h
@@ -2855,25 +2855,38 @@
 			/* size_t wrap-around */
 			return (NULL);
 		}
+
+		/*
+		 * Remove the old region from the tree now.  If mremap()
+		 * returns the region to the system, other thread may
+		 * map it for same huge allocation and insert it to the
+		 * tree before we acquire the mutex lock again.
+		 */
+		malloc_mutex_lock(chunks_mtx);
+		key.chunk = __DECONST(void *, ptr);
+		/* LINTED */
+		node = RB_FIND(chunk_tree_s, huge, key);
+		assert(node != NULL);
+		assert(node-chunk == ptr);
+		assert(node-size == oldcsize);
+		RB_REMOVE(chunk_tree_s, huge, node);
+		malloc_mutex_unlock(chunks_mtx);
+
 		newptr = mremap(ptr, oldcsize, NULL, newcsize,
 		MAP_ALIGNED(chunksize_2pow));
-		if (newptr != MAP_FAILED) {
+		if (newptr == MAP_FAILED) {
+			/* We still own the old region. */
+			malloc_mutex_lock(chunks_mtx);
+			RB_INSERT(chunk_tree_s, huge, node);
+			malloc_mutex_unlock(chunks_mtx);
+		} else {
 			assert(CHUNK_ADDR2BASE(newptr) == newptr);
 
-			/* update tree */
+			/* Insert new or resized old region. */
 			malloc_mutex_lock(chunks_mtx);
-			key.chunk = __DECONST(void *, ptr);
-			/* LINTED */
-			node = RB_FIND(chunk_tree_s, huge, key);
-			assert(node != NULL);
-			assert(node-chunk == ptr);
-			assert(node-size == oldcsize);
 			node-size = newcsize;
-			if (ptr != newptr) {
-RB_REMOVE(chunk_tree_s, huge, node);
-node-chunk = newptr;
-RB_INSERT(chunk_tree_s, huge, node);
-			}
+			node-chunk = newptr;
+			RB_INSERT(chunk_tree_s, huge, node);
 #ifdef MALLOC_STATS
 			huge_nralloc++;
 			huge_allocated += newcsize - oldcsize;



CVS commit: [netbsd-5] src/lib/libc/stdlib

2009-10-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Oct 20 01:59:46 UTC 2009

Modified Files:
src/lib/libc/stdlib [netbsd-5]: getsubopt.3

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1106):
lib/libc/stdlib/getsubopt.3: revision 1.12
Fix header to include. From Kristaps Dzonsons.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.38.1 src/lib/libc/stdlib/getsubopt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/getsubopt.3
diff -u src/lib/libc/stdlib/getsubopt.3:1.11 src/lib/libc/stdlib/getsubopt.3:1.11.38.1
--- src/lib/libc/stdlib/getsubopt.3:1.11	Thu Aug  7 16:43:40 2003
+++ src/lib/libc/stdlib/getsubopt.3	Tue Oct 20 01:59:46 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: getsubopt.3,v 1.11 2003/08/07 16:43:40 agc Exp $
+.\	$NetBSD: getsubopt.3,v 1.11.38.1 2009/10/20 01:59:46 snj Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)getsubopt.3	8.1 (Berkeley) 6/9/93
 .\
-.Dd June 9, 1993
+.Dd October 19, 2009
 .Dt GETSUBOPT 3
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In stdlib.h
+.In unistd.h
 .Vt extern char *suboptarg
 .Ft int
 .Fn getsubopt char **optionp char * const *tokens char **valuep



CVS commit: [netbsd-5] src/lib/libc/stdlib

2009-04-11 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Apr 12 02:31:34 UTC 2009

Modified Files:
src/lib/libc/stdlib [netbsd-5]: tsearch.3

Log Message:
Pull up following revision(s) (requested by joerg in ticket #695):
lib/libc/stdlib/tsearch.3: revision 1.10
Fix markup.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.12.1 src/lib/libc/stdlib/tsearch.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/tsearch.3
diff -u src/lib/libc/stdlib/tsearch.3:1.9 src/lib/libc/stdlib/tsearch.3:1.9.12.1
--- src/lib/libc/stdlib/tsearch.3:1.9	Fri Dec  7 07:33:13 2007
+++ src/lib/libc/stdlib/tsearch.3	Sun Apr 12 02:31:34 2009
@@ -1,4 +1,4 @@
-.\ $NetBSD: tsearch.3,v 1.9 2007/12/07 07:33:13 simonb Exp $
+.\ $NetBSD: tsearch.3,v 1.9.12.1 2009/04/12 02:31:34 snj Exp $
 .\ Copyright (c) 1997 Todd C. Miller todd.mil...@courtesan.com
 .\ All rights reserved.
 .\
@@ -86,7 +86,7 @@
 .Pp
 .Fn twalk
 walks the binary search tree rooted in
-.fa root
+.Va root
 and calls the function
 .Fa action
 on each node.