blob: f08e0f4e16763777ca518e163fcc60805df5bab1 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Syscall stubs for newlib on Kelvin */
#include <errno.h>
#include <sys/stat.h>
int _close(int file) { return -1; }
int _fstat(int file, struct stat* st) { return 0; }
int _isatty(int file) {
errno = ENOTTY;
return 0;
}
int _lseek(int file, int ptr, int dir) { return 0; }
int _read(int file, char* ptr, int len) {
errno = EBADF;
return -1;
}
int _write(int file, char* ptr, int len) {
errno = EBADF;
return -1;
}
int _open(const char* path, int flags, ...) { return -1; }
void _exit(int status) {
while (1) {
}
}
int _kill(int pid, int sig) { return -1; }
int _getpid(void) { return -1; }
// Based on newlib's nosys sbrk
void* _sbrk(int bytes) {
extern char __heap_end__;
static char* heap_end;
char* prev_heap_end;
if (heap_end == 0) {
heap_end = &__heap_end__;
}
prev_heap_end = heap_end;
heap_end += bytes;
return (void*)prev_heap_end;
}