mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
compiler: Merge the runtime into the Go code, for better code size
This commit is contained in:
+10
-6
@@ -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,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))
|
||||
|
||||
Reference in New Issue
Block a user