Lines Matching +full:divide +full:- +full:10
2 * Copyright (c) 2011-2014, Wind River Systems, Inc.
4 * SPDX-License-Identifier: Apache-2.0
40 * @defgroup sys-util Utility Functions
80 (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
83 * @brief Create a contiguous 64-bit bitmask starting at bit position @p l
87 (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
89 /** @brief 0 if @p cond is true-ish; causes a compile error otherwise. */
90 #define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1)
94 /* The built-in function used below for type checking in C is not
152 * in that it also ensures that @p ptr is aligned to an array-element boundary
165 (POINTER_TO_UINT(ptr) - POINTER_TO_UINT(array)) % sizeof((array)[0]) == 0)
172 * is not aligned to an array-element boundary of @p array.
184 (__typeof__((array)[0]) *)(ptr) - (array); \
202 * @brief Array-index of @p ptr within @p array, rounded down
206 * exclusively a @p ptr aligned to an array-element boundary of @p array.
221 (POINTER_TO_UINT(ptr) - POINTER_TO_UINT(array)) / sizeof((array)[0]); \
239 for (__typeof__(*(array)) *ptr = (array); (size_t)((ptr) - (array)) < ARRAY_SIZE(array); \
256 BUILD_ASSERT(SAME_TYPE(*(ptr), ((type *)0)->field) || \
287 ((type *)(((char *)(ptr)) - offsetof(type, field))); \
298 #define SIZEOF_FIELD(type, member) sizeof((((type *)0)->member))
323 ((((unsigned long)(x) + ((unsigned long)(align) - 1)) / \
339 * @brief Divide and round up.
352 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
355 * @brief Divide and round to the nearest integer.
360 * DIV_ROUND_CLOSEST(5, -2); // -3
370 (((((__typeof__(n))-1) < 0) && (((__typeof__(d))-1) < 0) && ((n) < 0) ^ ((d) < 0)) \
371 ? ((n) - ((d) / 2)) / (d) \
378 * @note Arguments are evaluated twice. Use Z_MAX for a GCC-only, single
393 * @note Arguments are evaluated twice. Use Z_MIN for a GCC-only, single
408 * @note Arguments are evaluated multiple times. Use Z_CLAMP for a GCC-only,
448 * multiple use-cases, but NULL checks can generate warnings if such a macro
454 * b) tracking of macro expansions are turned off (-ftrack-macro-expansion=0)
487 sign_ext = -sign_ext; in arithmetic_shift_right()
490 return (value >> shift) | (sign_ext << (64 - shift)); in arithmetic_shift_right()
527 for (; size > 0; --size) { in byteswp()
587 return ((10 * (bcd >> 4)) + (bcd & 0x0F)); in bcd2bin()
599 return (((bin / 10) << 4) | (bin % 10)); in bin2bcd()
627 uint8_t shift = 31 - index; in sign_extend()
642 uint8_t shift = 63 - index; in sign_extend_64()
648 * @brief Properly truncate a NULL-terminated UTF-8 string
650 * Take a NULL-terminated UTF-8 string and ensure that if the string has been
652 * the string ends with a properly formatted UTF-8 character (1-4 bytes).
661 * trunc_utf8[sizeof(trunc_utf8) - 1] = '\0';
667 * @param utf8_str NULL-terminated string
674 * @brief Copies a UTF-8 encoded string from @p src to @p dst
677 * and the @p dst string will always be properly UTF-8 truncated.
679 * @param dst The destination of the UTF-8 string.
682 * is @p n - 1. If 0 nothing will be done, and the @p dst will not be
689 #define __z_log2d(x) (32 - __builtin_clz(x) - 1)
690 #define __z_log2q(x) (64 - __builtin_clzll(x) - 1)
701 * @return log2(x) when 1 <= x <= max(x), -1 when x < 1
703 #define LOG2(x) ((x) < 1 ? -1 : __z_log2(x))
715 #define LOG2CEIL(x) ((x) <= 1 ? 0 : __z_log2((x)-1) + 1)
727 * @return 2^ceil(log2(x)) or 0 if 2^ceil(log2(x)) would saturate 64-bits
745 ((UINTPTR_MAX - (uintptr_t)(addr)) <= ((uintptr_t)((buflen) - 1))))
757 while (len--) { in mem_xor_n()
800 #define KB(x) ((x) << 10)
802 #define KB(x) (((size_t)(x)) << 10)
805 #define MB(x) (KB(x) << 10)
807 #define GB(x) (MB(x) << 10)
816 * For other architectures this is a no-op.
851 while (!(expr) && (_wf_cycle_count > (k_cycle_get_32() - _wf_start))) { \
853 Z_SPIN_DELAY(10); \