Home | Forums | What's new | Resources | |
calling time() or gettimeofday() freezes Saturn |
RockinB - Dec 13, 2004 |
Borisz | Dec 13, 2004 | |||
if you are testing it on emus, its possible that none of the emus have those commands implemented in the SMPC block. |
antime | Dec 13, 2004 | |||
Have you verified that you even have proper Saturn-specific implementations of either function? |
RockinB | Dec 14, 2004 | ||||
Not really. I got the libc manual where time() and others are explained, so I guess it should be located in libc.a. The SGL got such a file. But as I discovered while trying 32x dev, this libc.a has to be declared when linking with ld, but SGL programs have to be linked with gcc(see SGL readme or something). Bute when linking with gcc, you don't need to declare libc.a, so where does gcc take it's time() implementation from? |
antime | Dec 14, 2004 | |||
There is no C library provided with SGL. The default time() function provided by Newlib (the C library bundled with KPIT's toolchain eventually resolves to an attempt to do a system call through the "trapa" instruction which probably ends up in the default exception handler which just sits in a loop doing nothing.) |
RockinB | Dec 17, 2004 | ||||
Hmm, I meant the libc.a that came with the old Saturn compiler. So I would have to reimplement time() and gettimeofday(). Oh, I always hated these functions. |
vbt | Dec 25, 2006 | |||
Maybe the solution is here : http://forums.segaxtreme.net/showthread.php?t=1508... |
dibz | Dec 25, 2006 | |||
Wow, you replied to thread over 2 years old vbt. |
RockinB | Jan 5, 2007 | |||||
You're right, that might be an option to reimplement the Newlib functions. AFAIR that has been an issue for me when I tried to port SoftVMS to Saturn, years ago... |
antime | Jan 5, 2007 | |||
You don't have to reimplement newlib, as all operating system calls eventually become a "trapa #34". Since the syscall number and its parameters are passed as normal function parameters in the registers and on the stack you only have to hook the right vector and implement the functions you need. (However looking at the sources for gettimeofday you only get a single-second resolution. If you also need microseconds you will need to modify newlib.) |
antime | Jan 5, 2007 | ||||
This is completely untested, but something like this could be used to wrap syscalls implemented in C. You have to fill in "TrapTable" with the addresses of the corresponding syscall implementation and then set the trap 34 vector to point to "OSTrap". If the syscall wants to set errno it should set "OSTrapErrno" instead, as newlib takes errno from r1 when returning from the trap. The parameter shuffling works because all calls use 0 to 3 parameters (see newlib/libc/sys/sh/syscalls.c).
Code:
|