Retro68/libretro/syscalls.c

99 lines
1.9 KiB
C
Raw Normal View History

/*
2014-09-14 22:43:30 +00:00
Copyright 2012 Wolfgang Thaller.
2014-09-14 22:43:30 +00:00
This file is part of Retro68.
2014-09-14 22:43:30 +00:00
Retro68 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2014-09-14 22:43:30 +00:00
Retro68 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2014-09-14 22:43:30 +00:00
You should have received a copy of the GNU General Public License
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
*/
2012-03-29 08:29:41 +00:00
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <MacMemory.h>
#include <Processes.h>
int isatty(int fd) { return fd >= 0 && fd <= 2; }
void *sbrk(long increment)
{
2014-09-14 22:43:30 +00:00
Debugger();
return NewPtrClear(increment);
2012-03-29 08:29:41 +00:00
}
void _exit(int status)
{
2014-09-14 22:43:30 +00:00
if(status != 0)
Debugger();
ExitToShell();
for(;;)
;
2012-03-29 08:29:41 +00:00
}
ssize_t (*__write_hook)(int fd, const void*buf, size_t count) = NULL;
2014-09-14 22:00:45 +00:00
ssize_t (*__read_hook)(int fd, void*buf, size_t count) = NULL;
2012-03-29 08:29:41 +00:00
ssize_t consolewrite(int fd, const void *buf, size_t count);
ssize_t consoleread(int fd, void *buf, size_t count);
2012-03-29 08:29:41 +00:00
ssize_t write(int fd, const void *buf, size_t count)
{
2014-09-14 22:43:30 +00:00
if(__write_hook)
return (*__write_hook)(fd,buf,count);
else
return consolewrite(fd,buf,count);
2014-09-14 22:43:30 +00:00
return -1;
2012-03-29 08:29:41 +00:00
}
ssize_t read(int fd, void *buf, size_t count)
{
2014-09-14 22:00:45 +00:00
if(__read_hook)
2014-09-14 22:43:30 +00:00
return (*__read_hook)(fd,buf,count);
else
return consoleread(fd,buf,count);
2014-09-14 22:43:30 +00:00
return -1;
2012-03-29 08:29:41 +00:00
}
int open(const char* name, int flags, mode_t mode)
{
2014-09-14 22:43:30 +00:00
__asm__ __volatile__ ("dc.w 0xa9ff");
return -1;
2012-03-29 08:29:41 +00:00
}
int close(int fd)
{
2014-09-14 22:43:30 +00:00
return -1;
2012-03-29 08:29:41 +00:00
}
int fstat(int fd, struct stat *buf)
{
2014-09-14 22:43:30 +00:00
return -1;
2012-03-29 08:29:41 +00:00
}
off_t lseek(int fd, off_t offset, int whence)
{
2014-09-14 22:43:30 +00:00
return (off_t) -1;
2012-03-29 08:29:41 +00:00
}
int kill(pid_t pid, int sig)
{
2014-09-14 22:43:30 +00:00
if(pid == 42)
_exit(42);
else
return -1;
2012-03-29 08:29:41 +00:00
}
pid_t getpid(void)
{
2014-09-14 22:43:30 +00:00
return 42;
2012-03-29 08:29:41 +00:00
}