-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Unify lengthof/string_lengthof -like macros #61537
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
What are the |
eb0d614
to
1725ec7
Compare
1725ec7
to
ad9e726
Compare
There were about 32 definitions of those macros repo-wide, this patch moves the definitions in a single place: runtime/src/native/minipal/utils.h Lines 7 to 10 in ad9e726
|
What is the most common name used for this macro in the universe? Would it look better to standardize on that name without any prefix? |
There is no common name i think, mono uses the name from glib. |
Note that the Jit also uses an |
I don't have strong opinions about the name (naming stuff is hard), so whatever is decided I'm fine with it; now that find & replace after this patch is much easier. ;) Prefix convention (used heavily in mono) helps identifying where the macro or function definitions are coming from. Recently, we prefixed functions with |
Renamed |
That doesn't match the mono coding conventions and looks very much like some kind of compiler intrinsic. |
@vargaz What would be your preferred name? |
Not sure this particular macro needs to be unified between the runtimes, both of them already has their own version. |
I hope that we will share more code between the runtimes over time. I think it is important that we get the details like these unified to something reasonable. Do you have an opinion what should be the name to standardize on in the code shared between runtimes for this one? |
Imho the problem is that the runtimes have different coding conventions, so not sure a macro name can fit both equally well. I'd prefer the traditional uppercase macro naming style. |
src/native/eventpipe is another example of code shared between runtimes, where we have function, as well as the macro names prefixed and macros are upper cased. coreclr uses many different conventions (prefix, no prefix, upper, lower, mixed casing) for macros so there is no problem in changing it to whichever name is suitable. |
Would |
Based on the feedback, here is my proposal to land this PR:
@am11 If there is no push back in next two days, could you please implement these change? I am sorry about the back and forth, and thank you for your work on various cleanups! |
Sounds good |
390335e
to
47d1dbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
src/native/common
tosrc/native/minipal
_countof
and_strcountof
._countof
,lengthof
,NumItems
,ARRAY{_}SIZE
like macros with_countof
.lengthof
andStrLen
like macros with_strcountof
._countof() - 1
patterns to_strcountof()
in few places.In second commit, ran editor macro to cleanup trailing whitespaces in files touched by the first commit.