PebbleOS
Loading...
Searching...
No Matches
Modules
Utilities

Generic helpers shared by the firmware, the bootloader and host tools (lib/util). More...

Modules

 Library assertions
 Assertions of the utility library.
 
 Base64
 Base64 encoding.
 
 Bit operations
 Bit sets stored in byte or word arrays, rotation and bit reversal.
 
 Bits and bit fields
 Bit, mask and register field macros.
 
 Linear buffer
 Append-only byte buffer with its storage after the header.
 
 Build ID
 GNU build ID note inserted by the linker.
 
 Byte order
 Conversions between the CPU byte order (always little-endian) and fixed byte orders.
 
 Circular buffer
 Single-reader, single-writer byte ring buffer.
 
 Circular cache
 Fixed-size, array-backed cache that evicts its oldest item.
 
 Generic attributes
 Packed lists of id/length/value attributes, as exchanged with the phone.
 
 Hashing
 Non-cryptographic hash.
 
 Heap
 First-fit heap allocator over a caller-provided memory region.
 
 Hex dump
 xxd-style hex dumps through a line callback.
 
 Iterator
 Generic bidirectional iterator over caller-defined state.
 
 Keyed circular cache
 Fixed-size cache of items looked up by integer key, evicting the oldest item.
 
 Linked list
 Intrusive doubly linked list.
 
 Listify
 Preprocessor repetition.
 
 Library logging
 Logging hooks of the utility library.
 
 Integer math
 Integer math macros and helpers.
 
 Fixed-point math
 Signed fixed-point types and a generic recursive filter.
 
 Miscellaneous
 Small generic macros.
 
 Ordering
 Comparator type used by the sorted containers.
 
 Pascal strings
 Length-prefixed strings and lists of them.
 
 Random numbers
 Random number source used by the library.
 
 Ratios
 Real numbers in [0, 1] stored as scaled integers.
 
 Shared circular buffer
 Circular buffer with one writer and several independent readers.
 
 Sizes
 Array and member size helpers.
 
 Singly linked list
 Intrusive singly linked list.
 
 Sorting
 In-place sorting of small arrays.
 
 Statistics
 Basic statistics over arrays of int32_t.
 
 Strings
 String helpers.
 
 String lists
 Serialized arrays of NUL-separated strings.
 
 Structure access
 Structure access helpers.
 
 Unit test hooks
 Linkage helpers that let unit tests override firmware functions.
 
 Calendar time
 Calendar arithmetic independent of the time zone and the RTC.
 
 Trigonometry
 Fixed-point trigonometry helpers.
 
 Units
 Size, distance and time unit conversion factors.
 
 UTF-8
 UTF-8 decoder (Bjoern Hoehrmann's DFA).
 
 UUID
 128-bit universally unique identifiers.
 

Detailed Description

Generic helpers shared by the firmware, the bootloader and host tools (lib/util).

The library does not depend on the kernel. Logging and assertions go through util_log() and util_assertion_failed(), weak functions the firmware overrides.

static const uint16_t s_rates[] = {10, 25, 50, 100};
for (size_t i = 0; i < ARRAY_LENGTH(s_rates); i++) {
max_rate = MAX(max_rate, s_rates[i]);
}
level = CLIP(level, 0, 100);
struct item *item = container_of(node, struct item, list_node);
#define CLIP(n, min, max)
Clamp a value to a range.
Definition math.h:62
#define MAX(a, b)
Get the larger of two values.
Definition math.h:46
#define container_of(ptr, type, member)
Get the structure that contains a member.
Definition misc.h:44
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18