Re: complicated inline assembly

Oliver Xymoron (oxymoron@waste.org)
Mon, 23 Aug 1999 19:39:56 -0500 (CDT)


On Mon, 23 Aug 1999, Mehta, Hiren wrote:

> Can anybody explain the following complicated assembly that I found
> include/asm-i386/unistd.h file ?
>
> #define _syscall0(type,name) \
> type name(void) \
> { \
> long __res; \
> __asm__ volatile ("int $0x80" \
> : "=a" (__res) \
> : "0" (__NR_##name)); \
> if (__res >= 0) \
> return (type) __res; \
> errno = -__res; \
> return -1; \
> }

_syscall0(foo_t, foo) expands into approximately:
foo_t foo(void)
{
long result;

/* make the call */
result=call_interrupt_vector_0x80(__NR_foo);

if(result>=0) return (foo_t) result;

errno=result;

return -1;
}

--
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.." 

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/