Skip to content

Support bits wider than 64 bits#104

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/support-wider-bits-implementation
Draft

Support bits wider than 64 bits#104
Copilot wants to merge 2 commits intomasterfrom
copilot/support-wider-bits-implementation

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Emboss previously limited bits types to 64 bits, preventing representation of protocols like NovAtel's RANGECMP (192-bit bitfield) and GPS subframes (300-bit sequences).

Changes

Compiler (constraints.py)

  • Remove 64-bit size limit for bits types
  • Individual fields within bits remain limited to 64 bits via prelude type constraints

C++ Runtime (emboss_memory_util.h)

  • Add LittleEndianWideBitBlock / BigEndianWideBitBlock for >64-bit bit blocks
  • Add corresponding WideOffsetBitBlock classes for field access
  • These read/write bytes individually rather than loading entire bitfield into a single integer
  • Add data() to byte orderers for raw buffer access

Code Generator (header_generator.py)

  • Use WideBitBlock variants when size > 64 bits

Example

bits WideBits:
  0   [+64]  UInt  first_64
  64  [+64]  UInt  second_64
  128 [+64]  UInt  third_64

struct ContainsWideBits:
  0 [+24]  WideBits  wide_field
auto view = MakeContainsWideBitsView(buffer, 24);
view.wide_field().first_64().Write(0x1122334455667788ULL);
view.wide_field().second_64().Write(0xAABBCCDDEEFF0011ULL);
Original prompt

This section details on the original issue you should resolve

<issue_title>Support bits wider than 64 bits</issue_title>
<issue_description>This issue was copied from the upstream repository google/emboss.

Original issue: google#40
Original state: open, created at: 2022-04-19T19:37:41Z, updated at: 2024-12-18T23:14:42Z, by @reventlov


Original description

NovAtel's RANGECMP (pp 842-844) record contains a 192-bit bitfield.

GPS subframes are defined as 300-bit sequences.

RTCM defines some wide bitfields which -- even more problematically -- contain 64-bit integers that are not aligned to byte boundaries.

Emboss should support bits of arbitrary size.

Note: the restriction that individual integers within those fields are no more than 64 bits is a separate feature that should be evaluated and implemented on its own.


Discussion (copied comments)

Comment by @AaronWebster on 2022-05-14T00:58:18Z:

GMP might be worth looking into, using mpz_import and mpz_import to escrow data.


</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Remove 64-bit constraint in constraints.py for bits types
- Add LittleEndianWideBitBlock and BigEndianWideBitBlock classes to handle wide bits
- Add LittleEndianWideOffsetBitBlock and BigEndianWideOffsetBitBlock for field access
- Add data() method to byte orderers for wide bit block support
- Update code generator to use appropriate WideBitBlock for sizes > 64
- Update tests to verify wide bits work correctly

Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Copilot AI changed the title [WIP] Support bits wider than 64 bits in Emboss Support bits wider than 64 bits Dec 6, 2025
Copilot AI requested a review from AaronWebster December 6, 2025 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support bits wider than 64 bits

2 participants