Skip to content

Commit 783cfa8

Browse files
committed
Add: Overflow-risk error codes
1 parent a0fd136 commit 783cfa8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

include/stringzilla/types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,10 @@ typedef enum sz_status_t {
443443
sz_invalid_utf8_k = -2,
444444
/** For algorithms that take collections of unique elements, this status indicates presence of duplicates. */
445445
sz_contains_duplicates_k = -3,
446+
/** For algorithms dealing with large inputs, this error reports the need to upcast the logic to larger types. */
447+
sz_overflow_risk_k = -4,
446448
/** A sink-hole status for unknown errors. */
447-
sz_status_unknown_k = -4,
449+
sz_status_unknown_k = -5,
448450
} sz_status_t;
449451

450452
/**

include/stringzilla/types.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ enum class status_t {
119119
bad_alloc_k = sz_bad_alloc_k,
120120
invalid_utf8_k = sz_invalid_utf8_k,
121121
contains_duplicates_k = sz_contains_duplicates_k,
122+
overflow_risk_k = sz_overflow_risk_k,
122123
unknown_k = sz_status_unknown_k,
123124
};
124125

@@ -794,6 +795,8 @@ struct cpu_specs_t {
794795
size_t cache_line_width = 64; // ? 64 bytes on x86, sometimes 128 on ARM
795796
size_t cores_per_socket = 1; // ? at least 1 core
796797
size_t sockets = 1; // ? at least 1 socket
798+
799+
size_t cores_total() const noexcept { return cores_per_socket * sockets; }
797800
};
798801

799802
/**

0 commit comments

Comments
 (0)