[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r4331 - in /fsf/trunk/libc: ./ nscd/ posix/ wcsmbs/
- To: commits@xxxxxxxxxx
- Subject: [commits] r4331 - in /fsf/trunk/libc: ./ nscd/ posix/ wcsmbs/
- From: eglibc@xxxxxxxxxx
- Date: Wed, 28 Nov 2007 08:04:45 -0000
Author: eglibc
Date: Wed Nov 28 00:04:43 2007
New Revision: 4331
Log:
Import glibc-mainline for 2007-11-28
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/nscd/aicache.c
fsf/trunk/libc/nscd/cache.c
fsf/trunk/libc/nscd/grpcache.c
fsf/trunk/libc/nscd/hstcache.c
fsf/trunk/libc/nscd/initgrcache.c
fsf/trunk/libc/nscd/mem.c
fsf/trunk/libc/nscd/nscd.h
fsf/trunk/libc/nscd/pwdcache.c
fsf/trunk/libc/nscd/servicescache.c
fsf/trunk/libc/posix/regex.h
fsf/trunk/libc/posix/unistd.h
fsf/trunk/libc/wcsmbs/wchar.h
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Wed Nov 28 00:04:43 2007
@@ -1,3 +1,25 @@
+2007-11-26 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * posix/unistd.h: Declare fsync also for __USE_XOPEN2K.
+ * posix/regex.h (REG_ENOSYS): Likewise.
+ * wcsmbs/wchar.h: Define __need_file also for __USE_XOPEN2K.
+
+2007-11-25 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * nscd/nscd.h (MAX_STACK_USE): Define.
+ * nscd/mem.c (MAX_STACK_USE): Remove definition here.
+ (gc): Initialize stack_used based on allocation in prune_cache.
+ * nscd/cache.c (prune_cache): Use heap for mark array if necessary.
+ Clear array before use.
+
+ * nscd/aicache.c (addhstaiX): Update statistics counter in case
+ memory allocation failed.
+ * nscd/hstcache.c (cache_addhst): Likewise.
+ * nscd/grpcache.c (cache_addgr): Likewise.
+ * nscd/servicescache.c (cache_addserv): Likewise.
+ * nscd/pwdcache.c (cache_addpw): Likewise.
+ * nscd/initgrcache.c (addinitgroupsX): Likewise.
+
2007-11-23 Ulrich Drepper <drepper@xxxxxxxxxx>
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Add open
Modified: fsf/trunk/libc/nscd/aicache.c
==============================================================================
--- fsf/trunk/libc/nscd/aicache.c (original)
+++ fsf/trunk/libc/nscd/aicache.c Wed Nov 28 00:04:43 2007
@@ -339,7 +339,7 @@
= (struct dataset *) mempool_alloc (db,
total
+ req->key_len);
- if (newp != NULL)
+ if (__builtin_expect (newp != NULL, 1))
{
/* Adjust pointer into the memory block. */
key_copy = (char *) newp + (key_copy
@@ -349,6 +349,8 @@
total + req->key_len);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
Modified: fsf/trunk/libc/nscd/cache.c
==============================================================================
--- fsf/trunk/libc/nscd/cache.c (original)
+++ fsf/trunk/libc/nscd/cache.c Wed Nov 28 00:04:43 2007
@@ -34,6 +34,10 @@
#include "nscd.h"
#include "dbg_log.h"
+
+
+/* Wrapper functions with error checking for standard functions. */
+extern void *xcalloc (size_t n, size_t s);
/* Number of times a value is reloaded without being used. UINT_MAX
@@ -278,7 +282,20 @@
we don't need to get any lock. It is at all timed assured that the
linked lists are set up correctly and that no second thread prunes
the cache. */
- bool mark[cnt];
+ bool *mark;
+ size_t memory_needed = cnt * sizeof (bool);
+ bool mark_use_alloca;
+ if (__builtin_expect (memory_needed <= MAX_STACK_USE, 1))
+ {
+ mark = alloca (cnt * sizeof (bool));
+ memset (mark, '\0', memory_needed);
+ mark_use_alloca = true;
+ }
+ else
+ {
+ mark = xcalloc (1, memory_needed);
+ mark_use_alloca = false;
+ }
size_t first = cnt + 1;
size_t last = 0;
char *const data = table->data;
@@ -471,6 +488,9 @@
}
}
+ if (__builtin_expect (! mark_use_alloca, 0))
+ free (mark);
+
/* Run garbage collection if any entry has been removed or replaced. */
if (any)
gc (table);
Modified: fsf/trunk/libc/nscd/grpcache.c
==============================================================================
--- fsf/trunk/libc/nscd/grpcache.c (original)
+++ fsf/trunk/libc/nscd/grpcache.c Wed Nov 28 00:04:43 2007
@@ -285,6 +285,8 @@
dataset = memcpy (newp, dataset, total + n);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
Modified: fsf/trunk/libc/nscd/hstcache.c
==============================================================================
--- fsf/trunk/libc/nscd/hstcache.c (original)
+++ fsf/trunk/libc/nscd/hstcache.c Wed Nov 28 00:04:43 2007
@@ -325,6 +325,8 @@
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
}
/* Mark the old record as obsolete. */
Modified: fsf/trunk/libc/nscd/initgrcache.c
==============================================================================
--- fsf/trunk/libc/nscd/initgrcache.c (original)
+++ fsf/trunk/libc/nscd/initgrcache.c Wed Nov 28 00:04:43 2007
@@ -110,7 +110,7 @@
bool all_tryagain = true;
bool any_success = false;
- /* This is temporary memory, we need not (ad must not) call
+ /* This is temporary memory, we need not (and must not) call
mempool_alloc. */
// XXX This really should use alloca. need to change the backends.
gid_t *groups = (gid_t *) malloc (size * sizeof (gid_t));
@@ -338,6 +338,8 @@
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
Modified: fsf/trunk/libc/nscd/mem.c
==============================================================================
--- fsf/trunk/libc/nscd/mem.c (original)
+++ fsf/trunk/libc/nscd/mem.c Wed Nov 28 00:04:43 2007
@@ -74,10 +74,6 @@
#define ALLBITS ((((BITMAP_T) 1) << BITS) - 1)
#define HIGHBIT (((BITMAP_T) 1) << (BITS - 1))
-/* Maximum size of stack frames we allow the thread to use. We use
- 80% of the thread stack size. */
-#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
-
static void
markrange (BITMAP_T *mark, ref_t start, size_t len)
@@ -129,7 +125,11 @@
BITMAP_T *mark;
bool mark_use_malloc;
- size_t stack_used = 0;
+ /* In prune_cache we are also using a dynamically allocated array.
+ If the array in the caller is too large we have malloc'ed it. */
+ size_t stack_used = sizeof (bool) * db->head->module;
+ if (__builtin_expect (stack_used > MAX_STACK_USE, 0))
+ stack_used = 0;
size_t memory_needed = ((db->head->first_free / BLOCK_ALIGN + BITS - 1)
/ BITS) * sizeof (BITMAP_T);
if (memory_needed <= MAX_STACK_USE)
Modified: fsf/trunk/libc/nscd/nscd.h
==============================================================================
--- fsf/trunk/libc/nscd/nscd.h (original)
+++ fsf/trunk/libc/nscd/nscd.h Wed Nov 28 00:04:43 2007
@@ -57,6 +57,10 @@
/* Stack size for worker threads. */
#define NSCD_THREAD_STACKSIZE 1024 * 1024 * (sizeof (void *) / 4)
+
+/* Maximum size of stack frames we allow the thread to use. We use
+ 80% of the thread stack size. */
+#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
/* Structure describing dynamic part of one database. */
Modified: fsf/trunk/libc/nscd/pwdcache.c
==============================================================================
--- fsf/trunk/libc/nscd/pwdcache.c (original)
+++ fsf/trunk/libc/nscd/pwdcache.c Wed Nov 28 00:04:43 2007
@@ -280,6 +280,8 @@
dataset = memcpy (newp, dataset, total + n);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
Modified: fsf/trunk/libc/nscd/servicescache.c
==============================================================================
--- fsf/trunk/libc/nscd/servicescache.c (original)
+++ fsf/trunk/libc/nscd/servicescache.c Wed Nov 28 00:04:43 2007
@@ -272,6 +272,8 @@
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
+ else
+ ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
Modified: fsf/trunk/libc/posix/regex.h
==============================================================================
--- fsf/trunk/libc/posix/regex.h (original)
+++ fsf/trunk/libc/posix/regex.h Wed Nov 28 00:04:43 2007
@@ -302,7 +302,7 @@
`re_error_msg' table in regex.c. */
typedef enum
{
-#ifdef _XOPEN_SOURCE
+#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
REG_ENOSYS = -1, /* This will never happen for this implementation. */
#endif
Modified: fsf/trunk/libc/posix/unistd.h
==============================================================================
--- fsf/trunk/libc/posix/unistd.h (original)
+++ fsf/trunk/libc/posix/unistd.h Wed Nov 28 00:04:43 2007
@@ -915,13 +915,13 @@
#endif /* Use BSD || X/Open. */
-#if defined __USE_BSD || defined __USE_XOPEN
+#if defined __USE_BSD || defined __USE_XOPEN || defined __USE_XOPEN2K
/* Make all changes done to FD actually appear on disk.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int fsync (int __fd);
-#endif /* Use BSD || X/Open. */
+#endif /* Use BSD || X/Open || Unix98. */
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
Modified: fsf/trunk/libc/wcsmbs/wchar.h
==============================================================================
--- fsf/trunk/libc/wcsmbs/wchar.h (original)
+++ fsf/trunk/libc/wcsmbs/wchar.h Wed Nov 28 00:04:43 2007
@@ -31,7 +31,7 @@
#ifdef _WCHAR_H
/* Get FILE definition. */
# define __need___FILE
-# ifdef __USE_UNIX98
+# if defined __USE_UNIX98 || defined __USE_XOPEN2K
# define __need_FILE
# endif
# include <stdio.h>