Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22018

How to call gettimeofday syscall in inline assembly in FreeBSD?

$
0
0

I am trying to get the current time using syscalls and inline assembly in FreeBSD 5.2.1 32-bit.

My problem is that I struggle to pass needed structs as arguments to the function resulting in error:

error: impossible register constraint in `asm'

My current code which I am actually running looks like this:

#include <sys/syscall.h>#include <sys/time.h>struct timeval val;struct timezone zone;zone.tz_minuteswest = 0;zone.tz_dsttime = 0;long ret;asm("int $0x80"    : "=a"(ret)    : "0"(SYS_gettimeofday), "D"(val), "S"(zone)    : "memory");

I was trying to get inspired be these 2 examples, but I couldn't make it work link1, link2.

Only other thing that I managed was, calling syscalls such as getuid, because it requires no arguments and directly returns value.

I am open to using clock_gettime syscall, but other than that I really want to get it using inline assembly syscalls.


Viewing all articles
Browse latest Browse all 22018

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>