-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc] Cleanup startup/baremetal/arm/start.cpp #151532
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
Conversation
Post-commit review changes as suggested by @petrhosek in llvm#146863
|
@llvm/pr-subscribers-libc Author: William Huynh (saturn691) ChangesPost-commit review changes as suggested by @petrhosek in #146863 Full diff: https://github.com/llvm/llvm-project/pull/151532.diff 1 Files Affected:
diff --git a/libc/startup/baremetal/arm/start.cpp b/libc/startup/baremetal/arm/start.cpp
index 123efc4750941..493445e2922b0 100644
--- a/libc/startup/baremetal/arm/start.cpp
+++ b/libc/startup/baremetal/arm/start.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/stdint_proxy.h"
#include "src/__support/macros/config.h"
#include "src/stdlib/atexit.h"
#include "src/stdlib/exit.h"
@@ -14,8 +15,6 @@
#include "startup/baremetal/fini.h"
#include "startup/baremetal/init.h"
-#include <stdint.h>
-
extern "C" {
int main(int argc, char **argv);
void _start();
@@ -31,7 +30,9 @@ extern uintptr_t __data_start[];
extern uintptr_t __data_size[];
extern uintptr_t __bss_start[];
extern uintptr_t __bss_size[];
+} // extern "C"
+namespace {
// Based on
// https://developer.arm.com/documentation/107565/0101/Use-case-examples/Generic-Information/What-is-inside-a-program-image-/Vector-table
void NMI_Handler() {}
@@ -49,35 +50,37 @@ void SysTick_Handler() {}
// to be zero and Cortex-M23 can require up to 10, so 1024-byte align the vector
// table.
using HandlerType = void (*)(void);
-const HandlerType vector_table[]
- __attribute__((section(".vectors"), aligned(1024), used)) = {
- (HandlerType)&__stack, // SP
- _start, // Reset
- NMI_Handler, // NMI Handler
- HardFault_Handler, // Hard Fault Handlerß
- MemManage_Handler, // MPU Fault Han`dler
- BusFault_Handler, // Bus Fault Handler
- UsageFault_Handler, // Usage Fault Handler
- 0, // Reserved
- 0, // Reserved
- 0, // Reserved
- 0, // Reserved
- SVC_Handler, // SVC Handler
- DebugMon_Handler, // Debug Monitor Handler
- 0, // Reserved
- PendSV_Handler, // PendSV Handler
- SysTick_Handler, // SysTick Handler
- // Unused
+[[gnu::section(".vectors"), gnu::aligned(1024), gnu::used]]
+const HandlerType vector_table[] = {
+ reinterpret_cast<HandlerType>(&__stack), // SP
+ _start, // Reset
+ NMI_Handler, // NMI Handler
+ HardFault_Handler, // Hard Fault Handlerß
+ MemManage_Handler, // MPU Fault Han`dler
+ BusFault_Handler, // Bus Fault Handler
+ UsageFault_Handler, // Usage Fault Handler
+ 0, // Reserved
+ 0, // Reserved
+ 0, // Reserved
+ 0, // Reserved
+ SVC_Handler, // SVC Handler
+ DebugMon_Handler, // Debug Monitor Handler
+ 0, // Reserved
+ PendSV_Handler, // PendSV Handler
+ SysTick_Handler, // SysTick Handler
+ // Unused
};
-} // extern "C"
+} // namespace
namespace LIBC_NAMESPACE_DECL {
[[noreturn]] void do_start() {
// FIXME: set up the QEMU test environment
// Perform the equivalent of scatterloading
- LIBC_NAMESPACE::memcpy(__data_start, __data_source, (uintptr_t)__data_size);
- LIBC_NAMESPACE::memset(__bss_start, '\0', (uintptr_t)__bss_size);
+ LIBC_NAMESPACE::memcpy(__data_start, __data_source,
+ reinterpret_cast<uintptr_t>(__data_size));
+ LIBC_NAMESPACE::memset(__bss_start, '\0',
+ reinterpret_cast<uintptr_t>(__bss_size));
__libc_init_array();
_platform_init();
|
|
Once again, I will request a post-commit review, I am going to build upon this |
petrhosek
left a comment
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.
LGTM and thank you for the cleanup.
Post-commit review changes as suggested by @petrhosek in #146863