mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-18 06:30:05 +00:00
* iconvdata/gbk.c (BODY): Make buf and cp char instead of unsigned
char array resp. pointer. * iconvdata/iso-2022-kr.c (BODY): Make buf unsigned char instead of char array. * iconvdata/cns11643.h (cns11643_to_ucs4): Change first argument to const unsigned char **. (ucs4_to_cns11643): Change second argument to unsigned char *. * iconvdata/euc-tw.c (BODY): Change endp type to const unsigned char *. * iconvdata/iso-ir-165.h (ucs4_to_isoir165): Change second argument to unsigned char *. * iconvdata/ibm1008_420.c (LOOP_NEED_FLAGS): Don't define. * iconvdata/iso-2022-cn.c (BODY): Change buf to unsigned char array. * iconvdata/iso-2022-cn-ext.c (BODY): Change buf, tmpbuf, tmp types to unsigned char pointers/arrays instead of char. * iconvdata/jis0201.h (ucs4_to_jisx0201): Change second argument to unsigned char *. * iconvdata/jis0208.h (ucs4_to_jisx0208): Likewise. * iconvdata/jis0212.h: Include assert.h. (ucs4_to_jisx0212): Change second argument to unsigned char *. assert that if cp[0] is not '\0', cp[1] is not '\0' either instead of trying to handle that. * iconvdata/euc-kr.c (euckr_from_ucs4): Initialize also cp[1] to shut up a warning. * iconvdata/euc-jp-ms.c (from_ucs4_lat1, from_ucs4_greek, from_ucs4_cjk, from_ucs4_cjkcpt, from_ucs4_extra): Change type to two dimensional const unsigned char arrays. (BODY): Cast "" to (const unsigned char *) for assignment to cp. Initialize endp to inptr to shut up a warning.
This commit is contained in:
parent
ae1ad762f0
commit
085a441220
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
|||||||
|
2007-07-26 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* iconvdata/gbk.c (BODY): Make buf and cp char instead of unsigned
|
||||||
|
char array resp. pointer.
|
||||||
|
* iconvdata/iso-2022-kr.c (BODY): Make buf unsigned char instead of
|
||||||
|
char array.
|
||||||
|
* iconvdata/cns11643.h (cns11643_to_ucs4): Change first argument
|
||||||
|
to const unsigned char **.
|
||||||
|
(ucs4_to_cns11643): Change second argument to unsigned char *.
|
||||||
|
* iconvdata/euc-tw.c (BODY): Change endp type to
|
||||||
|
const unsigned char *.
|
||||||
|
* iconvdata/iso-ir-165.h (ucs4_to_isoir165): Change second argument
|
||||||
|
to unsigned char *.
|
||||||
|
* iconvdata/ibm1008_420.c (LOOP_NEED_FLAGS): Don't define.
|
||||||
|
* iconvdata/iso-2022-cn.c (BODY): Change buf to unsigned char array.
|
||||||
|
* iconvdata/iso-2022-cn-ext.c (BODY): Change buf, tmpbuf, tmp
|
||||||
|
types to unsigned char pointers/arrays instead of char.
|
||||||
|
* iconvdata/jis0201.h (ucs4_to_jisx0201): Change second argument
|
||||||
|
to unsigned char *.
|
||||||
|
* iconvdata/jis0208.h (ucs4_to_jisx0208): Likewise.
|
||||||
|
* iconvdata/jis0212.h: Include assert.h.
|
||||||
|
(ucs4_to_jisx0212): Change second argument to unsigned char *.
|
||||||
|
assert that if cp[0] is not '\0', cp[1] is not '\0' either instead
|
||||||
|
of trying to handle that.
|
||||||
|
* iconvdata/euc-kr.c (euckr_from_ucs4): Initialize also cp[1] to
|
||||||
|
shut up a warning.
|
||||||
|
* iconvdata/euc-jp-ms.c (from_ucs4_lat1, from_ucs4_greek,
|
||||||
|
from_ucs4_cjk, from_ucs4_cjkcpt, from_ucs4_extra): Change type to
|
||||||
|
two dimensional const unsigned char arrays.
|
||||||
|
(BODY): Cast "" to (const unsigned char *) for assignment to cp.
|
||||||
|
Initialize endp to inptr to shut up a warning.
|
||||||
|
|
||||||
2007-07-20 Jakub Jelinek <jakub@redhat.com>
|
2007-07-20 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
[BZ #4772]
|
[BZ #4772]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Access functions for CNS 11643 handling.
|
/* Access functions for CNS 11643 handling.
|
||||||
Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
|
Copyright (C) 1998,1999,2000,2001,2002,2003,2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ extern const uint32_t __cns11643l15_to_ucs4_tab[];
|
|||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
cns11643_to_ucs4 (const char **s, size_t avail, unsigned char offset)
|
cns11643_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
|
||||||
{
|
{
|
||||||
unsigned char ch = *(*s);
|
unsigned char ch = *(*s);
|
||||||
unsigned char ch2;
|
unsigned char ch2;
|
||||||
@ -142,7 +143,7 @@ extern const char __cns11643_from_ucs4p2c_tab[][3];
|
|||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
ucs4_to_cns11643 (uint32_t wch, char *s, size_t avail)
|
ucs4_to_cns11643 (uint32_t wch, unsigned char *s, size_t avail)
|
||||||
{
|
{
|
||||||
unsigned int ch = (unsigned int) wch;
|
unsigned int ch = (unsigned int) wch;
|
||||||
char buf[2];
|
char buf[2];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Mapping tables for EUCJP-MS handling.
|
/* Mapping tables for EUCJP-MS handling.
|
||||||
Copyright (C) 1998,1999,2000,2001,2003 Free Software Foundation, Inc.
|
Copyright (C) 1998,1999,2000,2001,2003,2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by MORIYAMA Masayuki <msyk@mtg.biglobe.ne.jp>, 2003.
|
Contributed by MORIYAMA Masayuki <msyk@mtg.biglobe.ne.jp>, 2003.
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ static const uint16_t cjk_block_ibm[268] =
|
|||||||
/* 0x8ff4fd */ 0xfa2d, 0x9ed1
|
/* 0x8ff4fd */ 0xfa2d, 0x9ed1
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char from_ucs4_lat1[256][2] =
|
static const unsigned char from_ucs4_lat1[256][2] =
|
||||||
{
|
{
|
||||||
/* start = 0x0000, end = 0x00ff */
|
/* start = 0x0000, end = 0x00ff */
|
||||||
[ 0] = "\x00\x00", [ 1] = "\x01\x00", [ 2] = "\x02\x00",
|
[ 0] = "\x00\x00", [ 1] = "\x01\x00", [ 2] = "\x02\x00",
|
||||||
@ -244,7 +244,7 @@ static const char from_ucs4_lat1[256][2] =
|
|||||||
[ 255] = "\xab\x73"
|
[ 255] = "\xab\x73"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char from_ucs4_greek[864][2] =
|
static const unsigned char from_ucs4_greek[864][2] =
|
||||||
{
|
{
|
||||||
/* start = 0x0100, end = 0x045f */
|
/* start = 0x0100, end = 0x045f */
|
||||||
[ 0] = "\xaa\x27", [ 1] = "\xab\x27", [ 2] = "\xaa\x25",
|
[ 0] = "\xaa\x27", [ 1] = "\xab\x27", [ 2] = "\xaa\x25",
|
||||||
@ -351,7 +351,7 @@ static const char from_ucs4_greek[864][2] =
|
|||||||
[ 860] = "\xa7\x7c", [ 862] = "\xa7\x7d", [ 863] = "\xa7\x7e"
|
[ 860] = "\xa7\x7c", [ 862] = "\xa7\x7d", [ 863] = "\xa7\x7e"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char from_ucs4_cjk[32662][2] =
|
static const unsigned char from_ucs4_cjk[32662][2] =
|
||||||
{
|
{
|
||||||
/* start = 0x2010, end = 0x9fa5 */
|
/* start = 0x2010, end = 0x9fa5 */
|
||||||
[ 0] = "\xa1\xbe", [ 4] = "\xa1\xbd", [ 5] = "\xa1\xbd",
|
[ 0] = "\xa1\xbe", [ 4] = "\xa1\xbd", [ 5] = "\xa1\xbd",
|
||||||
@ -4556,7 +4556,7 @@ static const char from_ucs4_cjk[32662][2] =
|
|||||||
[32661] = "\xed\x63"
|
[32661] = "\xed\x63"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char from_ucs4_cjkcpt[261][2] =
|
static const unsigned char from_ucs4_cjkcpt[261][2] =
|
||||||
{
|
{
|
||||||
/* start = 0xf929, end = 0xfa2d */
|
/* start = 0xf929, end = 0xfa2d */
|
||||||
[ 0] = "\xf4\x45", [ 179] = "\xf4\x72", [ 229] = "\xf4\x34",
|
[ 0] = "\xf4\x45", [ 179] = "\xf4\x72", [ 229] = "\xf4\x34",
|
||||||
@ -4573,7 +4573,7 @@ static const char from_ucs4_cjkcpt[261][2] =
|
|||||||
[ 260] = "\xf4\x7d"
|
[ 260] = "\xf4\x7d"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char from_ucs4_extra[229][2] =
|
static const unsigned char from_ucs4_extra[229][2] =
|
||||||
{
|
{
|
||||||
/* start = 0xff01, end = 0xffe5 */
|
/* start = 0xff01, end = 0xffe5 */
|
||||||
[ 0] = "\xa1\xaa", [ 1] = "\xf4\x2a", [ 2] = "\xa1\xf4",
|
[ 0] = "\xa1\xaa", [ 1] = "\xf4\x2a", [ 2] = "\xa1\xf4",
|
||||||
@ -4719,7 +4719,7 @@ static const char from_ucs4_extra[229][2] =
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
const unsigned char *endp; \
|
const unsigned char *endp = inptr; \
|
||||||
int mblen = 1; \
|
int mblen = 1; \
|
||||||
\
|
\
|
||||||
if (__builtin_expect(ch == 0x8f, 0)) \
|
if (__builtin_expect(ch == 0x8f, 0)) \
|
||||||
@ -4758,7 +4758,7 @@ static const char from_ucs4_extra[229][2] =
|
|||||||
ch = __UNKNOWN_10646_CHAR; \
|
ch = __UNKNOWN_10646_CHAR; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
ch = __UNKNOWN_10646_CHAR; \
|
ch = __UNKNOWN_10646_CHAR; \
|
||||||
} \
|
} \
|
||||||
else if (ch2 <= 0xfe) \
|
else if (ch2 <= 0xfe) \
|
||||||
{ \
|
{ \
|
||||||
@ -4766,7 +4766,7 @@ static const char from_ucs4_extra[229][2] =
|
|||||||
endp = inptr + mblen; \
|
endp = inptr + mblen; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
ch = __UNKNOWN_10646_CHAR; \
|
ch = __UNKNOWN_10646_CHAR; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else if (__builtin_expect(0xa1 <= ch, 1)) \
|
else if (__builtin_expect(0xa1 <= ch, 1)) \
|
||||||
@ -4804,10 +4804,10 @@ static const char from_ucs4_extra[229][2] =
|
|||||||
endp = inptr + mblen; \
|
endp = inptr + mblen; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
ch = __UNKNOWN_10646_CHAR; \
|
ch = __UNKNOWN_10646_CHAR; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
ch = __UNKNOWN_10646_CHAR; \
|
ch = __UNKNOWN_10646_CHAR; \
|
||||||
\
|
\
|
||||||
if (__builtin_expect (ch, 1) == 0) \
|
if (__builtin_expect (ch, 1) == 0) \
|
||||||
{ \
|
{ \
|
||||||
@ -4880,7 +4880,7 @@ static const char from_ucs4_extra[229][2] =
|
|||||||
{ \
|
{ \
|
||||||
UNICODE_TAG_HANDLER (ch, 4); \
|
UNICODE_TAG_HANDLER (ch, 4); \
|
||||||
/* Illegal character. */ \
|
/* Illegal character. */ \
|
||||||
cp = ""; \
|
cp = (const unsigned char *) ""; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Mapping tables for EUC-KR handling.
|
/* Mapping tables for EUC-KR handling.
|
||||||
Copyright (C) 1998, 1999, 2000-2002, 2003 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2000-2002, 2003, 2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>
|
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>
|
||||||
and Ulrich Drepper <drepper@cygnus.com>, 1998.
|
and Ulrich Drepper <drepper@cygnus.com>, 1998.
|
||||||
@ -46,7 +47,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
|
|||||||
cp[1] |= 0x80;
|
cp[1] |= 0x80;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cp[0] = '\0';
|
cp[0] = cp[1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Mapping tables for EUC-TW handling.
|
/* Mapping tables for EUC-TW handling.
|
||||||
Copyright (C) 1998, 1999, 2000-2002, 2003 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2000-2002, 2003, 2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
||||||
|
|
||||||
@ -74,7 +75,7 @@
|
|||||||
if (ch == 0x8e) \
|
if (ch == 0x8e) \
|
||||||
{ \
|
{ \
|
||||||
/* This is code set 2: CNS 11643, planes 1 to 16. */ \
|
/* This is code set 2: CNS 11643, planes 1 to 16. */ \
|
||||||
const char *endp = inptr + 1; \
|
const unsigned char *endp = inptr + 1; \
|
||||||
\
|
\
|
||||||
ch = cns11643_to_ucs4 (&endp, inend - inptr - 1, 0x80); \
|
ch = cns11643_to_ucs4 (&endp, inend - inptr - 1, 0x80); \
|
||||||
\
|
\
|
||||||
|
@ -13213,8 +13213,8 @@ static const char __gbk_from_ucs4_tab12[][2] =
|
|||||||
#define BODY \
|
#define BODY \
|
||||||
{ \
|
{ \
|
||||||
uint32_t ch = get32 (inptr); \
|
uint32_t ch = get32 (inptr); \
|
||||||
unsigned char buf[2]; \
|
char buf[2]; \
|
||||||
const unsigned char *cp = buf; \
|
const char *cp = buf; \
|
||||||
\
|
\
|
||||||
if (ch <= L'\x7f') \
|
if (ch <= L'\x7f') \
|
||||||
/* It's plain ASCII. */ \
|
/* It's plain ASCII. */ \
|
||||||
|
@ -176,7 +176,6 @@ static const char __from_ibm420_to_ibm1008[256] =
|
|||||||
*outptr++ = ch; \
|
*outptr++ = ch; \
|
||||||
++inptr; \
|
++inptr; \
|
||||||
}
|
}
|
||||||
#define LOOP_NEED_FLAGS
|
|
||||||
#include <iconv/loop.c>
|
#include <iconv/loop.c>
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +189,6 @@ static const char __from_ibm420_to_ibm1008[256] =
|
|||||||
*outptr++ = ch; \
|
*outptr++ = ch; \
|
||||||
++inptr; \
|
++inptr; \
|
||||||
}
|
}
|
||||||
#define LOOP_NEED_FLAGS
|
|
||||||
#include <iconv/loop.c>
|
#include <iconv/loop.c>
|
||||||
|
|
||||||
/* Now define the toplevel functions. */
|
/* Now define the toplevel functions. */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Conversion module for ISO-2022-CN-EXT.
|
/* Conversion module for ISO-2022-CN-EXT.
|
||||||
Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 2000-2002, 2004, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||||
|
|
||||||
@ -304,8 +304,8 @@ enum
|
|||||||
{ \
|
{ \
|
||||||
/* This is a character from CNS 11643 plane 3 or higher. \
|
/* This is a character from CNS 11643 plane 3 or higher. \
|
||||||
XXX Currently GB7590 and GB13132 are not supported. */ \
|
XXX Currently GB7590 and GB13132 are not supported. */ \
|
||||||
char buf[3]; \
|
unsigned char buf[3]; \
|
||||||
const char *tmp = buf; \
|
const unsigned char *tmp = buf; \
|
||||||
\
|
\
|
||||||
buf[1] = inptr[2]; \
|
buf[1] = inptr[2]; \
|
||||||
buf[2] = inptr[3]; \
|
buf[2] = inptr[3]; \
|
||||||
@ -426,7 +426,7 @@ enum
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
char buf[2]; \
|
unsigned char buf[2]; \
|
||||||
int used; \
|
int used; \
|
||||||
\
|
\
|
||||||
if (set == GB2312_set || ((ann & SO_ann) != CNS11643_1_ann \
|
if (set == GB2312_set || ((ann & SO_ann) != CNS11643_1_ann \
|
||||||
@ -456,7 +456,7 @@ enum
|
|||||||
used = CNS11643_2_set; \
|
used = CNS11643_2_set; \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
char tmpbuf[3]; \
|
unsigned char tmpbuf[3]; \
|
||||||
\
|
\
|
||||||
switch (0) \
|
switch (0) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Conversion module for ISO-2022-CN.
|
/* Conversion module for ISO-2022-CN.
|
||||||
Copyright (C) 1999, 2000-2002 Free Software Foundation, Inc.
|
Copyright (C) 1999, 2000-2002, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ enum
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
char buf[2]; \
|
unsigned char buf[2]; \
|
||||||
int used; \
|
int used; \
|
||||||
size_t written = 0; \
|
size_t written = 0; \
|
||||||
\
|
\
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Conversion module for ISO-2022-KR.
|
/* Conversion module for ISO-2022-KR.
|
||||||
Copyright (C) 1998, 1999, 2000-2002 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2000-2002, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ enum
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
char buf[2]; \
|
unsigned char buf[2]; \
|
||||||
size_t written; \
|
size_t written; \
|
||||||
\
|
\
|
||||||
written = ucs4_to_ksc5601 (ch, buf, 2); \
|
written = ucs4_to_ksc5601 (ch, buf, 2); \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Tables for conversion to and from ISO-IR-165.
|
/* Tables for conversion to and from ISO-IR-165.
|
||||||
converting from UCS using gaps.
|
converting from UCS using gaps.
|
||||||
Copyright (C) 2000, 2003 Free Software Foundation, Inc.
|
Copyright (C) 2000, 2003, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ extern const char __isoir165_from_tab[];
|
|||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
ucs4_to_isoir165 (uint32_t wch, char *s, size_t avail)
|
ucs4_to_isoir165 (uint32_t wch, unsigned char *s, size_t avail)
|
||||||
{
|
{
|
||||||
unsigned int ch = (unsigned int) wch;
|
unsigned int ch = (unsigned int) wch;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Access functions for JISX0201 conversion.
|
/* Access functions for JISX0201 conversion.
|
||||||
Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
|
Copyright (C) 1997, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ jisx0201_to_ucs4 (char ch)
|
|||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
ucs4_to_jisx0201 (uint32_t wch, char *s)
|
ucs4_to_jisx0201 (uint32_t wch, unsigned char *s)
|
||||||
{
|
{
|
||||||
char ch;
|
unsigned char ch;
|
||||||
|
|
||||||
if (wch == 0xa5)
|
if (wch == 0xa5)
|
||||||
ch = '\x5c';
|
ch = '\x5c';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Access functions for JISX0208 conversion.
|
/* Access functions for JISX0208 conversion.
|
||||||
Copyright (C) 1997,1998,1999,2000,2003,2005 Free Software Foundation, Inc.
|
Copyright (C) 1997,1998,1999,2000,2003,2005,2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ jisx0208_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
|
|||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
ucs4_to_jisx0208 (uint32_t wch, char *s, size_t avail)
|
ucs4_to_jisx0208 (uint32_t wch, unsigned char *s, size_t avail)
|
||||||
{
|
{
|
||||||
unsigned int ch = (unsigned int) wch;
|
unsigned int ch = (unsigned int) wch;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Access functions for JISX0212 conversion.
|
/* Access functions for JISX0212 conversion.
|
||||||
Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
|
Copyright (C) 1997, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
|
|
||||||
@ -21,6 +21,7 @@
|
|||||||
#ifndef _JIS0212_H
|
#ifndef _JIS0212_H
|
||||||
#define _JIS0212_H 1
|
#define _JIS0212_H 1
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <gconv.h>
|
#include <gconv.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ jisx0212_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
|
|||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
ucs4_to_jisx0212 (uint32_t wch, char *s, size_t avail)
|
ucs4_to_jisx0212 (uint32_t wch, unsigned char *s, size_t avail)
|
||||||
{
|
{
|
||||||
const struct jisx0212_idx *rp = __jisx0212_from_ucs_idx;
|
const struct jisx0212_idx *rp = __jisx0212_from_ucs_idx;
|
||||||
unsigned int ch = (unsigned int) wch;
|
unsigned int ch = (unsigned int) wch;
|
||||||
@ -98,14 +99,11 @@ ucs4_to_jisx0212 (uint32_t wch, char *s, size_t avail)
|
|||||||
return __UNKNOWN_10646_CHAR;
|
return __UNKNOWN_10646_CHAR;
|
||||||
|
|
||||||
s[0] = cp[0];
|
s[0] = cp[0];
|
||||||
if (cp[1] != '\0')
|
assert (cp[1] != '\0');
|
||||||
{
|
if (avail < 2)
|
||||||
if (avail < 2)
|
return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
s[1] = cp[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
s[1] = cp[1];
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,88 @@
|
|||||||
|
2007-07-24 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* allocatestack.c (__nptl_setxid, __wait_lookup_done): Replace
|
||||||
|
lll_private_futex_* (*) with lll_futex_* (*, LLL_PRIVATE).
|
||||||
|
* pthread_create.c (start_thread): Likewise.
|
||||||
|
* init.c (sighandler_setxid): Likewise.
|
||||||
|
* sysdeps/alpha/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/ia64/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/s390/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/powerpc/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/x86_64/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/sparc/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/sh/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
|
||||||
|
* sysdeps/pthread/aio_misc.h (AIO_MISC_NOTIFY, AIO_MISC_WAIT):
|
||||||
|
Likewise.
|
||||||
|
* sysdeps/pthread/gai_misc.h (GAI_MISC_NOTIFY, GAI_MISC_WAIT):
|
||||||
|
Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/unregister-atfork.c (__unregister_atfork):
|
||||||
|
Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_waitzero,
|
||||||
|
__rtld_notify): Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/fork.c (__libc_fork): Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/powerpc/pthread_once.c (clear_once_control,
|
||||||
|
__pthread_once): Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/alpha/pthread_once.c (clear_once_control,
|
||||||
|
__pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/alpha/lowlevellock.h (FUTEX_PRIVATE_FLAG,
|
||||||
|
LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
|
||||||
|
(lll_futex_wait): Add private argument, define as wrapper around
|
||||||
|
lll_futex_timed_wait.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Add private argument,
|
||||||
|
use __lll_private_flag macro.
|
||||||
|
(lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
|
||||||
|
__lll_mutex_unlock_force): Pass LLL_SHARED as last arg to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/ia64/pthread_once.c (clear_once_control,
|
||||||
|
__pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/ia64/lowlevellock.h (FUTEX_PRIVATE_FLAG,
|
||||||
|
LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
|
||||||
|
(lll_futex_wait): Add private argument, define as wrapper around
|
||||||
|
lll_futex_timed_wait.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Add private argument,
|
||||||
|
use __lll_private_flag macro.
|
||||||
|
(__lll_mutex_unlock, __lll_robust_mutex_unlock, lll_wait_tid,
|
||||||
|
__lll_mutex_unlock_force): Pass LLL_SHARED as last arg to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (__lll_private_flag):
|
||||||
|
Define.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Use it.
|
||||||
|
(lll_private_futex_wait, lll_private_futex_timed_wait,
|
||||||
|
lll_private_futex_wake): Removed.
|
||||||
|
* sysdeps/unix/sysv/linux/s390/pthread_once.c (clear_once_control,
|
||||||
|
__pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_PRIVATE_FLAG,
|
||||||
|
LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
|
||||||
|
(lll_futex_wait): Add private argument, define as wrapper around
|
||||||
|
lll_futex_timed_wait.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Add private argument,
|
||||||
|
use __lll_private_flag macro.
|
||||||
|
(lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
|
||||||
|
lll_wait_tid, __lll_mutex_unlock_force): Pass LLL_SHARED as last arg
|
||||||
|
to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
|
||||||
|
(lll_private_futex_wait, lll_private_futex_timed_wait,
|
||||||
|
lll_private_futex_wake): Removed.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (__lll_private_flag):
|
||||||
|
Fix !__ASSUME_PRIVATE_FUTEX non-constant private case.
|
||||||
|
(lll_private_futex_wait, lll_private_futex_timed_wait,
|
||||||
|
lll_private_futex_wake): Removed.
|
||||||
|
* sysdeps/unix/sysv/linux/sparc/pthread_once.c (clear_once_control,
|
||||||
|
__pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/sparc/lowlevellock.h (FUTEX_PRIVATE_FLAG,
|
||||||
|
LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
|
||||||
|
(lll_futex_wait): Add private argument, define as wrapper around
|
||||||
|
lll_futex_timed_wait.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Add private argument,
|
||||||
|
use __lll_private_flag macro.
|
||||||
|
(lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
|
||||||
|
lll_wait_tid, __lll_mutex_unlock_force): Pass LLL_SHARED as last arg
|
||||||
|
to lll_futex_*.
|
||||||
|
* sysdeps/unix/sysv/linux/sh/lowlevellock.h (__lll_private_flag):
|
||||||
|
Define.
|
||||||
|
(lll_futex_timed_wait, lll_futex_wake): Use it.
|
||||||
|
(lll_private_futex_wait, lll_private_futex_timed_wait,
|
||||||
|
lll_private_futex_wake): Removed.
|
||||||
|
|
||||||
2007-07-27 Jakub Jelinek <jakub@redhat.com>
|
2007-07-27 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* sysdeps/sparc/tls.h (tcbhead_t): Move gscope_flag to the end
|
* sysdeps/sparc/tls.h (tcbhead_t): Move gscope_flag to the end
|
||||||
|
@ -951,7 +951,7 @@ __nptl_setxid (struct xid_command *cmdp)
|
|||||||
int cur = cmdp->cntr;
|
int cur = cmdp->cntr;
|
||||||
while (cur != 0)
|
while (cur != 0)
|
||||||
{
|
{
|
||||||
lll_private_futex_wait (&cmdp->cntr, cur);
|
lll_futex_wait (&cmdp->cntr, cur, LLL_PRIVATE);
|
||||||
cur = cmdp->cntr;
|
cur = cmdp->cntr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,7 +1037,7 @@ __wait_lookup_done (void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
do
|
do
|
||||||
lll_private_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT);
|
lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT, LLL_PRIVATE);
|
||||||
while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
|
while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1059,7 +1059,7 @@ __wait_lookup_done (void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
do
|
do
|
||||||
lll_private_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT);
|
lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT, LLL_PRIVATE);
|
||||||
while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
|
while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
|
|||||||
__xidcmd->id[1], __xidcmd->id[2]);
|
__xidcmd->id[1], __xidcmd->id[2]);
|
||||||
|
|
||||||
if (atomic_decrement_val (&__xidcmd->cntr) == 0)
|
if (atomic_decrement_val (&__xidcmd->cntr) == 0)
|
||||||
lll_private_futex_wake (&__xidcmd->cntr, 1);
|
lll_futex_wake (&__xidcmd->cntr, 1, LLL_PRIVATE);
|
||||||
|
|
||||||
/* Reset the SETXID flag. */
|
/* Reset the SETXID flag. */
|
||||||
struct pthread *self = THREAD_SELF;
|
struct pthread *self = THREAD_SELF;
|
||||||
@ -225,7 +225,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
|
|||||||
|
|
||||||
/* And release the futex. */
|
/* And release the futex. */
|
||||||
self->setxid_futex = 1;
|
self->setxid_futex = 1;
|
||||||
lll_private_futex_wake (&self->setxid_futex, 1);
|
lll_futex_wake (&self->setxid_futex, 1, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ start_thread (void *arg)
|
|||||||
/* Some other thread might call any of the setXid functions and expect
|
/* Some other thread might call any of the setXid functions and expect
|
||||||
us to reply. In this case wait until we did that. */
|
us to reply. In this case wait until we did that. */
|
||||||
do
|
do
|
||||||
lll_private_futex_wait (&pd->setxid_futex, 0);
|
lll_futex_wait (&pd->setxid_futex, 0, LLL_PRIVATE);
|
||||||
while (pd->cancelhandling & SETXID_BITMASK);
|
while (pd->cancelhandling & SETXID_BITMASK);
|
||||||
|
|
||||||
/* Reset the value so that the stack can be reused. */
|
/* Reset the value so that the stack can be reused. */
|
||||||
|
@ -131,7 +131,7 @@ typedef struct
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -449,7 +449,7 @@ union user_desc_init
|
|||||||
: "i" (offsetof (struct pthread, header.gscope_flag)), \
|
: "i" (offsetof (struct pthread, header.gscope_flag)), \
|
||||||
"0" (THREAD_GSCOPE_FLAG_UNUSED)); \
|
"0" (THREAD_GSCOPE_FLAG_UNUSED)); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -173,7 +173,7 @@ register struct pthread *__thread_self __asm__("r13");
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -190,7 +190,7 @@ register void *__thread_register __asm__ ("r13");
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#define AIO_MISC_NOTIFY(waitlist) \
|
#define AIO_MISC_NOTIFY(waitlist) \
|
||||||
do { \
|
do { \
|
||||||
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
|
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
|
||||||
lll_private_futex_wake (waitlist->counterp, 1); \
|
lll_futex_wake (waitlist->counterp, 1, LLL_PRIVATE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define AIO_MISC_WAIT(result, futex, timeout, cancel) \
|
#define AIO_MISC_WAIT(result, futex, timeout, cancel) \
|
||||||
@ -49,8 +49,8 @@
|
|||||||
int status; \
|
int status; \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
status = lll_private_futex_timed_wait (futexaddr, oldval, \
|
status = lll_futex_timed_wait (futexaddr, oldval, timeout, \
|
||||||
timeout); \
|
LLL_PRIVATE); \
|
||||||
if (status != -EWOULDBLOCK) \
|
if (status != -EWOULDBLOCK) \
|
||||||
break; \
|
break; \
|
||||||
\
|
\
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#define GAI_MISC_NOTIFY(waitlist) \
|
#define GAI_MISC_NOTIFY(waitlist) \
|
||||||
do { \
|
do { \
|
||||||
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
|
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
|
||||||
lll_private_futex_wake (waitlist->counterp, 1); \
|
lll_futex_wake (waitlist->counterp, 1, LLL_PRIVATE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define GAI_MISC_WAIT(result, futex, timeout, cancel) \
|
#define GAI_MISC_WAIT(result, futex, timeout, cancel) \
|
||||||
@ -50,8 +50,8 @@
|
|||||||
int status; \
|
int status; \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
status = lll_private_futex_timed_wait (futexaddr, oldval, \
|
status = lll_futex_timed_wait (futexaddr, oldval, timeout, \
|
||||||
timeout); \
|
LLL_PRIVATE); \
|
||||||
if (status != -EWOULDBLOCK) \
|
if (status != -EWOULDBLOCK) \
|
||||||
break; \
|
break; \
|
||||||
\
|
\
|
||||||
|
@ -183,7 +183,7 @@ typedef struct
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -164,7 +164,7 @@ typedef struct
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -157,7 +157,7 @@ register struct pthread *__thread_self __asm__("%g7");
|
|||||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
@ -36,34 +36,63 @@
|
|||||||
#define FUTEX_LOCK_PI 6
|
#define FUTEX_LOCK_PI 6
|
||||||
#define FUTEX_UNLOCK_PI 7
|
#define FUTEX_UNLOCK_PI 7
|
||||||
#define FUTEX_TRYLOCK_PI 8
|
#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. */
|
/* Initializer for compatibility lock. */
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
#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); \
|
INTERNAL_SYSCALL_DECL (__err); \
|
||||||
long int __ret; \
|
long int __ret; \
|
||||||
__ret = INTERNAL_SYSCALL (futex, __err, 4, \
|
__ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
|
||||||
(futexp), FUTEX_WAIT, (val), 0); \
|
__lll_private_flag (FUTEX_WAIT, private), \
|
||||||
|
(val), (timespec)); \
|
||||||
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
|
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); \
|
INTERNAL_SYSCALL_DECL (__err); \
|
||||||
long int __ret; \
|
long int __ret; \
|
||||||
__ret = INTERNAL_SYSCALL (futex, __err, 4, \
|
__ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
|
||||||
(futexp), FUTEX_WAIT, (val), (timespec)); \
|
__lll_private_flag (FUTEX_WAKE, private), \
|
||||||
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
|
(nr), 0); \
|
||||||
})
|
|
||||||
|
|
||||||
#define lll_futex_wake(futexp, nr) \
|
|
||||||
({ \
|
|
||||||
INTERNAL_SYSCALL_DECL (__err); \
|
|
||||||
long int __ret; \
|
|
||||||
__ret = INTERNAL_SYSCALL (futex, __err, 4, \
|
|
||||||
(futexp), FUTEX_WAKE, (nr), 0); \
|
|
||||||
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
|
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -72,7 +101,7 @@
|
|||||||
{ \
|
{ \
|
||||||
int *__futexp = &(futexv); \
|
int *__futexp = &(futexv); \
|
||||||
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
||||||
lll_futex_wake (__futexp, 1); \
|
lll_futex_wake (__futexp, 1, LLL_SHARED); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
@ -198,7 +227,7 @@ __lll_mutex_unlock (int *futex)
|
|||||||
{
|
{
|
||||||
int val = atomic_exchange_rel (futex, 0);
|
int val = atomic_exchange_rel (futex, 0);
|
||||||
if (__builtin_expect (val > 1, 0))
|
if (__builtin_expect (val > 1, 0))
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
|
#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
|
||||||
|
|
||||||
@ -208,7 +237,7 @@ __lll_robust_mutex_unlock (int *futex, int mask)
|
|||||||
{
|
{
|
||||||
int val = atomic_exchange_rel (futex, 0);
|
int val = atomic_exchange_rel (futex, 0);
|
||||||
if (__builtin_expect (val & mask, 0))
|
if (__builtin_expect (val & mask, 0))
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_robust_mutex_unlock(futex) \
|
#define lll_robust_mutex_unlock(futex) \
|
||||||
__lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
|
__lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
|
||||||
@ -218,7 +247,7 @@ static inline void __attribute__ ((always_inline))
|
|||||||
__lll_mutex_unlock_force (int *futex)
|
__lll_mutex_unlock_force (int *futex)
|
||||||
{
|
{
|
||||||
(void) atomic_exchange_rel (futex, 0);
|
(void) atomic_exchange_rel (futex, 0);
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
|
#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
|
||||||
|
|
||||||
@ -252,10 +281,10 @@ typedef int lll_lock_t;
|
|||||||
thread ID while the clone is running and is reset to zero
|
thread ID while the clone is running and is reset to zero
|
||||||
afterwards. */
|
afterwards. */
|
||||||
#define lll_wait_tid(tid) \
|
#define lll_wait_tid(tid) \
|
||||||
do { \
|
do { \
|
||||||
__typeof (tid) __tid; \
|
__typeof (tid) __tid; \
|
||||||
while ((__tid = (tid)) != 0) \
|
while ((__tid = (tid)) != 0) \
|
||||||
lll_futex_wait (&(tid), __tid); \
|
lll_futex_wait (&(tid), __tid, LLL_SHARED); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -28,7 +28,7 @@ clear_once_control (void *arg)
|
|||||||
pthread_once_t *once_control = (pthread_once_t *) arg;
|
pthread_once_t *once_control = (pthread_once_t *) arg;
|
||||||
|
|
||||||
*once_control = 0;
|
*once_control = 0;
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -72,7 +72,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Same generation, some other thread was faster. Wait. */
|
/* Same generation, some other thread was faster. Wait. */
|
||||||
lll_futex_wait (once_control, oldval);
|
lll_futex_wait (once_control, oldval, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This thread is the first here. Do the initialization.
|
/* This thread is the first here. Do the initialization.
|
||||||
@ -88,7 +88,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|||||||
atomic_increment (once_control);
|
atomic_increment (once_control);
|
||||||
|
|
||||||
/* Wake up all other threads. */
|
/* Wake up all other threads. */
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ __libc_fork (void)
|
|||||||
|
|
||||||
if (atomic_decrement_and_test (&allp->handler->refcntr)
|
if (atomic_decrement_and_test (&allp->handler->refcntr)
|
||||||
&& allp->handler->need_signal)
|
&& allp->handler->need_signal)
|
||||||
lll_private_futex_wake (allp->handler->refcntr, 1);
|
lll_futex_wake (allp->handler->refcntr, 1, LLL_PRIVATE);
|
||||||
|
|
||||||
allp = allp->next;
|
allp = allp->next;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,39 @@
|
|||||||
#define FUTEX_LOCK_PI 6
|
#define FUTEX_LOCK_PI 6
|
||||||
#define FUTEX_UNLOCK_PI 7
|
#define FUTEX_UNLOCK_PI 7
|
||||||
#define FUTEX_TRYLOCK_PI 8
|
#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
|
||||||
|
|
||||||
|
|
||||||
/* Delay in spinlock loop. */
|
/* Delay in spinlock loop. */
|
||||||
#define BUSY_WAIT_NOP asm ("hint @pause")
|
#define BUSY_WAIT_NOP asm ("hint @pause")
|
||||||
@ -43,18 +76,22 @@
|
|||||||
/* Initializer for compatibility lock. */
|
/* Initializer for compatibility lock. */
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
||||||
|
|
||||||
#define lll_futex_wait(futex, val) lll_futex_timed_wait (futex, val, 0)
|
#define lll_futex_wait(futex, val, private) \
|
||||||
|
lll_futex_timed_wait (futex, val, NULL, private)
|
||||||
|
|
||||||
#define lll_futex_timed_wait(ftx, val, timespec) \
|
#define lll_futex_timed_wait(ftx, val, timespec, private) \
|
||||||
({ \
|
({ \
|
||||||
DO_INLINE_SYSCALL(futex, 4, (long) (ftx), FUTEX_WAIT, (int) (val), \
|
DO_INLINE_SYSCALL(futex, 4, (long) (ftx), \
|
||||||
(long) (timespec)); \
|
__lll_private_flag (FUTEX_WAIT, private), \
|
||||||
|
(int) (val), (long) (timespec)); \
|
||||||
_r10 == -1 ? -_retval : _retval; \
|
_r10 == -1 ? -_retval : _retval; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define lll_futex_wake(ftx, nr) \
|
#define lll_futex_wake(ftx, nr, private) \
|
||||||
({ \
|
({ \
|
||||||
DO_INLINE_SYSCALL(futex, 3, (long) (ftx), FUTEX_WAKE, (int) (nr)); \
|
DO_INLINE_SYSCALL(futex, 3, (long) (ftx), \
|
||||||
|
__lll_private_flag (FUTEX_WAKE, private), \
|
||||||
|
(int) (nr)); \
|
||||||
_r10 == -1 ? -_retval : _retval; \
|
_r10 == -1 ? -_retval : _retval; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -188,7 +225,7 @@ extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
|
|||||||
int __val = atomic_exchange_rel (__futex, 0); \
|
int __val = atomic_exchange_rel (__futex, 0); \
|
||||||
\
|
\
|
||||||
if (__builtin_expect (__val > 1, 0)) \
|
if (__builtin_expect (__val > 1, 0)) \
|
||||||
lll_futex_wake (__futex, 1); \
|
lll_futex_wake (__futex, 1, LLL_SHARED); \
|
||||||
}))
|
}))
|
||||||
#define lll_mutex_unlock(futex) \
|
#define lll_mutex_unlock(futex) \
|
||||||
__lll_mutex_unlock(&(futex))
|
__lll_mutex_unlock(&(futex))
|
||||||
@ -200,7 +237,7 @@ extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
|
|||||||
int __val = atomic_exchange_rel (__futex, 0); \
|
int __val = atomic_exchange_rel (__futex, 0); \
|
||||||
\
|
\
|
||||||
if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
|
if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
|
||||||
lll_futex_wake (__futex, 1); \
|
lll_futex_wake (__futex, 1, LLL_SHARED); \
|
||||||
}))
|
}))
|
||||||
#define lll_robust_mutex_unlock(futex) \
|
#define lll_robust_mutex_unlock(futex) \
|
||||||
__lll_robust_mutex_unlock(&(futex))
|
__lll_robust_mutex_unlock(&(futex))
|
||||||
@ -210,7 +247,7 @@ extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
|
|||||||
((void) ({ \
|
((void) ({ \
|
||||||
int *__futex = (futex); \
|
int *__futex = (futex); \
|
||||||
(void) atomic_exchange_rel (__futex, 0); \
|
(void) atomic_exchange_rel (__futex, 0); \
|
||||||
lll_futex_wake (__futex, 1); \
|
lll_futex_wake (__futex, 1, LLL_SHARED); \
|
||||||
}))
|
}))
|
||||||
#define lll_mutex_unlock_force(futex) \
|
#define lll_mutex_unlock_force(futex) \
|
||||||
__lll_mutex_unlock_force(&(futex))
|
__lll_mutex_unlock_force(&(futex))
|
||||||
@ -241,12 +278,12 @@ typedef int lll_lock_t;
|
|||||||
thread ID while the clone is running and is reset to zero
|
thread ID while the clone is running and is reset to zero
|
||||||
afterwards. */
|
afterwards. */
|
||||||
#define lll_wait_tid(tid) \
|
#define lll_wait_tid(tid) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
__typeof (tid) __tid; \
|
__typeof (tid) __tid; \
|
||||||
while ((__tid = (tid)) != 0) \
|
while ((__tid = (tid)) != 0) \
|
||||||
lll_futex_wait (&(tid), __tid); \
|
lll_futex_wait (&(tid), __tid, LLL_SHARED); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ clear_once_control (void *arg)
|
|||||||
pthread_once_t *once_control = (pthread_once_t *) arg;
|
pthread_once_t *once_control = (pthread_once_t *) arg;
|
||||||
|
|
||||||
*once_control = 0;
|
*once_control = 0;
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
if (((oldval ^ newval) & -4) == 0)
|
if (((oldval ^ newval) & -4) == 0)
|
||||||
{
|
{
|
||||||
/* Same generation, some other thread was faster. Wait. */
|
/* Same generation, some other thread was faster. Wait. */
|
||||||
lll_futex_wait (once_control, newval);
|
lll_futex_wait (once_control, newval, LLL_PRIVATE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
atomic_increment (once_control);
|
atomic_increment (once_control);
|
||||||
|
|
||||||
/* Wake up all other threads. */
|
/* Wake up all other threads. */
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,15 +134,6 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
#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
|
#ifdef UP
|
||||||
# define __lll_acq_instr ""
|
# define __lll_acq_instr ""
|
||||||
# define __lll_rel_instr ""
|
# define __lll_rel_instr ""
|
||||||
|
@ -30,7 +30,7 @@ clear_once_control (void *arg)
|
|||||||
pthread_once_t *once_control = (pthread_once_t *) arg;
|
pthread_once_t *once_control = (pthread_once_t *) arg;
|
||||||
|
|
||||||
*once_control = 0;
|
*once_control = 0;
|
||||||
lll_private_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Same generation, some other thread was faster. Wait. */
|
/* Same generation, some other thread was faster. Wait. */
|
||||||
lll_private_futex_wait (once_control, oldval);
|
lll_futex_wait (once_control, oldval, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|||||||
atomic_increment (once_control);
|
atomic_increment (once_control);
|
||||||
|
|
||||||
/* Wake up all other threads. */
|
/* Wake up all other threads. */
|
||||||
lll_private_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@
|
|||||||
int val = word; \
|
int val = word; \
|
||||||
if (val == 0) \
|
if (val == 0) \
|
||||||
break; \
|
break; \
|
||||||
lll_private_futex_wait (&(word), val); \
|
lll_futex_wait (&(word), val, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define __rtld_notify(word) \
|
#define __rtld_notify(word) \
|
||||||
lll_private_futex_wake (&(word), 1)
|
lll_futex_wake (&(word), 1, LLL_PRIVATE)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,31 +35,50 @@
|
|||||||
#define FUTEX_LOCK_PI 6
|
#define FUTEX_LOCK_PI 6
|
||||||
#define FUTEX_UNLOCK_PI 7
|
#define FUTEX_UNLOCK_PI 7
|
||||||
#define FUTEX_TRYLOCK_PI 8
|
#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. */
|
/* Initializer for compatibility lock. */
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
||||||
|
|
||||||
#define lll_futex_wait(futex, val) \
|
#define lll_futex_wait(futex, val, private) \
|
||||||
({ \
|
lll_futex_timed_wait (futex, val, NULL, private)
|
||||||
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
|
|
||||||
register unsigned long int __r3 asm ("3") = FUTEX_WAIT; \
|
|
||||||
register unsigned long int __r4 asm ("4") = (unsigned long int) (val); \
|
|
||||||
register unsigned long int __r5 asm ("5") = 0ul; \
|
|
||||||
register unsigned long __result asm ("2"); \
|
|
||||||
\
|
|
||||||
__asm __volatile ("svc %b1" \
|
|
||||||
: "=d" (__result) \
|
|
||||||
: "i" (SYS_futex), "0" (__r2), "d" (__r3), \
|
|
||||||
"d" (__r4), "d" (__r5) \
|
|
||||||
: "cc", "memory" ); \
|
|
||||||
__result; \
|
|
||||||
})
|
|
||||||
|
|
||||||
|
#define lll_futex_timed_wait(futex, val, timespec, private) \
|
||||||
#define lll_futex_timed_wait(futex, val, timespec) \
|
|
||||||
({ \
|
({ \
|
||||||
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
|
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
|
||||||
register unsigned long int __r3 asm ("3") = FUTEX_WAIT; \
|
register unsigned long int __r3 asm ("3") \
|
||||||
|
= __lll_private_flag (FUTEX_WAIT, private); \
|
||||||
register unsigned long int __r4 asm ("4") = (unsigned long int) (val); \
|
register unsigned long int __r4 asm ("4") = (unsigned long int) (val); \
|
||||||
register unsigned long int __r5 asm ("5") = (unsigned long int)(timespec);\
|
register unsigned long int __r5 asm ("5") = (unsigned long int)(timespec);\
|
||||||
register unsigned long int __result asm ("2"); \
|
register unsigned long int __result asm ("2"); \
|
||||||
@ -73,10 +92,11 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
#define lll_futex_wake(futex, nr) \
|
#define lll_futex_wake(futex, nr, private) \
|
||||||
({ \
|
({ \
|
||||||
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
|
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
|
||||||
register unsigned long int __r3 asm ("3") = FUTEX_WAKE; \
|
register unsigned long int __r3 asm ("3") \
|
||||||
|
__lll_private_flag (FUTEX_WAKE, private); \
|
||||||
register unsigned long int __r4 asm ("4") = (unsigned long int) (nr); \
|
register unsigned long int __r4 asm ("4") = (unsigned long int) (nr); \
|
||||||
register unsigned long int __result asm ("2"); \
|
register unsigned long int __result asm ("2"); \
|
||||||
\
|
\
|
||||||
@ -94,7 +114,7 @@
|
|||||||
int *__futexp = &(futexv); \
|
int *__futexp = &(futexv); \
|
||||||
\
|
\
|
||||||
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
||||||
lll_futex_wake (__futexp, 1); \
|
lll_futex_wake (__futexp, 1, LLL_SHARED); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
@ -271,7 +291,7 @@ __lll_mutex_unlock (int *futex)
|
|||||||
|
|
||||||
lll_compare_and_swap (futex, oldval, newval, "slr %2,%2");
|
lll_compare_and_swap (futex, oldval, newval, "slr %2,%2");
|
||||||
if (oldval > 1)
|
if (oldval > 1)
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_mutex_unlock(futex) \
|
#define lll_mutex_unlock(futex) \
|
||||||
__lll_mutex_unlock(&(futex))
|
__lll_mutex_unlock(&(futex))
|
||||||
@ -286,7 +306,7 @@ __lll_robust_mutex_unlock (int *futex, int mask)
|
|||||||
|
|
||||||
lll_compare_and_swap (futex, oldval, newval, "slr %2,%2");
|
lll_compare_and_swap (futex, oldval, newval, "slr %2,%2");
|
||||||
if (oldval & mask)
|
if (oldval & mask)
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_robust_mutex_unlock(futex) \
|
#define lll_robust_mutex_unlock(futex) \
|
||||||
__lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
|
__lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
|
||||||
@ -297,7 +317,7 @@ __attribute__ ((always_inline))
|
|||||||
__lll_mutex_unlock_force (int *futex)
|
__lll_mutex_unlock_force (int *futex)
|
||||||
{
|
{
|
||||||
*futex = 0;
|
*futex = 0;
|
||||||
lll_futex_wake (futex, 1);
|
lll_futex_wake (futex, 1, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_mutex_unlock_force(futex) \
|
#define lll_mutex_unlock_force(futex) \
|
||||||
__lll_mutex_unlock_force(&(futex))
|
__lll_mutex_unlock_force(&(futex))
|
||||||
@ -338,7 +358,7 @@ __lll_wait_tid (int *ptid)
|
|||||||
int tid;
|
int tid;
|
||||||
|
|
||||||
while ((tid = *ptid) != 0)
|
while ((tid = *ptid) != 0)
|
||||||
lll_futex_wait (ptid, tid);
|
lll_futex_wait (ptid, tid, LLL_SHARED);
|
||||||
}
|
}
|
||||||
#define lll_wait_tid(tid) __lll_wait_tid(&(tid))
|
#define lll_wait_tid(tid) __lll_wait_tid(&(tid))
|
||||||
|
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
|
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ clear_once_control (void *arg)
|
|||||||
pthread_once_t *once_control = (pthread_once_t *) arg;
|
pthread_once_t *once_control = (pthread_once_t *) arg;
|
||||||
|
|
||||||
*once_control = 0;
|
*once_control = 0;
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
if (((oldval ^ newval) & -4) == 0)
|
if (((oldval ^ newval) & -4) == 0)
|
||||||
{
|
{
|
||||||
/* Same generation, some other thread was faster. Wait. */
|
/* Same generation, some other thread was faster. Wait. */
|
||||||
lll_futex_wait (once_control, newval);
|
lll_futex_wait (once_control, newval, LLL_PRIVATE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
: "m" (*once_control) : "cc" );
|
: "m" (*once_control) : "cc" );
|
||||||
|
|
||||||
/* Wake up all other threads. */
|
/* Wake up all other threads. */
|
||||||
lll_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,31 @@
|
|||||||
#define LLL_SHARED FUTEX_PRIVATE_FLAG
|
#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. */
|
/* Initializer for compatibility lock. */
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER_LOCKED (1)
|
#define LLL_MUTEX_LOCK_INITIALIZER_LOCKED (1)
|
||||||
@ -278,7 +303,7 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
|
|||||||
1: mov r1,r15"\
|
1: mov r1,r15"\
|
||||||
: "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \
|
: "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \
|
||||||
: "r0", "r1", "memory"); \
|
: "r0", "r1", "memory"); \
|
||||||
lll_futex_wake (__futex, 1, 0); })
|
lll_futex_wake (__futex, 1, LLL_SHARED); })
|
||||||
|
|
||||||
#define lll_mutex_islocked(futex) \
|
#define lll_mutex_islocked(futex) \
|
||||||
(futex != 0)
|
(futex != 0)
|
||||||
@ -312,7 +337,8 @@ typedef int lll_lock_t;
|
|||||||
int __status; \
|
int __status; \
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
||||||
register unsigned long __r5 asm ("r5") = FUTEX_WAIT; \
|
register unsigned long __r5 asm ("r5") \
|
||||||
|
= __lll_private_flag (FUTEX_WAIT, private); \
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (val); \
|
register unsigned long __r6 asm ("r6") = (unsigned long) (val); \
|
||||||
register unsigned long __r7 asm ("r7") = (timeout); \
|
register unsigned long __r7 asm ("r7") = (timeout); \
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
||||||
@ -329,7 +355,8 @@ typedef int lll_lock_t;
|
|||||||
int __ignore; \
|
int __ignore; \
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
||||||
register unsigned long __r5 asm ("r5") = FUTEX_WAKE; \
|
register unsigned long __r5 asm ("r5") \
|
||||||
|
= __lll_private_flag (FUTEX_WAKE, private); \
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \
|
register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \
|
||||||
register unsigned long __r7 asm ("r7") = 0; \
|
register unsigned long __r7 asm ("r7") = 0; \
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
||||||
@ -340,81 +367,6 @@ typedef int lll_lock_t;
|
|||||||
} while (0)
|
} 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) \
|
|
||||||
({ \
|
|
||||||
int __status; \
|
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
|
||||||
register unsigned long __r5 asm ("r5") = FUTEX_WAIT | FUTEX_PRIVATE_FLAG; \
|
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (val); \
|
|
||||||
register unsigned long __r7 asm ("r7") = (timeout); \
|
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
|
||||||
: "=z" (__status) \
|
|
||||||
: "r" (__r3), "r" (__r4), "r" (__r5), \
|
|
||||||
"r" (__r6), "r" (__r7) \
|
|
||||||
: "memory", "t"); \
|
|
||||||
__status; \
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
# define lll_private_futex_wake(futex, nr) \
|
|
||||||
do { \
|
|
||||||
int __ignore; \
|
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
|
||||||
register unsigned long __r5 asm ("r5") = FUTEX_WAKE | FUTEX_PRIVATE_FLAG; \
|
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \
|
|
||||||
register unsigned long __r7 asm ("r7") = 0; \
|
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
|
||||||
: "=z" (__ignore) \
|
|
||||||
: "r" (__r3), "r" (__r4), "r" (__r5), \
|
|
||||||
"r" (__r6), "r" (__r7) \
|
|
||||||
: "memory", "t"); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
# define lll_private_futex_timed_wait(futex, val, timeout) \
|
|
||||||
({ \
|
|
||||||
int __status; \
|
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
|
||||||
register unsigned long __r5 asm ("r5"); \
|
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (val); \
|
|
||||||
register unsigned long __r7 asm ("r7") = (timeout); \
|
|
||||||
__r5 = THREAD_GETMEM (THREAD_SELF, header.private_futex); \
|
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
|
||||||
: "=z" (__status) \
|
|
||||||
: "r" (__r3), "r" (__r4), "r" (__r5), \
|
|
||||||
"r" (__r6), "r" (__r7) \
|
|
||||||
: "memory", "t"); \
|
|
||||||
__status; \
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
# define lll_private_futex_wake(futex, nr) \
|
|
||||||
do { \
|
|
||||||
int __ignore; \
|
|
||||||
register unsigned long __r3 asm ("r3") = SYS_futex; \
|
|
||||||
register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \
|
|
||||||
register unsigned long __r5 asm ("r5") = FUTEX_WAKE; \
|
|
||||||
register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \
|
|
||||||
register unsigned long __r7 asm ("r7") = 0; \
|
|
||||||
__r5 |= THREAD_GETMEM (THREAD_SELF, header.private_futex); \
|
|
||||||
__asm __volatile (SYSCALL_WITH_INST_PAD \
|
|
||||||
: "=z" (__ignore) \
|
|
||||||
: "r" (__r3), "r" (__r4), "r" (__r5), \
|
|
||||||
"r" (__r6), "r" (__r7) \
|
|
||||||
: "memory", "t"); \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The states of a lock are:
|
/* The states of a lock are:
|
||||||
0 - untaken
|
0 - untaken
|
||||||
1 - taken by one user
|
1 - taken by one user
|
||||||
@ -438,7 +390,7 @@ extern int __lll_wait_tid (int *tid) attribute_hidden;
|
|||||||
do { \
|
do { \
|
||||||
__typeof (tid) *__tid = &(tid); \
|
__typeof (tid) *__tid = &(tid); \
|
||||||
while (*__tid != 0) \
|
while (*__tid != 0) \
|
||||||
lll_futex_wait (__tid, *__tid, 0); \
|
lll_futex_wait (__tid, *__tid, LLL_SHARED); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
|
extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
|
||||||
|
@ -35,37 +35,66 @@
|
|||||||
#define FUTEX_LOCK_PI 6
|
#define FUTEX_LOCK_PI 6
|
||||||
#define FUTEX_UNLOCK_PI 7
|
#define FUTEX_UNLOCK_PI 7
|
||||||
#define FUTEX_TRYLOCK_PI 8
|
#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. */
|
/* Initializer for compatibility lock. */
|
||||||
#define LLL_MUTEX_LOCK_INITIALIZER (0)
|
#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); \
|
INTERNAL_SYSCALL_DECL (__err); \
|
||||||
long int __ret; \
|
long int __ret; \
|
||||||
\
|
\
|
||||||
__ret = INTERNAL_SYSCALL (futex, __err, 4, \
|
__ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
|
||||||
(futexp), FUTEX_WAIT, (val), 0); \
|
__lll_private_flag (FUTEX_WAIT, private), \
|
||||||
|
(val), (timespec)); \
|
||||||
__ret; \
|
__ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define lll_futex_timed_wait(futexp, val, timespec) \
|
#define lll_futex_wake(futexp, nr, private) \
|
||||||
({ \
|
({ \
|
||||||
INTERNAL_SYSCALL_DECL (__err); \
|
INTERNAL_SYSCALL_DECL (__err); \
|
||||||
long int __ret; \
|
long int __ret; \
|
||||||
\
|
\
|
||||||
__ret = INTERNAL_SYSCALL (futex, __err, 4, \
|
__ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
|
||||||
(futexp), FUTEX_WAIT, (val), (timespec)); \
|
__lll_private_flag (FUTEX_WAKE, private), \
|
||||||
__ret; \
|
(nr), 0); \
|
||||||
})
|
|
||||||
|
|
||||||
#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; \
|
__ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -86,7 +115,7 @@
|
|||||||
{ \
|
{ \
|
||||||
int *__futexp = &(futexv); \
|
int *__futexp = &(futexv); \
|
||||||
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
atomic_or (__futexp, FUTEX_OWNER_DIED); \
|
||||||
lll_futex_wake (__futexp, 1); \
|
lll_futex_wake (__futexp, 1, LLL_SHARED); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
@ -212,7 +241,7 @@ __lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
|
|||||||
int *__futex = &(lock); \
|
int *__futex = &(lock); \
|
||||||
int __val = atomic_exchange_24_rel (__futex, 0); \
|
int __val = atomic_exchange_24_rel (__futex, 0); \
|
||||||
if (__builtin_expect (__val > 1, 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) \
|
#define lll_robust_mutex_unlock(lock) \
|
||||||
@ -220,14 +249,14 @@ __lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
|
|||||||
int *__futex = &(lock); \
|
int *__futex = &(lock); \
|
||||||
int __val = atomic_exchange_rel (__futex, 0); \
|
int __val = atomic_exchange_rel (__futex, 0); \
|
||||||
if (__builtin_expect (__val & FUTEX_WAITERS, 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) \
|
#define lll_mutex_unlock_force(lock) \
|
||||||
((void) ({ \
|
((void) ({ \
|
||||||
int *__futex = &(lock); \
|
int *__futex = &(lock); \
|
||||||
(void) atomic_exchange_24_rel (__futex, 0); \
|
(void) atomic_exchange_24_rel (__futex, 0); \
|
||||||
lll_futex_wake (__futex, 1); \
|
lll_futex_wake (__futex, 1, LLL_SHARED); \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
#define lll_mutex_islocked(futex) \
|
#define lll_mutex_islocked(futex) \
|
||||||
@ -255,12 +284,12 @@ typedef int lll_lock_t;
|
|||||||
thread ID while the clone is running and is reset to zero
|
thread ID while the clone is running and is reset to zero
|
||||||
afterwards. */
|
afterwards. */
|
||||||
#define lll_wait_tid(tid) \
|
#define lll_wait_tid(tid) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
__typeof (tid) __tid; \
|
__typeof (tid) __tid; \
|
||||||
while ((__tid = (tid)) != 0) \
|
while ((__tid = (tid)) != 0) \
|
||||||
lll_futex_wait (&(tid), __tid); \
|
lll_futex_wait (&(tid), __tid, LLL_SHARED); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
extern int __lll_timedwait_tid (int *, const struct timespec *)
|
||||||
|
@ -30,7 +30,7 @@ clear_once_control (void *arg)
|
|||||||
pthread_once_t *once_control = (pthread_once_t *) arg;
|
pthread_once_t *once_control = (pthread_once_t *) arg;
|
||||||
|
|
||||||
*once_control = 0;
|
*once_control = 0;
|
||||||
lll_private_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
if (((oldval ^ newval) & -4) == 0)
|
if (((oldval ^ newval) & -4) == 0)
|
||||||
{
|
{
|
||||||
/* Same generation, some other thread was faster. Wait. */
|
/* Same generation, some other thread was faster. Wait. */
|
||||||
lll_futex_wait (once_control, newval);
|
lll_futex_wait (once_control, newval, LLL_PRIVATE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ __pthread_once (once_control, init_routine)
|
|||||||
atomic_increment (once_control);
|
atomic_increment (once_control);
|
||||||
|
|
||||||
/* Wake up all other threads. */
|
/* Wake up all other threads. */
|
||||||
lll_private_futex_wake (once_control, INT_MAX);
|
lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ __unregister_atfork (dso_handle)
|
|||||||
atomic_decrement (&deleted->handler->refcntr);
|
atomic_decrement (&deleted->handler->refcntr);
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
while ((val = deleted->handler->refcntr) != 0)
|
while ((val = deleted->handler->refcntr) != 0)
|
||||||
lll_private_futex_wait (&deleted->handler->refcntr, val);
|
lll_futex_wait (&deleted->handler->refcntr, val, LLL_PRIVATE);
|
||||||
|
|
||||||
deleted = deleted->next;
|
deleted = deleted->next;
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
: (fl)) \
|
: (fl)) \
|
||||||
: ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
|
: ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
|
||||||
asm ("andl %%fs:%P1, %0" : "+r" (__fl) \
|
asm ("andl %%fs:%P1, %0" : "+r" (__fl) \
|
||||||
: "i" offsetof (struct pthread, header.private_futex)); \
|
: "i" (offsetof (struct pthread, header.private_futex))); \
|
||||||
__fl | (fl); })
|
__fl | (fl); }))
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -215,15 +215,6 @@ LLL_STUB_UNWIND_INFO_END
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define lll_private_futex_wait(futex, val) \
|
|
||||||
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. */
|
/* Does not preserve %eax and %ecx. */
|
||||||
extern int __lll_mutex_lock_wait (int *__futex, int __val) attribute_hidden;
|
extern int __lll_mutex_lock_wait (int *__futex, int __val) attribute_hidden;
|
||||||
|
@ -355,7 +355,7 @@ typedef struct
|
|||||||
: "i" (offsetof (struct pthread, header.gscope_flag)), \
|
: "i" (offsetof (struct pthread, header.gscope_flag)), \
|
||||||
"0" (THREAD_GSCOPE_FLAG_UNUSED)); \
|
"0" (THREAD_GSCOPE_FLAG_UNUSED)); \
|
||||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||||
lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
|
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define THREAD_GSCOPE_SET_FLAG() \
|
#define THREAD_GSCOPE_SET_FLAG() \
|
||||||
|
Loading…
Reference in New Issue
Block a user