PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
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.
 
 Frequency tracking
 Estimate the frequency of a drifting oscillator from noisy gated measurements.
 
 Generic attributes
 Packed lists of id/length/value attributes, as exchanged with the phone.
 
 Hashing
 Non-cryptographic hash.
 
 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 PebbleOS overrides in lib/c.

static const uint16_t s_rates[] = {10, 25, 50, 100};
for (size_t i = 0; i < PBL_ARRAY_SIZE(s_rates); i++) {
max_rate = PBL_MAX(max_rate, s_rates[i]);
}
level = PBL_CLAMP(level, 0, 100);
struct item *item = PBL_CONTAINER_OF(node, struct item, list_node);
#define PBL_CLAMP(n, min, max)
Clamp a value to a range.
Definition math.h:59
#define PBL_MAX(a, b)
Get the larger of two values.
Definition math.h:44
#define PBL_CONTAINER_OF(ptr, type, member)
Get the structure that contains a member.
Definition misc.h:44
#define PBL_ARRAY_SIZE(array)
Get the number of elements of an array.
Definition size.h:40