compiler: Merge the runtime into the Go code, for better code size

This commit is contained in:
Ayke van Laethem
2018-04-26 18:06:54 +02:00
parent 775445cceb
commit 2d19bb11ba
4 changed files with 47 additions and 25 deletions
+10 -6
View File
@@ -1,15 +1,19 @@
#include "runtime.h"
#include <string.h>
void go_main() __asm__("main.main");
void __go_runtime_main() {
go_main();
}
__attribute__((weak))
int main() {
__go_runtime_main();
go_main();
return 0;
}
__attribute__((weak))
void * memset(void *s, int c, size_t n) {
for (size_t i = 0; i < n; i++) {
((uint8_t*)s)[i] = c;
}
return s;
}
+2 -3
View File
@@ -2,6 +2,7 @@
#include "hal/nrf_uart.h"
#include "nrf.h"
#include "runtime.h"
#include <string.h>
void uart_init(uint32_t pin_tx) {
NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled;
@@ -30,9 +31,7 @@ __attribute__((weak))
void __aeabi_memclr(uint8_t *dest, size_t n) {
// TODO: link with compiler-rt for a better implementation.
// For now, use a simple memory zeroer.
for (size_t i = 0; i < n; i++) {
dest[i] = 0;
}
memset(dest, 0, n);
}
__attribute__((weak))