Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Make bitfield integers unsigned #25051

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

seberg
Copy link
Member

@seberg seberg commented Nov 1, 2023

I am getting a lot of compile warnings recently. Not sure exactly why, but one source here is that the 1 we store is cast to -1 for a signed integer bitfield. Making it explicitly unsigned quenches the warning and seems easiest.


This was just the easiest. I have two other sources of warnings:

  • Headers which are included in places but were once designed to be more stand-alone and thus redefine things like NpyAuxData. I would have thought that is fine in C, but I am getting requires C11 warning.
  • Unused simd functions, I think because on my target (M1) some fallback implementations are really guaranteed to not be used.

I am getting a lot of compile warnings recently.  Not sure exactly
why, but one source here is that the 1 we store is cast to -1 for
a signed integer bitfield.  Making it explicitly unsigned quenches
the warning and seems easiest.
// returns '1' if the type represent a vector
int is_vector:1;
unsigned int is_vector:1;
// returns the len of multi-vector if the type represent x2 or x3 vector
// otherwise returns 0, e.g. returns 2 if data type is simd_data_vu8x2
int is_vectorx;
Copy link
Member

@charris charris Nov 2, 2023

Choose a reason for hiding this comment

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

I wonder why this isn't a bit field, must be some SIMD thing.

EDIT: Never mind. But it looks like it could also be unsigned.

@charris
Copy link
Member

charris commented Nov 2, 2023

LGTM, but I wonder how that structure is supposed to be used. Using bit fields seems a micro optimization.

@charris
Copy link
Member

charris commented Nov 2, 2023

OK, unsigned is probably the right thing to do here.

@charris charris merged commit 7a4f6b0 into numpy:main Nov 2, 2023
59 checks passed
@charris
Copy link
Member

charris commented Nov 2, 2023

Thanks Sebastian.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Nov 2, 2023
@seberg seberg deleted the unsigned-bitfield branch November 7, 2023 11:07
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants