Skip to content
Draft
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
b8f699f
Separate linker scripts out into include files
will-v-pi Dec 1, 2025
6dc06e6
Add customisable heap location, with pico_set_linker_script_var function
will-v-pi Dec 1, 2025
727cabd
Add kitchen sink test of custom linker scripts
will-v-pi Dec 1, 2025
3a83dc7
Separate out rp2_common and platform-specific linker script sections
will-v-pi Dec 2, 2025
4b1a3ec
More de-duplication
will-v-pi Dec 2, 2025
ae97a22
Make overriding ram locations simpler
will-v-pi Dec 2, 2025
3811e67
Make it possible to reference default locations in pico_set_linker_sc…
will-v-pi Dec 4, 2025
a20f86a
Add pico_add_linker_script_override_path to make overriding individua…
will-v-pi Feb 11, 2026
6bd9e5b
Add simple overlay demo
will-v-pi Feb 26, 2026
2bf8555
Add scripts to bazel build
will-v-pi Feb 27, 2026
fe2d56b
Move linker scripts out of crt0
will-v-pi Mar 6, 2026
1bd7089
Make rp2350 text sections the default
will-v-pi Mar 6, 2026
72adb67
Rename scripts include directories to standard_scripts and platform_s…
will-v-pi Mar 6, 2026
e47fe09
Move and add example to Bazel docs for changing linker scripts
will-v-pi Mar 6, 2026
9c0ed0c
Add cc_library load to new bazel files
will-v-pi Mar 6, 2026
e44bdea
Add excludes.ld files for default memmap
will-v-pi Mar 16, 2026
dc3a2e8
Put mem functions in SRAM
will-v-pi Mar 16, 2026
afbc07e
transplant sleep2 onto develop
kilograham Aug 27, 2024
dffd4a5
Add sleep3 notes from meeting
liamfraser Dec 12, 2024
c81b09f
Make it compile and work with RP2040 and RP2350
will-v-pi Aug 20, 2025
1807c25
Implement pstate functions
will-v-pi Aug 21, 2025
bcd2797
Fix pin_state functions on RP2350
will-v-pi Aug 21, 2025
b62de58
Fix hello_sleep_gpio on RP2040
will-v-pi Aug 22, 2025
abc6255
Add support for RP2040 dormant (using external RTC clock)
will-v-pi Aug 22, 2025
ed3716e
Pass low power state through powman reboot, so software knows what wa…
will-v-pi Aug 22, 2025
5a2677c
Implement exclusive variable when sleeping
will-v-pi Aug 22, 2025
c3a3b7c
Demonstrate non-exclusive sleep
will-v-pi Aug 22, 2025
a1eb46f
Add skips of data_copy in arm crt0
will-v-pi Sep 1, 2025
26b0a66
Add Risc-V crt0 data_cpy skip
will-v-pi Sep 1, 2025
fa1199e
Tidy up non-RP2040 defines
will-v-pi Sep 1, 2025
1c65750
Redo memory handling
will-v-pi Sep 4, 2025
e2232d8
Add runtime init function to unpin xip cache that isn't persistent data
will-v-pi Sep 4, 2025
edb8838
Accept NULL pstate as default
will-v-pi Sep 4, 2025
0e27c5b
Make persistent_data NOLOAD
will-v-pi Sep 4, 2025
7bf2452
Persistent data now zeroed on non-persisted boot
will-v-pi Sep 5, 2025
95eacfe
Add USB support and chars_available callback
will-v-pi Sep 5, 2025
7e23f0b
Implement low_power_sleep_until_irq
will-v-pi Sep 5, 2025
0559a34
Fix infinite loop with no persistent data
will-v-pi Sep 5, 2025
e65135f
Add encrypted sleep test
will-v-pi Sep 5, 2025
7aa06f4
Update xip pinning load map
will-v-pi Sep 9, 2025
49d03aa
Add support for sleep, dormant, and powman with tinyusb device and host
will-v-pi Sep 9, 2025
10aa674
Use better runtime_init_rp2350_sleep_fix
will-v-pi Sep 10, 2025
1806da6
Fix powman doc
will-v-pi Sep 12, 2025
9cc19ed
Add bazel build, and some CMake function docs
will-v-pi Sep 15, 2025
c65b596
Fix config check
will-v-pi Sep 15, 2025
7293ceb
Fix hardware_rosc bazel build
will-v-pi Sep 15, 2025
575617e
Fix some kitchen sink errors
will-v-pi Sep 15, 2025
7ce8c6a
fixups
will-v-pi Sep 15, 2025
6509d94
Separate linker scripts out into include files
will-v-pi Dec 1, 2025
9c1b67f
Add customisable heap location, with pico_set_linker_script_var function
will-v-pi Dec 1, 2025
7fa5cbb
Add kitchen sink test of custom linker scripts
will-v-pi Dec 1, 2025
fe63e92
Remove pico_ld_constants and use pico_set_linker_script_var
will-v-pi Dec 1, 2025
81a182b
Separate out rp2_common and platform-specific linker script sections
will-v-pi Dec 2, 2025
fba2c74
More de-duplication
will-v-pi Dec 2, 2025
f33d5a4
Make overriding ram locations simpler
will-v-pi Dec 2, 2025
12c92b1
Make it possible to reference default locations in pico_set_linker_sc…
will-v-pi Dec 4, 2025
1bcfac3
Add pico_add_linker_script_override_path to make overriding individua…
will-v-pi Feb 11, 2026
609e666
Add simple overlay demo
will-v-pi Feb 26, 2026
5343b6e
Add scripts to bazel build
will-v-pi Feb 27, 2026
59fe386
Mark rtc_clksrc as rp2040 only in bazel build
will-v-pi Feb 27, 2026
cacafe6
Add some docs to low power functions
will-v-pi Mar 5, 2026
1deea52
Run clk_sys from ROSC when dormant with DORMANT_CLOCK_SOURCE_LPOSC
will-v-pi Mar 6, 2026
89276fa
Tidy up comments, and add more docs
will-v-pi Mar 6, 2026
5ae8b76
Tidy up some comments
will-v-pi Mar 6, 2026
b521c11
Use gmtime_r instead of localtime_r on Clang
will-v-pi Mar 6, 2026
e464234
Apply documentation suggestions from code review to low_power.h
will-v-pi Mar 10, 2026
e51ca45
Apply suggestions from code review to low_power.c and low_power.h
will-v-pi Mar 10, 2026
fa6064c
Review fixups
will-v-pi Mar 10, 2026
298fd2a
Fix some returns
will-v-pi Mar 10, 2026
77e9e40
Add some doxygen to bitset.h, and tidy up some macros
will-v-pi Mar 10, 2026
d249a90
Rename clock_dest_set_... to clock_dest_bitset_... to avoid confusing…
will-v-pi Mar 10, 2026
b6589e7
Update copyright years
will-v-pi Mar 10, 2026
50a241b
Apply some suggestions from code review
will-v-pi Mar 10, 2026
97705aa
Improve rosc docs, and add RP2350 notes/asserts
will-v-pi Mar 10, 2026
8b9d9ec
Rename standard_scripts and platform_scripts to script_include
will-v-pi Mar 19, 2026
91c3a9a
Move pico_platform_link stuff into pico_plaftorm
will-v-pi Mar 19, 2026
614f7f0
Remove rigidity from linker include paths
will-v-pi Mar 19, 2026
da23cf4
Rename all linker scripts intended to be included to .incl
will-v-pi Mar 19, 2026
780c05e
Separate into section_... files which do only contain one section, an…
will-v-pi Mar 19, 2026
2e7ca67
Add section_extra files to make adding extra sections simpler
will-v-pi Mar 19, 2026
4180427
Fix comments, and add some more extra files
will-v-pi Mar 19, 2026
c122bf7
Add generated override files - currently unused, but can be overridde…
will-v-pi Mar 19, 2026
ea8320b
pico_add_linker_script_override_path can now be called after target_l…
will-v-pi Mar 19, 2026
ad35ad8
Add extra post_platform_end sections
will-v-pi Mar 19, 2026
8e3aca5
review fixups
will-v-pi Mar 19, 2026
e9e9a09
Fix bazel PICO_DEFAULT_LINKER_SCRIPT comment
will-v-pi Mar 20, 2026
519544e
Add PICO_DEFAULT_BINARY_TYPE to Bazel
will-v-pi Mar 20, 2026
3f0615d
Fix PICO_DEFAULT_BINARY_TYPE descriptions
will-v-pi Mar 20, 2026
a26a42b
Add azel pico_set_binary_type transition, to allow setting binary typ…
will-v-pi Mar 25, 2026
df68b1e
Refactor bazel functionality following review
will-v-pi Mar 25, 2026
41fd36e
Add kitchen_sink_ram_section and kitchen_sink_simple_overlay tests to…
will-v-pi Mar 25, 2026
ea9b114
Some tidyups
will-v-pi Mar 25, 2026
7b040da
Merge branch 'include-linker-scripts' into low-power-new
will-v-pi Mar 26, 2026
09e2857
Fixup merge
will-v-pi Mar 26, 2026
b144c1a
Merge branch 'develop' into low-power-new
will-v-pi Mar 26, 2026
df27c7b
Merge remote-tracking branch 'origin/develop' into low-power-new
will-v-pi Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions bazel/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,22 @@ string_flag(
build_setting_default = "Debug",
)

# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_TYPE, The default binary type to use, type=string, default=default, group=build
string_flag(
name = "PICO_DEFAULT_BINARY_TYPE",
build_setting_default = "default",
values = [
"default",
"no_flash",
"copy_to_ram",
"blocked_ram",
],
)

# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_standard_link:default_linker_script, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_LINKER_SCRIPT",
build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script",
build_setting_default = "//src/rp2_common/pico_standard_link:default_linker_script",
)

# PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
Expand Down
15 changes: 15 additions & 0 deletions bazel/constraint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,18 @@ config_setting(
name = "pico_compilation_no_fastbuild_args_set",
flag_values = {"//bazel/config:PICO_COMPILATION_NO_FASTBUILD_ARGS": "True"},
)

config_setting(
name = "pico_binary_type_no_flash",
flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "no_flash"},
)

config_setting(
name = "pico_binary_type_copy_to_ram",
flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "copy_to_ram"},
)

config_setting(
name = "pico_binary_type_blocked_ram",
flag_values = {"//bazel/config:PICO_DEFAULT_BINARY_TYPE": "blocked_ram"},
)
38 changes: 38 additions & 0 deletions bazel/util/pico_linker_scripts.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "use_cpp_toolchain")

def _linker_scripts_impl(ctx):
link_flags = []
for script in ctx.attr.include_scripts:
link_include_dir = script.label.package
if ctx.label.workspace_root:
link_include_dir = "/".join((ctx.label.workspace_root, link_include_dir))
link_flag = "-L" + str(link_include_dir)
if not (link_flag in link_flags):
link_flags.append(link_flag)

for script in ctx.files.link_scripts:
link_flags.append("-T" + str(script.path))

all_scripts = ctx.files.link_scripts + ctx.files.include_scripts

linking_inputs = cc_common.create_linker_input(
owner = ctx.label,
user_link_flags = depset(
direct = link_flags,
),
additional_inputs = depset(direct = all_scripts),
)
return [
DefaultInfo(files = depset(direct = all_scripts)),
CcInfo(linking_context = cc_common.create_linking_context(linker_inputs = depset(direct = [linking_inputs]))),
]

linker_scripts = rule(
implementation = _linker_scripts_impl,
attrs = {
"link_scripts": attr.label_list(allow_files = [".ld"], doc = "List of scripts to explicitly link"),
"include_scripts": attr.label_list(allow_files = [".incl"], doc = "List of scripts to include"),
},
toolchains = use_cpp_toolchain(),
fragments = ["cpp"],
)
30 changes: 30 additions & 0 deletions bazel/util/transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,33 @@ extra_copts_for_all_deps = declare_transtion(
"//command_line_option:copt": "extra_copts",
},
)

# This transition sets the binary type
pico_set_binary_type = declare_transtion(
attrs = {
"binary_type": attr.string(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_DEFAULT_BINARY_TYPE": "binary_type",
},
)

# This transition sets the binary type
pico_set_linker_script = declare_transtion(
attrs = {
"linker_script": attr.string(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT": "linker_script",
},
)
2 changes: 2 additions & 0 deletions src/cmake/rp2_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pico_add_subdirectory(rp2_common/hardware_pio)
pico_add_subdirectory(rp2_common/hardware_pll)
pico_add_subdirectory(rp2_common/hardware_pwm)
pico_add_subdirectory(rp2_common/hardware_resets)
pico_add_subdirectory(rp2_common/hardware_rosc)
if (PICO_RP2040 OR PICO_COMBINED_DOCS)
pico_add_subdirectory(rp2_common/hardware_rtc)
endif()
Expand Down Expand Up @@ -103,6 +104,7 @@ if (NOT PICO_BARE_METAL)
pico_add_subdirectory(rp2_common/pico_int64_ops)
pico_add_subdirectory(rp2_common/pico_flash)
pico_add_subdirectory(rp2_common/pico_float)
pico_add_subdirectory(rp2_common/pico_low_power)
pico_add_subdirectory(rp2_common/pico_mem_ops)
pico_add_subdirectory(rp2_common/pico_malloc)
pico_add_subdirectory(rp2_common/pico_printf)
Expand Down
6 changes: 6 additions & 0 deletions src/common/pico_base_headers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ cc_library(
"//bazel/constraint:rp2040": ["PICO_RP2040=1"],
"//bazel/constraint:rp2350": ["PICO_RP2350=1"],
"//conditions:default": [],
}) + select({
"//bazel/constraint:pico_binary_type_no_flash": ["PICO_NO_FLASH=1"],
"//bazel/constraint:pico_binary_type_copy_to_ram": ["PICO_COPY_TO_RAM=1"],
"//bazel/constraint:pico_binary_type_blocked_ram": ["PICO_USE_BLOCKED_RAM=1"],
"//conditions:default": [],
}),
)

Expand Down Expand Up @@ -113,6 +118,7 @@ cc_library(
"//src/rp2_common/hardware_ticks:__pkg__",
"//src/rp2_common/hardware_timer:__pkg__",
"//src/rp2_common/hardware_watchdog:__pkg__",
"//src/rp2_common/hardware_rosc:__pkg__",
"//src/rp2_common/hardware_xosc:__pkg__",
"//src/rp2_common/pico_crt0:__pkg__",
"//src/rp2_common/pico_platform_common:__pkg__",
Expand Down
1 change: 1 addition & 0 deletions src/common/pico_util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cc_library(
"queue.c",
],
hdrs = [
"include/pico/util/bitset.h",
"include/pico/util/datetime.h",
"include/pico/util/pheap.h",
"include/pico/util/queue.h",
Expand Down
234 changes: 234 additions & 0 deletions src/common/pico_util/include/pico/util/bitset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
/*
* Copyright (c) 2026 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _PICO_UTIL_BITSET_H
#define _PICO_UTIL_BITSET_H

#include "pico.h"

/** \file bitset.h
* \defgroup bitset bitset
* \brief Simple bitset implementation
*
* \ingroup pico_util
*/

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
uint16_t size; \
uint16_t word_size; \
uint32_t words[];
} generic_bitset_t;

/*! \brief Macro used to define a bitset type
* \ingroup pico_util
* This macro is used to define a bitset type. It is used as follows:
* ```
* typedef bitset_type_t(32) my_bitset_t;
* ```
* will define a new bitset type called `my_bitset_t` that can hold 32 bits.
*
* The type can be used as `my_bitset_t bitset;` to declare a new bitset.
*
* \param N the number of bits in the bitset
*/
#define bitset_type_t(N) union { \
generic_bitset_t bitset; \
struct { \
uint16_t size; \
uint16_t word_size; \
uint32_t words[((N) + 31) / 32]; \
} sized_bitset; \
}
#define bitset_sizeof_for(N) ((((N) + 63u) / 32u) * 4u)

/*! \brief Macro used to create a bitset with all bits set to a value
* \ingroup pico_util
* \param type the type of the bitset
* \param N the number of bits in the bitset
* \param value the value to set the bits to (0 or 1)
* \return the bitset
*/
#define bitset_with_value(type, N, value) ({ type bitset; bitset_init(&bitset, type, N, value); bitset; })

// Quick test that the bitset macros give the correct size
extern bitset_type_t(32) __not_real_bitset32;
extern bitset_type_t(33) __not_real_bitset33;
static_assert(sizeof(__not_real_bitset32) == bitset_sizeof_for(1),"");
static_assert(sizeof(__not_real_bitset33) == bitset_sizeof_for(37), "");

/*! \brief Initialize a bitset
* \ingroup pico_util
* \param ptr the bitset to initialize
* \param type the type of the bitset
* \param N the number of bits in the bitset
* \param fill the value to fill the bitset with (0 or 1)
*/
#define bitset_init(ptr, type, N, fill) ({ \
assert(sizeof(type) == bitset_sizeof_for(N)); \
__unused type *type_check = ptr; \
__builtin_memset(ptr, (fill) ? 0xff : 0, sizeof(type)); \
(ptr)->bitset.size = N; \
(ptr)->bitset.word_size = ((N) + 31u) / 32u; \
})

/*! \brief Get the size of the bitset
* \ingroup pico_util
* \param bitset the bitset to get the size of
* \return the size of the bitset
*/
static inline uint bitset_size(const generic_bitset_t *bitset) {
return bitset->size;
}

/*! \brief Get the size of the bitset in words
* \ingroup pico_util
* \param bitset the bitset to get the size of
* \return the size of the bitset in words
*/
static inline uint bitset_word_size(const generic_bitset_t *bitset) {
return bitset->word_size;
}

/*! \brief Check that the bitset is valid
* \ingroup pico_util
* This function will assert if the bitset is not valid.
* \param bitset the bitset to check
*/
static inline void check_bitset(const generic_bitset_t *bitset) {
assert(bitset->word_size == (bitset->size + 31) / 32);
}

/*! \brief Write a word in the bitset
* \ingroup pico_util
* \param bitset the bitset to write to
* \param word_num the word number to write to
* \param value the value to write to the word
* \return the bitset
*/
static inline generic_bitset_t *bitset_write_word(generic_bitset_t *bitset, uint word_num, uint32_t value) {
check_bitset(bitset);
if (word_num < bitset_word_size(bitset)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this raise an error if word_num >= bitset_word_size(bitset) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a question for @kilograham, but given that the other functions don't throw any errors when you attempt to pass a value that is outside the range and just return 0/do nothing, I think this one should also not throw an error?

bitset->words[word_num] = value;
}
return bitset;
}

/*! \brief Read a word in the bitset
* \ingroup pico_util
* \param bitset the bitset to read from
* \param word_num the word number to read from
* \return the value of the word
*/
static inline uint32_t bitset_read_word(const generic_bitset_t *bitset, uint word_num) {
check_bitset(bitset);
if (word_num < bitset_word_size(bitset)) {
return bitset->words[word_num];
}
return 0;
}

/*! \brief Clear all bits in the bitset
* \ingroup pico_util
* \param bitset the bitset to clear
* \return the bitset
*/
static inline generic_bitset_t *bitset_clear(generic_bitset_t *bitset) {
check_bitset(bitset);
__builtin_memset(bitset->words, 0, bitset->word_size * sizeof(uint32_t));
return bitset;
}

/*! \brief Set all bits in the bitset
* \ingroup pico_util
* \param bitset the bitset to set
* \return the bitset
*/
static inline generic_bitset_t *bitset_set_all(generic_bitset_t *bitset) {
check_bitset(bitset);
__builtin_memset(bitset->words, 0xff, bitset->word_size * sizeof(uint32_t));
return bitset;
}

/*! \brief Set a single bit in the bitset
* \ingroup pico_util
* \param bitset the bitset to set
* \param bit the bit to set
* \return the bitset
*/
static inline generic_bitset_t *bitset_set_bit(generic_bitset_t *bitset, uint bit) {
check_bitset(bitset);
if (bit < bitset->size) {
bitset->words[bit / 32u] |= 1u << (bit % 32u);
}
return bitset;
}

/*! \brief Clear a single bit in the bitset
* \ingroup pico_util
* \param bitset the bitset to clear
* \param bit the bit to clear
* \return the bitset
*/
static inline generic_bitset_t *bitset_clear_bit(generic_bitset_t *bitset, uint bit) {
check_bitset(bitset);
if (bit < bitset->size) {
bitset->words[bit / 32u] &= ~(1u << (bit % 32u));
}
return bitset;
}

/*! \brief Get the value of a single bit in the bitset
* \ingroup pico_util
* \param bitset the bitset to get the value of
* \param bit the bit to get the value of
* \return the value of the bit
*/
static inline bool bitset_get_bit(generic_bitset_t *bitset, uint bit) {
check_bitset(bitset);
assert(bit < bitset->size);
// if (bit < bitset->size) {
return bitset->words[bit / 32u] & (1u << (bit % 32u));
// }
return false;
}

/*! \brief Check if two bitsets are equal
* \ingroup pico_util
* \param bitset1 the first bitset to check
* \param bitset2 the second bitset to check
* \return true if the bitsets are equal, false otherwise
*/
static inline bool bitset_equal(const generic_bitset_t *bitset1, const generic_bitset_t *bitset2) {
check_bitset(bitset1);
check_bitset(bitset2);
assert(bitset1->size == bitset2->size);
return __builtin_memcmp(bitset1->words, bitset2->words, bitset1->word_size * sizeof(uint32_t)) == 0;
}

typedef uint32_t tiny_encoded_bitset_t;
typedef uint64_t encoded_bitset_t;

#define encoded_bitset_empty() 0
#define encoded_bitset_of1(v) (1u | ((v) << 8))
#define encoded_bitset_of2(v1, v2) (2u | ((v1) << 8) | ((v2) << 16))
#define encoded_bitset_of3(v1, v2, v3) (3u | ((v1) << 8) | ((v2) << 16) | (((v3) << 24)))
#define encoded_bitset_of4(v1, v2, v3, v4) (4u | ((v1) << 8) | ((v2) << 16) | (((v3) << 24)) | (((uint64_t)(v4)) << 32))
#define encoded_bitset_of5(v1, v2, v3, v4, v5) (5u | ((v1) << 8) | ((v2) << 16) | (((v3) << 24)) | (((uint64_t)((v4) | ((v5)<<8u))) << 32))

#define encoded_bitset_foreach(bitset, x) ({ \
for(uint _i=0;_i<((bitset)&0xffu);_i++) { \
uint bit = (uint8_t)((bitset) >> (8 * _i)); \
x; \
} \
})
Comment on lines +215 to +230
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT it looks like this encoded_bitset stuff is only used in kitchen_sink.c, so maybe it's not actually needed? 🤷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’ll be a question for @kilograham

#ifdef __cplusplus
}
#endif
#endif
Loading
Loading