From: Roy Lee <roylee17@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Could someone tell me more about the asmlinkage
Date: Sat, 18 Jun 2005 22:00:39 +0800 [thread overview]
Message-ID: <42B42907.8060404@gmail.com> (raw)
"Why is there a asmlinkage before a syscall?"
I know this is a FAQ already, but I couldn't find an answer that clear enough
for me to understand after "gooling" for some time. I've also read the FAQ of
kernelnewbies.
The following is quoted from the FAQ of kernelnewbies.
-------
The asmlinkage tag is one other thing that we should observe about this simple
function. This is a #define for some gcc magic that tells the compiler that the
function should not expect to find any of its arguments in registers (a common
optimization), but only on the CPU's stack. Recall our earlier assertion that
system_call consumes its first argument, the system call number, and allows up
to four more arguments that are passed along to the real system call. system_call
achieves this feat simply by leaving its other arguments (which were passed to it
in registers) on the stack. All system calls are marked with the asmlinkage tag,
so they all look to the stack for arguments. Of course, in sys_ni_syscall's case,
this doesn't make any difference, because sys_ni_syscall doesn't take any arguments,
but it's an issue for most other system calls. And, because you'll be seeing asmlinkage
in front of many other functions, I thought you should know what it was about.
--------
It says that "To tell a compiler not to use the argument in the registers". but the
syscall's argument does pass the arguments though registers, doesn't it?
While tracing the code, I found the asmlinkage was a #define of a extern "C", and
the only usage of extern "C" that I know is to avoid the name mangling while calling
a C function in C++. Does the asmlinkage here have connection with that?
Roy
next reply other threads:[~2005-06-18 13:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-18 14:00 Roy Lee [this message]
2005-06-18 14:29 ` Could someone tell me more about the asmlinkage Paolo Ornati
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42B42907.8060404@gmail.com \
--to=roylee17@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox