kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* question regarding SYSCALL macros
@ 2011-04-28 10:16 Sudheer Divakaran
  2011-04-28 12:25 ` Mulyadi Santosa
  2011-04-29 20:30 ` Dave Hylands
  0 siblings, 2 replies; 3+ messages in thread
From: Sudheer Divakaran @ 2011-04-28 10:16 UTC (permalink / raw)
  To: kernelnewbies

Hi,
 I was going through the file kernel/time.c and found the definition
of 'gettimeofday' system call as follows.

SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
		struct timezone __user *, tz)   <--- NOTE THE COMMA between variable
types and names.

In syscalls.h I could find the needed macros for expanding the
definition to its final form i.e.,

asmlinkage long sys_gettimeofday(struct timeval __user * tv, struct
timezone __user *tz)


[syscalls.h macros]

#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)


#define SYSCALL_DEFINEx(x, sname, ...)	\
	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)


#define __SYSCALL_DEFINEx(x, name, ...)	\
	asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))


#define __SC_DECL1(t1, a1)	t1 a1
#define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__)


[Question]
Note the comma between the variable types and names in the original
definition  (e.g., "struct timeval __user *, tv" instead of "struct
timeval __user *tv").

What is is the reason behind separating variable types and variable
names using 'comma' and latter removing the comma character using
_SC_DECLx macros?


-- 
Thanks
Sudheer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* question regarding SYSCALL macros
  2011-04-28 10:16 question regarding SYSCALL macros Sudheer Divakaran
@ 2011-04-28 12:25 ` Mulyadi Santosa
  2011-04-29 20:30 ` Dave Hylands
  1 sibling, 0 replies; 3+ messages in thread
From: Mulyadi Santosa @ 2011-04-28 12:25 UTC (permalink / raw)
  To: kernelnewbies

Hi :)

On Thu, Apr 28, 2011 at 17:16, Sudheer Divakaran
<inbox1.sudheer@gmail.com> wrote:
> [Question]
> Note the comma between the variable types and names in the original
> definition ?(e.g., "struct timeval __user *, tv" instead of "struct
> timeval __user *tv").
>
> What is is the reason behind separating variable types and variable
> names using 'comma' and latter removing the comma character using
> _SC_DECLx macros?

IMHO, that is done for separating type declaration and the variable
name itself. In other word, modularity...


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* question regarding SYSCALL macros
  2011-04-28 10:16 question regarding SYSCALL macros Sudheer Divakaran
  2011-04-28 12:25 ` Mulyadi Santosa
@ 2011-04-29 20:30 ` Dave Hylands
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Hylands @ 2011-04-29 20:30 UTC (permalink / raw)
  To: kernelnewbies

Hi Sudheer,

On Thu, Apr 28, 2011 at 3:16 AM, Sudheer Divakaran
<inbox1.sudheer@gmail.com> wrote:
> Hi,
> ?I was going through the file kernel/time.c and found the definition
> of 'gettimeofday' system call as follows.
>
> SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
> ? ? ? ? ? ? ? ?struct timezone __user *, tz) ? <--- NOTE THE COMMA between variable
> types and names.
>
> In syscalls.h I could find the needed macros for expanding the
> definition to its final form i.e.,
>
> asmlinkage long sys_gettimeofday(struct timeval __user * tv, struct
> timezone __user *tz)
>
>
> [syscalls.h macros]
>
> #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
>
>
> #define SYSCALL_DEFINEx(x, sname, ...) ?\
> ? ? ? ?__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
>
>
> #define __SYSCALL_DEFINEx(x, name, ...) \
> ? ? ? ?asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
>
>
> #define __SC_DECL1(t1, a1) ? ? ?t1 a1
> #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__)
>
>
> [Question]
> Note the comma between the variable types and names in the original
> definition ?(e.g., "struct timeval __user *, tv" instead of "struct
> timeval __user *tv").
>
> What is is the reason behind separating variable types and variable
> names using 'comma' and latter removing the comma character using
> _SC_DECLx macros?

Some of the other macros, like SC_CAST1

#define __SC_CAST1(t1, a1)	(t1) a1

need the type to be separated from the argument.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-29 20:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 10:16 question regarding SYSCALL macros Sudheer Divakaran
2011-04-28 12:25 ` Mulyadi Santosa
2011-04-29 20:30 ` Dave Hylands

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).