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
feat(c11): Adapt code to be compatible with ISO C11 #122
Conversation
8bc69f6
to
a631628
Compare
I don't think we need the wip in #120. We can use just this PR for both enabling pedantic C11 and adding the fixes to the new errors. |
@miguelafsilva5 please fix your commit messages to pass gitlint checks and apply the code formatter. I also see that the builds are still failing due to |
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.
Finally, the scopes you are using in your commit messages don't make much sense. Scopes are supposed to be more of a component of subsystem of the code or a topic regarding the modification, not a keyword for the modification you are introducing. As many of these are related to ISO C, C11, pedantic c, I would suggest using some scope in this sense or none at all.
d9c9fed
to
bb051a1
Compare
49032e3
to
f5b9d65
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.
The changes seem OK to me and well-documented on each commit description. However, build checkers are failing.
Commit 1853b59 seems to have fixed it. |
8cb9f80
to
f769441
Compare
Initial commit for the process of adapting bao to the standard C11. Modified the makefile to compile according to C11 and reject the use of any extension. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
The asm keyword is a GNU extension. Changed all instances to the C11 counterpart __asm__ Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
The use of binary constants (e.g., 0b0101) is a GCC extension. Refactor all binary constants to hex (e.g., 0x5). Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
GCC issues an error ("initializer element is not constant") when SPINLOCK_INITVAL was defined in a macro. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Most macros expand to functions. C11 does not allow the use of ; at the end of non-statements. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
sgi_base[0] was used for better legibility while ensuring the the next registers were aligned properly. C11 does not allow these declarations. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Using an expression in return statement is illegal in C11. In this case, the function has a void return type. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
__VA_OPT__ is only available as a GNU extension or in C23. The error issued by gcc is "error: __VA_OPT__ is not available until C2X" Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
C11 does not allow arithmetic operations on void* ptrs. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Add a dummy uint8_t to the structs page_table_arch and iommu_vm_arch since C11 does not allow structs to be declared without members. This was the best solution available avoiding majors modifications to bao. Considering both structs are only used in a small number of ocasions, the increase in memory usage is acceptable. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
The macro DEFINED evaluates if a given macro was defined or not. Its expansion ends in a variadic macro that was not receiving the correct number of arguments if the evaluated macro was not defined. It was fixed by added a dummy argument that is ignored. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
ISO C forbids zero-size arrays. From our understanding, that declaration does not achieve anything. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
ISO C forbids braced-groups within expressions which was used in the CSRR macro. We use the same strategy as in arm code, by generating static functions accessors for each CSR Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Pedantic C does not allow for the initialization of flexible array members. The presented solution follows the same pattern as other attributes in structs used in the configuration (e.g., shmemlist or regions). Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
With the changes to the type of vmlist, the system fails to build to generate the headers without adding an entry to the new vmlist array. Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
PR Description
This PR is the first on the chain of PRs (This PR <- #146 <- #147 ).
The main goal of this PR is to force ISO C11 on bao and deal with all -pedantic errors. Each commit tries to deal with a specific error.
The platforms tested were: