Commit graph

219 commits

Author SHA1 Message Date
Andrei Alexeyev
2b21ee0e3f
util/assert: remove __builtin_unreachable() after assert trap 2024-09-22 21:18:31 +02:00
Andrei Alexeyev
d84a94d2f8
util/stringops: add strfmt_arena() 2024-09-10 14:32:22 +02:00
Andrei Alexeyev
56f0fde7c6
util/compat: fix windows UNICODE defines 2024-09-10 14:31:55 +02:00
Andrei Alexeyev
fda8556a39
src: deprecate strdup(), use mem_strdup() explicitly
This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.

Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
2024-09-10 14:31:55 +02:00
Andrei Alexeyev
c73aa60b0d
util/stringops: constify hexdigest() 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
7e5a7fa513
util/strbuf: make UBSan happy 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
fa2c13d116
util/compat: workaround for clangd in gcc-based build dirs 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
b7025a4d4c
util/stringops: strappend: make src param const 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
551c82b4f0
util: add portable sort_r() 2024-06-16 22:33:38 +02:00
Andrei Alexeyev
a8322f5e1d
util/rectpack: refactor to use standard mempools 2024-06-05 23:53:30 +02:00
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
0fc68b5778
util/consideredharmful: work around some false positives in clang 18 2024-05-16 22:24:43 +02:00
Andrei Alexeyev
c8b017f974
geometry: add paranoid check to lineseg_ellipse_intersect 2024-05-08 16:14:28 +02:00
Andrei Alexeyev
b8bdaf1cca
util/miscmath: force inline cdot[f] and cabs2[f]
These massively affect the performance of quantize_laser()
Shouldn't matter in LTO builds, but helps for quick debug/dev builds
2024-04-04 04:45:33 +02:00
Andrei Alexeyev
b9df3cb2d7
util/miscmath: add cswapf() 2024-03-21 23:33:57 +01:00
Andrei Alexeyev
d6e2e1ae80
rectpack: allow optional rotation 2024-03-21 23:33:57 +01:00
Andrei Alexeyev
9d6e45f51d
rectpack: tune split and fitness heuristics 2024-03-21 23:33:57 +01:00
Andrei Alexeyev
968edfb4fe
util/rectpack: fix wrong subsplit direction in split_vertical
Doesn't seem to ever actually matter in practice, but theoretically it
was wrong.
2023-10-20 16:15:06 +02:00
Andrei Alexeyev
ee09f33a5f
util/miscmath: deprecate iclamp and clampf 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
68f3678575
util/miscmath: implement clamp() as a type-generic macro 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
4e6929d605
util/miscmath: change assume to assert in ASSUME_FINITE for now
On some toolchains isfinite compiles to a function call and trips a
-Wassume warning
2023-09-28 17:43:14 +02:00
Andrei Alexeyev
8f8ca2beca
all: use min/max macros; avoid some unnecessary conversions 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
a45c6498d2
util/miscmath: deprecate various min/max functions 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
b02d831e41
util/geometry: small ellipse collision optimizations 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
4f6384b257
util/miscmath: add component-wise complex div functions 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
806427e8e0
util/miscmath: add cmplx mul & div functions that don't care about infs and nans 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
c2810e228d
all: use re()/im() macros 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
95053f7fe8
util/miscmath: annotate unlikely branches in approach_asymptotic funcs 2023-09-20 04:01:14 +02:00
Andrei Alexeyev
4547f6dc09
util/miscmath: deprecate creal/cimag/crealf/cimagf 2023-09-20 03:58:55 +02:00
Andrei Alexeyev
8b987dcc37
util/miscmath: add csort(z) and csortf(z) functions 2023-09-20 03:43:30 +02:00
Andrei Alexeyev
6e80df6e22
util/miscmath: mark smoothmin as attr_const 2023-09-20 03:42:21 +02:00
Andrei Alexeyev
13ae7a2f72
util/miscmath: remove some unused functions 2023-09-19 14:24:48 +02:00
Andrei Alexeyev
2795419256
util/miscmath: add type-generic min() and max() macros 2023-09-19 13:56:36 +02:00
Andrei Alexeyev
83373d139d
util/miscmath: add re(z) and im(z) macros
Shorter and type-generic replacements for creal() and cimag(). If z is
an l-value, the returned value is also an l-value, e.g.:

	cmplx foo = 420 + 69i;
	im(foo) = 1337;
	assert(foo == 420 + 1337i);
2023-09-19 13:51:10 +02:00
Andrei Alexeyev
83708429af
util/geometry: remove bogus attr_pure from rect_join 2023-05-26 02:27:14 +02:00
Andrei Alexeyev
84e44fba12
util/geometry: remove bogus attr_pure from rect_rect_intersection
Causes gcc to miscompile calls to this function, assuming it doesn't
actually write to *out. Breaks ReimuB.
2023-05-26 02:25:00 +02:00
Andrei Alexeyev
f21d997fc6
util: add SWAP(a,b) macro
Equivalent to:
	auto t = a;
	a = b;
	b = t;
2023-04-28 22:14:38 +02:00
Nhalrath
2d47ab0fe7
util/stringops: use strncmp for strendswith (#362)
Minor change, doesn't really fix anything.

Similar to strstartswith, it may be better to use strncmp instead of
looping through every char in a string.
2023-04-18 12:06:42 +03:00
Andrei Alexeyev
3dc0faec9e
renderer/api: rename ClearBufferFlags to BufferKindFlags 2023-04-10 06:47:55 +02:00
Andrei Alexeyev
886ba290a9
util/callchain: split from eventloop 2023-04-07 16:08:49 +02:00
Andrei Alexeyev
8b9602c402
util/rectpack: pool sections, support custom allocators 2023-04-03 01:53:36 +02:00
Andrei Alexeyev
f5c5803b1a
util/strbuf: inline strbuf_cat 2023-03-30 03:38:07 +02:00
Andrei Alexeyev
a4717b996c
util/strbuf: make cat and ncat return number of chars written 2023-03-30 02:21:04 +02:00
Andrei Alexeyev
e957f11790
thread: add over-engineered wrapper for thread management 2023-03-29 20:47:27 +02:00
Andrei Alexeyev
beae2e0302
util/assert: fix static_assert 2023-03-26 14:06:05 +02:00
Andrei Alexeyev
15bdbc496b
util/compat: include assert(0) in UNREACHABLE macro
Stop overriding it in log.h
2023-03-26 03:14:07 +02:00
Andrei Alexeyev
6c30decd8e
util/miscmath: don't check for __GNUC__ 2023-03-26 03:12:01 +02:00
Andrei Alexeyev
277e003510
util/assert: don't check for __GNUC__ 2023-03-26 03:10:16 +02:00
Andrei Alexeyev
9363c6b883
util/compat: don't check for __GNUC__ 2023-03-26 03:08:33 +02:00