Skip to content

Prefix public bitfield macros with LBT_ to avoid namespace pollution#177

Merged
ViralBShah merged 2 commits into
mainfrom
cleanup-header-macros
Jun 6, 2026
Merged

Prefix public bitfield macros with LBT_ to avoid namespace pollution#177
ViralBShah merged 2 commits into
mainfrom
cleanup-header-macros

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

What

src/libblastrampoline.h is the public header, yet it leaked the unprefixed macros BF_CHUNK, BF_MASK, and BITFIELD_{GET,SET,CLEAR} into every consumer's preprocessor namespace. BF_MASK especially is a plausible collision.

This renames them to LBT_-prefixed names:

  • LBT_BF_CHUNK, LBT_BF_MASK (internal helpers — renamed, no alias)
  • LBT_BITFIELD_{GET,SET,CLEAR}

and updates the in-tree usages (config.c, libblastrampoline.c) plus the active_forwards docstring.

Backwards compatibility

The three macros documented for consumers (used to read the public active_forwards bitfield) keep unprefixed aliases:

#define BITFIELD_GET(array, idx)   LBT_BITFIELD_GET(array, idx)
#define BITFIELD_CLEAR(array, idx) LBT_BITFIELD_CLEAR(array, idx)
#define BITFIELD_SET(array, idx)   LBT_BITFIELD_SET(array, idx)

so existing code keeps compiling. Builds cleanly.

Possible follow-up (not done here)

The header also defines platform macros (_OS_LINUX_, etc.) that leak into consumers. Confining those is a larger, riskier change (they gate LBT_DLLEXPORT), so it's deliberately left out of this PR.

Draft for review.

`src/libblastrampoline.h` is the public header, but it defined the unprefixed
macros `BF_CHUNK`, `BF_MASK`, and `BITFIELD_{GET,SET,CLEAR}` into every
consumer's namespace. `BF_MASK` in particular is a likely collision.

Rename them to `LBT_`-prefixed names (`LBT_BF_CHUNK`, `LBT_BF_MASK`,
`LBT_BITFIELD_{GET,SET,CLEAR}`) and update the in-tree usages. The three
documented public macros (`BITFIELD_{GET,SET,CLEAR}`, referenced from the
`active_forwards` docstring) are kept as backwards-compatible aliases so
existing consumers don't break; `BF_CHUNK`/`BF_MASK` were internal helpers and
are renamed without aliases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ViralBShah ViralBShah marked this pull request as ready for review June 6, 2026 16:11
@ViralBShah ViralBShah marked this pull request as draft June 6, 2026 16:13
Comment thread src/libblastrampoline.h Outdated
@ViralBShah ViralBShah marked this pull request as ready for review June 6, 2026 16:29
Per review discussion, remove the backwards-compatible `BITFIELD_{GET,SET,CLEAR}`
aliases and keep only the `LBT_`-prefixed macros. These are compile-time-only
helper macros (not exported symbols), so removing them does not affect the ABI /
soversion — no major version bump required.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ViralBShah ViralBShah merged commit 7bb5f53 into main Jun 6, 2026
45 checks passed
@ViralBShah ViralBShah deleted the cleanup-header-macros branch June 6, 2026 23:21
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.

2 participants