Elffuss BraidHub

kikocis/kleidiai public

main · 679 BRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2017, 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6
7#pragma once
8
9// Macro for unreachable code (e.g. impossible default cases on switch)
10#ifndef UNREACHABLE
11#define UNREACHABLE(why) __builtin_unreachable()
12#endif
13
14inline int iceildiv(const int a, const int b) {
15 return (a + b - 1) / b;
16}
17
18// Undefine any existing roundup macro from macOS headers
19#if defined(__APPLE__) && defined(roundup)
20#undef roundup
21#endif
22
23template <typename T>
24inline T roundup(const T a, const T b) {
25 T rem = a % b;
26
27 if (rem) {
28 return a + b - rem;
29 } else {
30 return a;
31 }
32}