Uros Bizjak
b8253693b7
x86: Define atomic_compare_and_exchange_{val, bool}_acq using __atomic_compare_exchange_n
...
No functional changes.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org >
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2025-09-09 07:58:52 -07:00
Uros Bizjak
935ee691bc
x86: Define atomic_exchange_acq using __atomic_exchange_n
...
The resulting libc.so is identical on both x86_64 and
i386 targets compared to unpatched builds:
$ sha1sum libc-x86_64-old.so libc-x86_64-new.so
74eca1b87f2ecc9757a984c089a582b7615d93e7 libc-x86_64-old.so
74eca1b87f2ecc9757a984c089a582b7615d93e7 libc-x86_64-new.so
$ sha1sum libc-i386-old.so libc-i386-new.so
882bbab8324f79f4fbc85224c4c914fc6822ece7 libc-i386-old.so
882bbab8324f79f4fbc85224c4c914fc6822ece7 libc-i386-new.so
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org >
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2025-09-09 07:51:41 -07:00
Uros Bizjak
e6b5ad1b1d
x86: Define atomic_full_barrier using __sync_synchronize
...
For x86_64 targets, __sync_synchronize emits a full 64-bit
'LOCK ORQ $0x0,(%rsp)' instead of 'LOCK ORL $0x0,(%rsp)'.
No functional changes.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org >
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2025-09-09 07:44:41 -07:00
Uros Bizjak
4eef002328
x86: Remove catomic_* locking primitives
...
Remove obsolete catomic_* locking primitives which don't map
to standard compiler builtins.
There are still a couple of places in the tree that uses them
(malloc/arena.c and malloc/malloc.c).
x86 didn't define __arch_c_compare_and_exchange_bool_* primitives
so fallback code used __arch_c_compare_and_exchange_val_* primitives
instead. This resulted in unoptimal code for
catomic_compare_and_exchange_bool_acq where superfluous
CMP was emitted after CMPXCHG, e.g. in arena_get2:
775b8: 48 8d 4a 01 lea 0x1(%rdx),%rcx
775bc: 48 89 d0 mov %rdx,%rax
775bf: 64 83 3c 25 18 00 00 cmpl $0x0,%fs:0x18
775c6: 00 00
775c8: 74 01 je 775cb <arena_get2+0x35b>
775ca: f0 48 0f b1 0d 75 3d lock cmpxchg %rcx,0x163d75(%rip) # 1db348 <narenas>
775d1: 16 00
775d3: 48 39 c2 cmp %rax,%rdx
775d6: 74 7f je 77657 <arena_get2+0x3e7>
that now becomes:
775b8: 48 8d 4a 01 lea 0x1(%rdx),%rcx
775bc: 48 89 d0 mov %rdx,%rax
775bf: f0 48 0f b1 0d 80 3d lock cmpxchg %rcx,0x163d80(%rip) # 1db348 <narenas>
775c6: 16 00
775c8: 74 7f je 77649 <arena_get2+0x3d9>
OTOH, catomic_decrement does not fallback to atomic_fetch_add (, -1)
builtin but to the cmpxchg loop, so the generated code in arena_get2
regresses a bit, from using LOCK DECQ insn:
77829: 64 83 3c 25 18 00 00 cmpl $0x0,%fs:0x18
77830: 00 00
77832: 74 01 je 77835 <arena_get2+0x5c5>
77834: f0 48 ff 0d 0c 3b 16 lock decq 0x163b0c(%rip) # 1db348 <narenas>
7783b: 00
to a cmpxchg loop:
7783d: 48 8b 0d 04 3b 16 00 mov 0x163b04(%rip),%rcx # 1db348 <narenas>
77844: 48 8d 71 ff lea -0x1(%rcx),%rsi
77848: 48 89 c8 mov %rcx,%rax
7784b: f0 48 0f b1 35 f4 3a lock cmpxchg %rsi,0x163af4(%rip) # 1db348 <narenas>
77852: 16 00
77854: 0f 84 c9 fa ff ff je 77323 <arena_get2+0xb3>
7785a: eb e1 jmp 7783d <arena_get2+0x5cd>
Defining catomic_exchange_and_add using __atomic_fetch_add solves the
above issue and generates optimal:
77809: f0 48 83 2d 36 3b 16 lock subq $0x1,0x163b36(%rip) # 1db348 <narenas>
77810: 00 01
Depending on the target processor, the compiler may emit either
'LOCK ADD/SUB $1, m' or 'INC/DEC $1, m' instruction, due to partial
flag register stall issue.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org >
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2025-09-09 07:36:02 -07:00
Uros Bizjak
af5b01dc26
x86: Remove unused atomics
...
Remove unused atomics from <sysdeps/x86/atomic-machine.h>.
The resulting libc.so is identical on both x86_64 and
i386 targets compared to unpatched builds:
$ sha1sum libc-x86_64-old.so libc-x86_64-new.so
b89aaa2b71efd435104ebe6f4cd0f2ef89fcac90 libc-x86_64-old.so
b89aaa2b71efd435104ebe6f4cd0f2ef89fcac90 libc-x86_64-new.so
$ sha1sum libc-i386-old.so libc-i386-new.so
aa70f2d64da2f0f516634b116014cfe7af3e5b1a libc-i386-old.so
aa70f2d64da2f0f516634b116014cfe7af3e5b1a libc-i386-new.so
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org >
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2025-09-09 07:29:57 -07:00
Uros Bizjak
119d658ac2
x86: Use flag output operands for inline asm in atomic-machine.h
...
Use the flag output constraints feature available in gcc 6+
("=@cc<cond>") instead of explicitly setting a boolean variable
with SETcc instruction. This approach decouples the instruction
that sets the flags from the code that consumes them, allowing
the compiler to create better code when working with flags users.
Instead of e.g.:
lock add %esi,(%rdi)
sets %sil
test %sil,%sil
jne <...>
the compiler now generates:
lock add %esi,(%rdi)
js <...>
No functional changes intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com >
Cc: H.J.Lu <hjl.tools@gmail.com >
Cc: Florian Weimer <fweimer@redhat.com >
Cc: Carlos O'Donell <carlos@redhat.com >
Reviewed-by: Florian Weimer <fweimer@redhat.com >
2025-08-29 09:05:23 +02:00
Paul Eggert
2642002380
Update copyright dates with scripts/update-copyrights
2025-01-01 11:22:09 -08:00
Paul Eggert
dff8da6b3e
Update copyright dates with scripts/update-copyrights
2024-01-01 10:53:40 -08:00
Joseph Myers
6d7e8eda9b
Update copyright dates with scripts/update-copyrights
2023-01-06 21:14:39 +00:00
Paul Eggert
581c785bf3
Update copyright dates with scripts/update-copyrights
...
I used these shell commands:
../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")
and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 7061 files FOO.
I then removed trailing white space from math/tgmath.h,
support/tst-support-open-dev-null-range.c, and
sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following
obscure pre-commit check failure diagnostics from Savannah. I don't
know why I run into these diagnostics whereas others evidently do not.
remote: *** 912-#endif
remote: *** 913:
remote: *** 914-
remote: *** error: lines with trailing whitespace found
...
remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2022-01-01 11:40:24 -08:00
Adhemerval Zanella
92ff345137
Remove atomic-machine.h atomic typedefs
...
Now that memusage.c uses generic types we can remove them.
2021-12-28 14:57:57 -03:00
Florian Weimer
cca75bd8b5
i386: Explain why __HAVE_64B_ATOMICS has to be 0
2021-11-02 10:26:23 +01:00
Paul Eggert
2b778ceb40
Update copyright dates with scripts/update-copyrights
...
I used these shell commands:
../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")
and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
2021-01-02 12:17:34 -08:00
Florian Weimer
0f34d426ac
x86: Remove UP macro. Define LOCK_PREFIX unconditionally.
...
The UP macro is never defined. Also define LOCK_PREFIX
unconditionally, to the same string.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org >
2020-11-13 15:20:03 +01:00
Joseph Myers
d614a75396
Update copyright dates with scripts/update-copyrights.
2020-01-01 00:14:33 +00:00
Paul Eggert
5a82c74822
Prefer https to http for gnu.org and fsf.org URLs
...
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 02:43:31 -07:00
Joseph Myers
04277e02d7
Update copyright dates with scripts/update-copyrights.
...
* All files with FSF copyright notices: Update copyright dates
using scripts/update-copyrights.
* locale/programs/charmap-kw.h: Regenerated.
* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
H.J. Lu
cd815050e5
x86: Merge i386/x86_64 atomic-machine.h
...
Merge i386 and x86_64 atomic-machine.h to x86 atomic-machine.h.
Tested on i686 and x86_64 as well as with build-many-glibcs.py.
* sysdeps/i386/atomic-machine.h: Merged with ...
* sysdeps/x86_64/atomic-machine.h: To ...
* sysdeps/x86/atomic-machine.h: This. New file.
2018-12-18 04:25:26 -08:00