ack/plat/osx386/libsys/gettimeofday.s
George Koehler b6b707d9df Make working gettimeofday() for Mac OS X.
The system call puts the time in a pair of registers, not in the
timeval structure.  Add code to move the time to the structure, so
programs see the correct time, not garbage.  This fixes our example
programs that use the time as a random seed.
2016-11-23 13:25:55 -05:00

19 lines
414 B
ArmAsm

! The system call checks the timeval pointer but doesn't store the
! time there. If the pointer wasn't NULL, then the system call
! returns the time in a pair of registers.
.sect .text
.define _gettimeofday
_gettimeofday:
mov eax, 116
int 0x80
jb .set_errno
mov ebx, 4(esp) ! timeval pointer
test ebx, ebx
je 1f
mov 0(ebx), eax ! seconds
mov 4(ebx), edx ! microseconds
1:
mov eax, 0 ! return 0
ret