Compare commits

..
96 Commits
Author SHA1 Message Date
Mark Johnston 2e6399fe39 Add UPDATING entries and bump version
Approved by:	so
2026-04-30 21:21:13 +00:00
Dag-Erling Smørgrav b362b6b6c8 dhclient: Improve server and filename validation
* Don't iterate over each string three times; once is enough.

* Reject control characters (anything below space) in addition to the
  double quote and backslash.

* If an unsafe character is encountered, discard the string instead of
  rejecting the entire lease.

* If backslashes are encountered in the file name option, convert them
  to forward slashes instead of rejecting the option.

* Tweak the warning messages a bit.  Looking through the rest of the
  code, it seems to me that notes generally end with a period while
  warnings generally don't.

Approved by:	so
Security:	FreeBSD-EN-26:11.dhclient
Fixes:		8008e4b88d ("dhclient: Check for unexpected characters in some DHCP server options")
PR:		294886
MFC after:	1 week
Reviewed by:	brooks, markj
Differential Revision:	https://reviews.freebsd.org/D56740

(cherry picked from commit 873a195ba6)
(cherry picked from commit b1ece85741)
2026-04-30 21:20:57 +00:00
Mark Johnston bf0db64e03 Add UPDATING entries and bump version
Approved by:	so
2026-04-28 20:32:11 +00:00
Mariusz Zaborski f7f48005fb libnv: fix heap overflow in nvlist_recv()
nvlist_check_header() validated nvlh_size for overflow before
performing conversion. An mallicous user can set
NV_FLAG_BIG_ENDIAN in the header and craft nvlh_size so that
the orginall value passes the check, but after the conversion the
sizeof(nvlist_header) + size can overflow.
This can lead to a heap buffer overflow.

Approved by:	so
Security:	FreeBSD-SA-26:17.libnv
Security:	CVE-2026-35547
Fixes:		36fa90dbde
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D56342
2026-04-28 20:32:11 +00:00
Mariusz Zaborski 32d12677ff libnv: switch fd_wait() from select(2) to poll(2)
The previous implementation used FD_SET() on a stack-allocated fd_set,
which is an out-of-bounds write whenever the socket fd is >= FD_SETSIZE
(1024).

Approved by:	so
Security:	FreeBSD-SA-26:16.libnv
Security:	CVE-2026-39457
Reported by:	Joshua Rogers of AISLE Research Team (https://aisle.com/)
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D56689
2026-04-28 20:32:11 +00:00
Kristof Provost 0ab05345fb pf: improve SCTP validation
As per RFC5061 "4.2.  New Parameter Types" the add/delete IP address
parameters (0xc001, 0xc002) may not be present in an INIT or INIT-ACK
chunk. They are only allowed to be present in an ASCONF chunk.

This also prevents unbounded recursion while parsing an SCTP packet.

Approved by:	so
Security:	FreeBSD-SA-26:14.pf
Security:	CVE-2026-7164
PR:		294799
Reported by:	Igor Gabriel Sousa e Souza
MFC after:	3 days
Sponsored by:	Orange Business Services
2026-04-28 20:32:11 +00:00
Mark Johnston 5a5e7883a3 dhclient: Fix reallocation of dhclient script environments
When the number of DHCP options exceeds a threshold, script_set_env()
will reallocate the environment, stored as an array of pointers.  The
calculation of the array size failed to multiply by the pointer size,
resulting in a smaller than expected buffer which admits out-of-bounds
writes.

Approved by:	so
Security:	FreeBSD-SA-26:15.dhclient
Security:	CVE-2026-42511
Reported by:	Joshua Rogers of AISLE Research Team (https://aisle.com/)
2026-04-28 20:32:11 +00:00
Mark Johnston a2d45189b9 dhclient: Check for unexpected characters in some DHCP server options
Some options are written directly to the lease file, which may be parsed
by subsequent dhclient invocations.  We must make sure that a malicious
server can't control the "medium" field of a lease definition, otherwise
they can achieve RCE by injecting one into the lease file, whereupon it
will be passed to dhclient-script, which passes it through eval.

Approved by:	so
Security:	FreeBSD-SA-26:12.dhclient
Security:	CVE-2026-42511
Reported by:	Joshua Rogers of AISLE Research Team (https://aisle.com/)
2026-04-28 20:32:11 +00:00
Mark Johnston 7c5c37ac8f execve: Fix an operator precedence bug
The buggy version allowed userspace to overflow the copy into adjacent
execve KVA regions, which enables, among other things, injecting
environment variables into privileged processes.

Approved by:	so
Security:	FreeBSD-SA-26:13.exec
Security:	CVE-2026-7270
Reported by:	Ryan Austin of Calif.io
Reviewed by:	brooks, kib
Fixes:		f373437a01 ("Add helper functions to copy strings into struct image_args.")
Differential Revision:	https://reviews.freebsd.org/D56665
2026-04-28 20:32:11 +00:00
Philip Paeps f7e6b9f128 contrib/tzdata: import tzdata 2025c, 2026a and 2026b
Changes: https://github.com/eggert/tz/blob/2025c/NEWS
Changes: https://github.com/eggert/tz/blob/2026a/NEWS
Changes: https://github.com/eggert/tz/blob/2026b/NEWS

Approved by:	so
Security:	FreeBSD-EN-26:09.tzdata

(cherry picked from commit a86dc94b84)
(cherry picked from commit c7edaaf43f)
(cherry picked from commit 6becc3dff9)
(cherry picked from commit c0b2aff48f)
(cherry picked from commit 9b95cab0a2)
(cherry picked from commit 18787e4ae2)
2026-04-28 20:32:11 +00:00
Mark Johnston 6c36e5dd0c Add UPDATING entries and bump version
Approved by:	so
2026-04-21 15:47:00 +00:00
Mark Johnston a2f6f2d001 pkru: Fix handling of 1GB largepage mappings
pmap_pkru_update_range() did not handle the case where a PDPE has PG_PS
set.  More generally, the SET_PKRU and CLEAR_PKRU sysarch
implementations did not check whether the request covers a "boundary" vm
map entry.  Fix this, add the missing PG_PS test, and add some tests.

Approved by:	so
Security:	FreeBSD-SA-26:11.amd64
Security:	CVE-2026-6386
Reported by:	Nicholas Carlini <[email protected]>
Reviewed by:	kib, alc
Differential Revision:	https://reviews.freebsd.org/D56184
2026-04-21 15:47:00 +00:00
Mark Johnston 2862a33bdd tty: Avoid leaving dangling pointers in tty_drop_ctty()
The TIOCNOTTY handler detaches the calling process from its controlling
terminal.  It clears the link from the session to the tty, but not the
pointers from the tty to the session and process group.  This means that
sess_release() doesn't call tty_rel_sess(), and that pgdelete() doesn't
call tty_rel_pgrp(), so the pointers are left dangling.

Fix this by clearing pointers in tty_drop_ctty().  Add a standalone
regression test.

Approved by:	so
Security:	FreeBSD-SA-26:10.tty
Security:	CVE-2026-5398
Reported by:	Nicholas Carlini <[email protected]>
Reviewed by:	kib, kevans
Fixes:		1b50b999f9 ("tty: implement TIOCNOTTY")
Differential Revision:	https://reviews.freebsd.org/D56046
2026-04-21 15:47:00 +00:00
Mark Johnston 6c9dd75283 vm_fault: Reset m_needs_zeroing properly
- When allocating a page, we should only consider the PG_ZERO flag when
  handling the top-level page.
- Unconditionally reset the flag when restarting the fault handler.
  Previously, vm_fault_busy_sleep() would fail to reset it.

Approved by:	so
Security:	FreeBSD-EN-26:05.vm
PR:		294039
Reviewed by:	kib
Tested by:	Peter Much <[email protected]>
MFC after:	3 days
Fixes:		cff67bc43d ("vm_fault: only rely on PG_ZERO when the page was newly allocated")
Differential Revision:	https://reviews.freebsd.org/D56234

(cherry picked from commit 04132e0100)
(cherry picked from commit 50f7b62f08)
2026-04-21 15:46:57 +00:00
Mark Johnston 5c4e558ab4 Add UPDATING entries and bump version
Approved by:	so
2026-03-26 09:31:01 +08:00
Mark Johnston c4f53a1adb rpcsec_gss: Fix a stack overflow in svc_rpc_gss_validate()
svc_rpc_gss_validate() copies the input message into a stack buffer
without ensuring that the buffer is large enough.  Sure enough,
oa_length may be up to 400 bytes, much larger than the provided space.
This enables an unauthenticated user to trigger an overflow and obtain
remote code execution.

Add a runtime check which verifies that the copy won't overflow.

Approved by:	so
Security:	FreeBSD-SA-26:08.rpcsec_gss
Security:	CVE-2026-4747
Reported by:	Nicholas Carlini <[email protected]>
Reviewed by:	rmacklem
Fixes:		a9148abd9d
2026-03-26 09:30:59 +08:00
Mark Johnston 9d3e842358 Add UPDATING entries and bump version
Approved by:	so
2026-02-24 16:04:27 +00:00
Mark Johnston c2e2bfbd9e rtsock: Fix stack overflow
Approved by:	so
Security:	FreeBSD-SA-26:05.route
Security:	CVE-2026-3038
Fixes:		92be2847e8 ("rtsock: Avoid copying uninitialized padding bytes")

(cherry picked from commit f3be7df50f)
(cherry picked from commit 8b476ffc4e)
2026-02-24 16:03:49 +00:00
Mark Johnston 933abe4a19 amd64/conf: Remove a config committed by accident
Approved by:	so
Reported by:	kib, kp
Fixes:		350ba9672a ("unix: Set O_RESOLVE_BENEATH on fds transferred between jails")

(cherry picked from commit 3ef39f58e5)
(cherry picked from commit 3b0f13ca60)
2026-02-23 01:48:38 +00:00
Mark Johnston ecec541087 unix/tests: Add a regression test for fd transfer across jails
Approved by:	so
MFC after:	3 weeks

(cherry picked from commit 5843b8ee02)
(cherry picked from commit c997713286)
2026-02-23 01:48:38 +00:00
Mark Johnston e6b96891ef unix: Set O_RESOLVE_BENEATH on fds transferred between jails
If a pair of jails with different filesystem roots is able to exchange
SCM_RIGHTS messages (e.g., using a unix socket in a shared nullfs
mount), a process in one jail can open a directory outside of the root
of the second jail and then pass the fd to that second jail, allowing
the receiving process to escape the jail chroot.

Address this using the new FD_RESOLVE_BENEATH flag.  When externalizing
an SCM_RIGHTS message into the receiving process, automatically set this
flag on all new fds where a jail boundary is crossed.  This ensures that
the receiver cannot do more than access files underneath the directory;
in particular, the received fd cannot be used to access vnodes not
accessible by the sender.

Approved by:	so
PR:		262179
Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D50371

(cherry picked from commit 350ba9672a)
(cherry picked from commit 73530e4c2e)
2026-02-23 01:48:38 +00:00
Mark Johnston 82cee749b5 file: Add a fd flag with O_RESOLVE_BENEATH semantics
The O_RESOLVE_BENEATH openat(2) flag restricts name lookups such that
they remain under the directory referenced by the dirfd.  This commit
introduces an implicit version of the flag, FD_RESOLVE_BENEATH, stored
in the file descriptor entry.  When the flag is set, any lookup relative
to that fd automatically has O_RESOLVE_BENEATH semantics.  Furthermore,
the flag is sticky, meaning that it cannot be cleared, and it is copied
by dup() and openat().

File descriptors with FD_RESOLVE_BENEATH set may not be passed to
fchdir(2) or fchroot(2).  Various fd lookup routines are modified to
return fd flags to the caller.

This flag will be used to address a case where jails with different root
directories and the ability to pass SCM_RIGHTS messages across the jail
boundary can transfer directory fds in such as way as to allow a
filesystem escape.

Approved by:	so
PR:		262180
Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D50371

(cherry picked from commit f35525ff20)
(cherry picked from commit f7cbcb19a9)
2026-02-23 01:48:38 +00:00
Mark Johnston 0b18e4842c file: Qualify pointers to capsicum rights as const
File descriptor lookup routines typically take a set of capsicum rights
as input to the lookup, so that the fd's rights can be atomically
checked.  This set should be qualified with const.

No functional change intended.

Approved by:	so
Reviewed by:	olce, oshogbo, brooks, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50419

(cherry picked from commit 5319cb2161)
(cherry picked from commit ecc1e61d31)
2026-02-09 23:11:00 +00:00
Mark Johnston 0e9fc21ec0 Add UPDATING entries and bump patch version
Approved by:	so
2026-01-27 16:55:52 +00:00
Gordon Tetlow 9afc16c4e8 openssl: Fix multiple vulnerabilities
This is a rollup commit from upstream to fix:
  Heap out-of-bounds write in BIO_f_linebuffer on short writes (CVE-2025-68160)
  Unauthenticated/unencrypted trailing bytes with low-level OCB function calls (CVE-2025-69418)
  Out of bounds write in PKCS12_get_friendlyname() UTF-8 conversion (CVE-2025-69419)
  Missing ASN1_TYPE validation in TS_RESP_verify_response() function (CVE-2025-69420)
  NULL Pointer Dereference in PKCS12_item_decrypt_d2i_ex function (CVE-2025-69421)
  Missing ASN1_TYPE validation in PKCS#12 parsing (CVE-2026-22795)
  ASN1_TYPE Type Confusion in the PKCS7_digest_from_attributes() function (CVE-2026-22796)

See https://openssl-library.org/news/secadv/ for additional details.

Approved by:	so
Obtained from:	OpenSSL
Security:	FreeBSD-SA-26:01.openssl
Security:	CVE-2025-68160
Security:	CVE-2025-69418
Security:	CVE-2025-69419
Security:	CVE-2025-69420
Security:	CVE-2025-69421
Security:	CVE-2026-22795
Security:	CVE-2026-22796
2026-01-27 16:55:52 +00:00
Konstantin Belousov e91e8b785b namei: clear internal flags in NDREINIT()
same as it is done for NDRESTART()

Approved by:	so
Fixes:  e05e33041c
Reported and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 58b2bd33af)
(cherry picked from commit 53963866f7)
2026-01-27 16:55:52 +00:00
Mark Johnston 15b39c1df3 namei: Fix cn_flags width in various places
This truncation is mostly harmless today, but fix it anyway to avoid
pain later down the road.

Approved by:	so
Reviewed by:	olce, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50417

(cherry picked from commit 0d224af399)
(cherry picked from commit 503ab844ce)
2026-01-27 16:55:52 +00:00
Mark Johnston 4613405fd6 vfs cache: Add NAMEILOOKUP to the whitelist of fastpath lookup flags
Otherwise the lockless name lookup path is inadvertently disabled since
NAMEILOOKUP isn't recognized.

Approved by:	so
Reviewed by:	olce, kib
Fixes:		7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")
Differential Revision:	https://reviews.freebsd.org/D50532

(cherry picked from commit f415895300)
(cherry picked from commit adb8c1a9d0)
2026-01-27 16:55:52 +00:00
Mark Johnston 4586c4f500 namei: Remove a now-unused variable
Approved by:	so
Reported by:	bapt
Fixes:		7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")

(cherry picked from commit 14ec281a09)
(cherry picked from commit 4e31059f80)
2026-01-27 16:55:52 +00:00
Mark Johnston 9f959a9837 tests: Add a regression test for commit 7587f6d484
Approved by:	so
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50533

(cherry picked from commit a5dac34f6e)
(cherry picked from commit b55b927296)
2026-01-27 16:55:48 +00:00
Mark Johnston fbb71f3a14 vfs: Don't clobber namei flags in vn_open_cred()
Otherwise NAMEILOOKUP is cleared.  More generally it seems quite
surprising that the flags set by vn_open_cred() callers are not
automatically preserved.  Modify open2nameif() such that it takes
already-set namei flags into account.

Approved by:	so
Reviewed by:	olce, kib
Fixes:		7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")
Differential Revision:	https://reviews.freebsd.org/D50531

(cherry picked from commit e05e33041c)
(cherry picked from commit 8c63056ea8)
2026-01-26 16:46:30 +00:00
Mark Johnston e87a5dd805 namei: Make stackable filesystems check harder for jail roots
Suppose a process has its cwd pointing to a nullfs directory, where the
lower directory is also visible in the jail's filesystem namespace.
Suppose that the lower directory vnode is moved out from under the
nullfs mount.  The nullfs vnode still shadows the lower vnode, and
dotdot lookups relative to that directory will instantiate new nullfs
vnodes outside of the nullfs mountpoint, effectively shadowing the lower
filesystem.

This phenomenon can be abused to escape a chroot, since the nullfs
vnodes instantiated by these dotdot lookups defeat the root vnode check
in vfs_lookup(), which uses vnode pointer equality to test for the
process root.

Fix this by extending nullfs and unionfs to perform the same check,
exploiting the fact that the passed componentname is embedded in a
nameidata structure to avoid changing the VOP_LOOKUP interface.  That
is, add a flag to indicate that containerof can be used to get the full
nameidata structure, and perform the root vnode check on the lower vnode
when performing a dotdot lookup.

Approved by:	so
Security:	FreeBSD-SA-26:02.jail
Security:	CVE-2025-15547
PR:		262180
Reviewed by:	olce, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50418

(cherry picked from commit 7587f6d484)
(cherry picked from commit 592de68e32)
2026-01-26 16:45:56 +00:00
Konstantin Belousov 78b90c34c3 nullfs lookup: cn_flags is 64bit
Approved by:	so
Reviewed by:	olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50390

(cherry picked from commit 89549c2348)
(cherry picked from commit 19b91b1553)
2026-01-26 16:45:53 +00:00
Konstantin Belousov fd02eb5592 vm_fault: only rely on PG_ZERO when the page was newly allocated
Approved by:	so
Security:	FreeBSD-EN-26:03.vm

(cherry picked from commit cff67bc43d)
(cherry picked from commit babac9d7bc)
2026-01-26 15:38:02 +00:00
Konstantin Belousov 4967e14ba2 vm_object_page_remove(): clear pager even if there is no resident pages
Approved by:	so
Security:	FreeBSD-EN-26:03.vm

(cherry picked from commit 72a447d0bc)
(cherry picked from commit 1dc8b622b3)
2026-01-26 15:37:47 +00:00
Mark Johnston eb5a6f5f9f Add UPDATING entries and bump version
Approved by:	so
2025-12-16 23:41:46 +00:00
Mark Johnston 35cee6a901 rtsold: Validate entries in domain search lists
Reported by:	Kevin Day <[email protected]>
Approved by:	so
Security:	FreeBSD-SA-25:12.rtsold
Security:	CVE-2025-14558
2025-12-16 23:41:40 +00:00
Kyle Evans 60026b0636 ipfw: pmod: avoid further rule processing after tcp-mod failures
m_pullup() here will have freed the mbuf chain, but we pass back an
IP_FW_DENY without any signal that the outer loop should finish.  Thus,
rule processing continues without an mbuf and there's a chance that we
conclude that the packet may pass (but there's no mbuf remaining)
depending on the rules that follow it.

PR:		284606
Reviewed by:	ae
Approved by:	so
Security:	FreeBSD-SA-25:11.ipfw
Security:	CVE-2025-14769

(cherry picked from commit c0382512bf)
(cherry picked from commit 9436058454)
2025-12-16 01:55:38 +00:00
Gordon Tetlow 4fc17862cb Add UPDATING entries and bump version.
Approved by:	so
2025-11-26 08:12:10 -08:00
Gordon Tetlow 9b0808259a Add a fix to scrub unsolicited NS RRSets to prevent cache poisoning.
Approved by:	so
Obtained from:	NLnet Labs
Security:	FreeBSD-SA-25:10.unbound
Security:	CVE-2025-11411
2025-11-26 08:09:36 -08:00
Mark Johnston c4530d6e5f Add UPDATING entries and bump version
Approved by:	so
2025-10-22 15:53:22 +00:00
Mark Johnston 8a7adde307 so_reuseport_lb_test: Add a test case for connected UDP sockets
Approved by:	so

(cherry picked from commit 1dd66c6ac2)
(cherry picked from commit 8e999e63c3)
2025-10-22 15:53:11 +00:00
Mark Johnston 90e14aa082 inpcb: Ignore SO_REUSEPORT_LB on connected sockets
While TCP disallows connect()ing a socket with SO_REUSEPORT_LB, UDP does
not.  As a result, a connected UDP socket can be placed in the lbgroup
hash and thus receive datagrams from sources other than the connected
host.

Reported by:	Amit Klein <[email protected]>
Reported by:	Omer Ben Simhon <[email protected]>
Reviewed by:	glebius
Approved by:	so
Security:	FreeBSD-SA-25:09.netinet
Security:	CVE-2025-24934

(cherry picked from commit 320ad3dec5)
(cherry picked from commit df888c8f41)
2025-10-22 15:52:57 +00:00
Gordon Tetlow c106ed3325 Add UPDATING entries and bump version.
Approved by:	so
2025-09-30 08:36:55 -07:00
Gordon Tetlow ae7c74cfa5 Fix issue from OpenSSL.
Out-of-bounds read & write in RFC 3211 KEK Unwrap (CVE-2025-9230)

Obtained from:	OpenSSL
Approved by:	so
Security:	FreeBSD-SA-25:08.openssl
Security:	CVE-2025-9230

(cherry picked from commit c0dbaf2b5d)
2025-09-30 08:32:35 -07:00
Colin Percival ab91dd76ff freebsd-update: Library ordering
Upgrading from 14.x to 15.x with freebsd-update broke because libc
depends on the new libsys library; freebsd-update installed the new
libc before creating libsys, and every step after that failed because
all the tools (including gunzip and install) are dynamically linked
and need a working libc.

Enforce ordering when installing shared objects: First libsys, then
libc, then libthr, and then all the rest of the shared object files.

This is a candidate for an Errata Notice since the issue this fixes
breaks upgrades.

PR:		289769
Reported by:	Graham Perrin
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D52688
Approved by:	so
Security:	FreeBSD-EN-25:18.freebsd-update

(cherry picked from commit 7ece602e00)
(cherry picked from commit 87eb52f1b0)
2025-09-29 21:58:26 -07:00
Gordon Tetlow e8acfa0be3 Add UPDATING entries and bump version.
Approved by:    so
2025-09-16 09:28:16 -07:00
John-Mark Gurney 751971e554 arm64: prevent panic when using syscall mux + large arg call (mmap)
if the syscall muxes are used, up to two additional arguments
may be required.  This means that the 8 required for mmap increases
up to 10 (for __syscall).

Sponsored by:   Juniper Networks, Inc.
Approved by:	so
Security:	FreeBSD-EN-25:15.arm64

(cherry picked from commit 740b879c6a)
(cherry picked from commit 98ac13c4ba)
2025-09-13 17:22:42 -07:00
Gordon Tetlow 23bc592b8f Add UPDATING entries and bump version.
Approved by:	so
2025-08-07 17:23:24 -07:00
Martin Matuska 798b7b161a libarchive: merge from vendor branch
libarchive 3.8.1

New features:
 #2088 7-zip reader: improve self-extracting archive detection
 #2137 zip writer: added XZ, LZMA, ZSTD and BZIP2 support
 #2403 zip writer: added LZMA + RISCV BCJ filter
 #2601 bsdtar: support --mtime and --clamp-mtime
 #2602 libarchive: mbedtls 3.x compatibility

Security fixes:
 #2422 tar reader: Handle truncation in the middle of a GNU long linkname
       (CVE-2024-57970)
 #2532 tar reader: fix unchecked return value in list_item_verbose()
       (CVE-2025-25724)
 #2532 unzip: fix null pointer dereference (CVE-2025-1632)
 #2568 warc: prevent signed integer overflow (CVE-2025-5916)
 #2584 rar: do not skip past EOF while reading (CVE-2025-5918)
 #2588 tar: fix overflow in build_ustar_entry (CVE-2025-5917)
 #2598 rar: fix double free with over 4 billion nodes (CVE-2025-5914)
 #2599 rar: fix heap-buffer-overflow (CVE-2025-5915)

Important bugfixes:
 #2399 7-zip reader: add SPARC filter support for non-LZMA compressors
 #2405 tar reader: ignore ustar size when pax size is present
 #2435 tar writer: fix bug when -s/a/b/ used more than once with b flag
 #2459 7-zip reader: add POWERPC filter support for non-LZMA compressors
 #2519 libarchive: handle ARCHIVE_FILTER_LZOP in archive_read_append_filter
 #2539 libarchive: add missing seeker function to archive_read_open_FILE()
 #2544 gzip: allow setting the original filename for gzip compressed files
 #2564 libarchive: improve lseek handling
 #2582 rar: support large headers on 32 bit systems
 #2587 bsdtar: don't hardlink negative inode files together
 #2596 rar: support large headers on 32 bit systems
 #2606 libarchive: support @-prefixed Unix epoch timestamps as date strings
 #2634 tar: Support negative time values with pax
 #2637 tar: Keep block alignment after pax error
 #2642 libarchive: fix FILE_skip regression
 #2643 tar: Handle extra bytes after sparse entries
 #2649 compress: Prevent call stack overflow
 #2651 iso9660: always check archive_string_ensure return value

CVE:		CVE-2024-57970, CVE-2025-1632, CVE-2025-25724,
		CVE-2025-5914, CVE-2025-5915, CVE-2025-5916,
		CVE-2025-5917, CVE-2025-5918
PR:		286944 (exp-run on main, libarchive 3.8.0)

Approved by:	so
Security:	FreeBSD-SA-25:07.libarchive

(cherry picked from commit 2e113ef824)
(cherry picked from commit f47afeb2ce)
2025-08-07 16:50:06 -07:00
Gordon Tetlow 341d92aef0 Add UPDATING entries and bump version.
Approved by:    so
2025-07-01 23:01:59 -07:00
Gordon Tetlow 95e9c54b39 Fix Use-after-free in multi-threaded xz decoder.
Approved by:	so
Security:	FreeBSD-SA-25:06.xz
Security:	CVE-2025-31115
2025-07-01 22:55:41 -07:00
Arthur Kiyanovski 575644144d ena: Bump driver version to v2.8.1
Approved by:	so
Security:	FreeBSD-EN-25:11.ena

(cherry picked from commit 59b30c1a86)
(cherry picked from commit 7ea71ba86a)
2025-07-01 22:53:06 -07:00
David Arinzon 35c2729211 ena: Fix misconfiguration when requesting regular LLQ
Patch 0a33c047a443 introduced new values to
hw.ena.force_large_llq_header. The default value of 2 means no
preference, while 0 and 1 act as the previous false and true
respectively, which allowed forcefully setting regular or large LLQ.

There are 2 ways to force the driver to select regular LLQ:

1. Setting hw.ena.force_large_llq_header = 0 via sysctl.
2. Turning on ena express, which makes the recommendation by the FW to
   be regular LLQ.

When the device supports large LLQ but the driver is forced to
regular LLQ, llq_config->llq_ring_entry_size_value is never initialized
and since it is a variable allocated on the stack, it stays garbage.

Since this variable is involved in calculating max_entries_in_tx_burst,
it could cause the maximum burst size to be zero. This causes the driver
to ignore the real maximum burst size of the device, leading to driver
resets in devices that have a maximum burst size (Nitro v4 and on. see
[1] for more information).

In case the garbage value is 0, the calculation of
max_entries_in_tx_burst divides by 0 and causes kernel panic.

The patch modifies the logic to take into account all use-cases and
ensure that the relevant fields are properly initialized.

[1]: https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html

Fixes: 0a33c047a443 ("ena: Support LLQ entry size recommendation from device")
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D50040
Approved by:	so
Security:	FreeBSD-EN-25:11.ena

(cherry picked from commit 56c45700f2)
(cherry picked from commit 162b5bbb40)
2025-07-01 22:52:31 -07:00
Gordon Tetlow 4d9c4ecf6a Fix corruption in ZFS replication streams from encrypted datasets.
From the upstream pull request merges:
 #17340 b144b160b Fix 2 bugs in non-raw send with encryption

Obtained from:	OpenZFS
Approved by:	so
Security:	FreeBSD-EN-25:10.zfs
2025-07-01 22:47:29 -07:00
Aurélien Croc de Suray f936833911 libc: allow __cxa_atexit handlers to be added during __cxa_finalize
science/dlib-cpp reveals an interesting scenario that works fine on
other platforms but not on FreeBSD; notably, it ends up creating a new
global object from some destructor which is called during
__cxa_finalize.  This breaks when libdlib is dlopen()ed and then
subsequently dlclose()ed, as we never end up invoking the created
object's dtor until program exit when the shlib is already unmapped.

Fix it by noting when we're in the middle of __cxa_finalize for a dso,
and then restarting the search if __cxa_atexit() was called in the
middle somewhere.

We wait until we've processed the initial set before starting over and
processing the newly added handlers as if it were a complete set of
handlers added during runtime.  The alternative is calling them as
they're added to maintain a LIFO in terms of total ordering, but in
theory a constructor could add another global object that also needs to
be destroyed, and that object needs to be destroyed after the one that
constructed it to avoid creating unexpected lifetime issues.

This manifests in the pdlib PHP extension for dlib crashing, see [0].

[0] https://github.com/goodspb/pdlib/issues/39

PR:		285870
Reviewed by:	kevans (also supplied commit message)
Approved by:	so
Security:	FreeBSD-EN-25:09.libc

(cherry picked from commit 23427c8e1f)
(cherry picked from commit 04f7496f89)
2025-07-01 22:42:46 -07:00
Philip Paeps 37edc07ede Add UPDATING entries and bump version
Approved by:	so
2025-04-10 22:39:09 +08:00
Michael Osipov 74176002ff caroot: update the root bundle
Summary:
- Seven (7) new roots
- Four (4) distrusted roots
- Fourteen (14) removed (expired) roots

Approved by:	so
Security:	FreeBSD-EN-25:08.caroot
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D49294

(cherry picked from commit 0100da4deb)
(cherry picked from commit f89c056e11)
2025-04-10 22:39:08 +08:00
Philip Paeps dec0bf8096 contrib/expat: update libexpat from 2.6.4 to 2.7.1
Changes: https://github.com/libexpat/libexpat/blob/R_2_7_1/expat/Changes

Note that libbsdxml(3) is only intended to used by utilities in the
FreeBSD base system.  The vulnerability addressed by expat 2.7.0 is not
exploitable on FreeBSD as supported by the security-officer@ team.

Approved by:	so
Security:	FreeBSD-EN-25:05.expat
Security:	CVE-2024-8176

(cherry picked from commit fe9278888f)
(cherry picked from commit 41b768ae19)
(cherry picked from commit 03a1992591)
(cherry picked from commit adc9e9e8db)
(cherry picked from commit 00c8538e87)
(cherry picked from commit 5630672e6f)
2025-04-10 22:39:08 +08:00
Philip Paeps 74aa5e2a7b contrib/tzdata: import tzdata 2025b
Changes: https://github.com/eggert/tz/blob/2025b/NEWS

Approved by:	so
Security:	FreeBSD-EN-25:04.tzdata

(cherry picked from commit d2cccdef30)
(cherry picked from commit 7b17666c32)
2025-04-10 22:39:08 +08:00
Colin Percival 882b9f3f22 Update in preparation for 13.5-RELEASE
- Bump BRANCH to RELEASE
- Add the anticipated RELEASE announcement date
- Set a static __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Amazon
2025-03-07 00:00:00 +00:00
Colin Percival a24b044a1e 13.5: Update to RC1
Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-27 16:48:37 -08:00
Colin Percival 956fb94dd6 13.5: Switch from "quarterly" to "release" pkgs
Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-27 16:48:26 -08:00
Olivier Certner cf411e5ed3 queue: Fix STAILQ_ASSERT_EMPTY()
The 'while' part corresponding to the 'do' was missing.

Did not notice the problem as later commits using it have been stashed
and never reworked up to now, and it is currently unused in the tree.

While here, fix spacing after the '#define' in the !(_KERNEL &&
INVARIANS) part.

Fixes:          34740937f7 ("queue: New debug macros for STAILQ")
MFC after:      1 minute
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit d3c4b002d1)
(cherry picked from commit 4fd887f08b)

Approved by:    re (cperciva)
2025-02-28 00:33:27 +01:00
Jose Luis Duran e8043c76e3 openssh: Fix blacklistd sshd-session integration
In version 9.8, the server was split into a listener binary, sshd(8),
and a per-session binary "sshd-session".

Our blacklistd changes also have to be moved from sshd.c to
sshd-session.c.

Reviewed by:	emaste
Approved by:	emaste (mentor)
Fixes:	0fdf8fae8b ("openssh: Update to 9.8p1")
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D49116

(cherry picked from commit 61d8af38bf)
(cherry picked from commit 707ac59c2b)
(cherry picked from commit f931a32bca)

Approved by:	re (cperciva)
2025-02-26 17:16:16 +00:00
Colin Percival 93b7f9301c pkg-stage.sh: Remove kde entirely
The package set for FreeBSD 13.5 comes from the 2025Q1 branch, which
doesn't have the new x11/kde (aka KDE 6) port; but shipping x11/kde5
(which is still in the 2025Q1 branch) doesn't make much sense either
since a few weeks after the release that will no longer be available
in either "latest" or "quarterly" package sets.

Just remove KDE packages from the 13.5 DVD entirely; this also makes
the DVD image fit into 4.7 GB size limit of physical DVDs again.

Direct commit to releng/13.5.

With hat:	re
Approved by:	re (cperciva)
Fixes:	ee6c7bf50b ("pkg-stage.sh: kde5 -> kde")
Sponsored by:	Amazon
2025-02-21 08:18:19 -08:00
Colin Percival 7f6d09003a 13.5: Update to BETA3
Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-20 16:05:22 -08:00
Colin Percival ee6c7bf50b pkg-stage.sh: kde5 -> kde
The "kde5" package no longer exists; KDE goes to 6.

Note: Depending on the size of 13.5-BETA3 DVD images, KDE might end
up being removed from this list in the near future.

With hat:	re@
Approved by:	re (cperciva)
MFC after:	30 seconds
Sponsored by:	Amazon

(cherry picked from commit 0d7b98c06c)
(cherry picked from commit 4ddbb7945c)
2025-02-20 16:05:11 -08:00
Ed Maste 31dcdee20a openssh: Update to 9.9p2
This release exists primarily to fix two security bugs.  The fixes have
been independently imported into FreeBSD.  This import serves to update
the ssh and sshd version number.

A few minor bug fixes are also included; see the upstream release notes
for full details of the 9.9p2 release
(https://www.openssh.com/releasenotes.html).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0ae642c7dd)

Approved by:	re (accelerated MFC)

(cherry picked from commit 059b786b7d)
(cherry picked from commit a8c1ea2614)

Approved by:	re (cperciva)
2025-02-20 13:45:48 -05:00
Ed Maste cb8e164fbb openssh: Update to 9.9p1
Highlights from the release notes are reproduced below.  Bug fixes and
improvements that were previously merged into FreeBSD have been elided.

See the upstream release notes for full details of the 9.9p1 release
(https://www.openssh.com/releasenotes.html).

---

Future deprecation notice
=========================

OpenSSH plans to remove support for the DSA signature algorithm in
early 2025.

Potentially-incompatible changes
--------------------------------

 * ssh(1): remove support for pre-authentication compression.

 * ssh(1), sshd(8): processing of the arguments to the "Match"
   configuration directive now follows more shell-like rules for
   quoted strings, including allowing nested quotes and \-escaped
   characters.

New features
------------

 * ssh(1), sshd(8): add support for a new hybrid post-quantum key
   exchange based on the FIPS 203 Module-Lattice Key Enapsulation
   mechanism (ML-KEM) combined with X25519 ECDH as described by
   https://datatracker.ietf.org/doc/html/draft-kampanakis-curdle-ssh-pq-ke-03
   This algorithm "mlkem768x25519-sha256" is available by default.

 * ssh(1), sshd(8), ssh-agent(1): prevent private keys from being
   included in core dump files for most of their lifespans. This is
   in addition to pre-existing controls in ssh-agent(1) and sshd(8)
   that prevented coredumps. This feature is supported on OpenBSD,
   Linux and FreeBSD.

 * All: convert key handling to use the libcrypto EVP_PKEY API, with
   the exception of DSA.

Bugfixes
--------

 * sshd(8): do not apply authorized_keys options when signature
   verification fails. Prevents more restrictive key options being
   incorrectly applied to subsequent keys in authorized_keys. bz3733

 * ssh-keygen(1): include pathname in some of ssh-keygen's passphrase
   prompts. Helps the user know what's going on when ssh-keygen is
   invoked via other tools. Requested in GHPR503

 * ssh(1), ssh-add(1): make parsing user@host consistently look for
   the last '@' in the string rather than the first. This makes it
   possible to more consistently use usernames that contain '@'
   characters.

 * ssh(1), sshd(8): be more strict in parsing key type names. Only
   allow short names (e.g "rsa") in user-interface code and require
   full SSH protocol names (e.g. "ssh-rsa") everywhere else. bz3725

 * ssh-keygen(1): clarify that ed25519 is the default key type
   generated and clarify that rsa-sha2-512 is the default signature
   scheme when RSA is in use. GHPR505

---

Reviewed by:	jlduran (build infrastructure)
Reviewed by:	cy (build infrastructure)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48947

(cherry picked from commit 3d9fd9fcb4)

Approved by:	re (accelerated MFC)

(cherry picked from commit 802386cd37)
(cherry picked from commit 6e688e6d4f)

Approved by:	re (cperciva)
2025-02-20 13:45:36 -05:00
Ed Maste b74bb7f011 openssh: Update to 9.8p1
Highlights from the release notes are reproduced below.  Some security
and bug fixes were previously merged into FreeBSD and have been elided.
See the upstream release notes for full details
(https://www.openssh.com/releasenotes.html).

---

Future deprecation notice
=========================

OpenSSH plans to remove support for the DSA signature algorithm in
early 2025.

Potentially-incompatible changes
--------------------------------

 * sshd(8): the server will now block client addresses that
   repeatedly fail authentication, repeatedly connect without ever
   completing authentication or that crash the server. See the
   discussion of PerSourcePenalties below for more information.
   Operators of servers that accept connections from many users, or
   servers that accept connections from addresses behind NAT or
   proxies may need to consider these settings.

 * sshd(8): the server has been split into a listener binary, sshd(8),
   and a per-session binary "sshd-session". This allows for a much
   smaller listener binary, as it no longer needs to support the SSH
   protocol. As part of this work, support for disabling privilege
   separation (which previously required code changes to disable) and
   disabling re-execution of sshd(8) has been removed. Further
   separation of sshd-session into additional, minimal binaries is
   planned for the future.

 * sshd(8): several log messages have changed. In particular, some
   log messages will be tagged with as originating from a process
   named "sshd-session" rather than "sshd".

 * ssh-keyscan(1): this tool previously emitted comment lines
   containing the hostname and SSH protocol banner to standard error.
   This release now emits them to standard output, but adds a new
   "-q" flag to silence them altogether.

 * sshd(8): (portable OpenSSH only) sshd will no longer use argv[0]
   as the PAM service name. A new "PAMServiceName" sshd_config(5)
   directive allows selecting the service name at runtime. This
   defaults to "sshd". bz2101

New features
------------

 * sshd(8): sshd(8) will now penalise client addresses that, for various
   reasons, do not successfully complete authentication. This feature is
   controlled by a new sshd_config(5) PerSourcePenalties option and is
   on by default.

 * ssh(8): allow the HostkeyAlgorithms directive to disable the
   implicit fallback from certificate host key to plain host keys.

Portability
-----------

 * sshd(8): expose SSH_AUTH_INFO_0 always to PAM auth modules
   unconditionally. The previous behaviour was to expose it only when
   particular authentication methods were in use.

 * ssh(1), ssh-agent(8): allow the presence of the WAYLAND_DISPLAY
   environment variable to enable SSH_ASKPASS, similarly to the X11
   DISPLAY environment variable. GHPR479

---

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48914

(cherry picked from commit 0fdf8fae8b)
(cherry picked from commit b4bb480ae9)
(cherry picked from commit e95979047a)
(cherry picked from commit dcb4ae528d)

Approved by:	re (accelerated MFC)

(cherry picked from commit ff2fd01609)
(cherry picked from commit c845ae4755)

Approved by:	re (cperciva)
2025-02-20 13:45:19 -05:00
Ed Maste d2b7937c2c ssh_config.5: Remove redundant CheckHostIP default text
In 2000 (commit a95c122521) we changed the CheckHostIP default to
"no".  We added text to ssh_config(5) documenting FreeBSD's default.

In 2021 OpenSSH made the same change, released with OpenSSH 8.5p1.
When we imported the update the added text remained, resulting in:

    If the option is set to no (the default), the check will not be
    executed.  The default is no.

Remove the now-redundant text.

Fixes: 206be79acb ("Vendor import of OpenSSH 8.5p1")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 06016adacc)
(cherry picked from commit 2c97e33316)
(cherry picked from commit 935e29dcdd)

Approved by:	re (cperciva)
2025-02-20 13:45:11 -05:00
Ed Maste ef280c2e5f libssh: Remove progressmeter
It is used only by scp and sftp, and already included directly in their
Makefiles.  It does not belong in libssh.

Fixes: d8b043c8d4 ("Update for 3.6.1p1; also remove Kerberos IV shims.")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48871

(cherry picked from commit c0af329525)
(cherry picked from commit 8a02eb2c1e)
(cherry picked from commit 63d3c24522)

Approved by:	re (cperciva)
2025-02-20 13:45:03 -05:00
Ed Maste 6cb9cfffa8 ssh: Move XAUTH_PATH setting to ssh.mk
XAUTH_PATH is normally set (in the upstream build infrastructure) in
config.h.  We previously set it in ssh and sshd's Makefiles if LOCALBASE
is set, and over time have sometimes also defined it in config.h.

Leave it unset in config.h and move the CFLAGS logic to to ssh.mk so
that it will be set when building all ssh libraries and programs but
still be set by LOCALBASE.

Reviewed by:	jlduran
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48907

(cherry picked from commit a63701848f)
(cherry picked from commit 73dd56ffcd)
(cherry picked from commit 10e9add50f)

Approved by:	re (cperciva)
2025-02-20 13:44:55 -05:00
Ed Maste 78b4f77518 ssh: Bump VersionAddendum for CVE fixes
Approved by:	so
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 62df41ae0a)
(cherry picked from commit 24ce323f02)
(cherry picked from commit 2fc62d0bd4)

Approved by:	re (implicit)
2025-02-20 13:00:27 -05:00
Ed Maste 88fcdcb08a ssh: Fix cases where error codes were not correctly set
Obtained from:	OpenSSH 38df39ecf278
Security:	CVE-2025-26465
Approved by:	so
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 170059d6d3)
(cherry picked from commit 4ad8c195cf)
(cherry picked from commit 8c67967cb1)

Approved by:	re (implicit)
2025-02-20 13:00:19 -05:00
Ed Maste fb30987533 ssh: Don't reply to PING in preauth phase or during KEX
Obtained from:	OpenSSH 5e07dee272c3
Security:	CVE-2025-26466
Approved by:	so
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8a16d0831e)
(cherry picked from commit 34798cb576)
(cherry picked from commit 3ea366f744)

Approved by:	re (implicit)
2025-02-20 13:00:11 -05:00
Colin Percival 6e06a07978 13.5: Update to BETA2
Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-14 00:00:00 +00:00
Zhenlei Huang 6b0086795d sysctl: Harden sysctl_handle_string() against unterminated string
In case a variable string which is not null-terminated is passed in,
strlen() may report a length exceeding the max length, hence it is
possible to leak a portion of kernel memory to the userland.

Harden that by using strnlen() to limit the length to the max length.
While here, refactor the code a little to improve readability.

Note that, when calculating the out length, the null terminator '\0' of
the string is taken into account if available. This is not really
necessary but userland applications may have already relied on this
behavior.

Reviewed by:	avg, kib, olce
Approved by:	re (cperciva)
Fixes:		210176ad76 sysctl(9): add CTLFLAG_NEEDGIANT flag
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D48881

(cherry picked from commit 1951235537)
(cherry picked from commit 8ca77f9f9e)
(cherry picked from commit dcd7286d90)
2025-02-14 00:52:50 +08:00
Zhenlei Huang 3afa8f08bc MAC: mac_biba, mac_lomac: Fix setting loader tunables
A string loader tunable requires setting the len parameter to a nonzero
value, typically the size of the string, to have the flag CTLFLAG_TUN
work correctly [1] [2].

Without this fix security.mac.{biba,lomac}.trusted_interfaces would
have no effect at all.

[1] 3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically ...
[2] 6a3287f889 Fix regression issue after r267961. Handle special string case ...

Reviewed by:	olce, kib
Approved by:	re (cperciva)
Fixes:		af3b2549c4 Pull in r267961 and r267973 again ...
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D48898

(cherry picked from commit 7d4c0fac8c)
(cherry picked from commit 04f360b782)
(cherry picked from commit 87836ab994)
2025-02-14 00:52:50 +08:00
Michael Tuexen cd91df3292 icmp: use per rate limit randomized jitter
Using the same random jitter for multiple rate limits allows an
attacker to use one rate limiter to figure out the current jitter
and then use this knowledge to de-randomize the other rate limiters.
This can be mitigated by using a separate randomized jitter for each
rate limiter.
This issue was reported as issue number 10 in Keyu Man et al.:
SCAD: Towards a Universal and Automated Network Side-Channel
Vulnerability Detection

Reviewed by:		rrs, Peter Lei, glebius
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D48804
Approved by:		re (cperciva)

(cherry picked from commit 923c223f27)
(cherry picked from commit e1dd07ede9)
2025-02-13 15:04:39 +01:00
Michael Tuexen 5f2744d520 icmp: improve INVARIANTS check
Actually check the conditions that are enforced by the error checking
code instead of a condition which is
* checking a number to be non-negative instead of positive
* depending on a random number
Perform the checks consistently for ICMPv4 and ICMPv6.

Reviewed by:		glebius, rrs, cc
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D48001
Approved by:		re (cperciva)

(cherry picked from commit c9febea3dc)
(cherry picked from commit bd6a89a6c3)
2025-02-13 15:03:55 +01:00
Gleb Smirnoff a3b66c4bf0 icmp: correct the assertion that checks limit + jitter
Fixes:	4399e055ea
Approved by:	re (cperciva)

(cherry picked from commit f7c4d12bcd)
(cherry picked from commit 1b4561cf4b)
2025-02-13 15:03:13 +01:00
Gleb Smirnoff 881ba70c1a icmp: allow zero value for ICMP limits
Zero means limit is disabled, so the value doesn't need to be checked
against jitter value.

Fixes:	ac44739fd8
Fixes:	a03aff88a1
Approved by:	re (cperciva)

(cherry picked from commit 4399e055ea)
(cherry picked from commit 0b29ef1e3f)
2025-02-13 15:02:12 +01:00
Gleb Smirnoff ebda0be762 icmp6: bring rate limiting on a par with IPv4
Use counter_ratecheck() instead of racy and slow ppsratecheck. Use a
separate counter for every currently known type of ICMPv6. Provide logging
of ratelimit events. Provide jitter to counter open UDP port detection.

With minor tweaks from tuexen@ to fix merge problems.

Reviewed by:		tuexen, zlei
Differential Revision:	https://reviews.freebsd.org/D44482
Approved by:		re (cperciva)

(cherry picked from commit a03aff88a1)
(cherry picked from commit 1cc0ac5ef3)
2025-02-13 15:01:36 +01:00
Gleb Smirnoff a7ad643719 icmp6: rate limit our echo replies
The generation of ICMP6_ECHO_REPLY bypasses icmp6_error(), thus rate
limit was not applied.

Reviewed by:		tuexen, zlei
Differential Revision:	https://reviews.freebsd.org/D44480
Approved by:		re (cperciva)

(cherry picked from commit 32aeee8ce7)
(cherry picked from commit 90ecc3fc67)
2025-02-13 15:00:57 +01:00
Gleb Smirnoff 9880ce0765 icmp6: make icmp6_ratelimit() responsible to update the stats counter
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D44479
Approved by:		re (cperciva)

(cherry picked from commit c6c96aaba8)
(cherry picked from commit dc167e64dc)
2025-02-13 15:00:23 +01:00
Gleb Smirnoff 1ed60133f6 icmp: improve ICMP limit jitter
Instead of fixing up invalid values set by a user in badport_bandlim()
which is a fast path function, provide a sysctl handler
sysctl_icmplim_and_jitter(), that will check that jitter is less than the
limit.

Provide jitter initilization function icmplim_new_jitter() used at boot,
in the sysctl handler and when we actually hit the limit.  This also fixes
no jitter on a fresh booted system until first limit hit.

Instead of CVE number provide link the the actual paper that explains what
and why we are doing here.  The CVE number isn't very informative, it will
just tell you what RedHat version you need to upgrade to.

Reviewed by:		kp, tuexen, zlei
Differential Revision:	https://reviews.freebsd.org/D44478
Approved by:		re (cperciva)

(cherry picked from commit ac44739fd8)
(cherry picked from commit 18058544c6)
2025-02-13 14:59:46 +01:00
Gleb Smirnoff b6dc660155 icmp: when logging ICMP ratelimiting message use correct jitter value
The limiting of the very last second has been done using certain jitter
value.  We update the jitter for the next second.  But the logging should
report the jitter before the change.

Reviewed by:		kp, tuexen, zlei
Differential Revision:	https://reviews.freebsd.org/D44477
Approved by:		re (cperciva)

(cherry picked from commit b508545ce0)
(cherry picked from commit a71eee300b)
2025-02-13 14:59:09 +01:00
Gleb Smirnoff a0146592cd icmp: hide icmp_bandlimit_uninit() under VIMAGE
The uninitialization may be executed only on a kernel with VIMAGE.

Reviewed by:		kp, tuexen, zlei
Differential Revision:	https://reviews.freebsd.org/D44476
Approved by:		re (cperciva)

(cherry picked from commit 9d7f17d746)
(cherry picked from commit a6d5c6a04f)
2025-02-13 14:57:18 +01:00
Gleb Smirnoff ebc96321e7 icmp: do not store per-VNET identical array of strings
We need per-VNET struct counter_rate, but we don't need per-VNET set of
const char *.  Also, identical word "response" can go into the format
string instead of being stored 7 times.

Reviewed by:		kp, zlei, tuexen
Differential Revision:	https://reviews.freebsd.org/D44475
Approved by:		re (cperciva)

(cherry picked from commit 7142ab4790)
(cherry picked from commit 0939f3a046)
2025-02-13 14:56:10 +01:00
Ronald Klop e375421e24 Remove obsolete clang18 files for aarch64
This fixes a warning from "make delete-old" about a non-empty directory
on aarch64.

Reviewed by:	dim
Approved by:	re (cperciva)
Fixes:		0fca6ea1d4
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D48904

(cherry picked from commit 09b435d3dc)
(cherry picked from commit 9370c2c331)
2025-02-13 16:59:36 +01:00
Dag-Erling Smørgrav 1aaec1978a unifdef: Fix collision check when adding symbols.
findsym() is intended for use while parsing input, so it should not be
called from addsym2() or indirectsym(), which are called before any
input is processed.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D48733
Approved by:	re (cperciva)

(cherry picked from commit c63af363c2)
(cherry picked from commit 931b099029)
2025-02-13 16:12:02 +01:00
Kirk McKusick dfe803fdbc Defer the January 19, 2038 date limit in UFS1 filesystems to February 7, 2106
Standardize the definition of a UFS dinode.

Differential Revision: https://reviews.freebsd.org/D48472

(cherry picked from commit 1111a44301)
(cherry picked from commit aa90fbed15)
(cherry picked from commit 256389eaf1)
(cherry picked from commit 6cd973d903)
(cherry picked from commit e1ebda4458)
(cherry picked from commit 6f87402a02)

Approved-by: re (cperciva)
2025-02-09 23:38:51 -08:00
Colin Percival ef6b3c5888 release: Chase location of pkg repo databases
pkg used to store copies of upstream repository databases in
/var/db/pkg/repo-*.sqlite.  About a year ago this was moved to
/var/db/pkg/repos/*/, resulting in FreeBSD cloud images no longer
having those (unhelpful since they'll be long out of date before
the cloud images are launched) databases removed.

Remove the correct location, and hope that future pkg updates don't
break the base system again.

Sponsored by:	Amazon
Approved by:	re (cperciva)

(cherry picked from commit 078e8b34b1)
(cherry picked from commit 8984d070d6)
2025-02-09 13:18:40 -08:00
Colin Percival a8f9845e39 13.5: create releng/13.5 branch
Update from PRERELEASE to BETA1
Switch pkg(8) configuration to use the quarterly repository
Bump __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-07 00:00:00 +00:00
2832 changed files with 192124 additions and 240322 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ compute_engine_instance:
# gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
platform: freebsd
image_project: freebsd-org-cloud-dev
image: freebsd-13-5-release-amd64
image: freebsd-13-3-release-amd64
cpu: 8
memory: 8G
disk: 40
+1 -1
View File
@@ -2,7 +2,7 @@ name: Cross-build Kernel
on:
push:
branches: [ main, 'stable/[1-9][0-9]' ]
branches: [ main, 'stable/13' ]
pull_request:
branches: [ main ]
-1
View File
@@ -22,4 +22,3 @@ cscope.in.out
cscope.out
cscope.po.out
tags
/src.conf
+3 -8
View File
@@ -607,10 +607,7 @@ XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
# When building we want to find the cross tools before the host tools in ${BPATH}.
# We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
# toolchain files (clang, lld, etc.) during make universe/tinderbox
STRICTTMPPATH= ${XPATH}:${BPATH}
.if defined(UNIVERSE_TOOLCHAIN_PATH)
STRICTTMPPATH:=${STRICTTMPPATH}:${UNIVERSE_TOOLCHAIN_PATH}
.endif
STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
# We should not be using tools from /usr/bin accidentally since this could cause
# the build to break on other systems that don't have that tool. For now we
# still allow using the old behaviour (inheriting $PATH) if
@@ -785,7 +782,6 @@ TMAKE= \
# TOOLS_PREFIX set in BMAKE
XMAKE= ${BMAKE} \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
MK_CLANG=${MK_CLANG_BOOTSTRAP} \
MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
MK_LLDB=no \
MK_LLVM_BINUTILS=no \
@@ -1358,7 +1354,7 @@ _sysctl=sysctl
.endif
ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
date echo egrep find grep id install \
date echo egrep find grep id install ${_install-info} \
ln make mkdir mtree mv pwd_mkdb \
rm sed services_mkdb sh sort strip ${_sysctl} test true uname wc
@@ -2711,7 +2707,7 @@ _elftctools= lib/libelftc \
.endif
.if ${MK_CLANG_BOOTSTRAP} != "no"
_clang= usr.bin/clang/clang
_clang= usr.bin/clang
.endif
.if ${MK_LLD_BOOTSTRAP} != "no"
_lld= usr.bin/clang/lld
@@ -2850,7 +2846,6 @@ NXBMAKEARGS+= \
MK_DEBUG_FILES=no \
MK_HTML=no \
MK_LLDB=no \
MK_LLVM_LINK_STATIC_LIBRARIES=yes \
MK_MAN=no \
MK_MAN_UTILS=yes \
MK_OFED=no \
-113
View File
@@ -51,99 +51,6 @@
# xargs -n1 | sort | uniq -d;
# done
# 20260430: Regenerate trust store
OLD_FILES+=usr/share/certs/trusted/Entrust_net_Premium_2048_Secure_Server_CA.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Premium.pem
OLD_FILES+=usr/share/certs/trusted/Starfield_Class_2_CA.pem
OLD_FILES+=usr/share/certs/trusted/GTS_Root_R2.pem
OLD_FILES+=usr/share/certs/trusted/GLOBALTRUST_2020.pem
OLD_FILES+=usr/share/certs/trusted/Secure_Global_CA.pem
OLD_FILES+=usr/share/certs/trusted/GlobalSign_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_RSA_Root-01.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_ECC_P384_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/SwissSign_Gold_CA_-_G2.pem
OLD_FILES+=usr/share/certs/trusted/Go_Daddy_Class_2_CA.pem
OLD_FILES+=usr/share/certs/trusted/FIRMAPROFESIONAL_CA_ROOT-A_WEB.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_ECC_P256_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_ECC_Root-01.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_EC1.pem
OLD_FILES+=usr/share/certs/trusted/Certigna.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Commercial.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_Assured_ID_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/Baltimore_CyberTrust_Root.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_ECC_Root-02.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Premium_ECC.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_RSA_Root-02.pem
OLD_FILES+=usr/share/certs/trusted/TeliaSonera_Root_CA_v1.pem
OLD_FILES+=usr/share/certs/trusted/QuoVadis_Root_CA_2.pem
OLD_FILES+=usr/share/certs/trusted/COMODO_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/SecureTrust_CA.pem
OLD_FILES+=usr/share/certs/trusted/Comodo_AAA_Services_root.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_G2.pem
OLD_FILES+=usr/share/certs/trusted/QuoVadis_Root_CA_3.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_High_Assurance_EV_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/certSIGN_ROOT_CA.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_Global_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Networking.pem
OLD_FILES+=usr/share/certs/trusted/XRamp_Global_CA_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/Security_Communication_RootCA3.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/E-Tugra_Global_Root_CA_ECC_v3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_2_Public_Primary_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/blacklisted/EE_Certification_Centre_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/EC-ACC.pem
OLD_FILES+=usr/share/certs/blacklisted/Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Universal_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Global_Chambersign_Root_-_2008.pem
OLD_FILES+=usr/share/certs/blacklisted/Camerfirma_Global_Chambersign_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_1_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_1_Public_Primary_Certification_Authority_-_G6.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_RootCert_CA-2.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Universal_CA_2.pem
OLD_FILES+=usr/share/certs/blacklisted/Network_Solutions_Certificate_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/E-Tugra_Global_Root_CA_RSA_v3.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/Taiwan_GRCA.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_2_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_2_Public_Primary_Certification_Authority_-_G6.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem
OLD_FILES+=usr/share/certs/blacklisted/SwissSign_Platinum_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_RootCert_CA-1.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Camerfirma_Chambers_of_Commerce_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/SwissSign_Silver_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_ECA-1.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/blacklisted/SecureSign_RootCA11.pem
OLD_FILES+=usr/share/certs/blacklisted/Chambers_of_Commerce_Root_-_2008.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_3_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Universal_Root_Certification_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/LuxTrust_Global_Root_2.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_1_Public_Primary_Certification_Authority_-_G4.pem
# 20251006: Remove libnss_tacplus.a (it never should have been installed)
OLD_FILES+=usr/lib/libnss_tacplus.a
# 20250812: Remove a bogus manlink
OLD_FILES+=usr/share/man/man3/quota_statfs.3.gz
# 20250805: Test case renamed
OLD_FILES+=usr/tests/usr.bin/xargs/regress.n2147483647.out
# 20250710: share: Delete bitrotted make_*_driver.sh scripts
OLD_FILES+=usr/share/examples/drivers/README
OLD_FILES+=usr/share/examples/drivers/make_device_driver.sh
OLD_FILES+=usr/share/examples/drivers/make_pseudo_driver.sh
OLD_DIRS+=usr/share/examples/drivers
# 20250524: don't install zoneinfo version
OLD_FILES+=usr/share/zoneinfo/version
# 20250310: caroot bundle updated
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/trusted/SecureSign_RootCA11.pem
@@ -164,10 +71,6 @@ OLD_FILES+=usr/share/certs/blacklisted/Hongkong_Post_Root_CA_1.pem
OLD_FILES+=usr/share/certs/blacklisted/Security_Communication_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Trustis_FPS_Root_CA.pem
# 20250204: sys/vm/stack test symbols moved to /usr/lib/debug
OLD_FILES+=usr/tests/sys/vm/stack/.debug/libsoxstack.so.debug
OLD_DIRS+=usr/tests/sys/vm/stack/.debug
# 20241201: new clang import which bumps version from 18 to 19
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_builtin_vars.h
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_cmath.h
@@ -1512,22 +1415,6 @@ OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_ECC_v3.pem
OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_RSA_v3.pem
OLD_FILES+=usr/share/certs/trusted/Hongkong_Post_Root_CA_1.pem
# 20230807: GoogleTest 1.14.0 upgrade.
OLD_FILES+=usr/include/private/gmock/gmock-generated-actions.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-function-mockers.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-matchers.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-nice-strict.h
OLD_FILES+=usr/include/private/gmock/internal/gmock-generated-internal-utils.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-linked_ptr.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-param-util-generated.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-tuple.h
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-actions_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-function-mockers_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-internal-utils_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-matchers_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-matchers_test
OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-linked-ptr-test
# 20230806: Removal of support for the VTOC8 partitioning scheme
OLD_FILES+=usr/include/sys/disk/vtoc.h
OLD_FILES+=usr/include/sys/vtoc.h
+128 -5
View File
@@ -12,16 +12,139 @@ Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before updating system packages
and/or ports.
20260430:
13.5-RELEASE-p14 EN-26:11.dhclient
dhclient(8) lease validation is too strict. [EN-26:11.dhclient]
20260429:
13.5-RELEASE-p13 SA-26:12.dhclient
SA-26:13.exec
SA-26:14.pf
SA-26:15.dhclient
SA-26:16.libnv
SA-26:17.libnv
EN-26:09.tzdata
Remote code execution via malicious DHCP options. [SA-26:12.dhclient]
Local privilege escalation via execve(). [SA-26:13.exec]
pf can overflow the stack parsing crafted SCTP packets. [SA-26:14.pf]
Remotely triggerable out-of-bounds heap write in dhclient. [SA-26:15.dhclient]
Stack overflow via select() file descriptor set overflow. [SA-26:16.libnv]
Heap overflow in libnv. [SA-26:17.libnv]
Timezone database information update. [EN-26:09.tzdata]
20260421:
13.5-RELEASE-p12 SA-26:10.tty
SA-26:11.amd64
EN-26:05.vm
Kernel use-after-free bug in the TIOCNOTTY handler. [SA-26:10.tty]
Missing large page handling in pmap_pkru_update_range(). [SA-26:11.amd64]
The page fault handler fails to zero memory. [EN-26:05.vm]
20260325:
13.5-RELEASE-p11 SA-26:08.rpcsec_gss
Remote code execution via RPCSEC_GSS packet validation. [SA-26:08.rpcsec_gss]
20260224:
13.5-RELEASE-p10 SA-26:04.jail
SA-26:05.route
Jail chroot escape via fd exchange with a different jail. [SA-26:04.jail]
Local DoS and possible privilege escalation via routing sockets. [SA-26:05.route]
20260127:
13.5-RELEASE-p9 SA-26:01.openssl
SA-26:02.jail
EN-26:03.vm
Fix multiple vulnerabilities in OpenSSL. [SA-26:01.openssl]
Jail escape by a privileged user via nullfs. [SA-26:02.jail]
The page fault handler fails to zero memory. [EN-26:03.vm]
20251216:
13.5-RELEASE-p8 SA-25:11.ipfw
SA-25:12.rtsold
ipfw denial of service. [SA-25:11.ipfw]
Remote code execution via ND6 Router Advertisements. [SA-25:12.rtsold]
20251126:
13.5-RELEASE-p7 SA-25:10.unbound
Fix cache poison in local-unbound service. [SA-25:10.unbound]
20251022:
13.5-RELEASE-p6 SA-25:09.netinet
SO_REUSEPORT_LB breaks connect(2) for UDP sockets. [SA-25:09.netinet]
20250930:
13.5-RELEASE-p5 EN-25:18.freebsd-update
SA-25:08.openssl
Fix freebsd-update(8) installing libraries in incorrect order. [EN-25:18.freebsd-update]
Fix multiple vulnerabilities in OpenSSL. [SA-25:08.openssl]
20250916:
13.5-RELEASE-p4 EN-25:15.arm64
Fix arm64 syscall(2) allows unprivileged user to panic kernel. [EN-25:15.arm64]
20250808:
13.5-RELEASE-p3 SA-25:07.libarchive
Update libarchive to 3.8.1 to fix integer overflow leading to double
free. [SA-25:07.libarchive]
20250702:
13.5-RELEASE-p2 EN-25:09.libc
EN-25:10.zfs
EN-25:11.ena
SA-25:06.xz
Fix dynamically-loaded C++ libraries crashing at exit [EN-25:09.libc]
Fix corruption in ZFS replication streams from encrypted datasets [EN-25:10.zfs]
Fix ena resets and kernel panic on Nitro v4 or newer instances [EN-25:11.ena]
Fix use-after-free in multi-threaded xz decoder [SA-25:06.xz]
20250410:
13.5-RELEASE-p1 EN-25:04.tzdata
EN-25:05.expat
EN-25:08.caroot
Timezone database information update [EN-25:04.tzdata]
Update expat to 2.7.1 [EN-25:05.expat]
Root certificate bundle update [EN-25:08.caroot]
20250311:
13.5-RELEASE.
20250117:
The layout of NFS file handles for the cd9660 and ext2fs file systems
has changed. An NFS server that exports any of these file systems will
need its clients to unmount and remount the exports.
20250916:
If SRCCONF is unset and a file named src.conf is present at
the top of the source tree, it will now be used instead of
/etc/src.conf.
20240419:
Clang, llvm, lld, lldb, compiler-rt, libc++, libunwind and openmp have
been upgraded to 18.1.6. It is important that you run `make delete-old`
+9 -9
View File
@@ -227,7 +227,7 @@ main(int argc, char *argv[])
* Case (1). Target is not a directory.
*/
if (argc > 1)
errc(1, ENOTDIR, "%s", to.p_path);
errx(1, "%s is not a directory", to.p_path);
/*
* Need to detect the case:
@@ -250,17 +250,17 @@ main(int argc, char *argv[])
type = FILE_TO_FILE;
if (have_trailing_slash && type == FILE_TO_FILE) {
if (r == -1)
errc(1, ENOENT, "%s", to.p_path);
else
errc(1, ENOTDIR, "%s", to.p_path);
if (r == -1) {
errx(1, "directory %s does not exist",
to.p_path);
} else
errx(1, "%s is not a directory", to.p_path);
}
} else {
} else
/*
* Case (2). Target is a directory.
*/
type = FILE_TO_DIR;
}
/*
* For DIR_TO_DNE, we could provide copy() with the to_stat we've
@@ -368,8 +368,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
base = (p == NULL) ? 0 :
(int)(p - curr->fts_path + 1);
if (strcmp(curr->fts_path + base, "..")
== 0)
if (!strcmp(&curr->fts_path[base],
".."))
base += 1;
} else
base = curr->fts_pathlen;
+4 -4
View File
@@ -74,7 +74,7 @@ hardlink_body()
echo "foo" >foo
atf_check cp -l foo bar
atf_check -o inline:"foo\n" cat bar
atf_check test foo -ef bar
atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
}
atf_test_case hardlink_exists
@@ -84,7 +84,7 @@ hardlink_exists_body()
echo "bar" >bar
atf_check -s not-exit:0 -e match:exists cp -l foo bar
atf_check -o inline:"bar\n" cat bar
atf_check test ! foo -ef bar
atf_check_not_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
}
atf_test_case hardlink_exists_force
@@ -94,7 +94,7 @@ hardlink_exists_force_body()
echo "bar" >bar
atf_check cp -fl foo bar
atf_check -o inline:"foo\n" cat bar
atf_check test foo -ef bar
atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
}
atf_test_case matching_srctgt
@@ -247,7 +247,7 @@ file_is_sparse()
files_are_equal()
{
atf_check test ! "$1" -ef "$2"
atf_check_not_equal "$(stat -f%d,%i "$1")" "$(stat -f%d,%i "$2")"
atf_check cmp "$1" "$2"
}
+2 -5
View File
@@ -213,10 +213,7 @@ copy_file(const FTSENT *entp, int dne)
if (!use_copy_file_range) {
wcount = copy_fallback(from_fd, to_fd);
}
if (wcount >= 0)
wtotal += wcount;
else if (errno != EINTR)
break;
wtotal += wcount;
if (info) {
info = 0;
(void)fprintf(stderr,
@@ -224,7 +221,7 @@ copy_file(const FTSENT *entp, int dne)
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
}
} while (wcount != 0);
} while (wcount > 0);
if (wcount < 0) {
warn("%s", entp->fts_path);
rval = 1;
+4 -4
View File
@@ -31,7 +31,7 @@
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
.Dd September 1, 2025
.Dd February 27, 2023
.Dt DATE 1
.Os
.Sh NAME
@@ -128,7 +128,7 @@ format.
Parsing is done using
.Xr strptime 3 .
.It Fl I Ns Op Ar FMT
Use extended
Use
.St -iso8601
output format.
.Ar FMT
@@ -151,9 +151,9 @@ is
.Cm minutes
or
.Cm seconds ) ,
the extended
the
.St -iso8601
format includes the timezone offset.
format includes the timezone.
.It Fl j
Do not try to set the date.
This allows you to use the
+1 -1
View File
@@ -28,7 +28,7 @@
atf_check_same_file()
{
atf_check test "$1" -ef "$2"
atf_check_equal "$(stat -f %d,%i "$1")" "$(stat -f %d,%i "$2")"
}
atf_check_symlink_to()
+2 -7
View File
@@ -579,7 +579,6 @@ waitcmdloop(struct job *job)
freejob(job);
else {
job->remembered = 0;
deljob(job);
if (job == bgjob)
bgjob = NULL;
}
@@ -604,7 +603,7 @@ waitcmdloop(struct job *job)
break;
}
}
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, job) != -1);
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1);
sig = pendingsig_waitcmd;
pendingsig_waitcmd = 0;
@@ -1082,7 +1081,6 @@ waitforjob(struct job *jp, int *signaled)
#if JOBS
int propagate_int = jp->jobctl && jp->foreground;
#endif
int jobindex;
int status;
int st;
@@ -1090,11 +1088,8 @@ waitforjob(struct job *jp, int *signaled)
TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1));
while (jp->state == 0)
if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG |
DOWAIT_SIG_TRAP : 0), jp) == -1) {
jobindex = jp - jobtab;
DOWAIT_SIG_TRAP : 0), jp) == -1)
dotrap();
jp = jobtab + jobindex;
}
#if JOBS
if (jp->jobctl) {
if (ttyfd >= 0 && tcsetpgrp(ttyfd, rootpid) < 0)
+1 -1
View File
@@ -75,7 +75,7 @@ extern char optval[NOPTS];
extern const char optletter[NSHORTOPTS];
#ifdef DEFINE_OPTIONS
char optval[NOPTS];
const char optletter[NSHORTOPTS] __nonstring = "efIimnsxvVECabupTPh";
const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
static const unsigned char optname[] =
"\007errexit"
"\006noglob"
+6 -4
View File
@@ -33,7 +33,7 @@
.\"
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\"
.Dd March 8, 2025
.Dd November 20, 2024
.Dt SH 1
.Os
.Sh NAME
@@ -240,9 +240,11 @@ If a shell function is executed and its exit status is explicitly
tested, all commands of the function are considered to be tested as
well.
.Pp
Note that many commands return non-zero values to convey information other
than errors, which can cause unexpected program termination with
.Fl e .
It is recommended to check for failures explicitly
instead of relying on
.Fl e
because it tends to behave in unexpected ways,
particularly in larger scripts.
.It Fl f Li noglob
Disable pathname expansion.
.It Fl h Li trackall
-1
View File
@@ -186,6 +186,5 @@ ${PACKAGE}FILES+= wait7.0
${PACKAGE}FILES+= wait8.0
${PACKAGE}FILES+= wait9.127
${PACKAGE}FILES+= wait10.0
${PACKAGE}FILES+= wait11.0
.include <bsd.test.mk>
-6
View File
@@ -1,6 +0,0 @@
sleep 3 | sleep 2 &
sleep 3 &
kill %1
wait %1
r=$?
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = TERM ]
-1
View File
@@ -19,7 +19,6 @@ ${PACKAGE}FILES+= bg10.0 bg10.0.stdout
${PACKAGE}FILES+= bg11.0
${PACKAGE}FILES+= bg12.0
${PACKAGE}FILES+= bg13.0
${PACKAGE}FILES+= bg14.0
${PACKAGE}FILES+= env1.0
${PACKAGE}FILES+= fork1.0
${PACKAGE}FILES+= fork2.0
-9
View File
@@ -1,9 +0,0 @@
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf "$T"' 0
cd "$T" || exit 3
mkfifo fifo1 || exit 3
set -T
trap "for i in 1 2 3 4; do sleep 1 & done" USR1
sleep 1 &
{ kill -USR1 "$$"; echo .; } >fifo1 &
(read dummy <fifo1)
+1 -1
View File
@@ -117,7 +117,7 @@ enum token {
#define TOKEN_TYPE(token) ((token) & 0xff00)
static const struct t_op {
char op_text[2] __nonstring;
char op_text[2];
short op_num;
} ops1[] = {
{"=", STREQ},
+7 -99
View File
@@ -18,9 +18,7 @@
.\" CDDL HEADER END
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\"
.\" $FreeBSD$
.\"
.Dd November 8, 2025
.Dd September 7, 2021
.Dt DTRACE 1
.Os
.Sh NAME
@@ -517,18 +515,7 @@ option is not specified,
.Nm
does not permit the compilation or enabling of a D program that contains
destructive actions.
.Pp
Set the
.Va security.bsd.allow_destructive_dtrace
.Xr loader 8
tunable
to
.Ql 0
to disallow the possibility of enabling destructive actions system-wide at any point at all.
Any attempts to enable destructive actions will cause
.Nm
to exit with a runtime error.
.It Fl x Ar arg Ns Op = Ns Ar value
.It Fl x Ar arg Op Ns = Ns value
Enable or modify a DTrace runtime option or D compiler option.
Boolean options are enabled by specifying their name.
Options with values are set by separating the option name and value with an
@@ -608,52 +595,6 @@ Same as the
flag.
.It Sy dynvarsize Ns = Ns Ar size
Size of the dynamic variable space.
.Sm off
.It Sy evaltime = Cm exec | preinit | postinit | main
.Sm on
Process create mode.
When using
.Fl c Ar cmd
to start a command,
.Nm
will first stop the newly started
.Ar cmd ,
evaluate the
.Xr d 7
program,
and then resume the
.Ar cmd .
The
.Cm evaltime
option controls the exact moment when this happens.
.Pp
The following table describes supported modes.
.Bl -column -offset indent "postinit" "D Program Evaluation Time"
.It Sy Mode Ta Sy D Program Evaluation Time
.It Cm exec Ta
Right at the first instruction of the command
.Ar cmd
execution.
.It Cm preinit Ta
Before
.Xr elf 5 Ap s
.Dq .init
sections.
.It Cm postinit Ta
After
.Xr elf 5 Ap s
.Dq .init
sections.
Default on
.Fx .
.It Cm main Ta
Before the first instruction of the
.Fn main
function.
.El
.Pp
Usually, there is no reason to change the default mode,
but it might be handy in situations such as shared library tracing.
.It Sy flowindent
Turn on flow indentation.
Same as the
@@ -836,14 +777,6 @@ command line to define a set of macro variables and so forth).
The additional arguments can be used in D programs specified using the
.Fl s
option or on the command line.
.Sh ENVIRONMENT
.Bl -tag -width 'DTRACE_DEBUG'
.It Ev DTRACE_DEBUG
When defined,
.Nm
will output debug log messages to
.Xr stderr 4 .
.El
.Sh FILES
.Bl -tag -width /boot/dtrace.dof -compact
.It Pa /boot/dtrace.dof
@@ -868,40 +801,15 @@ failed or that the specified request could not be satisfied.
.It 2
Invalid command line options or arguments were specified.
.El
.Sh DIAGNOSTICS
.Bl -diag
.It dtrace: could not enable tracing: Permission denied
This can happen when
.Nm
fails to enable destructive actions because
.Va security.bsd.allow_destructive_dtrace
is set to
.Ql 0
in
.Xr loader.conf 5 .
.El
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.1 .
.Sh SEE ALSO
.Xr cpp 1 ,
.Xr dtrace_audit 4 ,
.Xr dtrace_callout_execute 4 ,
.Xr dtrace_fbt 4 ,
.Xr dtrace_io 4 ,
.Xr dtrace_ip 4 ,
.Xr dtrace_lockstat 4 ,
.Xr dtrace_proc 4 ,
.Xr dtrace_sched 4 ,
.Xr dtrace_sctp 4 ,
.Xr dtrace_tcp 4 ,
.Xr dtrace_udp 4 ,
.Xr dtrace_udplite 4 ,
.Xr dtrace_vfs 4 ,
.Xr elf 5 ,
.Xr SDT 9
.Rs
.%T Solaris Dynamic Tracing Guide
.Re
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.1 .
@@ -38,6 +38,9 @@
*/
#include <pthread.h>
#ifdef illumos
#include <synch.h>
#endif
#include <stdio.h>
#include "barrier.h"
@@ -46,7 +49,12 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
pthread_cond_init(&bar->bar_cv, NULL);
#ifdef illumos
sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
#else
sem_init(&bar->bar_sem, 0, 0);
#endif
bar->bar_numin = 0;
bar->bar_nthr = nthreads;
}
@@ -57,14 +65,26 @@ barrier_wait(barrier_t *bar)
pthread_mutex_lock(&bar->bar_lock);
if (++bar->bar_numin < bar->bar_nthr) {
pthread_cond_wait(&bar->bar_cv, &bar->bar_lock);
pthread_mutex_unlock(&bar->bar_lock);
#ifdef illumos
sema_wait(&bar->bar_sem);
#else
sem_wait(&bar->bar_sem);
#endif
return (0);
} else {
int i;
/* reset for next use */
bar->bar_numin = 0;
pthread_cond_broadcast(&bar->bar_cv);
for (i = 1; i < bar->bar_nthr; i++)
#ifdef illumos
sema_post(&bar->bar_sem);
#else
sem_post(&bar->bar_sem);
#endif
pthread_mutex_unlock(&bar->bar_lock);
return (1);
@@ -33,7 +33,12 @@
* APIs for the barrier synchronization primitive.
*/
#include <pthread.h>
#ifdef illumos
#include <synch.h>
#else
#include <semaphore.h>
typedef sem_t sema_t;
#endif
#ifdef __cplusplus
extern "C" {
@@ -43,7 +48,7 @@ typedef struct barrier {
pthread_mutex_t bar_lock; /* protects bar_numin */
int bar_numin; /* current number of waiters */
pthread_cond_t bar_cv; /* where everyone waits */
sema_t bar_sem; /* where everyone waits */
int bar_nthr; /* # of waiters to trigger release */
} barrier_t;
+2 -2
View File
@@ -1,6 +1,6 @@
# License
Copyright (c) 2018-2025 Gavin D. Howard <gavin@gavinhoward.com>
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -60,7 +60,7 @@ The files `src/rand.c` and `include/rand.h` are under the following copyrights
and license:
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors<br>
Copyright (c) 2018-2025 Gavin D. Howard <gavin@gavinhoward.com>
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
-80
View File
@@ -1,80 +0,0 @@
# Maintenance Terms
> Last Updated: 27 June 2025
The code, text, and other materials in this repository are provided as-is under
the terms of the repository's [`LICENSE.md`][0] file, as a gift to the commons
and the common good. In providing this software as-is, its author(s) admit no
further obligations from anyone using the software for any reason, particularly
with respect to:
* Releases,
* Response time,
* Change review and integration,
* Disclosure schedules,
* Discretionary, proprietary or otherwise secretive communications, and
* Any other non-contractual obligations or conventions, regardless of their
presumed urgency or severity.
Should anyone wish to make a contract with me (Gavin Howard) to ensure that work
he or she deems critical gets done, the terms are as follows:
* Compute time will be charged at \$25/hr.
* My time will be charged at \$100/hr.
* All issues deemed critical by either me or the requester, that also change the
source code (anything in `gen`, `include`, or `src`) will require at least two
weeks of fuzzing without error.
* If errors are found, those hours will still be charged on top of the final
two weeks.
* All changes will require running the [release script][2] on Linux (GCC), Linux
(Clang), FreeBSD, OpenBSD, macOS, Windows.
* Any hours spent on bugs or code that have been, or are suspected to have been,
generated by "AI" will be charged double rates.
Compute time includes, but is not limited to:
* Fuzzing.
* Running my [release script][2].
* Running tests and my [release script][2] on macOS.
My time includes, but is not limited to:
* Code review.
* Reading bug reports.
* Design.
* Coding.
* Any compute time that interferes with my ability to do any other work:
* Fuzzing makes my computer unusable, so fuzzing for the 8-12 hours of the
day that I could be working will be charged at \$100/hr.
* Same with running my [release script][2] because I run two instances on my
machine and two in VMs at the same time.
* Running my [release script][2] or any other compute time on Windows
because Windows blocks me from doing my main work on Linux.
* Any other instances of blocking compute time.
All amounts will be billed by, and paid to, [Yzena, LLC][2]. Invoices will be
provided, including line items for what each hour was spent on.
It is suggested that the following amounts be budgeted:
* At least \$3000 for a non-critical issue or change.
The release script takes about 10 hours, and I would need to run it once on
Linux (and others at the same time) and once on Windows, which is 20 hours.
Most of that won't be at the \$100/hr rate, but some probably will be. Then
an extra \$1000 for other work.
* At least \$15,000 for a critical issue or change.
The \$3000 above is the start, which leaves \$12,000. Fuzzing is expected to
cost \$11,400 (6 days a week, 8 hours a day, at \$100, the rest at \$25), and
rounded up to \$12,000 for good measure.
---
This document is inspired by [Mike Hoye's Maintenance Terms][1].
[0]: LICENSE.md
[1]: https://github.com/mhoye/maintenance-terms
[2]: scripts/release.sh
[3]: https://yzena.com/
+262 -21
View File
@@ -1,7 +1,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -38,8 +38,6 @@ GENDIR = $(ROOTDIR)/gen
BUILDDIR = %%BUILDDIR%%
VERSION = %%VERSION%%
SRC = %%SRC%%
OBJ = %%OBJ%%
GCDA = %%GCDA%%
@@ -101,16 +99,17 @@ BC_FUZZER_C = $(BIN)/$(BC)_fuzzer_C
DC_FUZZER = $(BIN)/$(DC)_fuzzer_c
DC_FUZZER_C = $(BIN)/$(DC)_fuzzer_C
BC_TEST_OUTPUTS = tests/bc_outputs
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
DC_TEST_OUTPUTS = tests/dc_outputs
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
LIB = libbcl
LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME)
BCL = bcl
GENERATE_TESTS = %%GENERATE_TESTS%%
PROBLEMATIC_TESTS = %%PROBLEMATIC_TESTS%%
BCL_TEST = $(BIN)/$(BCL)
BCL_TEST_C = $(TESTSDIR)/$(BCL).c
MANUALS = manuals
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
@@ -153,11 +152,11 @@ BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
BC_ENABLE_NLS = %%NLS%%
BC_EXCLUDE_EXTRA_MATH = %%EXCLUDE_EXTRA_MATH%%
BC_ENABLE_AFL = 0
BC_ENABLE_OSSFUZZ = 0
BC_ENABLE_MEMCHECK = 0
BC_ENABLE_AFL = %%FUZZ%%
BC_ENABLE_OSSFUZZ = %%OSSFUZZ%%
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
LIB_FUZZING_ENGINE = 0
LIB_FUZZING_ENGINE = %%LIB_FUZZING_ENGINE%%
BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
@@ -190,6 +189,10 @@ KARATSUBA = $(SCRIPTSDIR)/karatsuba.py
LOCALE_INSTALL = $(SCRIPTSDIR)/locale_install.sh
LOCALE_UNINSTALL = $(SCRIPTSDIR)/locale_uninstall.sh
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
TEST_STARS = ***********************************************************************
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
@@ -215,7 +218,7 @@ CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
CPPFLAGS9 = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
CPPFLAGS = -DVERSION=$(VERSION) $(CPPFLAGS9) -DBC_ENABLE_OSSFUZZ=$(BC_ENABLE_OSSFUZZ)
CPPFLAGS = $(CPPFLAGS9) -DBC_ENABLE_OSSFUZZ=$(BC_ENABLE_OSSFUZZ)
CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%%
LDFLAGS = %%LDFLAGS%%
@@ -290,10 +293,236 @@ help:
@printf ' check alias for `make test`\n'
@printf ' clean removes all build files\n'
@printf ' clean_config removes all build files as well as the generated Makefile\n'
@printf ' clean_tests removes all build files, the generated Makefile,\n'
@printf ' and generated tests\n'
@printf ' install installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
@printf ' and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
@printf ' karatsuba runs the karatsuba script (requires Python 3)\n'
@printf ' karatsuba_test runs the karatsuba script while running tests\n'
@printf ' (requires Python 3)\n'
@printf ' uninstall uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
@printf ' and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
@printf ' test runs the test suite\n'
@printf ' test_bc runs the bc test suite, if bc has been built\n'
@printf ' test_dc runs the dc test suite, if dc has been built\n'
@printf ' time_test runs the test suite, displaying times for some things\n'
@printf ' time_test_bc runs the bc test suite, displaying times for some things\n'
@printf ' time_test_dc runs the dc test suite, displaying times for some things\n'
@printf ' timeconst runs the test on the Linux timeconst.bc script,\n'
@printf ' if it exists and bc has been built\n'
run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np
bc_all_tests:
%%BC_ALL_TESTS%%
bc_all_tests_np:
%%BC_ALL_TESTS_NP%%
timeconst_all_tests:
%%TIMECONST_ALL_TESTS%%
dc_all_tests:
%%DC_ALL_TESTS%%
dc_all_tests_np:
%%DC_ALL_TESTS_NP%%
history_all_tests:
%%HISTORY_TESTS%%
check: test
test: %%TESTS%%
test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other
@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
test_bc_tests:%%BC_TESTS%%
test_bc_scripts:%%BC_SCRIPT_TESTS%%
test_bc_stdin:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh bc %%BC_TEST_EXEC%%
test_bc_read:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh bc %%BC_TEST_EXEC%%
test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%
test_bc_error_lines:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh bc %%BC_TEST_EXEC%%
test_bc_other:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%%
test_bc_header:
@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other
@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
test_dc_tests:%%DC_TESTS%%
test_dc_scripts:%%DC_SCRIPT_TESTS%%
test_dc_stdin:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh dc %%DC_TEST_EXEC%%
test_dc_read:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh dc %%DC_TEST_EXEC%%
test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%
test_dc_error_lines:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh dc %%DC_TEST_EXEC%%
test_dc_other:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%%
test_dc_header:
@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
timeconst:
%%TIMECONST%%
test_history: test_history_header test_bc_history test_dc_history
@printf '\nAll history tests passed.\n\n$(TEST_STARS)\n'
test_bc_history:%%BC_HISTORY_TEST_PREREQS%%
test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21
test_bc_history_skip:
@printf 'No bc history tests to run\n'
test_bc_history0:
@sh $(TESTSDIR)/history.sh bc 0 %%BC_TEST_EXEC%%
test_bc_history1:
@sh $(TESTSDIR)/history.sh bc 1 %%BC_TEST_EXEC%%
test_bc_history2:
@sh $(TESTSDIR)/history.sh bc 2 %%BC_TEST_EXEC%%
test_bc_history3:
@sh $(TESTSDIR)/history.sh bc 3 %%BC_TEST_EXEC%%
test_bc_history4:
@sh $(TESTSDIR)/history.sh bc 4 %%BC_TEST_EXEC%%
test_bc_history5:
@sh $(TESTSDIR)/history.sh bc 5 %%BC_TEST_EXEC%%
test_bc_history6:
@sh $(TESTSDIR)/history.sh bc 6 %%BC_TEST_EXEC%%
test_bc_history7:
@sh $(TESTSDIR)/history.sh bc 7 %%BC_TEST_EXEC%%
test_bc_history8:
@sh $(TESTSDIR)/history.sh bc 8 %%BC_TEST_EXEC%%
test_bc_history9:
@sh $(TESTSDIR)/history.sh bc 9 %%BC_TEST_EXEC%%
test_bc_history10:
@sh $(TESTSDIR)/history.sh bc 10 %%BC_TEST_EXEC%%
test_bc_history11:
@sh $(TESTSDIR)/history.sh bc 11 %%BC_TEST_EXEC%%
test_bc_history12:
@sh $(TESTSDIR)/history.sh bc 12 %%BC_TEST_EXEC%%
test_bc_history13:
@sh $(TESTSDIR)/history.sh bc 13 %%BC_TEST_EXEC%%
test_bc_history14:
@sh $(TESTSDIR)/history.sh bc 14 %%BC_TEST_EXEC%%
test_bc_history15:
@sh $(TESTSDIR)/history.sh bc 15 %%BC_TEST_EXEC%%
test_bc_history16:
@sh $(TESTSDIR)/history.sh bc 16 %%BC_TEST_EXEC%%
test_bc_history17:
@sh $(TESTSDIR)/history.sh bc 17 %%BC_TEST_EXEC%%
test_bc_history18:
@sh $(TESTSDIR)/history.sh bc 18 %%BC_TEST_EXEC%%
test_bc_history19:
@sh $(TESTSDIR)/history.sh bc 19 %%BC_TEST_EXEC%%
test_bc_history20:
@sh $(TESTSDIR)/history.sh bc 20 %%BC_TEST_EXEC%%
test_bc_history21:
@sh $(TESTSDIR)/history.sh bc 21 %%BC_TEST_EXEC%%
test_dc_history:%%DC_HISTORY_TEST_PREREQS%%
test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 test_dc_history10
test_dc_history_skip:
@printf 'No dc history tests to run\n'
test_dc_history0:
@sh $(TESTSDIR)/history.sh dc 0 %%DC_TEST_EXEC%%
test_dc_history1:
@sh $(TESTSDIR)/history.sh dc 1 %%DC_TEST_EXEC%%
test_dc_history2:
@sh $(TESTSDIR)/history.sh dc 2 %%DC_TEST_EXEC%%
test_dc_history3:
@sh $(TESTSDIR)/history.sh dc 3 %%DC_TEST_EXEC%%
test_dc_history4:
@sh $(TESTSDIR)/history.sh dc 4 %%DC_TEST_EXEC%%
test_dc_history5:
@sh $(TESTSDIR)/history.sh dc 5 %%DC_TEST_EXEC%%
test_dc_history6:
@sh $(TESTSDIR)/history.sh dc 6 %%DC_TEST_EXEC%%
test_dc_history7:
@sh $(TESTSDIR)/history.sh dc 7 %%DC_TEST_EXEC%%
test_dc_history8:
@sh $(TESTSDIR)/history.sh dc 8 %%DC_TEST_EXEC%%
test_dc_history9:
@sh $(TESTSDIR)/history.sh dc 9 %%DC_TEST_EXEC%%
test_dc_history10:
@sh $(TESTSDIR)/history.sh dc 10 %%DC_TEST_EXEC%%
test_history_header:
@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'
library_test: $(LIBBC)
$(CC) $(CFLAGS) -lpthread $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
test_library: library_test
%%BCL_TEST_EXEC%%
karatsuba:
%%KARATSUBA%%
karatsuba_test:
%%KARATSUBA_TEST%%
coverage_output:
%%COVERAGE_OUTPUT%%
coverage:%%COVERAGE_PREREQS%%
manpages:
$(MANPAGE) bc
@@ -330,25 +559,37 @@ clean_config: clean clean_benchmarks
@$(RM) -f compile_commands.json
@$(RM) -f $(BCL_PC)
test:
@if [ $(BC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n bc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(BC_EXEC); fi
@if [ $(DC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n dc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(DC_EXEC); fi
clean_coverage:
@printf 'Cleaning coverage files...\n'
@$(RM) -f *.gcov
@$(RM) -f *.html *.css
@$(RM) -f *.gcda *.gcno
@$(RM) -f *.profraw
@$(RM) -f $(GCDA) $(GCNO)
@$(RM) -f $(BC_GCDA) $(BC_GCNO)
@$(RM) -f $(DC_GCDA) $(DC_GCNO)
@$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
@$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
@$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
@$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
@$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
clean_tests: clean clean_config
clean_tests: clean clean_config clean_coverage
@printf 'Cleaning test files...\n'
@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
@$(RM) -f $(TESTSDIR)/bc/parse_*.txt $(TESTSDIR)/bc/parse_*_results.txt
@$(RM) -f $(TESTSDIR)/bc/print_*.txt $(TESTSDIR)/bc/print_*_results.txt
@$(RM) -f $(TESTSDIR)/bc/parse.txt $(TESTSDIR)/bc/parse_results.txt
@$(RM) -f $(TESTSDIR)/bc/print.txt $(TESTSDIR)/bc/print_results.txt
@$(RM) -f $(TESTSDIR)/bc/bessel.txt $(TESTSDIR)/bc/bessel_results.txt
@$(RM) -f $(TESTSDIR)/bc/strings2.txt $(TESTSDIR)/bc/strings2_results.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/bessel.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/parse.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/print.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/add_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/divide_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/add.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/divide.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/strings2.txt
@$(RM) -f $(TESTSDIR)/dc/scripts/prime.txt
@$(RM) -f .log_*.txt
-23
View File
@@ -1,27 +1,5 @@
# News
## 7.1.0
This is an ***UNTESTED*** release. If you would like testing, see the
[maintenance terms][23].
This fixes a few bugs:
* Improper response to double `SIGINT` with editline.
* Not letting `libedit` handle terminal size changes.
* A `dc` crash from improperly handling an error.
* A duplicate check for reference arrays.
* Build failures with GCC 15.
It also has a performance increase in the `band()` function and others in the
math library.
## 7.0.3
This is a production release that fixes build warnings on the musl libc.
Other users do ***NOT*** need to upgrade.
## 7.0.2
This is a production release that fixes `Ctrl+d` on FreeBSD and Linux when using
@@ -1610,4 +1588,3 @@ not thoroughly tested.
[20]: https://github.com/apjanke/ronn-ng
[21]: https://pandoc.org/
[22]: ./scripts/locale_uninstall.sh
[23]: ./MAINTENANCE-TERMS.md
+1 -1
View File
@@ -1,6 +1,6 @@
# Notice
Copyright 2018-2025 Gavin D. Howard and contributors.
Copyright 2018-2024 Gavin D. Howard and contributors.
## Contributors
+4 -17
View File
@@ -1,7 +1,9 @@
# `bc`
***WARNING: This project has moved back to GitHub temporarily; self-hosted Git
forges are not working for me, so I am trying to replace them.***
***WARNING: New user registration for <https://git.gavinhoward.com/> is disabled
because of spam. If you need to report a bug with `bc`, email gavin at this site
minus the `git.` part for an account, and I will create one for you. Or you can
report an issue at [GitHub][29].***
***WARNING: This project has moved to [https://git.gavinhoward.com/][20] for
[these reasons][21], though GitHub will remain a mirror.***
@@ -280,12 +282,6 @@ The easiest way to run this script is with `make karatsuba`.
If desired, maintainers can also skip running this script because there is a
sane default for the Karatsuba number.
##### `timeconst.bc`
The test suite will print a warning in normal usage. The warning is about a
missing `timeconst.bc`. This file [comes from][37] the [Linux kernel][38], which
has an incompatible license. The warning can be ignored.
## Status
This `bc` is robust.
@@ -436,8 +432,6 @@ Other projects based on this bc are:
* [macOS `bc`][35]. Any bugs in that `bc` should be reported to me, but do
expect bugs because the version is old.
* [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
* [A Fedora package][36]. If this package does not have any patches, you can
report bugs to me.
This is a non-comprehensive list of Linux distros that use this `bc` as the
system `bc`:
@@ -475,16 +469,12 @@ Files:
.gitignore The git ignore file (maintainer use only).
.gitattributes The git attributes file (maintainer use only).
bcl.pc.in A template pkg-config file for bcl.
build.gaml The GAML file with options for building under Rig.
build.pkg.rig The Rig build package file.
build.rig The Rig build script.
configure A symlink to configure.sh to make packaging easier.
configure.sh The configure script.
LICENSE.md A Markdown form of the BSD 2-clause License.
Makefile.in The Makefile template.
NEWS.md The changelog.
NOTICE.md List of contributors and copyright owners.
VERSION.txt A file containing the version.
Folders:
@@ -526,6 +516,3 @@ Folders:
[33]: https://github.com/gentoo/gentoo/blob/master/app-alternatives/bc/bc-0.ebuild#L8
[34]: https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bc.html
[35]: https://github.com/apple-oss-distributions/bc/tree/main/bc
[36]: https://copr.fedorainfracloud.org/coprs/tkbcopr/bc-gh/
[37]: https://github.com/torvalds/linux/blob/master/kernel/time/timeconst.bc
[38]: https://github.com/torvalds/linux
-1
View File
@@ -1 +0,0 @@
7.1.0
-402
View File
@@ -1,402 +0,0 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The build options file.
*
*/
project: @com.gavinhoward.bc
language: @C11
version: {
min: @24.04.05
}
mode: {
language: @iterative
stampers: @metadata
dependencies: @dynamic
}
default_target: @all
presets: {
debug: {
debug: true
optimization: "0"
memcheck: true
devtools: true
strip: false
}
release: {
optimization: "3"
lto: true
}
// This is the predefined build for BSDs.
bsd: {
optimization: "3"
history: @editline
generated_tests: false
install_manpages: false
install_locales: @system
strip: true
bc_default_banner: false
bc_default_sigint_reset: true
dc_default_sigint_reset: true
bc_default_tty_mode: true
dc_default_tty_mode: false
bc_default_prompt: @off
dc_default_prompt: @off
bc_default_expr_exit: true
dc_default_expr_exit: true
bc_default_digit_clamp: false
dc_default_digit_clamp: false
}
// This is the predefined build to match the GNU bc/dc.
gnu: {
optimization: "3"
generated_tests: false
install_manpages: true
install_locales: @system
strip: true
bc_default_banner: true
bc_default_sigint_reset: true
dc_default_sigint_reset: false
bc_default_tty_mode: true
dc_default_tty_mode: false
bc_default_prompt: @tty_mode
dc_default_prompt: @tty_mode
bc_default_expr_exit: true
dc_default_expr_exit: true
bc_default_digit_clamp: false
dc_default_digit_clamp: false
}
// This is the preferred release build of the author, Gavin D. Howard.
gdh: {
optimization: "3"
install_manpages: true
install_locales: @none
bc/default_banner: true
bc/default_sigint_reset: true
dc/default_sigint_reset: true
bc/default_tty_mode: true
dc/default_tty_mode: true
bc/default_prompt: @tty_mode
dc/default_prompt: @tty_mode
bc/default_expr_exit: false
dc/default_expr_exit: false
bc/default_digit_clamp: true
dc/default_digit_clamp: true
}
// This is the preferred debug build of the author, Gavin D. Howard.
dbg: {
optimization: "0"
debug: true
strip: false
install_manpages: true
install_locales: @system
bc/default_banner: true
bc/default_sigint_reset: true
dc/default_sigint_reset: true
bc/default_tty_mode: true
dc/default_tty_mode: true
bc/default_prompt: @tty_mode
dc/default_prompt: @tty_mode
bc/default_expr_exit: false
dc/default_expr_exit: false
bc/default_digit_clamp: true
dc/default_digit_clamp: true
}
}
default_development: @debug
default_release: @release
options: {
build_mode: {
type: @option
options: [
@both
@bc
@dc
@library
]
default: @both
desc: "Which of the executables or library to build."
}
extra_math: {
type: @bool
default: true
desc: "Enable the extra math extensions."
}
history: {
type: @option
options: [
@none
@builtin
@editline
@readline
]
default: @builtin
desc: "Which history implementation should be used, if any."
}
locales: {
type: @option
options: [
@none
@system
@all
]
default: @system
desc: "Whether to disable locales, use just the system ones, or use all (for building a package)."
}
bc/default_banner: {
type: @bool
default: false
desc: "Whether to display the bc version banner by default when in interactive mode."
}
bc/default_sigint_reset: {
type: @bool
default: true
desc: "Whether SIGINT will reset bc by default, instead of exiting, when in interactive mode."
}
dc/default_sigint_reset: {
type: @bool
default: true
desc: "Whether SIGINT will reset dc by default, instead of exiting, when in interactive mode."
}
bc/default_tty_mode: {
type: @bool
default: true
desc: "Whether TTY mode for bc should be on by default when available."
}
dc/default_tty_mode: {
type: @bool
default: false
desc: "Whether TTY mode for dc should be on by default when available."
}
bc/default_prompt: {
type: @option
options: [
@off
@tty_mode
@on
]
default: @tty_mode
desc: "Whether the prompt for bc should be on by default in TTY mode. This defaults to match TTY mode."
}
dc/default_prompt: {
type: @option
options: [
@off
@tty_mode
@on
]
default: @tty_mode
desc: "Whether the prompt for dc should be on by default in TTY mode. This defaults to match TTY mode."
}
bc/default_expr_exit: {
type: @bool
default: true
desc: "Whether to exit bc by default if an expression or expression file is given with the -e or -f options."
}
dc/default_expr_exit: {
type: @bool
default: true
desc: "Whether to exit dc by default if an expression or expression file is given with the -e or -f options."
}
bc/default_digit_clamp: {
type: @bool
default: false
desc: "Whether to have bc, by default, clamp digits that are greater than or equal to the current ibase when parsing numbers."
}
dc/default_digit_clamp: {
type: @bool
default: false
desc: "Whether to have dc, by default, clamp digits that are greater than or equal to the current ibase when parsing numbers."
}
karatsuba_len: {
type: @num
default: 32
desc: "Set the Karatsuba length (default is 32). Must be a number and greater than or equal to 16."
}
execprefix: {
type: @string
default: ""
desc: "The prefix to prepend to the executable names, to prevent collisions."
}
execsuffix: {
type: @string
default: ""
desc: "The suffix to append to the executable names, to prevent collisions."
}
debug: {
type: @bool
default: false
desc: "Enable debug info."
}
optimization: {
type: @string
default: "0"
desc: "The optimization level for the C compiler."
}
lto: {
type: @bool
default: false
desc: "Build with link-time optimization, if available."
}
strip: {
type: @bool
default: true
desc: "Strip any binaries."
}
strict: {
type: @bool
default: true
desc: "Build with strict compiler options."
}
force: {
type: @bool
default: false
desc: "Force options that don't work. THIS IS FOR DEV ONLY!"
}
memcheck: {
type: @bool
default: false
desc: "Enable memcheck mode, to check for memory leaks."
}
valgrind: {
type: @bool
default: false
desc: "Enable Valgrind mode, to check for memory bugs."
}
afl: {
type: @bool
default: false
desc: "Enable AFL++ mode."
}
ossfuzz: {
type: @bool
default: false
desc: "Enable OSSFUZZ mode."
}
generated_tests: {
type: @bool
default: true
desc: "Enable tests generated from a GNU bc-compatible program."
}
problematic_tests: {
type: @bool
default: true
desc: "Enable tests that may be problematic."
}
coverage: {
type: @bool
default: false
desc: "Enable code coverage (only works on GCC)."
}
install_manpages: {
type: @bool
default: true
desc: "Whether to install manpages or not."
}
cflags: {
type: @list
default: []
desc: "The command-line flags for the C compiler."
}
ldflags: {
type: @list
default: []
desc: "The command-line flags for the C linker."
}
destdir: {
type: @path
default: ""
desc: "The equivalent of $DESTDIR in other build systems."
}
prefix: {
type: @path
default: "/usr/local"
desc: "The default prefix to install everything into."
}
bindir: {
type: @path
default: ""
desc: "The directory to install executables into. Defaults to \"$prefix/bin\"."
}
libdir: {
type: @path
default: ""
desc: "The directory to install libraries into. Defaults to \"$prefix/lib\"."
}
includedir: {
type: @path
default: ""
desc: "The location to install headers in. Defaults to \"$prefix/include\"."
}
nlspath: {
type: @path
default: "/usr/share/locale/%L/%N"
desc: "The location to install locales."
}
pc_path: {
type: @path
default: ""
desc: "The location to pkg-config files to. Defaults to the output of `pkg-config --variable=pc_path pkg-config`."
}
datarootdir: {
type: @path
default: ""
desc: "The root directory for data files. Defaults to `$prefix/share`."
}
datadir: {
type: @path
default: ""
desc: "The directory for data files. Defaults to `$datarootdir`."
}
mandir: {
type: @path
default: ""
desc: "The root directory for manpages. Defaults to `$datadir/man`."
}
man1dir: {
type: @path
default: ""
desc: "The directory for manpages in section 1. Defaults to `$mandir/man1`."
}
man3dir: {
type: @path
default: ""
desc: "The directory for manpages in section 3. Defaults to `$mandir/man3`."
}
}
File diff suppressed because it is too large. Load diff
-575
View File
@@ -1,575 +0,0 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The build script file.
*
*/
if OS == "Windows" && bool(config["lto"])
{
error("Link-time optimization is not supported on Windows");
}
if LIBRARY_ENABLED == "0"
{
if OS != "Windows" && NLS_ENABLED != "0"
{
io.eprint("Testing NLS...\n");
clang_flags: []str =
if CC contains "clang"
{
@[ "-Wno_unreachable-code" ];
};
flags: []str = clang_flags +~ @[
DEFOPT +~ "BC_ENABLE_NLS=1",
DEFOPT +~ "BC_ENABLED=" +~ BC_ENABLED,
DEFOPT +~ "DC_ENABLED=" +~ DC_ENABLED,
DEFOPT +~ "BC_ENABLE_HISTORY=0",
DEFOPT +~ "BC_ENABLE_LIBRARY=0",
DEFOPT +~ "BC_ENABLE_AFL=0",
DEFOPT +~ "BC_ENABLE_EXTRA_MATH=" +~ EXTRA_MATH_ENABLED,
DEFOPT +~ "BC_ENABLE_OSSFUZZ=0",
DEFOPT +~ "_POSIX_C_SOURCE=200809L",
DEFOPT +~ "_XOPEN_SOURCE=700",
INCOPT,
];
res := $ $CC %(flags) -c @(path.join(src_dir, "src/vm.c")) -E;
if res.exitcode != 0
{
if FORCE
{
io.eprint("Forcing NLS...\n");
}
else
{
error("NLS does not work\n");
}
}
else
{
if path.isfile("vm.o")
{
path.rm("vm.o");
}
io.eprint("NLS works.\n\n");
io.eprint("Testing gencat...\n");
res2 := $ gencat ./en_US.cat
@(path.join(src_dir, "locales/en_US.msg"));
if res2.exitcode != 0
{
if FORCE
{
io.eprint("Forcing NLS...\n");
}
else
{
error("gencat does not work\n");
}
}
else
{
io.eprint("gencat works.\n\n");
if platform != host
{
error("Cross compiles will not work!\n\n");
}
}
}
}
if OS != "Windows" && sym(config["history"]) != @none
{
io.eprint("Testing history...\n");
flags: []str = @[
DEFOPT +~ "BC_ENABLE_HISTORY=1",
DEFOPT +~ "BC_ENABLED=" +~ BC_ENABLED,
DEFOPT +~ "DC_ENABLED=" +~ DC_ENABLED,
DEFOPT +~ "BC_ENABLE_NLS=" +~ NLS_ENABLED,
DEFOPT +~ "BC_ENABLE_LIBRARY=0",
DEFOPT +~ "BC_ENABLE_AFL=0",
DEFOPT +~ "BC_ENABLE_EDITLINE=" +~ EDITLINE_ENABLED,
DEFOPT +~ "BC_ENABLE_READLINE=" +~ READLINE_ENABLED,
DEFOPT +~ "BC_ENABLE_EXTRA_MATH=" +~ EXTRA_MATH_ENABLED,
DEFOPT +~ "BC_ENABLE_OSSFUZZ=0",
DEFOPT +~ "_POSIX_C_SOURCE=200809L",
DEFOPT +~ "_XOPEN_SOURCE=700",
INCOPT,
];
res := $ $CC %(flags) -c @(path.join(src_dir, "src/history.c")) -E;
if res.exitcode != 0
{
if FORCE
{
io.eprint("Forcing history...\n");
}
else
{
error("History does not work\n");
}
}
else
{
if path.isfile("history.o")
{
path.rm("history.o");
}
io.eprint("History works.\n\n");
}
}
}
freebsd_flags: []str =
if OS != "FreeBSD"
{
@[ DEFOPT +~ "_POSIX_C_SOURCE=200809L", DEFOPT +~ "_XOPEN_SOURCE=700" ];
};
macos: bool = (OS == "Darwin");
macos_flags: []str =
if macos
{
@[ DEFOPT +~ "_DARWIN_C_SOURCE" ];
};
openbsd_flags: []str =
if OS == "OpenBSD"
{
if READLINE_ENABLED != "0"
{
error("Cannot use readline on OpenBSD");
}
@[ DEFOPT +~ "_BSD_SOURCE" ];
};
strip_flag: []str =
if OS != "Windows" && !bool(config["debug"]) && !macos && bool(config["strip"])
{
@[ "-s" ];
};
lto_flag: []str =
if bool(config["lto"])
{
@[ "-flto" ];
};
strict_flags: []str =
if bool(config["strict"])
{
// Strict build only works for GCC and Clang, so we do want to set that
// here.
if CC contains "gcc" || CC contains "clang"
{
// These are the standard strict build flags for both compilers.
std_strict: []str = @[ "-Wall", "-Wextra", "-Werror", "-pedantic" ];
// Clang has -Weverything, which I ensure Yc builds under.
//
// I also want unlimited errors because Clang is my development
// compiler; it caps at 20 by default.
compiler_strict: []str =
if CC contains "clang"
{
// Oh, and add the standard.
@[ "-Weverything", "-ferror-limit=100000", "-Wno-padded",
"-Wno-unknown-warning-option", "-Wno-unsafe-buffer-usage",
"-Wno-documentation-unknown-command", "-Wno-pre-c11-compat",
"-Wno-enum-enum-conversion", "-Wno-switch-default" ];
};
// Return the combination of the sets.
std_strict +~ compiler_strict;
}
else if OS == "Windows"
{
// Return the combo of the strict options, the standard, and the
// sanitizer defines.
@[ "/W4", "/WX", "/wd\"4996\"", "/permissive-" ];
}
};
version_contents: str = io.read_file(path.join(src_dir, "VERSION.txt"));
version_lines: []str = version_contents.split("\n");
version: str = version_lines[0];
version_flag: []str = @[ DEFOPT +~ "VERSION=" +~ version ];
other_flags: []str = freebsd_flags +~ macos_flags +~ openbsd_flags +~
lto_flag +~ strict_flags +~ version_flag +~
if bool(config["debug"])
{
@[ compiler_db["opt.debug"] ];
};
history_files: []str =
if HISTORY != @none
{
HISTORY_C_FILES;
};
c_files: []str =
if BUILD_MODE == @both
{
COMMON_C_FILES +~ EXEC_C_FILES +~ BC_C_FILES +~ DC_C_FILES +~ history_files;
}
else if BUILD_MODE == @bc
{
COMMON_C_FILES +~ EXEC_C_FILES +~ BC_C_FILES +~ history_files;
}
else if BUILD_MODE == @dc
{
COMMON_C_FILES +~ EXEC_C_FILES +~ DC_C_FILES +~ history_files;
}
else
{
COMMON_C_FILES +~ LIBRARY_C_FILES;
};
build_config: Gaml = @(gaml){
other_cflags: $other_flags
strip_flag: $strip_flag
};
targets: []str =
push build_config: config_stack
{
gen_o_files: []str =
if BUILD_MODE != @library
{
@[
txt2o("gen/lib.bc", "bc_lib", "bc_lib_name", "BC_ENABLED", true),
txt2o("gen/lib2.bc", "bc_lib2", "bc_lib2_name",
"BC_ENABLED && BC_ENABLE_EXTRA_MATH", true),
txt2o("gen/bc_help.txt", "bc_help", "", "BC_ENABLED", false),
txt2o("gen/dc_help.txt", "dc_help", "", "DC_ENABLED", false),
];
};
obj_files: []str = gen_o_files +~
for f: c_files
{
c2o(f);
};
if BUILD_MODE == @both || BUILD_MODE == @bc
{
if OS != "Windows" && bool(config["install_manpages"])
{
src: str = path.join("manuals/bc", BUILD_TYPE +~ ".1");
target BC_MANPAGE: src
{
$ cp -f @(file_dep) @(tgt);
}
}
exe(BC_BIN, obj_files);
}
if BUILD_MODE == @both || BUILD_MODE == @dc
{
if OS != "Windows" && bool(config["install_manpages"])
{
src: str = path.join("manuals/dc", BUILD_TYPE +~ ".1");
target DC_MANPAGE: src
{
$ cp -f @(file_dep) @(tgt);
}
}
if BUILD_MODE == @both
{
ln(DC_BIN, BC_BIN);
}
else
{
exe(DC_BIN, obj_files);
}
}
if BUILD_MODE == @library
{
lib(LIBRARY, obj_files);
}
if BUILD_MODE == @both
{
@[ BC_BIN, DC_BIN ];
}
else if BUILD_MODE == @bc
{
@[ DC_BIN ];
}
else if BUILD_MODE == @dc
{
@[ DC_BIN ];
}
else
{
includedir: str = get_includedir();
libdir: str = get_libdir();
pc_config: Gaml = @(gaml){
INCLUDEDIR: $includedir
LIBDIR: $libdir
VERSION: $version
};
push pc_config: config_stack
{
target PC_FILE: PC_FILE +~ ".in"
{
configure_file(file_dep, tgt, "%%");
}
}
@[ LIBRARY, PC_FILE ];
}
};
if OS != "Windows"
{
if LIBRARY_ENABLED == "0"
{
target @install: targets
{
bindir: str = get_bindir();
if BC_ENABLED != "0"
{
$ $SAFE_INSTALL $EXEC_INSTALL_MODE $BC_BIN
@(path.join(bindir, BC_BIN));
}
if DC_ENABLED != "0"
{
if BC_ENABLED != "0"
{
$ ln -sf @("./" +~ BC_BIN) @(path.join(bindir, DC_BIN));
}
else
{
$ $SAFE_INSTALL $EXEC_INSTALL_MODE $BC_BIN
@(path.join(bindir, BC_BIN));
}
}
if NLS_ENABLED != "0"
{
locale_install_args: []str =
if sym(config["locales"]) == @all
{
@[ "-l" ];
};
if DESTDIR != ""
{
$ @(path.join(src_dir, "scripts/locale_install.sh"))
%(locale_install_args) @(str(config["nlspath"]))
$MAINEXEC $DESTDIR;
}
else
{
$ @(path.join(src_dir, "scripts/locale_install.sh"))
%(locale_install_args) @(str(config["nlspath"]))
$MAINEXEC;
}
}
if bool(config["install_manpages"])
{
man1dir: str = get_man1dir();
if BC_ENABLED != "0"
{
$ rm -rf @(path.join(man1dir, BC_MANPAGE));
}
if DC_ENABLED != "0"
{
$ rm -rf @(path.join(man1dir, DC_MANPAGE));
}
}
}
target @uninstall
{
bindir: str = get_bindir();
if BC_ENABLED != "0"
{
$ rm -rf @(path.join(bindir, BC_BIN));
}
if DC_ENABLED != "0"
{
$ rm -rf @(path.join(bindir, DC_BIN));
}
if NLS_ENABLED != "0"
{
if DESTDIR != ""
{
$ @(path.join(src_dir, "scripts/locale_uninstall.sh"))
@(str(config["nlspath"])) $MAINEXEC $DESTDIR;
}
else
{
$ @(path.join(src_dir, "scripts/locale_uninstall.sh"))
@(str(config["nlspath"])) $MAINEXEC;
}
}
if bool(config["install_manpages"])
{
man1dir: str = get_man1dir();
$ rm -rf @(path.join(man1dir, BC_MANPAGE))
@(path.join(man1dir, DC_MANPAGE));
}
}
}
else
{
target @install: targets, BCL_HEADER_PATH
{
full_libdir: str = get_libdir();
$ $SAFE_INSTALL $EXEC_INSTALL_MODE @(file_dep)
@(path.join(full_libdir, file_dep));
full_pc_path: str = get_pc_path();
bcl_pc: str = file_deps[1];
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE $bcl_pc
@(path.join(full_pc_path, bcl_pc));
full_includedir: str = get_includedir();
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE @(file_deps[2])
@(path.join(full_includedir, BCL_HEADER));
if bool(config["install_manpages"])
{
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE
@(path.join(src_dir, path.join("manuals", BCL_MANPAGE)))
@(path.join(get_man3dir(), BCL_MANPAGE));
}
}
target @uninstall
{
$ rm -rf @(path.join(get_libdir(), LIBRARY))
@(path.join(get_pc_path(), PC_FILE))
@(path.join(get_includedir(), BCL_HEADER));
if bool(config["install_manpages"])
{
$ rm -rf @(path.join(get_man3dir(), BCL_MANPAGE));
}
}
}
}
// If the platform matches the host, we can run the test suite.
if platform == host
{
// If we have the library, build and run that test.
if BUILD_MODE == @library
{
libtesto: str = c2o("tests/bcl.c");
libtest: str = "bcl";
exe(libtest, @[ libtesto, targets[0] ]);
test @bcl: libtest
{
$ @(str(tgt_name));
}
}
else
{
if BUILD_MODE != @dc
{
exe_tests("bc");
}
if BUILD_MODE != @bc
{
exe_tests("dc");
}
target @clean_tests
{
for f: path.find_ext(build_dir, "txt")
{
path.rm(f);
}
}
}
}
target "bitfuncgen"
{
error("TODO: Make this");
}
target @bitfuncgen: "bitfuncgen"
{
error("TODO: Make this");
}
target "ministat"
{
error("TODO: Make this");
}
target @ministat: "ministat"
{
error("TODO: Make this");
}
target @all: targets;
-3
View File
@@ -1,9 +1,6 @@
-Weverything
-pedantic
-Wno-unsafe-buffer-usage
-Wno-pre-c11-compat
-Wno-unknown-warning-option
-Wno-switch-default
-D_POSIX_C_SOURCE=200809L
-D_XOPEN_SOURCE=700
-D_BSD_SOURCE
+455 -26
View File
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -55,7 +55,7 @@ usage() {
printf ' %s [-a|-bD|-dB|-c] [-CeEfgGHilmMNPrtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script"
printf ' [-s SETTING] [-S SETTING] [-p TYPE]\n'
printf ' %s \\\n' "$script"
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc] \\\n'
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n'
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls --disable-strip] \\\n'
printf ' [--enable-editline] [--enable-readline] [--enable-internal-history] \\\n'
@@ -74,7 +74,7 @@ usage() {
printf '\n'
printf ' -a, --library\n'
printf ' Build the libbcl instead of the programs. This is meant to be used with\n'
printf ' other software like programming languages that want to make use of the\n'
printf ' Other software like programming languages that want to make use of the\n'
printf ' parsing and math capabilities. This option will install headers using\n'
printf ' `make install`.\n'
printf ' -b, --bc-only\n'
@@ -83,6 +83,10 @@ usage() {
printf ' -B, --disable-bc\n'
printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
printf ' are specified too.\n'
printf ' -c, --coverage\n'
printf ' Generate test coverage code. Requires gcov and gcovr.\n'
printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n'
printf ' Requires a compiler that use gcc-compatible coverage options\n'
printf ' -C, --disable-clean\n'
printf ' Disable the clean that configure.sh does before configure.\n'
printf ' -d, --dc-only\n'
@@ -129,6 +133,8 @@ usage() {
printf ' Installs all locales, regardless of how many are on the system. This\n'
printf ' option is useful for package maintainers who want to make sure that\n'
printf ' a package contains all of the locales that end users might need.\n'
printf ' -m, --enable-memcheck\n'
printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n'
printf ' -M, --disable-man-pages\n'
printf ' Disable installing manpages.\n'
printf ' -N, --disable-nls\n'
@@ -166,9 +172,17 @@ usage() {
printf ' Set the default named by SETTING to off. See below for possible values\n'
printf ' for SETTING. For multiple instances of the -s or -S for the the same\n'
printf ' setting, the last one is used.\n'
printf ' -t, --enable-test-timing\n'
printf ' Enable the timing of tests. This is for development only.\n'
printf ' -T, --disable-strip\n'
printf ' Disable stripping symbols from the compiled binary or binaries.\n'
printf ' Stripping symbols only happens when debug mode is off.\n'
printf ' -v, --enable-valgrind\n'
printf ' Enable a build appropriate for valgrind. For development only.\n'
printf ' -z, --enable-fuzz-mode\n'
printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n'
printf ' -Z, --enable-ossfuzz-mode\n'
printf ' Enable fuzzing mode for OSS-Fuzz. THIS IS FOR DEVELOPMENT ONLY.\n'
printf ' --prefix PREFIX\n'
printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
@@ -240,12 +254,12 @@ usage() {
printf ' path (or contain one). This is treated the same as the POSIX\n'
printf ' definition of $NLSPATH (see POSIX environment variables for\n'
printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n'
printf ' PC_PATH The location to install pkg-config files to. Must be a\n'
printf ' PC_PATH The location to install pkg-config files to. Must be an\n'
printf ' path or contain one. Default is the first path given by the\n'
printf ' output of `pkg-config --variable=pc_path pkg-config`.\n'
printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n'
printf ' interfere with other installed bc executables. Default is "".\n'
printf ' EXECPREFIX The prefix to prepend to the executable names, used to not\n'
printf ' EXECPREFIX The prefix to append to the executable names, used to not\n'
printf ' interfere with other installed bc executables. Default is "".\n'
printf ' DESTDIR For package creation. Default is "". If it is empty when\n'
printf ' `%s` is run, it can also be passed to `make install`\n' "$script"
@@ -468,7 +482,7 @@ find_src_files() {
}
# This function generates a list of files to go into the Makefile. It generates
# the list of object files.
# the list of object files, as well as the list of test coverage files.
#
# @param contents The contents of the Makefile template to put the list of
# files into.
@@ -489,6 +503,8 @@ gen_file_list() {
_gen_file_list_needle_src="SRC"
_gen_file_list_needle_obj="OBJ"
_gen_file_list_needle_gcda="GCDA"
_gen_file_list_needle_gcno="GCNO"
_gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
@@ -505,9 +521,151 @@ gen_file_list() {
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_obj" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcda" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcno" "$_gen_file_list_replacement")
printf '%s\n' "$_gen_file_list_contents"
}
# Generates the proper test targets for each test to have its own target. This
# allows `make test` to run in parallel.
#
# @param name Which calculator to generate tests for.
# @param extra_math An integer that, if non-zero, activates extra math tests.
# @param time_tests An integer that, if non-zero, tells the test suite to time
# the execution of each test.
gen_std_tests() {
_gen_std_tests_name="$1"
shift
_gen_std_tests_extra_math="$1"
shift
_gen_std_tests_time_tests="$1"
shift
_gen_std_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt")
for _gen_std_tests_t in $(cat "$scriptdir/tests/$_gen_std_tests_name/all.txt"); do
if [ "$_gen_std_tests_extra_math" -eq 0 ]; then
if [ -z "${_gen_std_tests_extra_required##*$_gen_std_tests_t*}" ]; then
printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \
"$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \
"$_gen_std_tests_t" >> "Makefile"
continue
fi
fi
printf 'test_%s_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/test.sh %s %s %s %s %s\n\n' \
"$_gen_std_tests_name" "$_gen_std_tests_t" "$builddir" "$_gen_std_tests_name" \
"$_gen_std_tests_t" "$generate_tests" "$time_tests" \
"$*" >> "Makefile"
done
}
# Generates a list of test targets that will be used as prerequisites for other
# targets.
#
# @param name The name of the calculator to generate test targets for.
gen_std_test_targets() {
_gen_std_test_targets_name="$1"
shift
_gen_std_test_targets_tests=$(cat "$scriptdir/tests/${_gen_std_test_targets_name}/all.txt")
for _gen_std_test_targets_t in $_gen_std_test_targets_tests; do
printf ' test_%s_%s' "$_gen_std_test_targets_name" "$_gen_std_test_targets_t"
done
printf '\n'
}
# Generates the proper test targets for each error test to have its own target.
# This allows `make test_bc_errors` and `make test_dc_errors` to run in
# parallel.
#
# @param name Which calculator to generate tests for.
gen_err_tests() {
_gen_err_tests_name="$1"
shift
_gen_err_tests_fs=$(ls "$scriptdir/tests/$_gen_err_tests_name/errors/")
for _gen_err_tests_t in $_gen_err_tests_fs; do
printf 'test_%s_error_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/error.sh %s %s %s %s\n\n' \
"$_gen_err_tests_name" "$_gen_err_tests_t" "$builddir" "$_gen_err_tests_name" \
"$_gen_err_tests_t" "$problematic_tests" "$*" >> "Makefile"
done
}
# Generates a list of error test targets that will be used as prerequisites for
# other targets.
#
# @param name The name of the calculator to generate test targets for.
gen_err_test_targets() {
_gen_err_test_targets_name="$1"
shift
_gen_err_test_targets_tests=$(ls "$scriptdir/tests/$_gen_err_test_targets_name/errors/")
for _gen_err_test_targets_t in $_gen_err_test_targets_tests; do
printf ' test_%s_error_%s' "$_gen_err_test_targets_name" "$_gen_err_test_targets_t"
done
printf '\n'
}
# Generates the proper script test targets for each script test to have its own
# target. This allows `make test` to run in parallel.
#
# @param name Which calculator to generate tests for.
# @param extra_math An integer that, if non-zero, activates extra math tests.
# @param generate An integer that, if non-zero, activates generated tests.
# @param time_tests An integer that, if non-zero, tells the test suite to time
# the execution of each test.
gen_script_tests() {
_gen_script_tests_name="$1"
shift
_gen_script_tests_extra_math="$1"
shift
_gen_script_tests_generate="$1"
shift
_gen_script_tests_time="$1"
shift
_gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt")
for _gen_script_tests_f in $_gen_script_tests_tests; do
_gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}")
printf 'test_%s_script_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/script.sh %s %s %s 1 %s %s %s\n\n' \
"$_gen_script_tests_name" "$_gen_script_tests_b" "$builddir" "$_gen_script_tests_name" \
"$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \
"$_gen_script_tests_time" "$*" >> "Makefile"
done
}
set_default() {
_set_default_on="$1"
@@ -552,6 +710,7 @@ predefined_build() {
BSD)
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -564,6 +723,11 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=0
bc_default_sigint_reset=1
@@ -580,6 +744,7 @@ predefined_build() {
GNU)
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -592,6 +757,11 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -607,10 +777,10 @@ predefined_build() {
GDH)
CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11"
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -623,6 +793,11 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -638,10 +813,10 @@ predefined_build() {
DBG)
CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11"
bc_only=0
dc_only=0
coverage=0
debug=1
optimization="0"
hist=1
@@ -654,6 +829,11 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=1
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -672,12 +852,36 @@ predefined_build() {
esac
}
# Generates a list of script test targets that will be used as prerequisites for
# other targets.
#
# @param name The name of the calculator to generate script test targets for.
gen_script_test_targets() {
_gen_script_test_targets_name="$1"
shift
_gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt")
for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do
_gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \
".$_gen_script_test_targets_name")
printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \
"$_gen_script_test_targets_b"
done
printf '\n'
}
# This is a list of defaults, but it is also the list of possible options for
# users to change.
#
# The development options are: force (force options even if they fail).
# The development options are: force (force options even if they fail), valgrind
# (build in a way suitable for valgrind testing), memcheck (same as valgrind),
# and fuzzing (build in a way suitable for fuzzing).
bc_only=0
dc_only=0
coverage=0
karatsuba_len=32
debug=0
hist=1
@@ -691,6 +895,11 @@ force=0
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
problematic_tests=1
@@ -711,12 +920,13 @@ dc_default_digit_clamp=0
# getopts is a POSIX utility, but it cannot handle long options. Thus, the
# handling of long options is done by hand, and that's the reason that short and
# long options cannot be mixed.
while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
case "$opt" in
a) library=1 ;;
b) bc_only=1 ;;
B) dc_only=1 ;;
c) coverage=1 ;;
C) clean=0 ;;
d) dc_only=1 ;;
D) bc_only=1 ;;
@@ -730,6 +940,7 @@ while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
i) hist_impl="internal" ;;
k) karatsuba_len="$OPTARG" ;;
l) all_locales=1 ;;
m) memcheck=1 ;;
M) install_manpages=0 ;;
N) nls=0 ;;
O) optimization="$OPTARG" ;;
@@ -738,7 +949,11 @@ while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
r) hist_impl="readline" ;;
S) set_default 0 "$OPTARG" ;;
s) set_default 1 "$OPTARG" ;;
t) time_tests=1 ;;
T) strip_bin=0 ;;
v) vg=1 ;;
z) fuzz=1 ;;
Z) ossfuzz=1 ;;
-)
arg="$1"
arg="${arg#--}"
@@ -748,6 +963,7 @@ while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
library) library=1 ;;
bc-only) bc_only=1 ;;
dc-only) dc_only=1 ;;
coverage) coverage=1 ;;
debug) debug=1 ;;
force) force=1 ;;
prefix=?*) PREFIX="$LONG_OPTARG" ;;
@@ -861,20 +1077,27 @@ while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
enable-editline) hist_impl="editline" ;;
enable-readline) hist_impl="readline" ;;
enable-internal-history) hist_impl="internal" ;;
enable-test-timing) time_tests=1 ;;
enable-valgrind) vg=1 ;;
enable-fuzz-mode) fuzz=1 ;;
enable-ossfuzz-mode) ossfuzz=1 ;;
enable-memcheck) memcheck=1 ;;
install-all-locales) all_locales=1 ;;
help* | bc-only* | dc-only* | debug*)
help* | bc-only* | dc-only* | coverage* | debug*)
usage "No arg allowed for --$arg option" ;;
disable-bc* | disable-dc* | disable-clean*)
usage "No arg allowed for --$arg option" ;;
disable-extra-math*)
usage "No arg allowed for --$arg option" ;;
disable-history*)
disable-generated-tests* | disable-history*)
usage "No arg allowed for --$arg option" ;;
disable-man-pages* | disable-nls* | disable-strip*)
usage "No arg allowed for --$arg option" ;;
disable-problematic-tests*)
usage "No arg allowed for --$arg option" ;;
install-all-locales*)
enable-fuzz-mode* | enable-test-timing* | enable-valgrind*)
usage "No arg allowed for --$arg option" ;;
enable-memcheck* | install-all-locales*)
usage "No arg allowed for --$arg option" ;;
enable-editline* | enable-readline*)
usage "No arg allowed for --$arg option" ;;
@@ -998,7 +1221,33 @@ link="@printf 'No link necessary\\\\n'"
main_exec="BC"
executable="BC_EXEC"
tests="test_bc timeconst test_dc"
bc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)"
bc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)"
dc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)"
dc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)"
timeconst="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/bc/timeconst.sh \$(TESTSDIR)/bc/scripts/timeconst.bc \$(BC_EXEC)"
# In order to have cleanup at exit, we need to be in
# debug mode, so don't run valgrind without that.
if [ "$vg" -ne 0 ]; then
debug=1
bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)'
dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)'
bcl_test_exec='valgrind $(VALGRIND_ARGS) $(BCL_TEST)'
else
bc_test_exec='$(BC_EXEC)'
dc_test_exec='$(DC_EXEC)'
bcl_test_exec='$(BCL_TEST)'
fi
test_bc_history_prereqs="test_bc_history_all"
test_dc_history_prereqs="test_dc_history_all"
karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
bc_lib="\$(GEN_DIR)/lib.o"
bc_help="\$(GEN_DIR)/bc_help.o"
@@ -1025,6 +1274,9 @@ if [ "$library" -ne 0 ]; then
default_target_prereqs="\$(BIN) \$(OBJ)"
default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
default_target="\$(LIBBC)"
tests="test_library"
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
install_prereqs=" install_library"
uninstall_prereqs=" uninstall_library"
@@ -1040,6 +1292,10 @@ elif [ "$bc_only" -eq 1 ]; then
executables="bc"
dc_test="@printf 'No dc tests to run\\\\n'"
dc_test_np="@printf 'No dc tests to run\\\\n'"
test_dc_history_prereqs=" test_dc_history_skip"
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage"
uninstall_prereqs=" uninstall_bc"
@@ -1047,6 +1303,7 @@ elif [ "$bc_only" -eq 1 ]; then
default_target="\$(BC_EXEC)"
second_target="\$(DC_EXEC)"
tests="test_bc timeconst"
elif [ "$dc_only" -eq 1 ]; then
@@ -1061,19 +1318,36 @@ elif [ "$dc_only" -eq 1 ]; then
main_exec="DC"
executable="DC_EXEC"
bc_test="@printf 'No bc tests to run\\\\n'"
bc_test_np="@printf 'No bc tests to run\\\\n'"
test_bc_history_prereqs=" test_bc_history_skip"
timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
install_prereqs=" install_execs"
install_man_prereqs=" install_dc_manpage"
uninstall_prereqs=" uninstall_dc"
uninstall_man_prereqs=" uninstall_dc_manpage"
else
tests="test_dc"
elif [ "$ossfuzz" -eq 1 ]; then
if [ "$bc_only" -ne 0 ] || [ "$dc_only" -ne 0 ]; then
usage "An OSS-Fuzz build must build both fuzzers."
fi
bc=1
dc=1
executables="bc and dc"
# Expressions *cannot* exit in an OSS-Fuzz build.
bc_default_expr_exit=0
dc_default_expr_exit=0
executables="bc_fuzzer and dc_fuzzer"
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
if [ "$library" -eq 0 ]; then
install_prereqs=" install_execs"
@@ -1085,6 +1359,38 @@ else
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
second_target_prereqs="src/bc_fuzzer.o $default_target_prereqs"
default_target_prereqs="\$(BC_FUZZER) src/dc_fuzzer.o $default_target_prereqs"
default_target_cmd="\$(CXX) \$(CFLAGS) src/dc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(DC_FUZZER) \&\& ln -sf ./dc_fuzzer_c \$(DC_FUZZER_C)"
second_target_cmd="\$(CXX) \$(CFLAGS) src/bc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(BC_FUZZER) \&\& ln -sf ./bc_fuzzer_c \$(BC_FUZZER_C)"
default_target="\$(DC_FUZZER) \$(DC_FUZZER_C)"
second_target="\$(BC_FUZZER) \$(BC_FUZZER_C)"
else
bc=1
dc=1
executables="bc and dc"
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
if [ "$library" -eq 0 ]; then
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage install_dc_manpage"
uninstall_prereqs=" uninstall_bc uninstall_dc"
uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage"
else
install_prereqs=" install_library install_bcl_header"
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
second_target_prereqs="$default_target_prereqs"
@@ -1093,6 +1399,18 @@ else
fi
if [ "$fuzz" -ne 0 ] && [ "$ossfuzz" -ne 0 ]; then
usage "Fuzzing mode and OSS-Fuzz mode are mutually exclusive"
fi
# We need specific stuff for fuzzing.
if [ "$fuzz" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then
debug=1
hist=0
nls=0
optimization="3"
fi
# This sets some necessary things for debug mode.
if [ "$debug" -eq 1 ]; then
@@ -1111,6 +1429,26 @@ if [ -n "$optimization" ]; then
CFLAGS="-O$optimization $CFLAGS"
fi
# Set test coverage defaults.
if [ "$coverage" -eq 1 ]; then
if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
usage "Can only specify -c without -b or -d"
fi
CFLAGS="-fprofile-arcs -ftest-coverage -g -O0 $CFLAGS"
CPPFLAGS="-DNDEBUG $CPPFLAGS"
COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)"
COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*"
COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --exclude-unreachable-branches --exclude-throw-branches --html-details --output index.html"
COVERAGE_PREREQS=" test coverage_output"
else
COVERAGE_OUTPUT="@printf 'Coverage not generated\\\\n'"
COVERAGE_PREREQS=""
fi
# Set some defaults.
if [ -z "${DESTDIR+set}" ]; then
destdir=""
@@ -1229,7 +1567,7 @@ if [ "$nls" -ne 0 ]; then
printf 'NLS works.\n\n'
printf 'Testing gencat...\n'
gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" 2>&1
gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" > /dev/null
err="$?"
@@ -1334,10 +1672,26 @@ else
fi
if [ "$hist" -eq 0 ]; then
# We have to disable the history tests if it is disabled or valgrind is on. Or
# if we are using editline or readline.
if [ "$hist" -eq 0 ] || [ "$vg" -ne 0 ]; then
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
history_tests="@printf 'Skipping history tests...\\\\n'"
CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
else
if [ "$editline" -eq 0 ] && [ "$readline" -eq 0 ]; then
history_tests="@printf '\$(TEST_STARS)\\\\n\\\\nRunning history tests...\\\\n\\\\n'"
history_tests="$history_tests \&\& \$(TESTSDIR)/history.sh bc -a \&\&"
history_tests="$history_tests \$(TESTSDIR)/history.sh dc -a \&\& printf"
history_tests="$history_tests '\\\\nAll history tests passed.\\\\n\\\\n\$(TEST_STARS)\\\\n'"
else
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
history_tests="@printf 'Skipping history tests...\\\\n'"
fi
# We are also setting the CFLAGS and LDFLAGS here.
if [ "$editline" -ne 0 ]; then
LDFLAGS="$LDFLAGS -ledit"
@@ -1441,7 +1795,7 @@ GEN_DIR="$scriptdir/gen"
# `gen/strgen.sh` is used.
GEN="strgen"
GEN_EXEC_TARGET="\$(HOSTCC) -DBC_ENABLE_AFL=0 -DBC_ENABLE_OSSFUZZ=0 -I$scriptdir/include/ \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)"
CLEAN_PREREQS=" clean_gen"
CLEAN_PREREQS=" clean_gen clean_coverage"
if [ -z "${GEN_HOST+set}" ]; then
GEN_HOST=1
@@ -1449,6 +1803,7 @@ else
if [ "$GEN_HOST" -eq 0 ]; then
GEN="strgen.sh"
GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'"
CLEAN_PREREQS=" clean_coverage"
fi
fi
@@ -1493,7 +1848,9 @@ else
headers="$headers \$(DC_HEADERS)"
fi
version=$(cat "$scriptdir/VERSION.txt" | head -n1)
# This convoluted mess does pull the version out. If you change the format of
# include/version.h, you may have to change this line.
version=$(cat "$scriptdir/include/version.h" | grep "VERSION " - | awk '{ print $3 }' -)
if [ "$library" -ne 0 ]; then
@@ -1523,6 +1880,14 @@ if [ "$library" -ne 0 ]; then
fi
elif [ "$ossfuzz" -ne 0 ]; then
unneeded="$unneeded library.c main.c"
PC_PATH=""
pkg_config_install=""
pkg_config_uninstall=""
else
unneeded="$unneeded library.c"
@@ -1544,6 +1909,10 @@ if [ "$manpage_args" = "" ]; then
manpage_args="A"
fi
if [ "$vg" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then
memcheck=1
fi
if [ "$bc_default_prompt" = "" ]; then
bc_default_prompt="$bc_default_tty_mode"
fi
@@ -1552,6 +1921,14 @@ if [ "$dc_default_prompt" = "" ]; then
dc_default_prompt="$dc_default_tty_mode"
fi
# Generate the test targets and prerequisites.
bc_tests=$(gen_std_test_targets bc)
bc_script_tests=$(gen_script_test_targets bc)
bc_err_tests=$(gen_err_test_targets bc)
dc_tests=$(gen_std_test_targets dc)
dc_script_tests=$(gen_script_test_targets dc)
dc_err_tests=$(gen_err_test_targets dc)
printf 'unneeded: %s\n' "$unneeded"
# Print out the values; this is for debugging.
@@ -1572,6 +1949,7 @@ printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library"
printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
printf 'BC_ENABLE_NLS=%s\n\n' "$nls"
printf 'BC_ENABLE_AFL=%s\n' "$fuzz"
printf '\n'
printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len"
printf '\n'
@@ -1668,11 +2046,26 @@ contents=$(replace "$contents" "BUILDDIR" "$builddir")
contents=$(replace "$contents" "HEADERS" "$headers")
contents=$(replace "$contents" "VERSION" "$version")
contents=$(replace "$contents" "BC_ENABLED" "$bc")
contents=$(replace "$contents" "DC_ENABLED" "$dc")
contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
contents=$(replace "$contents" "BC_ALL_TESTS_NP" "$bc_test_np")
contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
contents=$(replace "$contents" "BC_ERROR_TESTS" "$bc_err_tests")
contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
contents=$(replace "$contents" "DC_ALL_TESTS_NP" "$dc_test_np")
contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
contents=$(replace "$contents" "DC_ERROR_TESTS" "$dc_err_tests")
contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
contents=$(replace "$contents" "BCL_TEST_EXEC" "$bcl_test_exec")
contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args")
contents=$(replace "$contents" "EXCLUDE_EXTRA_MATH" "$exclude_extra_math")
@@ -1680,6 +2073,10 @@ contents=$(replace "$contents" "LIBRARY" "$library")
contents=$(replace "$contents" "HISTORY" "$hist")
contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
contents=$(replace "$contents" "NLS" "$nls")
contents=$(replace "$contents" "FUZZ" "$fuzz")
contents=$(replace "$contents" "OSSFUZZ" "$ossfuzz")
contents=$(replace "$contents" "MEMCHECK" "$memcheck")
contents=$(replace "$contents" "LIB_FUZZING_ENGINE" "$LIB_FUZZING_ENGINE")
contents=$(replace "$contents" "BC_LIB_O" "$bc_lib")
contents=$(replace "$contents" "BC_HELP_O" "$bc_help")
@@ -1702,6 +2099,8 @@ contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS")
contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS")
contents=$(replace "$contents" "CC" "$CC")
contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs")
contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
@@ -1727,14 +2126,22 @@ contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd")
contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq")
contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd")
contents=$(replace "$contents" "GENERATE_TESTS" "$generate_tests")
contents=$(replace "$contents" "PROBLEMATIC_TESTS" "$problematic_tests")
contents=$(replace "$contents" "EXECUTABLES" "$executables")
contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
contents=$(replace "$contents" "EXEC" "$executable")
contents=$(replace "$contents" "TESTS" "$tests")
contents=$(replace "$contents" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs")
contents=$(replace "$contents" "DC_HISTORY_TEST_PREREQS" "$test_dc_history_prereqs")
contents=$(replace "$contents" "HISTORY_TESTS" "$history_tests")
contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test")
contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test")
contents=$(replace "$contents" "TIMECONST" "$timeconst")
contents=$(replace "$contents" "KARATSUBA" "$karatsuba")
contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test")
contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE")
@@ -1762,6 +2169,28 @@ contents=$(replace "$contents" "DC_DEFAULT_DIGIT_CLAMP" "$dc_default_digit_clamp
# Do the first print to the Makefile.
printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "Makefile"
# Generate the individual test targets.
if [ "$bc" -ne 0 ]; then
gen_std_tests bc "$extra_math" "$time_tests" $bc_test_exec
gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec
gen_err_tests bc $bc_test_exec
fi
if [ "$dc" -ne 0 ]; then
gen_std_tests dc "$extra_math" "$time_tests" $dc_test_exec
gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec
gen_err_tests dc $dc_test_exec
fi
if [ "$ossfuzz" -ne 0 ]; then
printf 'bc_fuzzer_c: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_c\n' >> Makefile
printf 'bc_fuzzer_C: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_C\n' >> Makefile
printf 'dc_fuzzer_c: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_c\n' >> Makefile
printf 'dc_fuzzer_C: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_C\n' >> Makefile
fi
# Copy the correct manuals to the expected places.
mkdir -p manuals
cp -f "$scriptdir/manuals/bc/$manpage_args.1.md" manuals/bc.1.md
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -37,7 +37,7 @@ usage: %s [options] [file...]
bc is a command-line, arbitrary-precision calculator with a Turing-complete
language. For details, use `man %s` or see the online documentation at
https://github.com/gavinhoward/bc/tree/%s/manuals/bc/%s.1.md .
https://git.gavinhoward.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
This bc is compatible with both the GNU bc and the POSIX bc spec. See the GNU bc
manual (https://www.gnu.org/software/bc/manual/bc.html) and bc spec
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -37,7 +37,7 @@ usage: %s [options] [file...]
dc is a reverse-polish notation command-line calculator which supports unlimited
precision arithmetic. For details, use `man %s` or see the online documentation
at https://github.com/gavinhoward/bc/tree/%s/manuals/dc/%s.1.md .
at https://git.gavinhoward.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
This dc is (mostly) compatible with the OpenBSD dc and the GNU dc. See the
OpenBSD man page (http://man.openbsd.org/OpenBSD-current/man1/dc.1) and the GNU
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+87 -62
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -444,77 +444,108 @@ define void uint64(x){uintn(x,8)}
define void int64(x){intn(x,8)}
define void uint(x){uintn(x,ubytes(x))}
define void int(x){intn(x,sbytes(x))}
define bunrev(t){
auto a,s,m[]
s=scale
scale=0
t=abs(t)$
while(t!=1){
t=divmod(t,2,m[])
a*=2
a+=m[0]
}
scale=s
return a
}
define band(a,b){
auto r,p,s,m[]
auto s,t,m[],n[]
a=abs(a)$
b=abs(b)$
r=0
p=1
s=scale
scale=0
while(a&&b) {
a=divmod(a,2,m[])
if(m[0]){
b=divmod(b,2,m[])
if(m[0])r+=p
}else b/=2
p*=2
if(b>a){
t=b
b=a
a=t
}
scale=s
return r
}
define bor(a,b){
auto r,p,s,m[]
a=abs(a)$
b=abs(b)$
r=0
p=1
s=scale
scale=0
while(a||b){
a=divmod(a,2,m[])
if(!m[0])b=divmod(b,2,m[])
else b/=2
if(m[0])r+=p
p*=2
}
scale=s
return r
}
define bxor(a,b){
auto r,p,s,m[],n[]
a=abs(a)$
b=abs(b)$
r=0
p=1
s=scale
scale=0
while(a||b){
t=1
while(b){
a=divmod(a,2,m[])
b=divmod(b,2,n[])
if(m[0]+n[0]==1)r+=p
p*=2
t*=2
t+=(m[0]&&n[0])
}
scale=s
return r
return bunrev(t)
}
define bor(a,b){
auto s,t,m[],n[]
a=abs(a)$
b=abs(b)$
if(b>a){
t=b
b=a
a=t
}
s=scale
scale=0
t=1
while(b){
a=divmod(a,2,m[])
b=divmod(b,2,n[])
t*=2
t+=(m[0]||n[0])
}
while(a){
a=divmod(a,2,m[])
t*=2
t+=m[0]
}
scale=s
return bunrev(t)
}
define bxor(a,b){
auto s,t,m[],n[]
a=abs(a)$
b=abs(b)$
if(b>a){
t=b
b=a
a=t
}
s=scale
scale=0
t=1
while(b){
a=divmod(a,2,m[])
b=divmod(b,2,n[])
t*=2
t+=(m[0]+n[0]==1)
}
while(a){
a=divmod(a,2,m[])
t*=2
t+=m[0]
}
scale=s
return bunrev(t)
}
define bshl(a,b){return abs(a)$*2^abs(b)$}
define bshr(a,b){return(abs(a)$/2^abs(b)$)$}
define bnotn(x,n){
auto r,p,s,t,m[]
auto s,t,m[]
s=scale
scale=0
r=2^(abs(n)$*8)
x=abs(x)$%r+r
r=0
p=1
t=2^(abs(n)$*8)
x=abs(x)$%t+t
t=1
while(x!=1){
x=divmod(x,2,m[])
if(!m[0])r+=p
p*=2
t*=2
t+=!m[0]
}
scale=s
return r
return bunrev(t)
}
define bnot8(x){return bnotn(x,1)}
define bnot16(x){return bnotn(x,2)}
@@ -522,19 +553,13 @@ define bnot32(x){return bnotn(x,4)}
define bnot64(x){return bnotn(x,8)}
define bnot(x){return bnotn(x,ubytes(x))}
define brevn(x,n){
auto a,s,m[]
auto s,t,m[]
s=scale
scale=0
a=2^(abs(n)$*8)
x=abs(x)$%a+a
a=0
while(x!=1){
x=divmod(x,2,m[])
a*=2
a+=m[0]
}
t=2^(abs(n)$*8)
x=abs(x)$%t+t
scale=s
return a
return bunrev(x)
}
define brev8(x){return brevn(x,1)}
define brev16(x){return brevn(x,2)}
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -68,7 +68,7 @@ static const char* const bc_gen_ex_end = "{{ end }}";
// This is exactly what it looks like. It just slaps a simple license header on
// the generated C source file.
static const char* const bc_gen_header =
"// Copyright (c) 2018-2025 Gavin D. Howard and contributors.\n"
"// Copyright (c) 2018-2024 Gavin D. Howard and contributors.\n"
"// Licensed under the 2-clause BSD license.\n"
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n";
// clang-format on
+2 -2
View File
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -96,7 +96,7 @@ if [ -n "$remove_tabs" ]; then
fi
cat<<EOF
// Copyright (c) 2018-2025 Gavin D. Howard and contributors.
// Copyright (c) 2018-2024 Gavin D. Howard and contributors.
// Licensed under the 2-clause BSD license.
// *** AUTOMATICALLY GENERATED FROM ${input}. DO NOT MODIFY. ***
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+4 -4
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -265,9 +265,9 @@ bc_lex_token(BcLex* l);
* @return An expression entry for bc_parse_exprs[].
*/
#define BC_PARSE_EXPR_ENTRY(e1, e2, e3, e4, e5, e6, e7, e8) \
((UINT8_C(e1) << 7) | (UINT8_C(e2) << 6) | (UINT8_C(e3) << 5) | \
(UINT8_C(e4) << 4) | (UINT8_C(e5) << 3) | (UINT8_C(e6) << 2) | \
(UINT8_C(e7) << 1) | (UINT8_C(e8) << 0))
((UINTMAX_C(e1) << 7) | (UINTMAX_C(e2) << 6) | (UINTMAX_C(e3) << 5) | \
(UINTMAX_C(e4) << 4) | (UINTMAX_C(e5) << 3) | (UINTMAX_C(e6) << 2) | \
(UINTMAX_C(e7) << 1) | (UINTMAX_C(e8) << 0))
/**
* Returns true if token @a i is a token that belongs in an expression.
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+25 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -120,6 +120,30 @@ typedef struct BcHistory
extern const char bc_history_editrc[];
extern const size_t bc_history_editrc_len;
#ifdef __APPLE__
/**
* Returns true if the line is a valid line, false otherwise.
* @param line The line.
* @param len The length of the line.
* @return True if the line is valid, false otherwise.
*/
#define BC_HISTORY_INVALID_LINE(line, len) \
((line) == NULL && ((len) == -1 || errno == EINTR))
#else // __APPLE__
/**
* Returns true if the line is a valid line, false otherwise.
* @param line The line.
* @param len The length of the line.
* @return True if the line is valid, false otherwise.
*/
#define BC_HISTORY_INVALID_LINE(line, len) \
((line) == NULL && (len) == -1 && errno == EINTR)
#endif // __APPLE__
#else // BC_ENABLE_EDITLINE
#if BC_ENABLE_READLINE
+1 -5
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -533,10 +533,6 @@ typedef enum BcType
} BcType;
#if BC_ENABLED
/// Check if type array or array reference
#define BC_IS_ARRAY(e) (e == BC_TYPE_ARRAY || e == BC_TYPE_REF)
/// An auto variable in bc.
typedef struct BcAuto
{
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+4 -12
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -145,9 +145,6 @@ typedef struct BcProgram
#endif // BC_ENABLED
/// The number of results that have not been retired.
size_t nresults;
// The BcDig array for strmb. This uses BC_NUM_LONG_LOG10 because it is used
// in bc_num_ulong2num(), which attempts to realloc, unless it is big
// enough. This is big enough.
@@ -210,16 +207,11 @@ typedef struct BcProgram
* operands while preserving the result (which we assumed was pushed before the
* actual operation).
* @param p The program.
* @param nres The number of results returned by the instruction.
* @param nops The number of operands used by the instruction.
*/
#define bc_program_retire(p, nops) \
do \
{ \
bc_vec_npopAt(&(p)->results, (nops), \
(p)->results.len - ((p)->nresults + nops)); \
p->nresults = 0; \
} \
while (0)
#define bc_program_retire(p, nres, nops) \
(bc_vec_npopAt(&(p)->results, (nops), (p)->results.len - (nres + nops)))
#if DC_ENABLED
+1 -1
View File
@@ -13,7 +13,7 @@
* This code is under the following license:
*
* Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+6 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -683,7 +683,12 @@ typedef enum BcMode
#define BC_NO_SIG_EXC(vm) \
BC_LIKELY((vm)->status == (sig_atomic_t) BC_STATUS_SUCCESS && !(vm)->sig)
#ifndef _WIN32
#define BC_SIG_INTERRUPT(vm) \
BC_UNLIKELY((vm)->sig != 0 && (vm)->sig != SIGWINCH)
#else // _WIN32
#define BC_SIG_INTERRUPT(vm) BC_UNLIKELY((vm)->sig != 0)
#endif // _WIN32
#if BC_DEBUG
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+42
View File
@@ -0,0 +1,42 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The version of bc.
*
*/
#ifndef BC_VERSION_H
#define BC_VERSION_H
/// The current version.
#define VERSION 7.0.2
#endif // BC_VERSION_H
+2 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -52,6 +52,7 @@
#endif // BC_ENABLE_NLS
#include <version.h>
#include <status.h>
#include <num.h>
#include <lex.h>
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+13 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,6 +2109,17 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2932,7 +2943,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+12 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,6 +1766,16 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2511,7 +2521,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1758,7 +1758,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1509,7 +1509,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1731,7 +1731,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1483,7 +1483,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1725,7 +1725,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1475,7 +1475,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1752,7 +1752,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1501,7 +1501,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+13 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,6 +2109,17 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2905,7 +2916,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+12 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,6 +1766,16 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2485,7 +2495,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+13 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,6 +2109,17 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2899,7 +2910,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+12 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,6 +1766,16 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2477,7 +2487,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
# AUTHORS
+13 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,6 +2109,17 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2926,7 +2937,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://github.com/gavinhoward/bc .
Report bugs at https://git.gavinhoward.com/gavin/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
Loaded 100 of 2832 files, more files were not shown because too many files have changed in this diff. Show more