1_SYSCALL(2)                Linux Programmer's Manual               _SYSCALL(2)
2
3
4

NAME

6       _syscall - invoking a system call without library support (OBSOLETE)
7

SYNOPSIS

9       #include <linux/unistd.h>
10
11       A _syscall macro
12
13       desired system call
14

DESCRIPTION

16       The  important thing to know about a system call is its prototype.  You
17       need to know how many arguments, their types, and the  function  return
18       type.  There are seven macros that make the actual call into the system
19       easier.  They have the form:
20
21              _syscallX(type,name,type1,arg1,type2,arg2,...)
22
23       where
24
25              X is 0–6, which are the number of arguments taken by the  system
26              call
27
28              type is the return type of the system call
29
30              name is the name of the system call
31
32              typeN is the Nth argument's type
33
34              argN is the name of the Nth argument
35
36       These macros create a function called name with the arguments you spec‐
37       ify.  Once you include the _syscall() in your source file, you call the
38       system call by name.
39

FILES

41       /usr/include/linux/unistd.h
42

CONFORMING TO

44       The use of these macros is Linux-specific, and deprecated.
45

NOTES

47       Starting  around  kernel  2.6.18, the _syscall macros were removed from
48       header files supplied to user space.  Use  syscall(2)  instead.   (Some
49       architectures,  notably  ia64,  never  provided the _syscall macros; on
50       those architectures, syscall(2) was always required.)
51
52       The _syscall() macros do not produce a prototype.  You may have to cre‐
53       ate one, especially for C++ users.
54
55       System calls are not required to return only positive or negative error
56       codes.  You need to read the source to  be  sure  how  it  will  return
57       errors.   Usually,  it  is  the  negative of a standard error code, for
58       example, -EPERM.  The _syscall() macros will return the result r of the
59       system  call  when  r  is  non-negative, but will return -1 and set the
60       variable errno to -r when r is negative.   For  the  error  codes,  see
61       errno(3).
62
63       When defining a system call, the argument types must be passed by-value
64       or by-pointer (for aggregates like structs).
65

EXAMPLE

67       #include <stdio.h>
68       #include <stdlib.h>
69       #include <errno.h>
70       #include <linux/unistd.h>       /* for _syscallX macros/related stuff */
71       #include <linux/kernel.h>       /* for struct sysinfo */
72
73       _syscall1(int, sysinfo, struct sysinfo *, info);
74
75       /* Note: if you copy directly from the nroff source, remember to
76       REMOVE the extra backslashes in the printf statement. */
77
78       int
79       main(void)
80       {
81           struct sysinfo s_info;
82           int error;
83
84           error = sysinfo(&s_info);
85           printf("code error = %d\n", error);
86           printf("Uptime = %lds\nLoad: 1 min %lu / 5 min %lu / 15 min %lu\n"
87                  "RAM: total %lu / free %lu / shared %lu\n"
88                  "Memory in buffers = %lu\nSwap: total %lu / free %lu\n"
89                  "Number of processes = %d\n",
90                  s_info.uptime, s_info.loads[0],
91                  s_info.loads[1], s_info.loads[2],
92                  s_info.totalram, s_info.freeram,
93                  s_info.sharedram, s_info.bufferram,
94                  s_info.totalswap, s_info.freeswap,
95                  s_info.procs);
96           exit(EXIT_SUCCESS);
97       }
98
99   Sample Output
100       code error = 0
101       uptime = 502034s
102       Load: 1 min 13376 / 5 min 5504 / 15 min 1152
103       RAM: total 15343616 / free 827392 / shared 8237056
104       Memory in buffers = 5066752
105       Swap: total 27881472 / free 24698880
106       Number of processes = 40
107

SEE ALSO

109       intro(2), syscall(2), errno(3)
110

COLOPHON

112       This page is part of release 3.22 of the Linux  man-pages  project.   A
113       description  of  the project, and information about reporting bugs, can
114       be found at http://www.kernel.org/doc/man-pages/.
115
116
117
118Linux                             2007-12-19                       _SYSCALL(2)
Impressum