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

Add native target 64-bit support #3042

Merged
merged 8 commits into from
Apr 9, 2024
Merged

Conversation

m-gorecki
Copy link
Contributor

@m-gorecki m-gorecki commented Jul 17, 2023

This also requires changes from repositories apache-mynewt-nimble, apache-mynewt-mcumgr and mcuboot, which I commited.

.code64
.p2align 4, 0x90 /* align on 16-byte boundary and fill with NOPs */

.globl CNAME(os_arch_frame_init_64bit)
Copy link
Contributor

Choose a reason for hiding this comment

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

64bit -> x64

*/
movq %rdi,%rsp
subq $0x0c,%rsp /* make room for sigsetjmp() arguments */
andq $0xfffffffffffffff0,%rsp /* align %rsp on 16-byte boundary */
Copy link
Contributor

Choose a reason for hiding this comment

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

btrq $0xf,%rsp should also work (and you don't need to count fs)

os_arch_frame_init_64bit(sf);
} else {
printf("Void pointer should be either 4 or 8 bytes. Exiting.\n");
exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

#if __SIZEOF_POINTER__ == xxx and then #error instead of printf would be better since it gives an error during build

@@ -60,6 +60,7 @@ typedef unsigned int os_stack_t;
/* sim specific */
struct stack_frame;
void os_arch_frame_init(struct stack_frame *sf);
void os_arch_frame_init_64bit(struct stack_frame *sf);
Copy link
Contributor

Choose a reason for hiding this comment

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

probably would be better to have the same prototype regardless of arch and just use preprocessor to check that we build for supported arch (see c384bec#r1265232905)

@rojer
Copy link

rojer commented Jul 28, 2023

fwiw it covers all the changes i did in apache/mynewt-nimble#1563

Thanks to this the type casting code can be compiled
on both 32-bit and 64-bit architectures. This also changes
some printf functions, so they are also compatible with
both types of architectures.
This allows to run unit tests on 64-bit architecture.
This also modifies some mbuf tests, so the test pool buf size
is no longer hardcoded.
On some architectures va_list is defined as an array, which leads
to compilation errors if va_list type is caller argument and
callee expects a pointer to it as it's argument. Thanks to this
the compilation errors in this situation no longer occur.
On some compilers (for example 64-bit gcc 9.4.0) passing
SIZE_MAX/2 to vsnprintf as buffer size was causing an compilation error.
INT_MAX/2 should also be enough for buffer size and now it compiles
without problems.
This also removes force inclusion of "main" symbol.
-Wno-maybe-uninitialized flag is not supported by clang.
This suppresses warning related to this.
-m32 flag is removed. Now if the machine on which the code is compiled
is capable of running 64-bit code the generated code will be 64-bit.
Copy link
Contributor

@kasjer kasjer left a comment

Choose a reason for hiding this comment

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

LGTM, not tested though

@sjanc sjanc merged commit 456c0eb into apache:master Apr 9, 2024
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.

None yet

5 participants