minimalc/arch/generic.h

32 lines
828 B
C

/*
* This file is not meant to be included by user applications
* It contains generic arch agnostic implementations of helper functions
* and start code that can be included in <arch>.c when an architecture
* specific version is not nessisary.
*
* Copyright (c) 2025 Lucas Schumacher. All Rights Reserved.
*/
#ifndef MEMSET_DEFINED
#define MEMSET_DEFINED
// Generic memset implementation
void *memset(void* s, int c, unsigned long n) {
int8_t* mem = s;
for(long int i = 0; i < n; ++i) mem[i] = c;
return s;
}
#endif // !MEMSET_DEFINED
#ifndef _START_DEFINED
#define _START_DEFINED
// Generic _start implementation. Can't access any args
extern void exit(int8_t status);
extern int main(int argc, char** argv);
void _start() {
exit(main(0, 0));
}
void __start() {
exit(main(0, 0));
}
#endif // !_START_DEFINED