All work
Practice evidence2026 — in progress

C systems practice

Defensive C17 systems programming toolkit

Adarsh’s personal C17 systems programming practice: eight bit and field operations, selected code excerpts, and 61 recorded boundary and failure-path checks. Not employer work.

Contract path

Designed for failure paths too

  1. 01Contract
  2. 02Input validation
  3. 03Defined bit operation
  4. 04Unchanged-on-failure output
  5. 05Test matrix
6Bit and field helpers
2Population-count methods
61Recorded checks
0Strict-warning diagnostics

API behavior

What the toolkit proves

  • Implemented set, clear, toggle, test, extract, and insert helpers with explicit bounds and null-output handling.
  • Implemented fixed-iteration and Kernighan population counts for comparison.
  • Kept output values unchanged when validation fails and verified boundary behavior around bit 31 and full-width fields.
  • Compiled under C17 with strict warnings and ran 61 recorded checks.

Reasoning model

Defined operations first

  1. 1

    Use exact-width unsigned types and fixed-width integer constants to avoid signed-shift and width surprises.

  2. 2

    Validate the full field range before building a mask, including the special 32-bit-width case.

  3. 3

    Test success, rejection, boundary, and state-preservation behavior—not only expected arithmetic results.

Selected source

Boundary-safe operations

Personal C17 practice
bits32.cBounded field insertion
bool bits32_insert_field(uint32_t value,
                         uint32_t lsb,
                         uint32_t width,
                         uint32_t field,
                         uint32_t *result)
{
    uint32_t mask;
    uint32_t destination_mask;

    if (width < UINT32_C(1) || width > UINT32_C(32) ||
        lsb >= UINT32_C(32) || width > (UINT32_C(32) - lsb) ||
        result == NULL) {
        return false;
    }

    mask = (width == UINT32_C(32))
               ? UINT32_MAX
               : (UINT32_C(1) << width) - UINT32_C(1);
    if (field > mask) return false;

    destination_mask = mask << lsb;
    *result = (value & ~destination_mask) | (field << lsb);
    return true;
}
bits32.cTwo population counts
uint32_t bits32_popcount_fixed(uint32_t value)
{
    uint32_t count = UINT32_C(0);
    for (uint32_t i = UINT32_C(0); i < UINT32_C(32); ++i) {
        count += value & UINT32_C(1);
        value >>= 1;
    }
    return count;
}

uint32_t bits32_popcount_kernighan(uint32_t value)
{
    uint32_t count = UINT32_C(0);
    while (value != UINT32_C(0)) {
        value &= value - UINT32_C(1);
        ++count;
    }
    return count;
}

Direct answers · public evidence

Contribution, approach and validation

What is Adarsh’s C17 systems programming toolkit?

Personal C17 practice implementing eight operations: set, clear, toggle, test, field extraction, field insertion and two population-count methods. It is separate from professional employer work.

How are invalid inputs handled?

The helpers validate bounds, null outputs and field fit before operating. Full-width masks are handled explicitly, and output values remain unchanged when validation fails.

What evidence supports the toolkit?

The recorded strict-warning C17 build and 61 checks cover success, boundaries, null outputs, invalid ranges, field fit and unchanged-on-failure behavior. These are recorded practice results, not product performance metrics.

What can visitors inspect?

Technical mode exposes selected implementation details, including bounded field insertion and both population counts. The wider learning roadmap is not published.

Read Adarsh’s career and engineering experience or the public embedded-systems résumé for context. Technical mode adds the detailed engineering account above.

Connect practice to professional evidenceFirmware & bring-up