diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-08-22 07:34:59 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-08-22 07:34:59 +0000 |
commit | 8b0a52444c889fd368f51ba37ad401b6ca5d40f1 (patch) | |
tree | e61c0a96c4f02a2ae41a4a6b8b291cd0adfa75be | |
parent | 964f44e4d838ce28ae848f228c7212cf609ace3c (diff) |
Updated to fedora-glibc-20050822T0727
-rw-r--r-- | ChangeLog | 92 | ||||
-rw-r--r-- | argp/argp-help.c | 7 | ||||
-rw-r--r-- | debug/tst-chk1.c | 36 | ||||
-rw-r--r-- | debug/vfprintf_chk.c | 3 | ||||
-rw-r--r-- | fedora/branch.mk | 4 | ||||
-rw-r--r-- | include/atomic.h | 41 | ||||
-rw-r--r-- | include/stdio.h | 1 | ||||
-rw-r--r-- | intl/localealias.c | 7 | ||||
-rw-r--r-- | malloc/Makefile | 2 | ||||
-rw-r--r-- | malloc/memusage.c | 225 | ||||
-rw-r--r-- | nis/nis_subr.c | 2 | ||||
-rw-r--r-- | nis/nis_xdr.c | 2 | ||||
-rw-r--r-- | nis/nss_nis/nis-netgrp.c | 4 | ||||
-rw-r--r-- | nptl/ChangeLog | 2 | ||||
-rw-r--r-- | nscd/cache.c | 34 | ||||
-rw-r--r-- | nscd/connections.c | 12 | ||||
-rw-r--r-- | nscd/nscd_stat.c | 13 | ||||
-rw-r--r-- | nss/getent.c | 57 | ||||
-rw-r--r-- | posix/regex.h | 2 | ||||
-rw-r--r-- | resolv/res_send.c | 13 | ||||
-rw-r--r-- | sysdeps/generic/memusage.h | 18 | ||||
-rw-r--r-- | sysdeps/i386/i686/memusage.h | 22 | ||||
-rw-r--r-- | sysdeps/ia64/fpu/libm_error.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/Makefile | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/inotify.h | 83 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/syscalls.list | 3 |
26 files changed, 525 insertions, 170 deletions
@@ -1,3 +1,95 @@ +2005-08-21 Ulrich Drepper <drepper@redhat.com> + + * resolv/res_send.c (Aerror): Fix printing IP address. + + * resolv/res_send.c (send_vc): Pass correct sockaddr size to connect. + +2005-08-19 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/ia64/fpu/libm_error.c (__libm_error_support): Don't abort. + +2005-08-17 Robert Love <rml@novell.com> + + * sysdeps/unix/sysv/linux/sys/inotify.h: Add IN_MOVE_SELF event. + +2005-08-19 Bruno Haible <bruno@clisp.org> + + * intl/localealias.c (read_alias_file): In case of failure, close the + file descriptor and sort the array before returning. + +2005-08-19 Ulrich Drepper <drepper@redhat.com> + + * malloc/Makefile: Link libmemusage.so with ld.so. + * malloc/memusage.c: Use atomic operations for all counter and size + computations. Handle thread stacks. + * sysdeps/generic/memusage.h: Define memusage_cntr_t and + memusage_size_t. + * sysdeps/i386/i686/memusage.h: New file. + * include/atomic.h: Define atomic_max and atomic_min. + + * debug/tst-chk1.c: Add tests for mbstowcs and wcstombs. + +2005-08-17 Paul Eggert <eggert@cs.ucla.edu> + + [BZ #1207] + * posix/regex.h: Remove spurious space-before-tab. From gnulib. + +2005-08-16 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add + sys/inotify.h. + * sysdeps/unix/sysv/linux/sys/inotify.h: New file. + * sysdeps/unix/sysv/linux/syscalls.list: Add inotify syscalls. + + * nscd/cache.c (prune_cache): Add more debug output. Only for + debug level 3 and higher and very verbose. + + * nscd/cache.c (prune_cache): Use stat64 not stat. + * nscd/connections.c (nscd_init): Likewise. + +2005-08-10 Sergio Gelato <Sergio.Gelato@astro.su.se> + + [BZ #1188] + * nis/nss_nis/nis-netgrp.c (_nss_nis_setnetgrent): Change assert check + from (len > 0) to (len >= 0). + +2005-08-16 Ulrich Drepper <drepper@redhat.com> + + * nis/nis_xdr.c (_xdr_nis_result): Fix type of res variable. + Reported by Thomas Schwinge. + +2005-08-15 Jakub Jelinek <jakub@redhat.com> + + * nis/nis_subr.c (nis_leaf_of_r): Handle buflen == 0 correctly. + +2005-08-16 Ulrich Drepper <drepper@redhat.com> + + * nss/getent.c (more_help): Use open_memstream instead of handling + memory allocation ourselves. + +2005-08-16 Jay Fenlason <fenlason@redhat.com> + + * nss/getent.c (parse_options): change the -s option to support + {database}:{search} to override /etc/resolv.conf for only the + specified database. + +2005-08-08 Ulrich Drepper <drepper@redhat.com> + + * nscd/connections.c (main_loop_epoll): Pass NULL as event + argument for epoll_ctl(EPOLL_CTL_DEL) calls. + + * nscd/nscd_stat.c (receive_print_stats): Really print values of + thread number, paranoia, and restart interval the server is using. + + * argp/argp-help.c: Use _IO_vasprintf instead of vasprintf. + * include/stdio.h: Add libc_hidden_proto for __vfprintf_chk. + * debug/vfprintf_chk.c: Add libc_hidden_def. + +2005-08-08 Roland McGrath <roland@redhat.com> + + * argp/argp-help.c (__argp_error): __asprintf -> vasprintf. + (__argp_failure): Likewise. + 2005-08-08 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard): diff --git a/argp/argp-help.c b/argp/argp-help.c index ee61ed4d5c..4bc4d07b15 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -48,7 +48,8 @@ char *alloca (); #include <stdarg.h> #include <ctype.h> #include <limits.h> -#ifdef USE_IN_LIBIO +#ifdef _LIBC +# include <../libio/libioP.h> # include <wchar.h> #endif @@ -1766,7 +1767,7 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) #ifdef _LIBC char *buf; - if (__asprintf (&buf, fmt, ap) < 0) + if (_IO_vasprintf (&buf, fmt, ap) < 0) buf = NULL; __fxprintf (stream, "%s: %s\n", @@ -1836,7 +1837,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum, #ifdef _LIBC char *buf; - if (__asprintf (&buf, fmt, ap) < 0) + if (_IO_vasprintf (&buf, fmt, ap) < 0) buf = NULL; __fxprintf (stream, ": %s", buf); diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c index c22c2e8fc2..8940e880e6 100644 --- a/debug/tst-chk1.c +++ b/debug/tst-chk1.c @@ -1107,6 +1107,24 @@ do_test (void) CHK_FAIL_END #endif + cp = "A"; + if (mbstowcs (wenough, cp, 10) != 1) + { + puts ("first mbstowcs test failed"); + ret = 1; + } + +#if __USE_FORTIFY_LEVEL >= 1 + /* We know the wchar_t encoding is ISO 10646. So pick a + character which has a multibyte representation which does not + fit. */ + CHK_FAIL_START + wchar_t wsmallbuf[2]; + cp = "ABC"; + mbstowcs (wsmallbuf, cp, 10); + CHK_FAIL_END +#endif + memset (&s, '\0', sizeof (s)); cp = "A"; if (mbsnrtowcs (wenough, &cp, 1, 10, &s) != 1) @@ -1145,6 +1163,24 @@ do_test (void) CHK_FAIL_END #endif + wcp = L"A"; + if (wcstombs (enough, wcp, 10) != 1) + { + puts ("first wcstombs test failed"); + ret = 1; + } + +#if __USE_FORTIFY_LEVEL >= 1 + /* We know the wchar_t encoding is ISO 10646. So pick a + character which has a multibyte representation which does not + fit. */ + CHK_FAIL_START + char smallbuf[2]; + wcp = L"ABC"; + wcstombs (smallbuf, wcp, 10); + CHK_FAIL_END +#endif + memset (&s, '\0', sizeof (s)); wcp = L"A"; if (wcsnrtombs (enough, &wcp, 1, 10, &s) != 1) diff --git a/debug/vfprintf_chk.c b/debug/vfprintf_chk.c index c8e7c3bf3f..10dde3cb1e 100644 --- a/debug/vfprintf_chk.c +++ b/debug/vfprintf_chk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004 +/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -40,3 +40,4 @@ __vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) return done; } +libc_hidden_def (__vfprintf_chk) diff --git a/fedora/branch.mk b/fedora/branch.mk index 34b90fb2b7..28e9be93c0 100644 --- a/fedora/branch.mk +++ b/fedora/branch.mk @@ -3,5 +3,5 @@ glibc-branch := fedora glibc-base := HEAD DIST_BRANCH := devel COLLECTION := dist-fc4 -fedora-sync-date := 2005-08-08 21:26 UTC -fedora-sync-tag := fedora-glibc-20050808T2126 +fedora-sync-date := 2005-08-22 07:27 UTC +fedora-sync-tag := fedora-glibc-20050822T0727 diff --git a/include/atomic.h b/include/atomic.h index 8a23f6ee9e..8b76435a81 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -1,5 +1,5 @@ /* Internal macros for atomic operations for GNU C Library. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -108,7 +108,7 @@ __typeof (*(mem)) __value = (newvalue); \ \ do \ - __oldval = (*__memp); \ + __oldval = *__memp; \ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ __value, \ __oldval),\ @@ -130,7 +130,7 @@ __typeof (*(mem)) __value = (value); \ \ do \ - __oldval = (*__memp); \ + __oldval = *__memp; \ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ __oldval \ + __value,\ @@ -141,6 +141,41 @@ #endif + +#ifndef atomic_max +# define atomic_max(mem, value) \ + do { \ + __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __value = (value); \ + do { \ + __oldval = *__memp; \ + if (__oldval >= __value) \ + break; \ + } while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __value, \ + __oldval),\ + 0)); \ + } while (0) +#endif + +#ifndef atomic_min +# define atomic_min(mem, value) \ + do { \ + __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __value = (value); \ + do { \ + __oldval = *__memp; \ + if (__oldval <= __value) \ + break; \ + } while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __value, \ + __oldval),\ + 0)); \ + } while (0) +#endif + #ifndef atomic_add # define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value)) #endif diff --git a/include/stdio.h b/include/stdio.h index 9220db5b80..e040380d79 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -128,6 +128,7 @@ libc_hidden_proto (open_memstream) libc_hidden_proto (__libc_fatal) libc_hidden_proto (__vsprintf_chk) libc_hidden_proto (__vsnprintf_chk) +libc_hidden_proto (__vfprintf_chk) # if !defined NOT_IN_libc && defined SHARED && defined DO_VERSIONING \ && defined HAVE_VISIBILITY_ATTRIBUTE && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE\ diff --git a/intl/localealias.c b/intl/localealias.c index 32d05ff347..735107abd3 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -1,5 +1,5 @@ /* Handle aliases for locale names. - Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1995-2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -295,7 +295,7 @@ read_alias_file (fname, fname_len) if (nmap >= maxmap) if (__builtin_expect (extend_alias_table (), 0)) - return added; + goto out; alias_len = strlen (alias) + 1; value_len = strlen (value) + 1; @@ -308,7 +308,7 @@ read_alias_file (fname, fname_len) ? alias_len + value_len : 1024)); char *new_pool = (char *) realloc (string_space, new_size); if (new_pool == NULL) - return added; + goto out; if (__builtin_expect (string_space != new_pool, 0)) { @@ -349,6 +349,7 @@ read_alias_file (fname, fname_len) while (strchr (buf, '\n') == NULL); } +out: /* Should we test for ferror()? I think we have to silently ignore errors. --drepper */ fclose (fp); diff --git a/malloc/Makefile b/malloc/Makefile index 398dd2b031..ca427077f3 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -140,7 +140,7 @@ $(objpfx)memusage: memusage.sh # The implementation uses `dlsym' -$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so +$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so # Extra dependencies $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c diff --git a/malloc/memusage.c b/malloc/memusage.c index b552ec37b0..49bcc6f289 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -1,5 +1,5 @@ /* Profile heap and stack memory usage of running program. - Copyright (C) 1998-2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -18,6 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <atomic.h> #include <dlfcn.h> #include <errno.h> #include <fcntl.h> @@ -69,24 +70,22 @@ struct header #define MAGIC 0xfeedbeaf -static unsigned long int calls[idx_last]; -static unsigned long int failed[idx_last]; -static unsigned long long int total[idx_last]; -static unsigned long long int grand_total; -static unsigned long int histogram[65536 / 16]; -static unsigned long int large; -static unsigned long int calls_total; -static unsigned long int inplace; -static unsigned long int decreasing; -static unsigned long int inplace_mremap; -static unsigned long int decreasing_mremap; -static long int current_use[2]; -static long int peak_use[3]; -static uintptr_t start_sp; +static memusage_cntr_t calls[idx_last]; +static memusage_cntr_t failed[idx_last]; +static memusage_size_t total[idx_last]; +static memusage_size_t grand_total; +static memusage_cntr_t histogram[65536 / 16]; +static memusage_cntr_t large; +static memusage_cntr_t calls_total; +static memusage_cntr_t inplace; +static memusage_cntr_t decreasing; +static memusage_cntr_t inplace_mremap; +static memusage_cntr_t decreasing_mremap; +static memusage_size_t current_heap; +static memusage_size_t peak_use[3]; +static __thread uintptr_t start_sp; /* A few macros to make the source more readable. */ -#define current_heap current_use[0] -#define current_stack current_use[1] #define peak_heap peak_use[0] #define peak_stack peak_use[1] #define peak_total peak_use[2] @@ -109,8 +108,8 @@ struct entry uint32_t time_high; }; -static struct entry buffer[DEFAULT_BUFFER_SIZE]; -static size_t buffer_cnt; +static struct entry buffer[2 * DEFAULT_BUFFER_SIZE]; +static uatomic32_t buffer_cnt; static struct entry first; @@ -118,8 +117,6 @@ static struct entry first; static void update_data (struct header *result, size_t len, size_t old_len) { - long int total_use; - if (result != NULL) { /* Record the information we need and mark the block using a @@ -129,38 +126,60 @@ update_data (struct header *result, size_t len, size_t old_len) } /* Compute current heap usage and compare it with the maximum value. */ - current_heap += len - old_len; - if (current_heap > peak_heap) - peak_heap = current_heap; - - /* Compute current stack usage and compare it with the maximum value. */ + memusage_size_t heap + = atomic_exchange_and_add (¤t_heap, len - old_len) + len - old_len; + atomic_max (&peak_heap, heap); + + /* Compute current stack usage and compare it with the maximum + value. The base stack pointer might not be set if this is not + the main thread and it is the first call to any of these + functions. */ + if (__builtin_expect (!start_sp, 0)) + start_sp = GETSP (); + + uintptr_t sp = GETSP (); #ifdef STACK_GROWS_UPWARD - current_stack = GETSP () - start_sp; + /* This can happen in threads where we didn't catch the thread's + stack early enough. */ + if (__builtin_expect (sp < start_sp, 0)) + start_sp = sp; + size_t current_stack = sp - start_sp; #else - current_stack = start_sp - GETSP (); + /* This can happen in threads where we didn't catch the thread's + stack early enough. */ + if (__builtin_expect (sp > start_sp, 0)) + start_sp = sp; + size_t current_stack = start_sp - sp; #endif - if (current_stack > peak_stack) - peak_stack = current_stack; + atomic_max (&peak_stack, current_stack); /* Add up heap and stack usage and compare it with the maximum value. */ - total_use = current_heap + current_stack; - if (total_use > peak_total) - peak_total = total_use; + atomic_max (&peak_total, heap + current_stack); /* Store the value only if we are writing to a file. */ if (fd != -1) { - buffer[buffer_cnt].heap = current_heap; - buffer[buffer_cnt].stack = current_stack; - GETTIME (buffer[buffer_cnt].time_low, buffer[buffer_cnt].time_high); - ++buffer_cnt; - - /* Write out buffer if it is full. */ - if (buffer_cnt == buffer_size) + uatomic32_t idx = atomic_exchange_and_add (&buffer_cnt, 1); + if (idx >= 2 * buffer_size) { - write (fd, buffer, buffer_cnt * sizeof (struct entry)); - buffer_cnt = 0; + /* We try to reset the counter to the correct range. If + this fails because of another thread increasing the + counter it does not matter since that thread will take + care of the correction. */ + unsigned int reset = idx - 2 * buffer_size; + atomic_compare_and_exchange_val_acq (&buffer_size, reset, idx); + idx = reset; } + + buffer[idx].heap = current_heap; + buffer[idx].stack = current_stack; + GETTIME (buffer[idx].time_low, buffer[idx].time_high); + + /* Write out buffer if it is full. */ + if (idx + 1 == buffer_size) + write (fd, buffer, buffer_size * sizeof (struct entry)); + else if (idx + 1 == 2 * buffer_size) + write (fd, &buffer[buffer_size], buffer_size * sizeof (struct entry)); } } @@ -317,24 +336,24 @@ malloc (size_t len) return (*mallocp) (len); /* Keep track of number of calls. */ - ++calls[idx_malloc]; + atomic_increment (&calls[idx_malloc]); /* Keep track of total memory consumption for `malloc'. */ - total[idx_malloc] += len; + atomic_add (&total[idx_malloc], len); /* Keep track of total memory requirement. */ - grand_total += len; + atomic_add (&grand_total, len); /* Remember the size of the request. */ if (len < 65536) - ++histogram[len / 16]; + atomic_increment (&histogram[len / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ - ++calls_total; + atomic_increment (&calls_total); /* Do the real work. */ result = (struct header *) (*mallocp) (len + sizeof (struct header)); if (result == NULL) { - ++failed[idx_malloc]; + atomic_increment (&failed[idx_malloc]); return NULL; } @@ -383,36 +402,36 @@ realloc (void *old, size_t len) } /* Keep track of number of calls. */ - ++calls[idx_realloc]; + atomic_increment (&calls[idx_realloc]); if (len > old_len) { /* Keep track of total memory consumption for `realloc'. */ - total[idx_realloc] += len - old_len; + atomic_add (&total[idx_realloc], len - old_len); /* Keep track of total memory requirement. */ - grand_total += len - old_len; + atomic_add (&grand_total, len - old_len); } /* Remember the size of the request. */ if (len < 65536) - ++histogram[len / 16]; + atomic_increment (&histogram[len / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ - ++calls_total; + atomic_increment (&calls_total); /* Do the real work. */ result = (struct header *) (*reallocp) (real, len + sizeof (struct header)); if (result == NULL) { - ++failed[idx_realloc]; + atomic_increment (&failed[idx_realloc]); return NULL; } /* Record whether the reduction/increase happened in place. */ if (real == result) - ++inplace; + atomic_increment (&inplace); /* Was the buffer increased? */ if (old_len > len) - ++decreasing; + atomic_increment (&decreasing); /* Update the allocation data and write out the records if necessary. */ update_data (result, len, old_len); @@ -443,16 +462,16 @@ calloc (size_t n, size_t len) return (*callocp) (n, len); /* Keep track of number of calls. */ - ++calls[idx_calloc]; + atomic_increment (&calls[idx_calloc]); /* Keep track of total memory consumption for `calloc'. */ - total[idx_calloc] += size; + atomic_add (&total[idx_calloc], size); /* Keep track of total memory requirement. */ - grand_total += size; + atomic_add (&grand_total, size); /* Remember the size of the request. */ if (size < 65536) - ++histogram[size / 16]; + atomic_increment (&histogram[size / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ ++calls_total; @@ -460,7 +479,7 @@ calloc (size_t n, size_t len) result = (struct header *) (*mallocp) (size + sizeof (struct header)); if (result == NULL) { - ++failed[idx_calloc]; + atomic_increment (&failed[idx_calloc]); return NULL; } @@ -497,7 +516,7 @@ free (void *ptr) /* `free (NULL)' has no effect. */ if (ptr == NULL) { - ++calls[idx_free]; + atomic_increment (&calls[idx_free]); return; } @@ -511,9 +530,9 @@ free (void *ptr) } /* Keep track of number of calls. */ - ++calls[idx_free]; + atomic_increment (&calls[idx_free]); /* Keep track of total memory freed using `free'. */ - total[idx_free] += real->length; + atomic_add (&total[idx_free], real->length); /* Update the allocation data and write out the records if necessary. */ update_data (NULL, 0, real->length); @@ -547,22 +566,22 @@ mmap (void *start, size_t len, int prot, int flags, int fd, off_t offset) ? idx_mmap_a : prot & PROT_WRITE ? idx_mmap_w : idx_mmap_r); /* Keep track of number of calls. */ - ++calls[idx]; + atomic_increment (&calls[idx]); /* Keep track of total memory consumption for `malloc'. */ - total[idx] += len; + atomic_add (&total[idx], len); /* Keep track of total memory requirement. */ - grand_total += len; + atomic_add (&grand_total, len); /* Remember the size of the request. */ if (len < 65536) - ++histogram[len / 16]; + atomic_increment (&histogram[len / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ - ++calls_total; + atomic_increment (&calls_total); /* Check for failures. */ if (result == NULL) - ++failed[idx]; + atomic_increment (&failed[idx]); else if (idx == idx_mmap_w) /* Update the allocation data and write out the records if necessary. Note the first parameter is NULL which means @@ -599,22 +618,22 @@ mmap64 (void *start, size_t len, int prot, int flags, int fd, off64_t offset) ? idx_mmap_a : prot & PROT_WRITE ? idx_mmap_w : idx_mmap_r); /* Keep track of number of calls. */ - ++calls[idx]; + atomic_increment (&calls[idx]); /* Keep track of total memory consumption for `malloc'. */ - total[idx] += len; + atomic_add (&total[idx], len); /* Keep track of total memory requirement. */ - grand_total += len; + atomic_add (&grand_total, len); /* Remember the size of the request. */ if (len < 65536) - ++histogram[len / 16]; + atomic_increment (&histogram[len / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ - ++calls_total; + atomic_increment (&calls_total); /* Check for failures. */ if (result == NULL) - ++failed[idx]; + atomic_increment (&failed[idx]); else if (idx == idx_mmap_w) /* Update the allocation data and write out the records if necessary. Note the first parameter is NULL which means @@ -648,33 +667,33 @@ mremap (void *start, size_t old_len, size_t len, int flags) if (!not_me && trace_mmap) { /* Keep track of number of calls. */ - ++calls[idx_mremap]; + atomic_increment (&calls[idx_mremap]); if (len > old_len) { /* Keep track of total memory consumption for `malloc'. */ - total[idx_mremap] += len - old_len; + atomic_add (&total[idx_mremap], len - old_len); /* Keep track of total memory requirement. */ - grand_total += len - old_len; + atomic_add (&grand_total, len - old_len); } /* Remember the size of the request. */ if (len < 65536) - ++histogram[len / 16]; + atomic_increment (&histogram[len / 16]); else - ++large; + atomic_increment (&large); /* Total number of calls of any of the functions. */ - ++calls_total; + atomic_increment (&calls_total); /* Check for failures. */ if (result == NULL) - ++failed[idx_mremap]; + atomic_increment (&failed[idx_mremap]); else { /* Record whether the reduction/increase happened in place. */ if (start == result) - ++inplace_mremap; + atomic_increment (&inplace_mremap); /* Was the buffer increased? */ if (old_len > len) - ++decreasing_mremap; + atomic_increment (&decreasing_mremap); /* Update the allocation data and write out the records if necessary. Note the first parameter is NULL which means @@ -708,19 +727,19 @@ munmap (void *start, size_t len) if (!not_me && trace_mmap) { /* Keep track of number of calls. */ - ++calls[idx_munmap]; + atomic_increment (&calls[idx_munmap]); if (__builtin_expect (result == 0, 1)) { /* Keep track of total memory freed using `free'. */ - total[idx_munmap] += len; + atomic_add (&total[idx_munmap], len); /* Update the allocation data and write out the records if necessary. */ update_data (NULL, 0, len); } else - ++failed[idx_munmap]; + atomic_increment (&failed[idx_munmap]); } return result; @@ -772,16 +791,16 @@ dest (void) \e[00;34mrealloc|\e[0m %10lu %12llu %s%12lu\e[00;00m (in place: %ld, dec: %ld)\n\ \e[00;34m calloc|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ \e[00;34m free|\e[0m %10lu %12llu\n", - grand_total, (unsigned long int) peak_heap, + (unsigned long long int) grand_total, (unsigned long int) peak_heap, (unsigned long int) peak_stack, - calls[idx_malloc], total[idx_malloc], + calls[idx_malloc], (unsigned long long int) total[idx_malloc], failed[idx_malloc] ? "\e[01;41m" : "", failed[idx_malloc], - calls[idx_realloc], total[idx_realloc], + calls[idx_realloc], (unsigned long long int) total[idx_realloc], failed[idx_realloc] ? "\e[01;41m" : "", failed[idx_realloc], inplace, decreasing, - calls[idx_calloc], total[idx_calloc], + calls[idx_calloc], (unsigned long long int) total[idx_calloc], failed[idx_calloc] ? "\e[01;41m" : "", failed[idx_calloc], - calls[idx_free], total[idx_free]); + calls[idx_free], (unsigned long long int) total[idx_free]); if (trace_mmap) fprintf (stderr, "\ @@ -790,16 +809,16 @@ dest (void) \e[00;34mmmap(a)|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ \e[00;34m mremap|\e[0m %10lu %12llu %s%12lu\e[00;00m (in place: %ld, dec: %ld)\n\ \e[00;34m munmap|\e[0m %10lu %12llu %s%12lu\e[00;00m\n", - calls[idx_mmap_r], total[idx_mmap_r], + calls[idx_mmap_r], (unsigned long long int) total[idx_mmap_r], failed[idx_mmap_r] ? "\e[01;41m" : "", failed[idx_mmap_r], - calls[idx_mmap_w], total[idx_mmap_w], + calls[idx_mmap_w], (unsigned long long int) total[idx_mmap_w], failed[idx_mmap_w] ? "\e[01;41m" : "", failed[idx_mmap_w], - calls[idx_mmap_a], total[idx_mmap_a], + calls[idx_mmap_a], (unsigned long long int) total[idx_mmap_a], failed[idx_mmap_a] ? "\e[01;41m" : "", failed[idx_mmap_a], - calls[idx_mremap], total[idx_mremap], + calls[idx_mremap], (unsigned long long int) total[idx_mremap], failed[idx_mremap] ? "\e[01;41m" : "", failed[idx_mremap], inplace_mremap, decreasing_mremap, - calls[idx_munmap], total[idx_munmap], + calls[idx_munmap], (unsigned long long int) total[idx_munmap], failed[idx_munmap] ? "\e[01;41m" : "", failed[idx_munmap]); /* Write out a histoogram of the sizes of the allocations. */ diff --git a/nis/nis_subr.c b/nis/nis_subr.c index 5838e30e88..7e29168111 100644 --- a/nis/nis_subr.c +++ b/nis/nis_subr.c @@ -39,7 +39,7 @@ nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen) while (name[i] != '.' && name[i] != '\0') i++; - if (__builtin_expect (i > buflen - 1, 0)) + if (__builtin_expect (i >= buflen, 0)) { __set_errno (ERANGE); return NULL; diff --git a/nis/nis_xdr.c b/nis/nis_xdr.c index 820103b6e9..1ef08c7890 100644 --- a/nis/nis_xdr.c +++ b/nis/nis_xdr.c @@ -281,7 +281,7 @@ _xdr_nis_error (XDR *xdrs, nis_error *objp) bool_t _xdr_nis_result (XDR *xdrs, nis_result *objp) { - bool res = _xdr_nis_error (xdrs, &objp->status); + bool_t res = _xdr_nis_error (xdrs, &objp->status); if (__builtin_expect (res, TRUE)) { res = xdr_array (xdrs, (char **) &objp->objects.objects_val, diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index d339dd5097..7bd6527f2d 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004 +/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996. @@ -75,7 +75,7 @@ _nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp) which is one byte larger than the value in LEN specifies and the last byte is filled with NUL. So we can simply use that buffer. */ - assert (len > 0); + assert (len >= 0); assert (malloc_usable_size (netgrp->data) >= len + 1); assert (netgrp->data[len] == '\0'); diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e14555dce5..dc6e9b388d 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -124,6 +124,7 @@ 2005-04-27 Ulrich Drepper <drepper@redhat.com> + [BZ #1075] * tst-cancel17.c (do_test): Add arbitrary factor to make sure aio_write blocks. @@ -201,6 +202,7 @@ 2005-03-23 Ulrich Drepper <drepper@redhat.com> + [BZ #1112] * pthread_create.c (__pthread_create_2_1): Rename syscall error variable to scerr. diff --git a/nscd/cache.c b/nscd/cache.c index 800b7ecf27..a3f669bf8c 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -21,6 +21,7 @@ #include <atomic.h> #include <errno.h> #include <error.h> +#include <inttypes.h> #include <limits.h> #include <stdlib.h> #include <string.h> @@ -203,9 +204,9 @@ prune_cache (struct database_dyn *table, time_t now) the entries also in this case. */ if (table->check_file) { - struct stat st; + struct stat64 st; - if (stat (table->filename, &st) < 0) + if (stat64 (table->filename, &st) < 0) { char buf[128]; /* We cannot stat() the file, disable file checking if the @@ -238,6 +239,10 @@ prune_cache (struct database_dyn *table, time_t now) char *const data = table->data; bool any = false; + if (__builtin_expect (debug_level > 2, 0)) + dbg_log (_("pruning %s cache; time %ld"), + dbnames[table - dbs], (long int) now); + do { ref_t run = table->head->array[--cnt]; @@ -247,6 +252,25 @@ prune_cache (struct database_dyn *table, time_t now) struct hashentry *runp = (struct hashentry *) (data + run); struct datahead *dh = (struct datahead *) (data + runp->packet); + /* Some debug support. */ + if (__builtin_expect (debug_level > 2, 0)) + { + char buf[INET6_ADDRSTRLEN]; + const char *str; + + if (runp->type == GETHOSTBYADDR || runp->type == GETHOSTBYADDRv6) + { + inet_ntop (runp->type == GETHOSTBYADDR ? AF_INET : AF_INET6, + data + runp->key, buf, sizeof (buf)); + str = buf; + } + else + str = data + runp->key; + + dbg_log (_("considering %s entry \"%s\", timeout %" PRIu64), + serv2str[runp->type], str, dh->timeout); + } + /* Check whether the entry timed out. */ if (dh->timeout < now) { @@ -401,7 +425,7 @@ prune_cache (struct database_dyn *table, time_t now) /* Make sure the data is saved to disk. */ if (table->persistent) msync (table->head, - table->data + table->head->first_free - (char *) table->head, + data + table->head->first_free - (char *) table->head, MS_ASYNC); /* One extra pass if we do debugging. */ @@ -417,11 +441,11 @@ prune_cache (struct database_dyn *table, time_t now) if (runp->type == GETHOSTBYADDR || runp->type == GETHOSTBYADDRv6) { inet_ntop (runp->type == GETHOSTBYADDR ? AF_INET : AF_INET6, - table->data + runp->key, buf, sizeof (buf)); + data + runp->key, buf, sizeof (buf)); str = buf; } else - str = table->data + runp->key; + str = data + runp->key; dbg_log ("remove %s entry \"%s\"", serv2str[runp->type], str); diff --git a/nscd/connections.c b/nscd/connections.c index 42a36d39c0..33cde99cdf 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -710,9 +710,9 @@ cannot set socket to close on exec: %s; disabling paranoia mode"), if (dbs[cnt].check_file) { /* We need the modification date of the file. */ - struct stat st; + struct stat64 st; - if (stat (dbs[cnt].filename, &st) < 0) + if (stat64 (dbs[cnt].filename, &st) < 0) { /* We cannot stat() the file, disable file checking. */ dbg_log (_("cannot stat() file `%s': %s"), @@ -1459,7 +1459,7 @@ fd_ready (int fd) { /* We got another thread. */ ++nthreads; - /* The new thread might new a kick. */ + /* The new thread might need a kick. */ do_signal = true; } @@ -1644,8 +1644,7 @@ main_loop_epoll (int efd) else { /* Remove the descriptor from the epoll descriptor. */ - struct epoll_event ev = { 0, }; - (void) epoll_ctl (efd, EPOLL_CTL_DEL, revs[cnt].data.fd, &ev); + (void) epoll_ctl (efd, EPOLL_CTL_DEL, revs[cnt].data.fd, NULL); /* Get a worked to handle the request. */ fd_ready (revs[cnt].data.fd); @@ -1667,8 +1666,7 @@ main_loop_epoll (int efd) if (cnt != sock && starttime[cnt] != 0 && starttime[cnt] < laststart) { /* We are waiting for this one for too long. Close it. */ - struct epoll_event ev = {0, }; - (void) epoll_ctl (efd, EPOLL_CTL_DEL, cnt, &ev); + (void) epoll_ctl (efd, EPOLL_CTL_DEL, cnt, NULL); (void) close (cnt); diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c index 8bf50f39f4..43f6266c6e 100644 --- a/nscd/nscd_stat.c +++ b/nscd/nscd_stat.c @@ -75,6 +75,10 @@ struct statdata int debug_level; time_t runtime; unsigned long int client_queued; + int nthreads; + int max_nthreads; + int paranoia; + time_t restart_interval; int ndbs; struct dbstat dbs[lastdb]; #ifdef HAVE_SELINUX @@ -93,6 +97,10 @@ send_stats (int fd, struct database_dyn dbs[lastdb]) data.debug_level = debug_level; data.runtime = time (NULL) - start_time; data.client_queued = client_queued; + data.nthreads = nthreads; + data.max_nthreads = max_nthreads; + data.paranoia = paranoia; + data.restart_interval = restart_interval; data.ndbs = lastdb; for (cnt = 0; cnt < lastdb; ++cnt) @@ -230,8 +238,9 @@ receive_print_stats (void) "%15lu number of times clients had to wait\n" "%15s paranoia mode enabled\n" "%15lu restart internal\n"), - nthreads, max_nthreads, data.client_queued, - paranoia ? yesstr : nostr, (unsigned long int) restart_interval); + data.nthreads, data.max_nthreads, data.client_queued, + data.paranoia ? yesstr : nostr, + (unsigned long int) data.restart_interval); for (i = 0; i < lastdb; ++i) { diff --git a/nss/getent.c b/nss/getent.c index 0aea5eed2a..7124e6303f 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -757,12 +757,27 @@ D(shadow) static error_t parse_option (int key, char *arg, struct argp_state *state) { - int i; + char *endp; switch (key) { case 's': - for (i = 0; databases[i].name; ++i) - __nss_configure_lookup (databases[i].name, arg); + endp = strchr (arg, ':'); + if (endp == NULL) + /* No specific database, change them all. */ + for (int i = 0; databases[i].name != NULL; ++i) + __nss_configure_lookup (databases[i].name, arg); + else + { + int i; + for (i = 0; databases[i].name != NULL; ++i) + if (strncmp (databases[i].name, arg, endp - arg) == 0) + { + __nss_configure_lookup (databases[i].name, endp + 1); + break; + } + if (databases[i].name == NULL) + error (EXIT_FAILURE, 0, gettext ("Unknown database name")); + } break; default: @@ -776,31 +791,20 @@ parse_option (int key, char *arg, struct argp_state *state) static char * more_help (int key, const char *text, void *input) { - int len; - char *long_doc, *doc, *p; - switch (key) { + size_t len; + char *doc; + FILE *fp; + case ARGP_KEY_HELP_EXTRA: /* We print some extra information. */ -#if 0 - return xstrdup (gettext ("\ -For bug reporting instructions, please see:\n\ -<http://www.gnu.org/software/libc/bugs.html>.\n")); -#endif - long_doc = _("Supported databases:"); - len = strlen (long_doc) + 2; - - for (int i = 0; databases[i].name; ++i) - len += strlen (databases[i].name) + 1; - - doc = (char *) malloc (len); - if (doc != NULL) + fp = open_memstream (&doc, &len); + if (fp != NULL) { - p = stpcpy (doc, long_doc); - *p++ = '\n'; + fputs_unlocked (_("Supported databases:\n"), fp); - for (int i = 0, col = 0; databases[i].name; ++i) + for (int i = 0, col = 0; databases[i].name != NULL; ++i) { len = strlen (databases[i].name); if (i != 0) @@ -808,17 +812,18 @@ For bug reporting instructions, please see:\n\ if (col + len > 72) { col = 0; - *p++ = '\n'; + fputc_unlocked ('\n', fp); } else - *p++ = ' '; + fputc_unlocked (' ', fp); } - p = mempcpy (p, databases[i].name, len); + fputs_unlocked (databases[i].name, fp); col += len + 1; } - return doc; + if (fclose (fp) == 0) + return doc; } break; diff --git a/posix/regex.h b/posix/regex.h index b2d9a62fec..1f73d23866 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -207,7 +207,7 @@ extern reg_syntax_t re_syntax_options; & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ | RE_CONTEXT_INVALID_OPS )) -#define RE_SYNTAX_POSIX_AWK \ +#define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ | RE_INTERVALS | RE_NO_GNU_OPS) diff --git a/resolv/res_send.c b/resolv/res_send.c index 6f12b88d6f..e62cde2360 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -654,7 +654,9 @@ send_vc(res_state statp, } __set_errno (0); if (connect(statp->_vcsock, (struct sockaddr *)nsap, - sizeof *nsap) < 0) { + nsap->sin6_family == AF_INET + ? sizeof (struct sockaddr_in) + : sizeof (struct sockaddr_in6)) < 0) { *terrno = errno; Aerror(statp, stderr, "connect/vc", errno, (struct sockaddr *) nsap); @@ -1060,8 +1062,13 @@ Aerror(const res_state statp, FILE *file, const char *string, int error, fprintf(file, "res_send: %s ([%s].%u): %s\n", string, - inet_ntop(address->sa_family, address->sa_data, - tmp, sizeof tmp), + (address->sa_family == AF_INET + ? inet_ntop(address->sa_family, + &((const struct sockaddr_in *) address)->sin_addr, + tmp, sizeof tmp) + : inet_ntop(address->sa_family, + &((const struct sockaddr_in6 *) address)->sin6_addr, + tmp, sizeof tmp)), (address->sa_family == AF_INET ? ntohs(((struct sockaddr_in *) address)->sin_port) : address->sa_family == AF_INET6 diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index 3057beb6e7..a1205cec52 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,6 +17,9 @@ 02111-1307 USA. */ +#include <limits.h> +#include <atomic.h> + #ifndef GETSP # warning "GETSP is not defined for this architecture." # define GETSP 0 @@ -33,3 +36,16 @@ high = usecs >> 32; \ } #endif + +#if LONG_BIT == 32 +# define memusage_cntr_t uatomic32_t +#else +# define memusage_cntr_t uatomic64_t +#endif +#ifndef memusage_size_t +# if LONG_BIT == 32 +# define memusage_size_t uatomic32_t +# else +# define memusage_size_t uatomic64_t +# endif +#endif diff --git a/sysdeps/i386/i686/memusage.h b/sysdeps/i386/i686/memusage.h new file mode 100644 index 0000000000..235c3fc725 --- /dev/null +++ b/sysdeps/i386/i686/memusage.h @@ -0,0 +1,22 @@ +/* Copyright (C) 2000, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; }) +#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high)) + +#include <sysdeps/generic/memusage.h> diff --git a/sysdeps/ia64/fpu/libm_error.c b/sysdeps/ia64/fpu/libm_error.c index 24fb406a53..8ef4bb5a73 100644 --- a/sysdeps/ia64/fpu/libm_error.c +++ b/sysdeps/ia64/fpu/libm_error.c @@ -81,8 +81,8 @@ // 12/13/04: Corrected POSIX behavior for exp2_overflow, exp2_underflow, // exp10_overflow, exp10_underflow. Added ISOC to set errno for // exp10_underflow. -// 12/14/04: Corrected POSIX behavior for nextafter_overflow, -// nextafter_underflow, nexttoward_overflow, nexttoward_underflow. +// 12/14/04: Corrected POSIX behavior for nextafter_overflow, +// nextafter_underflow, nexttoward_overflow, nexttoward_underflow. // Added ISOC to set errno for nextafter and nexttoward underflow. // 12/15/04: Corrected POSIX behavior for exp, exp2, and exp10 underflow. // 03/31/05: Added missing ALIGNIT statement to 6 float constants. @@ -674,7 +674,7 @@ else if(_LIB_VERSIONIMF==_ISOC_) ERRNO_DOMAIN; break; } default: - abort(); + break; } return; } @@ -1374,7 +1374,7 @@ switch(input_tag) ERRNO_RANGE; break; } default: - abort(); + break; } return; /* _POSIX_ */ diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 37be75e964..c5e1da03e9 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -24,7 +24,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ sys/quota.h sys/fsuid.h \ scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \ sys/ultrasound.h sys/raw.h sys/personality.h sys/epoll.h \ - bits/a.out.h + bits/a.out.h sys/inotify.h install-others += $(inst_includedir)/bits/syscall.h diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h new file mode 100644 index 0000000000..c498fe8f18 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sys/inotify.h @@ -0,0 +1,83 @@ +/* Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_INOTIFY_H +#define _SYS_INOTIFY_H 1 + +#include <stdint.h> + + +/* Structure describing an inotify event. */ +struct inotify_event +{ + int wd; /* Watch descriptor. */ + uint32_t mask; /* Watch mask. */ + uint32_t cookie; /* Cookie to synchronize two events. */ + uint32_t len; /* Length (including NULs) of name. */ + char name __flexarr; /* Name. */ +}; + + +/* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. */ +#define IN_ACCESS 0x00000001 /* File was accessed. */ +#define IN_MODIFY 0x00000002 /* File was modified. */ +#define IN_ATTRIB 0x00000004 /* Metadata changed. */ +#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed. */ +#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed. */ +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */ +#define IN_OPEN 0x00000020 /* File was opened. */ +#define IN_MOVED_FROM 0x00000040 /* File was moved from X. */ +#define IN_MOVED_TO 0x00000080 /* File was moved to Y. */ +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */ +#define IN_CREATE 0x00000100 /* Subfile was created. */ +#define IN_DELETE 0x00000200 /* Subfile was deleted. */ +#define IN_DELETE_SELF 0x00000400 /* Self was deleted. */ +#define IN_MOVE_SELF 0x00000800 /* Self was moved. */ + +/* Events sent by the kernel. */ +#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted. */ +#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed. */ +#define IN_IGNORED 0x00008000 /* File was ignored. */ + +/* Special flags. */ +#define IN_ISDIR 0x40000000 /* Event occurred against dir. */ +#define IN_ONESHOT 0x80000000 /* Only send event once. */ + +/* All events which a program can wait on. */ +#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE \ + | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM \ + | IN_MOVED_TO | IN_CREATE | IN_DELETE \ + | IN_DELETE_SELF | IN_MOVE_SELF) + + +__BEGIN_DECLS + +/* Create and initialize inotify instance. */ +extern int inotify_init (void) __THROW; + +/* Add watch of object NAME to inotify instance FD. Notify about + events specified by MASK. */ +extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask) + __THROW; + +/* Remove the watch specified by WD from the inotify instance FD. */ +extern int inotify_rm_watch (int __fd, uint32_t __wd) __THROW; + +__END_DECLS + +#endif /* sys/inotify.h */ diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index a97305e822..3dc8c5ec48 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -25,6 +25,9 @@ getresuid - getresuid i:ppp getresuid getresgid - getresgid i:ppp getresgid getsid - getsid i:i getsid init_module EXTRA init_module 5 init_module +inotify_add_watch EXTRA inotify_add_watch i:isi inotify_add_watch +inotify_init EXTRA inotify_init i: inotify_init +inotify_rm_watch EXTRA inotify_rm_watch i:ii inotify_rm_watch ioperm - ioperm i:iii ioperm iopl - iopl i:i iopl keyctl EXTRA keyctl i:iiiii keyctl |