lkml.org 
[lkml]   [1999]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: complicated inline assembly
On Mon, 23 Aug 1999, Oliver Xymoron wrote:

> 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;

ITYM errno=-result; :)

>
> return -1;
> }
>

--
Mike <rickettm@ox.compsoc.net>

When we are planning for posterity, we ought to remember that virtue is
not hereditary.
-- Thomas Paine


-
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/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.119 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site