[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r2917 - in /fsf/trunk/libc: ./ iconv/ io/ locale/programs/ nptl/ nptl/sysdeps/unix/sysv/linux/powerpc/ nptl/sysdeps/unix/sys...
- To: commits@xxxxxxxxxx
- Subject: [commits] r2917 - in /fsf/trunk/libc: ./ iconv/ io/ locale/programs/ nptl/ nptl/sysdeps/unix/sysv/linux/powerpc/ nptl/sysdeps/unix/sys...
- From: eglibc@xxxxxxxxxx
- Date: Tue, 24 Jul 2007 07:02:24 -0000
Author: eglibc
Date: Tue Jul 24 00:02:23 2007
New Revision: 2917
Log:
Import glibc-mainline for 2007-07-24
Added:
fsf/trunk/libc/io/tst-posix_fallocate.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/iconv/iconvconfig.c
fsf/trunk/libc/io/Makefile
fsf/trunk/libc/locale/programs/ld-collate.c
fsf/trunk/libc/nptl/ChangeLog
fsf/trunk/libc/nptl/pthread_rwlock_rdlock.c
fsf/trunk/libc/nptl/pthread_rwlock_wrlock.c
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Tue Jul 24 00:02:23 2007
@@ -1,3 +1,11 @@
+2007-07-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * io/Makefile (tests): Add tst-posix_fallocate.
+ * io/tst-posix_fallocate.c: New file.
+
+ * sysdeps/unix/sysv/linux/kernel-features.h: Define
+ __ASSUME_FALLOCATE.
+
2007-07-22 Roland McGrath <roland@xxxxxxxx>
* hurd/getdport.c: Add missing copyright year update.
Modified: fsf/trunk/libc/iconv/iconvconfig.c
==============================================================================
--- fsf/trunk/libc/iconv/iconvconfig.c (original)
+++ fsf/trunk/libc/iconv/iconvconfig.c Tue Jul 24 00:02:23 2007
@@ -1012,6 +1012,34 @@
module name offset
(following last entry with step count 0)
*/
+
+static struct hash_entry *hash_table;
+static size_t hash_size;
+
+/* Function to insert the names. */
+static void name_insert (const void *nodep, VISIT value, int level)
+{
+ struct name *name;
+ unsigned int idx;
+ unsigned int hval2;
+
+ if (value != leaf && value != postorder)
+ return;
+
+ name = *(struct name **) nodep;
+ idx = name->hashval % hash_size;
+ hval2 = 1 + name->hashval % (hash_size - 2);
+
+ while (hash_table[idx].string_offset != 0)
+ if ((idx += hval2) >= hash_size)
+ idx -= hash_size;
+
+ hash_table[idx].string_offset = strtaboffset (name->strent);
+
+ assert (name->module_idx != -1);
+ hash_table[idx].module_idx = name->module_idx;
+}
+
static int
write_output (void)
{
@@ -1019,8 +1047,6 @@
char *string_table;
size_t string_table_size;
struct gconvcache_header header;
- struct hash_entry *hash_table;
- size_t hash_size;
struct module_entry *module_table;
char *extra_table;
char *cur_extra_table;
@@ -1032,31 +1058,6 @@
char finalname[prefix_len + sizeof GCONV_MODULES_CACHE];
char tmpfname[(output_file == NULL ? sizeof finalname : output_file_len + 1)
+ strlen (".XXXXXX")];
-
- /* Function to insert the names. */
- auto void
- name_insert (const void *nodep, VISIT value, int level)
- {
- struct name *name;
- unsigned int idx;
- unsigned int hval2;
-
- if (value != leaf && value != postorder)
- return;
-
- name = *(struct name **) nodep;
- idx = name->hashval % hash_size;
- hval2 = 1 + name->hashval % (hash_size - 2);
-
- while (hash_table[idx].string_offset != 0)
- if ((idx += hval2) >= hash_size)
- idx -= hash_size;
-
- hash_table[idx].string_offset = strtaboffset (name->strent);
-
- assert (name->module_idx != -1);
- hash_table[idx].module_idx = name->module_idx;
- }
/* Open the output file. */
if (output_file == NULL)
Modified: fsf/trunk/libc/io/Makefile
==============================================================================
--- fsf/trunk/libc/io/Makefile (original)
+++ fsf/trunk/libc/io/Makefile Tue Jul 24 00:02:23 2007
@@ -67,7 +67,8 @@
tst-openat tst-unlinkat tst-fstatat tst-futimesat \
tst-renameat tst-fchownat tst-fchmodat tst-faccessat \
tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \
- tst-mknodat tst-mkfifoat tst-ttyname_r bug-ftw5
+ tst-mknodat tst-mkfifoat tst-ttyname_r bug-ftw5 \
+ tst-posix_fallocate
distribute := ftwtest-sh
Added: fsf/trunk/libc/io/tst-posix_fallocate.c
==============================================================================
--- fsf/trunk/libc/io/tst-posix_fallocate.c (added)
+++ fsf/trunk/libc/io/tst-posix_fallocate.c Tue Jul 24 00:02:23 2007
@@ -1,0 +1,99 @@
+#include <sys/stat.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static int fd;
+
+static void
+do_prepare (void)
+{
+ fd = create_temp_file ("tst-posix_fallocate.", NULL);
+ if (fd == -1)
+ {
+ printf ("cannot create temporary file: %m\n");
+ exit (1);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct stat64 st;
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("1st fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 0)
+ {
+ puts ("file not created with size 0");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 512, 768) != 0)
+ {
+ puts ("1st posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("2nd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ printf ("file size after first posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 512u + 768u);
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 0, 1024) != 0)
+ {
+ puts ("2nd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("3rd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ puts ("file size changed in second posix_fallocate");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 2048, 64) != 0)
+ {
+ puts ("3rd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("4th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 2048 + 64)
+ {
+ printf ("file size after first posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 2048u + 64u);
+ return 1;
+ }
+
+ close (fd);
+
+ return 0;
+}
Modified: fsf/trunk/libc/locale/programs/ld-collate.c
==============================================================================
--- fsf/trunk/libc/locale/programs/ld-collate.c (original)
+++ fsf/trunk/libc/locale/programs/ld-collate.c Tue Jul 24 00:02:23 2007
@@ -1936,6 +1936,137 @@
return retval | ((elem->section->ruleidx & 0x7f) << 24);
}
+/* If localedef is every threaded, this would need to be __thread var. */
+static struct
+{
+ struct obstack *weightpool;
+ struct obstack *extrapool;
+ struct obstack *indpool;
+ struct locale_collate_t *collate;
+ struct collidx_table *tablewc;
+} atwc;
+
+static void add_to_tablewc (uint32_t ch, struct element_t *runp);
+
+static void
+add_to_tablewc (uint32_t ch, struct element_t *runp)
+{
+ if (runp->wcnext == NULL && runp->nwcs == 1)
+ {
+ int32_t weigthidx = output_weightwc (atwc.weightpool, atwc.collate,
+ runp);
+ collidx_table_add (atwc.tablewc, ch, weigthidx);
+ }
+ else
+ {
+ /* As for the singlebyte table, we recognize sequences and
+ compress them. */
+ struct element_t *lastp;
+
+ collidx_table_add (atwc.tablewc, ch,
+ -(obstack_object_size (atwc.extrapool)
+ / sizeof (uint32_t)));
+
+ do
+ {
+ /* Store the current index in the weight table. We know that
+ the current position in the `extrapool' is aligned on a
+ 32-bit address. */
+ int32_t weightidx;
+ int added;
+
+ /* Find out wether this is a single entry or we have more than
+ one consecutive entry. */
+ if (runp->wcnext != NULL
+ && runp->nwcs == runp->wcnext->nwcs
+ && wmemcmp ((wchar_t *) runp->wcs,
+ (wchar_t *)runp->wcnext->wcs,
+ runp->nwcs - 1) == 0
+ && (runp->wcs[runp->nwcs - 1]
+ == runp->wcnext->wcs[runp->nwcs - 1] + 1))
+ {
+ int i;
+ struct element_t *series_startp = runp;
+ struct element_t *curp;
+
+ /* Now add first the initial byte sequence. */
+ added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
+ if (sizeof (int32_t) == sizeof (int))
+ obstack_make_room (atwc.extrapool, added);
+
+ /* More than one consecutive entry. We mark this by having
+ a negative index into the indirect table. */
+ obstack_int32_grow_fast (atwc.extrapool,
+ -(obstack_object_size (atwc.indpool)
+ / sizeof (int32_t)));
+ obstack_int32_grow_fast (atwc.extrapool, runp->nwcs - 1);
+
+ do
+ runp = runp->wcnext;
+ while (runp->wcnext != NULL
+ && runp->nwcs == runp->wcnext->nwcs
+ && wmemcmp ((wchar_t *) runp->wcs,
+ (wchar_t *)runp->wcnext->wcs,
+ runp->nwcs - 1) == 0
+ && (runp->wcs[runp->nwcs - 1]
+ == runp->wcnext->wcs[runp->nwcs - 1] + 1));
+
+ /* Now walk backward from here to the beginning. */
+ curp = runp;
+
+ for (i = 1; i < runp->nwcs; ++i)
+ obstack_int32_grow_fast (atwc.extrapool, curp->wcs[i]);
+
+ /* Now find the end of the consecutive sequence and
+ add all the indeces in the indirect pool. */
+ do
+ {
+ weightidx = output_weightwc (atwc.weightpool, atwc.collate,
+ curp);
+ obstack_int32_grow (atwc.indpool, weightidx);
+
+ curp = curp->wclast;
+ }
+ while (curp != series_startp);
+
+ /* Add the final weight. */
+ weightidx = output_weightwc (atwc.weightpool, atwc.collate,
+ curp);
+ obstack_int32_grow (atwc.indpool, weightidx);
+
+ /* And add the end byte sequence. Without length this
+ time. */
+ for (i = 1; i < curp->nwcs; ++i)
+ obstack_int32_grow (atwc.extrapool, curp->wcs[i]);
+ }
+ else
+ {
+ /* A single entry. Simply add the index and the length and
+ string (except for the first character which is already
+ tested for). */
+ int i;
+
+ /* Output the weight info. */
+ weightidx = output_weightwc (atwc.weightpool, atwc.collate,
+ runp);
+
+ added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
+ if (sizeof (int) == sizeof (int32_t))
+ obstack_make_room (atwc.extrapool, added);
+
+ obstack_int32_grow_fast (atwc.extrapool, weightidx);
+ obstack_int32_grow_fast (atwc.extrapool, runp->nwcs - 1);
+ for (i = 1; i < runp->nwcs; ++i)
+ obstack_int32_grow_fast (atwc.extrapool, runp->wcs[i]);
+ }
+
+ /* Next entry. */
+ lastp = runp;
+ runp = runp->wcnext;
+ }
+ while (runp != NULL);
+ }
+}
void
collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
@@ -2293,132 +2424,21 @@
with the same wide character and add them one after the other to
the table. In case we have more than one sequence starting with
the same byte we have to use extra indirection. */
- {
- auto void add_to_tablewc (uint32_t ch, struct element_t *runp);
-
- void add_to_tablewc (uint32_t ch, struct element_t *runp)
- {
- if (runp->wcnext == NULL && runp->nwcs == 1)
- {
- int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
- collidx_table_add (&tablewc, ch, weigthidx);
- }
- else
- {
- /* As for the singlebyte table, we recognize sequences and
- compress them. */
- struct element_t *lastp;
-
- collidx_table_add (&tablewc, ch,
- -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
-
- do
- {
- /* Store the current index in the weight table. We know that
- the current position in the `extrapool' is aligned on a
- 32-bit address. */
- int32_t weightidx;
- int added;
-
- /* Find out wether this is a single entry or we have more than
- one consecutive entry. */
- if (runp->wcnext != NULL
- && runp->nwcs == runp->wcnext->nwcs
- && wmemcmp ((wchar_t *) runp->wcs,
- (wchar_t *)runp->wcnext->wcs,
- runp->nwcs - 1) == 0
- && (runp->wcs[runp->nwcs - 1]
- == runp->wcnext->wcs[runp->nwcs - 1] + 1))
- {
- int i;
- struct element_t *series_startp = runp;
- struct element_t *curp;
-
- /* Now add first the initial byte sequence. */
- added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
- if (sizeof (int32_t) == sizeof (int))
- obstack_make_room (&extrapool, added);
-
- /* More than one consecutive entry. We mark this by having
- a negative index into the indirect table. */
- obstack_int32_grow_fast (&extrapool,
- -(obstack_object_size (&indirectpool)
- / sizeof (int32_t)));
- obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
-
- do
- runp = runp->wcnext;
- while (runp->wcnext != NULL
- && runp->nwcs == runp->wcnext->nwcs
- && wmemcmp ((wchar_t *) runp->wcs,
- (wchar_t *)runp->wcnext->wcs,
- runp->nwcs - 1) == 0
- && (runp->wcs[runp->nwcs - 1]
- == runp->wcnext->wcs[runp->nwcs - 1] + 1));
-
- /* Now walk backward from here to the beginning. */
- curp = runp;
-
- for (i = 1; i < runp->nwcs; ++i)
- obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
-
- /* Now find the end of the consecutive sequence and
- add all the indeces in the indirect pool. */
- do
- {
- weightidx = output_weightwc (&weightpool, collate,
- curp);
- obstack_int32_grow (&indirectpool, weightidx);
-
- curp = curp->wclast;
- }
- while (curp != series_startp);
-
- /* Add the final weight. */
- weightidx = output_weightwc (&weightpool, collate, curp);
- obstack_int32_grow (&indirectpool, weightidx);
-
- /* And add the end byte sequence. Without length this
- time. */
- for (i = 1; i < curp->nwcs; ++i)
- obstack_int32_grow (&extrapool, curp->wcs[i]);
- }
- else
- {
- /* A single entry. Simply add the index and the length and
- string (except for the first character which is already
- tested for). */
- int i;
-
- /* Output the weight info. */
- weightidx = output_weightwc (&weightpool, collate, runp);
-
- added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
- if (sizeof (int) == sizeof (int32_t))
- obstack_make_room (&extrapool, added);
-
- obstack_int32_grow_fast (&extrapool, weightidx);
- obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
- for (i = 1; i < runp->nwcs; ++i)
- obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
- }
-
- /* Next entry. */
- lastp = runp;
- runp = runp->wcnext;
- }
- while (runp != NULL);
- }
- }
-
- tablewc.p = 6;
- tablewc.q = 10;
- collidx_table_init (&tablewc);
-
- wchead_table_iterate (&collate->wcheads, add_to_tablewc);
-
- collidx_table_finalize (&tablewc);
- }
+ tablewc.p = 6;
+ tablewc.q = 10;
+ collidx_table_init (&tablewc);
+
+ atwc.weightpool = &weightpool;
+ atwc.extrapool = &extrapool;
+ atwc.indpool = &indirectpool;
+ atwc.collate = collate;
+ atwc.tablewc = &tablewc;
+
+ wchead_table_iterate (&collate->wcheads, add_to_tablewc);
+
+ memset (&atwc, 0, sizeof (atwc));
+
+ collidx_table_finalize (&tablewc);
/* Now add the four tables. */
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEWC));
Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Tue Jul 24 00:02:23 2007
@@ -1,3 +1,61 @@
+2007-07-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: Fix
+ code used when private futexes are assumed.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+
+2007-07-23 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (__lll_private_flag): Define.
+ (lll_futex_wait): Define as a wrapper around lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake, lll_futex_wake_unlock): Use
+ __lll_private_flag.
+ (lll_private_futex_wait, lll_private_futex_timedwait,
+ lll_private_futex_wake): Define as wrapper around non-_private
+ macros.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (__lll_private_flag): Define.
+ (lll_futex_timed_wait, lll_futex_wake): Use __lll_private_flag.
+ (lll_private_futex_wait, lll_private_futex_timedwait,
+ lll_private_futex_wake): Define as wrapper around non-_private
+ macros.
+
+2007-07-10 Steven Munroe <sjmunroe@xxxxxxxxxx>
+
+ * pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Add LLL_SHARED
+ parameter to lll_futex_wait call.
+ * pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock): Likewise.
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c (__pthread_once):
+ Replace lll_futex_wait with lll_private_futex_wait.
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c (__new_sem_post):
+ Add LLL_SHARED parameter to lll_futex_wake().
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Define LLL_PRIVATE
+ LLL_SHARED, lll_private_futex_wait, lll_private_futex_timed_wait and
+ lll_private_futex_wake.
+ (lll_futex_wait): Add private parameter. Adjust FUTEX_PRIVATE_FLAG
+ bit from private parm before syscall.
+ (lll_futex_timed_wait): Likewise.
+ (lll_futex_wake): Likewise.
+ (lll_futex_wake_unlock): Likewise.
+ (lll_mutex_unlock): Add LLL_SHARED parm to lll_futex_wake call.
+ (lll_robust_mutex_unlock): Likewise.
+ (lll_mutex_unlock_force): Likewise.
+ (lll_wait_tid): Add LLL_SHARED parm to lll_futex_wait call.
+
+2007-07-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: Fix
+ compilation when unconditionally using private futexes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+
2007-07-17 Jakub Jelinek <jakub@xxxxxxxxxx>
* sysdeps/pthread/bits/stdio-lock.h (_IO_acquire_lock_clear_flags2):
Modified: fsf/trunk/libc/nptl/pthread_rwlock_rdlock.c
==============================================================================
--- fsf/trunk/libc/nptl/pthread_rwlock_rdlock.c (original)
+++ fsf/trunk/libc/nptl/pthread_rwlock_rdlock.c Tue Jul 24 00:02:23 2007
@@ -77,7 +77,9 @@
lll_mutex_unlock (rwlock->__data.__lock);
/* Wait for the writer to finish. */
- lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval);
+ lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval,
+ // XYZ check mutex flag
+ LLL_SHARED);
/* Get the lock. */
lll_mutex_lock (rwlock->__data.__lock);
Modified: fsf/trunk/libc/nptl/pthread_rwlock_wrlock.c
==============================================================================
--- fsf/trunk/libc/nptl/pthread_rwlock_wrlock.c (original)
+++ fsf/trunk/libc/nptl/pthread_rwlock_wrlock.c Tue Jul 24 00:02:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Martin Schwidefsky <schwidefsky@xxxxxxxxxx>, 2003.
@@ -68,7 +68,9 @@
lll_mutex_unlock (rwlock->__data.__lock);
/* Wait for the writer or reader(s) to finish. */
- lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval);
+ lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval,
+ // XYZ check mutex flag
+ LLL_SHARED);
/* Get the lock. */
lll_mutex_lock (rwlock->__data.__lock);
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h Tue Jul 24 00:02:23 2007
@@ -39,37 +39,61 @@
#define FUTEX_TRYLOCK_PI 8
#define FUTEX_PRIVATE_FLAG 128
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
-#define lll_futex_wait(futexp, val) \
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait (futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
\
- __ret = INTERNAL_SYSCALL (futex, __err, 4, \
- (futexp), FUTEX_WAIT, (val), 0); \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
})
-#define lll_futex_timed_wait(futexp, val, timespec) \
+#define lll_futex_wake(futexp, nr, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
\
- __ret = INTERNAL_SYSCALL (futex, __err, 4, \
- (futexp), FUTEX_WAIT, (val), (timespec)); \
- INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
- })
-
-#define lll_futex_wake(futexp, nr) \
- ({ \
- INTERNAL_SYSCALL_DECL (__err); \
- long int __ret; \
- \
- __ret = INTERNAL_SYSCALL (futex, __err, 4, \
- (futexp), FUTEX_WAKE, (nr), 0); \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
})
@@ -97,17 +121,27 @@
})
/* Returns non-zero if error happened, zero if success. */
-#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
\
- __ret = INTERNAL_SYSCALL (futex, __err, 6, \
- (futexp), FUTEX_WAKE_OP, (nr_wake), \
- (nr_wake2), (futexp2), \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+
+
+#define lll_private_futex_wait(futexp, val) \
+ lll_futex_timed_wait (futexp, val, NULL, LLL_PRIVATE)
+
+#define lll_private_futex_timed_wait(futexp, val, timeout) \
+ lll_futex_timed_wait (futexp, val, timeout, LLL_PRIVATE)
+
+#define lll_private_futex_wake(futexp, val) \
+ lll_futex_wake (futexp, val, LLL_PRIVATE)
#ifdef UP
# define __lll_acq_instr ""
@@ -230,7 +264,7 @@
int *__futex = &(lock); \
int __val = atomic_exchange_rel (__futex, 0); \
if (__builtin_expect (__val > 1, 0)) \
- lll_futex_wake (__futex, 1); \
+ lll_futex_wake (__futex, 1, LLL_SHARED); \
}))
#define lll_robust_mutex_unlock(lock) \
@@ -238,7 +272,7 @@
int *__futex = &(lock); \
int __val = atomic_exchange_rel (__futex, 0); \
if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
- lll_futex_wake (__futex, 1); \
+ lll_futex_wake (__futex, 1, LLL_SHARED); \
}))
#define lll_mutex_unlock_force(lock) \
@@ -246,7 +280,7 @@
int *__futex = &(lock); \
*__futex = 0; \
__asm __volatile (__lll_rel_instr ::: "memory"); \
- lll_futex_wake (__futex, 1); \
+ lll_futex_wake (__futex, 1, LLL_SHARED); \
}))
#define lll_mutex_islocked(futex) \
@@ -281,7 +315,7 @@
do { \
__typeof (tid) __tid; \
while ((__tid = (tid)) != 0) \
- lll_futex_wait (&(tid), __tid); \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
} while (0)
extern int __lll_timedwait_tid (int *, const struct timespec *)
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c Tue Jul 24 00:02:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@xxxxxxxxxx>, 2003.
@@ -30,7 +30,7 @@
pthread_once_t *once_control = (pthread_once_t *) arg;
*once_control = 0;
- lll_futex_wake (once_control, INT_MAX);
+ lll_private_futex_wake (once_control, INT_MAX);
}
@@ -74,7 +74,7 @@
break;
/* Same generation, some other thread was faster. Wait. */
- lll_futex_wait (once_control, oldval);
+ lll_private_futex_wait (once_control, oldval);
}
@@ -92,7 +92,7 @@
atomic_increment (once_control);
/* Wake up all other threads. */
- lll_futex_wake (once_control, INT_MAX);
+ lll_private_futex_wake (once_control, INT_MAX);
return 0;
}
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c Tue Jul 24 00:02:23 2007
@@ -1,5 +1,5 @@
/* sem_post -- post to a POSIX semaphore. Powerpc version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@xxxxxxxxxx>, 2003.
@@ -33,7 +33,7 @@
__asm __volatile (__lll_rel_instr ::: "memory");
int nr = atomic_increment_val (futex);
- int err = lll_futex_wake (futex, nr);
+ int err = lll_futex_wake (futex, nr, LLL_SHARED);
if (__builtin_expect (err, 0) < 0)
{
__set_errno (-err);
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h Tue Jul 24 00:02:23 2007
@@ -50,6 +50,31 @@
#define LLL_PRIVATE 0
#define LLL_SHARED FUTEX_PRIVATE_FLAG
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
+ asm ("andl %%fs:%P1, %0" : "+r" (__fl) \
+ : "i" offsetof (struct pthread, header.private_futex)); \
+ __fl | (fl); })
+# endif
+#endif
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -169,7 +194,8 @@
register __typeof (val) _val __asm ("edx") = (val); \
__asm __volatile ("syscall" \
: "=a" (__status) \
- : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (__lll_private_flag (FUTEX_WAIT, private)), \
"d" (_val), "r" (__to) \
: "memory", "cc", "r11", "cx"); \
__status; \
@@ -182,73 +208,21 @@
register __typeof (nr) _nr __asm ("edx") = (nr); \
__asm __volatile ("syscall" \
: "=a" (__ignore) \
- : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (__lll_private_flag (FUTEX_WAKE, private)), \
"d" (_nr) \
: "memory", "cc", "r10", "r11", "cx"); \
} while (0)
#define lll_private_futex_wait(futex, val) \
- lll_private_futex_timed_wait (futex, val, NULL)
-
-
-#ifdef __ASSUME_PRIVATE_FUTEX
-# define lll_private_futex_timed_wait(futex, val, timeout) \
- ({ \
- register const struct timespec *__to __asm ("r10") = timeout; \
- int __status; \
- register __typeof (val) _val __asm ("edx") = (val); \
- __asm __volatile ("syscall" \
- : "=a" (__status) \
- : "0" (SYS_futex), "D" (futex), \
- "S" (FUTEX_WAIT | FUTEX_PRIVATE_FLAG), \
- "d" (_val), "r" (__to) \
- : "memory", "cc", "r11", "cx"); \
- __status; \
- })
-
-
-# define lll_private_futex_wake(futex, nr) \
- do { \
- int __ignore; \
- register __typeof (nr) _nr __asm ("edx") = (nr); \
- __asm __volatile ("syscall" \
- : "=a" (__ignore) \
- : "0" (SYS_futex), "D" (futex), \
- "S" (FUTEX_WAKE | FUTEX_PRIVATE_FLAG), \
- "d" (_nr) \
- : "memory", "cc", "r10", "r11", "cx"); \
- } while (0)
-#else
-# define lll_private_futex_timed_wait(futex, val, timeout) \
- ({ \
- register const struct timespec *__to __asm ("r10") = timeout; \
- int __status; \
- int __ignore; \
- register __typeof (val) _val __asm ("edx") = (val); \
- __asm __volatile ("movl %%fs:%P3, %%esi\n\t" \
- "syscall" \
- : "=a" (__status), "=S" (__ignore) \
- : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \
- "d" (_val), "r" (__to) \
- : "memory", "cc", "r11", "cx"); \
- __status; \
- })
-
-
-# define lll_private_futex_wake(futex, nr) \
- do { \
- int __ignore; \
- int __ignore2; \
- register __typeof (nr) _nr __asm ("edx") = (nr); \
- __asm __volatile ("orl %%fs:%P3, %%esi\n\t" \
- "syscall" \
- : "=a" (__ignore), "=S" (__ignore2) \
- : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \
- "1" (FUTEX_WAKE), "d" (_nr) \
- : "memory", "cc", "r10", "r11", "cx"); \
- } while (0)
-#endif
+ lll_futex_timed_wait (futex, val, NULL, LLL_PRIVATE)
+
+#define lll_private_futex_timed_wait(futex, val, timeout) \
+ lll_futex_timed_wait (futex, val, timeout, LLL_PRIVATE)
+
+#define lll_private_futex_wake(futex, nr) \
+ lll_futex_wake (futex, nr, LLL_PRIVATE)
/* Does not preserve %eax and %ecx. */
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S Tue Jul 24 00:02:23 2007
@@ -76,7 +76,7 @@
jne 10f
11:
-#if __ASSUME_PRIVATE_FUTEX
+#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
xorl PSHARED(%rdi), %esi
#else
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S Tue Jul 24 00:02:23 2007
@@ -20,11 +20,13 @@
#include <sysdep.h>
#include <lowlevelrwlock.h>
#include <pthread-errnos.h>
+#include <kernel-features.h>
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_PRIVATE_FLAG 128
/* For the calculation see asm/vsyscall.h. */
#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
@@ -112,9 +114,9 @@
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
-#if __ASSUME_PRIVATE_FUTEX
+#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
- xorl PSHARED(%rdi), %esi
+ xorl PSHARED(%r12), %esi
#else
# if FUTEX_WAIT == 0
movl PSHARED(%r12), %esi
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S Tue Jul 24 00:02:23 2007
@@ -20,11 +20,13 @@
#include <sysdep.h>
#include <lowlevelrwlock.h>
#include <pthread-errnos.h>
+#include <kernel-features.h>
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_PRIVATE_FLAG 128
/* For the calculation see asm/vsyscall.h. */
#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
@@ -108,9 +110,9 @@
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
-#if __ASSUME_PRIVATE_FUTEX
+#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
- xorl PSHARED(%rdi), %esi
+ xorl PSHARED(%r12), %esi
#else
# if FUTEX_WAIT == 0
movl PSHARED(%r12), %esi
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S Tue Jul 24 00:02:23 2007
@@ -19,11 +19,13 @@
#include <sysdep.h>
#include <lowlevelrwlock.h>
+#include <kernel-features.h>
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_PRIVATE_FLAG 128
#ifndef UP
# define LOCK lock
@@ -78,7 +80,7 @@
jne 7f
8:
-#if __ASSUME_PRIVATE_FUTEX
+#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_PRIVATE_FLAG|FUTEX_WAKE, %esi
xorl PSHARED(%rdi), %esi
#else
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S Tue Jul 24 00:02:23 2007
@@ -20,11 +20,13 @@
#include <sysdep.h>
#include <lowlevelrwlock.h>
#include <pthread-errnos.h>
+#include <kernel-features.h>
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_PRIVATE_FLAG 128
#ifndef UP
# define LOCK lock
@@ -72,7 +74,7 @@
jne 10f
11:
-#if __ASSUME_PRIVATE_FUTEX
+#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
xorl PSHARED(%rdi), %esi
#else
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h Tue Jul 24 00:02:23 2007
@@ -468,3 +468,8 @@
#if __LINUX_KERNEL_VERSION >= 0x020616
# define __ASSUME_PRIVATE_FUTEX 1
#endif
+
+/* Support for fallocate was added in 2.6.23. */
+#if __LINUX_KERNEL_VERSION >= 0x020617
+# define __ASSUME_FALLOCATE 1
+#endif