41 lines
985 B
C
41 lines
985 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 _STRLEN_DEFINED
|
|
#define _STRLEN_DEFINED
|
|
int strlen(char* s) {
|
|
int len = 0;
|
|
for(;s[len] != 0; ++len);
|
|
return len;
|
|
}
|
|
#endif // !_STRLEN_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
|