aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/riscv
Commit message (Collapse)AuthorAgeFilesLines
* STACKALIGN: Reimplement in terms of __align_downJohn Baldwin2026-02-061-1/+2
| | | | | | | | | | This changes STACKALIGN to be type-preserving when operating on pointers. Reviewed by: brooks, kib Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54920
* libc/riscv64: implement bcopy() and bzero() through memcpy() and memset()Robert Clausecker2025-10-313-0/+30
| | | | | | | | | | | | This picks up the accelerated string functions written by strajabot@. Event: Google Summer of Code 2024 MFC after: 1 month MFC to: stable/15 See also: 79e01e7e643c9337d8d6046b6db7df674475a099 Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D53248
* libc: scalar strchrnul() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Scalar implementation of strchrnul() in RISC-V assembly and changes to the corresponding manpage. Performance was benchmarked on a HiFive Unmatched (SiFive HF105-001) board using: https://github.com/clausecker/strperf os: FreeBSD arch: riscv │ strchrnul_baseline │ strchrnul_scalar │ │ sec/op │ sec/op vs base │ Short 680.2µ ± 5% 435.3µ ± 0% -36.01% (p=0.000 n=20) Mid 314.7µ ± 3% 221.4µ ± 0% -29.63% (p=0.000 n=20) Long 152.3µ ± 0% 138.5µ ± 0% -9.08% (p=0.000 n=20) geomean 319.5µ 237.2µ -25.75% │ strchrnul_baseline │ strchrnul_scalar │ │ MiB/s │ MiB/s vs base │ Short 183.8 ± 5% 287.2 ± 0% +56.27% (p=0.000 n=20) Mid 397.3 ± 3% 564.6 ± 0% +42.12% (p=0.000 n=20) Long 820.5 ± 0% 902.5 ± 0% +9.99% (p=0.000 n=20) geomean 391.3 527.0 +34.68% MFC after: 1 month MFC to: stable/15 Approved by: markj (mentor) Reviewed by: fuz Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D46047
* libc: scalar strnlen() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimized implementation of strnlen() in RISC-V assembly Performance was measured using strperf on a HiFive Unmatched (SiFive HF105-001) board. os: FreeBSD arch: riscv │ strnlen_baseline │ strnlen_scalar │ │ sec/op │ sec/op vs base │ Short 787.0µ ± 0% 430.9µ ± 1% -45.24% (p=0.000 n=20) Mid 621.6µ ± 0% 195.1µ ± 1% -68.61% (p=0.000 n=20) Long 569.4µ ± 1% 100.6µ ± 0% -82.34% (p=0.000 n=20) geomean 653.1µ 203.7µ -68.81% │ strnlen_baseline │ strnlen_scalar │ │ MiB/s │ MiB/s vs base │ Short 158.8 ± 0% 290.1 ± 1% +82.62% (p=0.000 n=20) Mid 201.1 ± 0% 640.6 ± 1% +218.59% (p=0.000 n=20) Long 219.5 ± 1% 1242.9 ± 0% +466.19% (p=0.000 n=20) geomean 191.4 613.5 +220.57% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Reviewed by: fuz, Jari Sihvola <jsihv@gmx.com> Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D46230
* libc: scalar memcpy() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimized assembly implementation of memcpy() for the RISC-V architecture. The implementation has two paths: - An aligned path - (dst - src) % 8 = 0, runs faster - An unaligned path - (dst - src) % 8 != 0, runs slower os: FreeBSD arch: riscv │ memcpy_baseline │ memcpy_scalar │ │ sec/op │ sec/op vs base │ 64Align8 851.6µ ± 1% 488.9µ ± 1% -42.59% (p=0.000 n=12) 4kAlign8 681.5µ ± 1% 255.1µ ± 2% -62.57% (p=0.000 n=12) 256kAlign8 273.0µ ± 2% 230.7µ ± 2% -15.50% (p=0.000 n=12) 16mAlign8 98.07m ± 0% 95.29m ± 0% -2.84% (p=0.000 n=12) 64UAlign 887.5µ ± 1% 531.6µ ± 1% -40.10% (p=0.000 n=12) 4kUAlign 725.6µ ± 1% 262.2µ ± 1% -63.87% (p=0.000 n=12) 256kUAlign 844.1µ ± 2% 322.8µ ± 0% -61.76% (p=0.000 n=12) 16mUAlign 134.9m ± 0% 101.2m ± 0% -24.97% (p=0.000 n=20) geomean 2.410m 1.371m -43.12% │ memcpy_baseline │ memcpy_scalar │ │ MiB/s │ MiB/s vs base │ 64Align8 293.6 ± 1% 511.3 ± 1% +74.18% (p=0.000 n=12) 4kAlign8 366.8 ± 1% 980.0 ± 2% +167.15% (p=0.000 n=12) 256kAlign8 915.8 ± 2% 1083.7 ± 2% +18.34% (p=0.000 n=12) 16mAlign8 163.1 ± 0% 167.9 ± 0% +2.92% (p=0.000 n=12) 64UAlign 281.7 ± 1% 470.3 ± 1% +66.94% (p=0.000 n=12) 4kUAlign 344.5 ± 1% 953.6 ± 1% +176.77% (p=0.000 n=12) 256kUAlign 296.2 ± 2% 774.5 ± 0% +161.49% (p=0.000 n=12) 16mUAlign 118.6 ± 0% 158.1 ± 0% +33.28% (p=0.000 n=20) geomean 293.4 515.8 +75.81% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Reviewed by: fuz Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D46139
* libc: scalar strlen() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Includes a scalar implementation of strlen() for the RISC-V architecture and changes to the corresponding manpage. Performance was benchamarked using before and after: https://github.com/clausecker/strperf os: FreeBSD arch: riscv │ strlen_baseline │ strlen_scalar │ │ sec/op │ sec/op vs base │ Short 541.2µ ± 17% 401.6µ ± 0% -25.78% (p=0.000 n=21+20) Mid 249.6µ ± 3% 191.9µ ± 0% -23.13% (p=0.000 n=21+20) Long 124.6µ ± 0% 110.7µ ± 0% -11.13% (p=0.000 n=21+20) geomean 256.3µ 204.3µ -20.26% │ strlen_baseline │ strlen_scalar │ │ B/s │ B/s vs base │ Short 220.3Mi ± 14% 296.8Mi ± 0% +34.74% (p=0.000 n=21+20) Mid 477.6Mi ± 3% 621.3Mi ± 0% +30.09% (p=0.000 n=21+20) Long 956.9Mi ± 0% 1076.7Mi ± 0% +12.52% (p=0.000 n=21+20) geomean 465.2Mi 583.4Mi +25.40% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Reviewed by: fuz Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D45693
* libc: scalar memset() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds scalar implementation of memset for RISC-V and updates the relevant manpage os: FreeBSD arch: riscv │ ./results/memset/memset_baseline │ ./results/memset/memset_scalar │ │ sec/op │ sec/op vs base │ 40 527.5µ ± 1% 479.4µ ± 1% -9.12% (p=0.000 n=20) 168 254.5µ ± 1% 216.7µ ± 1% -14.86% (p=0.000 n=20) 2k 169.5µ ± 1% 128.4µ ± 0% -24.24% (p=0.000 n=20) 256k 161.2µ ± 1% 118.6µ ± 1% -26.42% (p=0.000 n=20) 16m 56.58m ± 0% 53.91m ± 0% -4.72% (p=0.000 n=20) geomean 730.2µ 611.2µ -16.29% │ ./results/memset/memset_baseline │ ./results/memset/memset_scalar │ │ B/s │ B/s vs base │ 40 452.0Mi ± 1% 497.3Mi ± 1% +10.04% (p=0.000 n=20) 168 936.9Mi ± 1% 1100.4Mi ± 1% +17.45% (p=0.000 n=20) 2k 1.373Gi ± 1% 1.813Gi ± 0% +32.00% (p=0.000 n=20) 256k 1.444Gi ± 1% 1.962Gi ± 1% +35.91% (p=0.000 n=20) 16m 269.7Mi ± 0% 283.1Mi ± 0% +4.96% (p=0.000 n=20) geomean 750.1Mi 896.1Mi +19.47% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Reviewed by: fuz Sponsored by: Google LLC (GSoc 2024) Differential Revision: https://reviews.freebsd.org/D45730
* libc: scalar memchr() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | Added an optimized memchr() implementation in RISC-V assembly and updated the relevant manpage. │ memchr_baseline │ memchr_scalar │ │ sec/op │ sec/op vs base │ Short 636.6µ ± 1% 495.9µ ± 1% -22.10% (p=0.000 n=20) Mid 279.7µ ± 1% 224.1µ ± 1% -19.87% (p=0.000 n=20) Long 138.8µ ± 0% 124.9µ ± 0% -10.00% (p=0.000 n=20) geomean 291.3µ 240.3µ -17.48% │ memchr_baseline │ memchr_scalar │ │ B/s │ B/s vs base │ Short 187.3Mi ± 1% 240.4Mi ± 1% +28.37% (p=0.000 n=20) Mid 426.2Mi ± 1% 531.9Mi ± 1% +24.79% (p=0.000 n=20) Long 859.0Mi ± 0% 954.4Mi ± 0% +11.11% (p=0.000 n=20) geomean 409.3Mi 496.0Mi +21.19% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Reviewed by: fuz Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D46023
* simd.7: add scalar strrchr() for RISC-V to manpageStrahinja Stanišić2025-10-311-0/+3
| | | | | | | | MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D47275
* libc: scalar strrchr() in RISC-V assemblyStrahinja Stanišić2025-10-312-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | Implements strrchr in RISC-V assembly, leading to the following improvements (performance measured on SiFive HF105-001) os: FreeBSD arch: riscv │ strrchr_baseline │ strrchr_scalar │ │ sec/op │ sec/op vs base │ Short 837.2µ ± 1% 574.6µ ± 1% -31.37% (p=0.000 n=20+21) Mid 639.7µ ± 0% 269.7µ ± 0% -57.84% (p=0.000 n=20+21) Long 589.1µ ± 0% 176.7µ ± 0% -70.01% (p=0.000 n=20+21) geomean 680.8µ 301.4µ -55.73% │ strrchr_baseline │ strrchr_scalar │ │ MiB/s │ MiB/s vs base │ Short 149.3 ± 1% 217.6 ± 1% +45.71% (p=0.000 n=20+21) Mid 195.4 ± 0% 463.6 ± 0% +137.22% (p=0.000 n=20+21) Long 212.2 ± 0% 707.4 ± 0% +233.40% (p=0.000 n=20+21) geomean 183.6 414.7 +125.88% MFC after: 1 month MFC to: stable/15 Approved by: mhorne, markj (mentor) Sponsored by: Google LLC (GSoC 2024) Differential Revision: https://reviews.freebsd.org/D47275
* libc, libthr: Ditch MD __pthread_distribute_static_tls helpersJessica Clarke2025-05-291-46/+0
| | | | | | | | | | | | | | | | | | _libc_get_static_tls_base() is just _tcb_get() followed by adding (for Variant I) or subtracting (for Variant II) the offset, so just inline that as the implementation (like we do in rtld-elf) rather than having another copy (or equivalent) of _tcb_get()'s assembly. _get_static_tls_base() doesn't even have any MD assembly as it's reading thr->tcb, the only difference is whether to add or subtract, so again just inline that. Whilst here add some missing blank lines to comply with style(9) for elf_utils.c's includes, and use a pointer type rather than uintptr_t to reduce the need to cast, as is done in rtld-elf. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D50592
* libc/riscv: Fix initial exec TLS mode for dynamically loaded shared objectsJessica Clarke2025-05-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | The offset here is relative to the TCB, not whatever the thread pointer points to, so as with powerpc and powerpc64 we need to account for that. However, rather than using hard-coded offsets as they did, due to predating machine/tls.h, we can just re-use _tcb_get(). Note that if libthr is used, and its initialiser has been called, it will take a different path that uses _get_static_tls_base, which works just fine on riscv (adding the offset to thr->tcb). This only affects programs that aren't linked against libthr (or that are but manage to dlopen before the initialiser is called, if that's even possible). In future this code should be made MI by just reusing _tcb_get() and checking the TLS variant (since the offset here is positive even for variant II, where it should be subtracted), but this is a targeted fix that makes it clear what's changing. Reviewed by: kib Fixes: 5d00c5a6571c ("Fix initial exec TLS mode for dynamically loaded shared objects.") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D50564
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* riscv: remove more riscv64sf supportBrooks Davis2024-03-211-10/+0
| | | | | | | | | | Remove a few more bits of riscv64sf support in libc and libm. Reduce floating point ABI checks to requiring double hard float. Reviewed by: imp, jhb Fixes: 1ca12bd927d7 Remove the riscv64sf architecture. Differential Revision: https://reviews.freebsd.org/D44334
* libc: Move per-arch sys/Makefile.inc to libsysBrooks Davis2024-02-051-6/+0
| | | | | | | | | | | | | | | libc/<arch>/sys/Makefile.inc -> libsys/<arch>/Makefile.sys. Require that libsys/<arch>/Makefile.sys exist. At least for current archtiectures, it's not possible for an architecture to not have and MD syscall bits. powerpcspe/Makefile.sys's structure means it had to be modified when moved so rename detection won't work, but it has trivial contents so the history is unimportant. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* libc: libc/<arch>/sys/__vdso_gettc -> libsys/<arch>/Brooks Davis2024-02-051-53/+0
| | | | | Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* libsys: relocate implementations and manpagesBrooks Davis2024-02-054-199/+0
| | | | | | | | | Remove core system call implementations and documentation to lib/libsys and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>. Update paths to allow libc to find them in their new home. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* riscv/SYS.h: implement _SYSCALL_BODY() macroBrooks Davis2023-12-181-9/+8
| | | | | | | | | Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and calls cerror as required. Use to implement PSEUDO() and RSYSCALL(). Reviewed by: imp, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43057
* libc/*/SYS.h: remove SYCALL macroBrooks Davis2023-12-121-8/+0
| | | | | | | | | | | This has not been a univerally available interface since it was removed from amd64 by commit efbef97de9805dec95db09953426f0b21bb2964f in 2004. I removed the last consumers in 2016 when I replaced pipe(2) with pipe2(2) in commit b60998c6331e2be21f1fc29fa6c82d94a1f72ef0. Reviewed by: imp, jhibbits Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42996
* libc: don't needlessly add vfork.o to NOASMBrooks Davis2023-12-061-3/+0
| | | | | | | | | | For architectures where vfork.S was named Ovfork.S this was needed, but it was always pointless here as an entry in either MDASM or NOASM is equivalent. Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42914
* Remove never implemented sbrk and sstk syscallsBrooks Davis2023-12-041-1/+1
| | | | | | | | | | | | | Both system calls were stubs returning EOPNOTSUPP and libc did not provide _ or __sys_ prefixed symbols. The actual implementation of sbrk(2) is on top of the undocumented break(2) system call. Technically this is a change in ABI, but no non-contrived program ever called these syscalls. Reviewed by: kib, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42872
* libc: centralize a few numeric symbolsBrooks Davis2023-11-151-3/+0
| | | | | | | | | | | | fabs, __infinity, and __nan are universally implemented so declare them in gen/Symbol.map. We would also include __flt_rounds, but it's under FBSD_1.3 on arm so until that's gone we're stuck with it. Likewise, everyone but i386 implements fp[gs]etmask. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42618
* libc: centralize makecontext symbolsBrooks Davis2023-11-151-5/+0
| | | | | | | | Declare makecontext() and __makecontext() symbols centrally as they are always implemented. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D42617
* libc: centralize {_,sig,}{set,long}jmp symbolsBrooks Davis2023-11-151-6/+0
| | | | | | | | | These symbols are universally exposed and documented so declare them centrally. Double- and triple-underscore versions exist on some platforms, but leave those alone for now. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D42616
* libc: centralize ntoh symbolsBrooks Davis2023-11-151-4/+0
| | | | | | | | These are implemented by net/ntoh.c via headers and compiler intrinsics so declare them in net/Symbol.map. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42615
* libc: further centralize syscall symbolsBrooks Davis2023-11-151-4/+0
| | | | | | | | All architectures necessarily implement _exit(2) and vfork(2) so declare them in sys/Symbol.map. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42614
* libc: Remove empty comments in Symbol.mapBrooks Davis2023-11-151-3/+0
| | | | | | | These were left over from $FreeBSD$ removal. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42612
* libc/<arch>/sys/Makefile.inc: remove cruftBrooks Davis2023-11-151-1/+0
| | | | | | | | Remove stray blank lines left over from $FreeBSD$ removal as well as some CVS-era (perhaps pre-repocopy) version comments. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42611
* libc: Purge unneeded cdefs.hWarner Losh2023-11-016-6/+0
| | | | | | | | | These sys/cdefs.h are not needed. Purge them. They are mostly left-over from the $FreeBSD$ removal. A few in libc are still required for macros that cdefs.h defines. Keep those. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42385
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1614-27/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-163-3/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-165-10/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* libc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-VJessica Clarke2023-01-092-0/+6
| | | | | | | | | | | These architectures fail to handle this special case, and will cause the corresponding setjmp/_setjmp to return 0 rather than 1. Fix this and add regression tests (also committed upstream). PR: 268684 Reviewed by: arichardson, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29363
* libc: Remove _get_tp() and _set_tp().John Baldwin2021-12-094-103/+0
| | | | | | | | | Their uses have been replaced by _tcb_get() and _tcb_set() from <machine/tls.h>. Reviewed by: kib, jrtc27 Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33354
* Add sched_getcpu()Konstantin Belousov2021-11-101-1/+2
| | | | | | | | | for compatibility with Linux. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32901
* riscv: Implement non-stub __vdso_gettc and __vdso_gettimekeepJessica Clarke2021-07-052-1/+57
| | | | | | | PR: 256905 Reviewed by: arichardson, mhorne MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30963
* libc: add _get_tp() private functionKonstantin Belousov2021-04-092-0/+50
| | | | | | | | which returns pointer to tcb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29623
* riscv: Fix whitespace issues in fabs added in 524b018d2004Jessica Clarke2021-03-011-2/+2
|
* riscv: Add a soft-float implementation of fabs()Alex Richardson2021-03-011-2/+9
| | | | | | | | | | | | | | | We could just use a C implementation using __builtin_fabs(), but using this assembly version guarantees that there is no additional prolog/epilog code. Additionally, clang generates worse code for masking off the top bit than GCC: https://bugs.llvm.org/show_bug.cgi?id=49377. This fixes the RISCV64 softfloat world build after cf97d2a1dab8. That commit added -fno-builtin to the msun tests which resulted in the first references to fabs (previously the compiler inlined all calls). Reviewed By: dim Reported by: mjg Differential Revision: https://reviews.freebsd.org/D28994
* libc: Provide sub fp(s|g)etmask() implementations for RISC-VKristof Provost2020-08-033-0/+96
| | | | | | | | | | | | | | | | | | | | RISC-V doesn't support floating-point exceptions. RISC-V Instruction Set Manual: Volume I: User-Level ISA, 11.2 Floating-Point Control and Status Register: "As allowed by the standard, we do not support traps on floating-point exceptions in the base ISA, but instead require explicit checks of the flags in software. We considered adding branches controlled directly by the contents of the floating-point accrued exception flags, but ultimately chose to omit these instructions to keep the ISA simple." We still need these functions, because some applications (notably Perl) call them, but we cannot provide a meaningful implementation. Sponsored by: Axiado Differential Revision: https://reviews.freebsd.org/D25740 Notes: svn path=/head/; revision=363796
* Fix printf(3) output of long doubles on RISC-VMitchell Horne2020-06-291-14/+0
| | | | | | | | | | | | | | | | | | | | | | When the RISC-V port was initially committed to FreeBSD, GCC would generate 64-bit long doubles, and the definitions in _fpmath.h reflected that. This was changed to 128-bit in GCC later that year [1], but the definitions were never updated, despite the documented workaround. This causes printf(3) and friends to interpret only the low 64-bits of a long double in ldtoa, thereby printing incorrect values. Update the definitions now that both clang and GCC generate 128-bit long doubles. [1] https://github.com/riscv/riscv-gcc/commit/54b21fc5ae83cefec44bc2caed4a8c664c274ba0 PR: 242067 Reported by: Dennis Clarke <dclarke@blastwave.org> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25420 Notes: svn path=/head/; revision=362788
* Check the magic value in longjmp() before calling sigprocmask().John Baldwin2020-04-211-5/+5
| | | | | | | | | | | | | This avoids passing garbage to sigprocmask() if the jump buffer is invalid. Reviewed by: mhorne Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24483 Notes: svn path=/head/; revision=360169
* Tidy the _set_tp function for RISC-V.John Baldwin2020-02-061-3/+4
| | | | | | | | | | | | | | - Use a constant for the offset instead of a magic number. - Use an addi instruction that writes to tp directly instead of a mv that writes the result of a compiler-generated addi. Reviewed by: mhorne MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23521 Notes: svn path=/head/; revision=357643
* Use "far" calls and branches so that lld uses valid relocations.John Baldwin2019-12-042-6/+10
| | | | | | | | | | | | | | Conditional branch and jump instructions do not always call via PLT stubs and thus will not honor LD_PRELOAD, etc. lld warns about using non-preemptible relocations for preemptible or unknown symbols whereas bfd does not (at least for RISC-V). Reviewed by: br, James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22658 Notes: svn path=/head/; revision=355403
* Use a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.John Baldwin2019-12-042-8/+4
| | | | | | | | | | | | This saves an instruction in each case as well as an extra memory indirection via the GOT for PIC code. Reviewed by: br, James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22656 Notes: svn path=/head/; revision=355402
* Fix initial exec TLS mode for dynamically loaded shared objects.Konstantin Belousov2019-03-291-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | If dso uses initial exec TLS mode, rtld tries to allocate TLS in static space. If there is no space left, the dlopen(3) fails. If space if allocated, initial content from PT_TLS segment is distributed to all threads' pcbs, which was missed and caused un-initialized TLS segment for such dso after dlopen(3). The mode is auto-detected either due to the relocation used, or if the DF_STATIC_TLS dynamic flag is set. In the later case, the TLS segment is tried to allocate earlier, which increases chance of the dlopen(3) to succeed. LLD was recently fixed to properly emit the flag, ld.bdf did it always. Initial test by: dumbbell Tested by: emaste (amd64), ian (arm) Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19072 Notes: svn path=/head/; revision=345703
* Fix setjmp for RISC-V:Ruslan Bukin2018-07-232-52/+52
| | | | | | | | | | | | | | o The correct value for _JB_SIGMASK is 27. o The storage size for double-precision floating point register is 8 bytes. Submitted by: "James Clarke" <jrtc4@cam.ac.uk> Reviewed by: markj@ Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D16344 Notes: svn path=/head/; revision=336633