source: trunk/libs/newlib/src/libgloss/cris/linunistd.h @ 646

Last change on this file since 646 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 13.2 KB
Line 
1/* Support for syscalls for cris*-axis-linux-gnu and simulators
2   Copyright (C) 1998-2005 Axis Communications.
3   All rights reserved.
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. Neither the name of Axis Communications nor the names of its
13      contributors may be used to endorse or promote products derived
14      from this software without specific prior written permission.
15
16   THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
17   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
20   COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27   POSSIBILITY OF SUCH DAMAGE.  */
28
29/* Derived from asm-etrax100/unistd.h with minor modifications to fit as
30   LOSS for newlib.  */
31
32#ifndef _ASM_ELINUX_UNISTD_H_
33#define _ASM_ELINUX_UNISTD_H_
34
35/* Our callers might want to use link_warning, so provide it from here.  */
36#include "../libnosys/config.h"
37#include "libnosys/warning.h"
38
39#include <errno.h>
40
41/*
42 * This file contains the system call numbers, and stub macros for libc.
43 */
44
45#define __NR_setup                0     /* used only by init, to get system going */
46#define __NR_exit                 1
47#define __NR_fork                 2
48#define __NR_read                 3
49#define __NR_write                4
50#define __NR_open                 5
51#define __NR_close                6
52#define __NR_waitpid              7
53#define __NR_creat                8
54#define __NR_link                 9
55#define __NR_unlink              10
56#define __NR_execve              11
57#define __NR_chdir               12
58#define __NR_time                13
59#define __NR_mknod               14
60#define __NR_chmod               15
61#define __NR_chown               16
62#define __NR_break               17
63#define __NR_oldstat             18
64#define __NR_lseek               19
65#define __NR_getpid              20
66#define __NR_mount               21
67#define __NR_umount              22
68#define __NR_setuid              23
69#define __NR_getuid              24
70#define __NR_stime               25
71#define __NR_ptrace              26
72#define __NR_alarm               27
73#define __NR_oldfstat            28
74#define __NR_pause               29
75#define __NR_utime               30
76#define __NR_stty                31
77#define __NR_gtty                32
78#define __NR_access              33
79#define __NR_nice                34
80#define __NR_ftime               35
81#define __NR_sync                36
82#define __NR_kill                37
83#define __NR_rename              38
84#define __NR_mkdir               39
85#define __NR_rmdir               40
86#define __NR_dup                 41
87#define __NR_pipe                42
88#define __NR_times               43
89#define __NR_prof                44
90#define __NR_brk                 45
91#define __NR_setgid              46
92#define __NR_getgid              47
93#define __NR_signal              48
94#define __NR_geteuid             49
95#define __NR_getegid             50
96#define __NR_acct                51
97#define __NR_phys                52
98#define __NR_lock                53
99#define __NR_ioctl               54
100#define __NR_fcntl               55
101#define __NR_mpx                 56
102#define __NR_setpgid             57
103#define __NR_ulimit              58
104#define __NR_oldolduname         59
105#define __NR_umask               60
106#define __NR_chroot              61
107#define __NR_ustat               62
108#define __NR_dup2                63
109#define __NR_getppid             64
110#define __NR_getpgrp             65
111#define __NR_setsid              66
112#define __NR_sigaction           67
113#define __NR_sgetmask            68
114#define __NR_ssetmask            69
115#define __NR_setreuid            70
116#define __NR_setregid            71
117#define __NR_sigsuspend          72
118#define __NR_sigpending          73
119#define __NR_sethostname         74
120#define __NR_setrlimit           75
121#define __NR_getrlimit           76
122#define __NR_getrusage           77
123#define __NR_gettimeofday        78
124#define __NR_settimeofday        79
125#define __NR_getgroups           80
126#define __NR_setgroups           81
127#define __NR_select              82
128#define __NR_symlink             83
129#define __NR_oldlstat            84
130#define __NR_readlink            85
131#define __NR_uselib              86
132#define __NR_swapon              87
133#define __NR_reboot              88
134#define __NR_readdir             89
135#define __NR_mmap                90
136#define __NR_munmap              91
137#define __NR_truncate            92
138#define __NR_ftruncate           93
139#define __NR_fchmod              94
140#define __NR_fchown              95
141#define __NR_getpriority         96
142#define __NR_setpriority         97
143#define __NR_profil              98
144#define __NR_statfs              99
145#define __NR_fstatfs            100
146#define __NR_ioperm             101
147#define __NR_socketcall         102
148#define __NR_syslog             103
149#define __NR_setitimer          104
150#define __NR_getitimer          105
151#define __NR_stat               106
152#define __NR_lstat              107
153#define __NR_fstat              108
154#define __NR_olduname           109
155#define __NR_iopl               110
156#define __NR_vhangup            111
157#define __NR_idle               112
158#define __NR_vm86               113
159#define __NR_wait4              114
160#define __NR_swapoff            115
161#define __NR_sysinfo            116
162#define __NR_ipc                117
163#define __NR_fsync              118
164#define __NR_sigreturn          119
165#define __NR_clone              120
166#define __NR_setdomainname      121
167#define __NR_uname              122
168#define __NR_modify_ldt         123
169#define __NR_adjtimex           124
170#define __NR_mprotect           125
171#define __NR_sigprocmask        126
172#define __NR_create_module      127
173#define __NR_init_module        128
174#define __NR_delete_module      129
175#define __NR_get_kernel_syms    130
176#define __NR_quotactl           131
177#define __NR_getpgid            132
178#define __NR_fchdir             133
179#define __NR_bdflush            134
180#define __NR_sysfs              135
181#define __NR_personality        136
182#define __NR_afs_syscall        137 /* Syscall for Andrew File System */
183#define __NR_setfsuid           138
184#define __NR_setfsgid           139
185#define __NR__llseek            140
186#define __NR_getdents           141
187#define __NR__newselect         142
188#define __NR_flock              143
189#define __NR_msync              144
190#define __NR_readv              145
191#define __NR_writev             146
192#define __NR_getsid             147
193#define __NR_fdatasync          148
194#define __NR__sysctl            149
195#define __NR_mlock              150
196#define __NR_munlock            151
197#define __NR_mlockall           152
198#define __NR_munlockall         153
199#define __NR_sched_setparam             154
200#define __NR_sched_getparam             155
201#define __NR_sched_setscheduler         156
202#define __NR_sched_getscheduler         157
203#define __NR_sched_yield                158
204#define __NR_sched_get_priority_max     159
205#define __NR_sched_get_priority_min     160
206#define __NR_sched_rr_get_interval      161
207#define __NR_nanosleep          162
208#define __NR_mremap             163
209
210#define __NR_mmap2              192
211
212#define PASTE(x,y) x##y
213#define XSTR(x) # x
214#define STR(x) XSTR (x)
215
216#ifdef __elinux__
217# define CRIS_SYSCALL "jir .$System.call"
218# define CALLNO_REG r1
219# define ARG5_REG r0
220# define MOVE_ARG5 "move.d"
221# define COLON_ARG5_CLOBBER : "r0"
222#else
223# define CRIS_SYSCALL "break 13"
224# define CALLNO_REG r9
225# define ARG5_REG srp
226# define MOVE_ARG5 "move"
227# define COLON_ARG5_CLOBBER
228#endif
229
230/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
231#define _syscall0(type,name) \
232type PASTE(_Sys_,name) (void) \
233{ \
234  register long __a __asm__ ("r10"); \
235  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
236  __asm__ __volatile__ (CRIS_SYSCALL \
237                        : "=r" (__a) \
238                        : "r" (__n_)); \
239  if (__a >= 0) \
240     return (type) __a; \
241  errno = -__a; \
242  return -1; \
243}
244
245#define _syscall1(type,name,type1,arg1) \
246type PASTE(_Sys_,name) (type1 arg1) \
247{ \
248  register long __a __asm__ ("r10") = (long) arg1; \
249  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
250  __asm__ __volatile__ (CRIS_SYSCALL \
251                        : "=r" (__a) \
252                        : "r" (__n_), "0" (__a)); \
253  if (__a >= 0) \
254     return (type) __a; \
255  errno = -__a; \
256  return -1; \
257}
258
259#define _syscall2(type,name,type1,arg1,type2,arg2) \
260type PASTE(_Sys_,name) (type1 arg1,type2 arg2) \
261{ \
262  register long __a __asm__ ("r10") = (long) arg1; \
263  register long __b __asm__ ("r11") = (long) arg2; \
264  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
265  __asm__ __volatile__ (CRIS_SYSCALL \
266                        : "=r" (__a) \
267                        : "r" (__n_), "0" (__a), "r" (__b)); \
268  if (__a >= 0) \
269     return (type) __a; \
270  errno = -__a; \
271  return -1; \
272}
273
274#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
275type PASTE(_Sys_,name) (type1 arg1,type2 arg2,type3 arg3) \
276{ \
277  register long __a __asm__ ("r10") = (long) arg1; \
278  register long __b __asm__ ("r11") = (long) arg2; \
279  register long __c __asm__ ("r12") = (long) arg3; \
280  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
281  __asm__ __volatile__ (CRIS_SYSCALL \
282                        : "=r" (__a) \
283                        : "r" (__n_), "0" (__a), "r" (__b), "r" (__c)); \
284  if (__a >= 0) \
285     return (type) __a; \
286  errno = -__a; \
287  return -1; \
288}
289
290#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
291type PASTE(_Sys_,name) (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
292{ \
293  register long __a __asm__ ("r10") = (long) arg1; \
294  register long __b __asm__ ("r11") = (long) arg2; \
295  register long __c __asm__ ("r12") = (long) arg3; \
296  register long __d __asm__ ("r13") = (long) arg4; \
297  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
298  __asm__ __volatile__ (CRIS_SYSCALL \
299                        : "=r" (__a) \
300                        : "r" (__n_), "0" (__a), "r" (__b), \
301                          "r" (__c), "r" (__d)); \
302  if (__a >= 0) \
303     return (type) __a; \
304  errno = -__a; \
305  return -1; \
306}
307
308#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
309          type5,arg5) \
310type PASTE(_Sys_,name) (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
311{ \
312  register long __a __asm__ ("r10") = (long) arg1; \
313  register long __b __asm__ ("r11") = (long) arg2; \
314  register long __c __asm__ ("r12") = (long) arg3; \
315  register long __d __asm__ ("r13") = (long) arg4; \
316  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
317  __asm__ __volatile__ (MOVE_ARG5 " %6,$" STR (ARG5_REG) "\n\t" \
318                        CRIS_SYSCALL \
319                        : "=r" (__a) \
320                        : "r" (__n_), "0" (__a), "r" (__b), \
321                          "r" (__c), "r" (__d), "g" (arg5) \
322                        COLON_ARG5_CLOBBER); \
323  if (__a >= 0) \
324     return (type) __a; \
325  errno = -__a; \
326  return -1; \
327}
328
329#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
330          type5,arg5,type6,arg6) \
331type PASTE(_Sys_,name) (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
332{ \
333  register long __a __asm__ ("r10") = (long) arg1; \
334  register long __b __asm__ ("r11") = (long) arg2; \
335  register long __c __asm__ ("r12") = (long) arg3; \
336  register long __d __asm__ ("r13") = (long) arg4; \
337  register long __n_ __asm__ (STR (CALLNO_REG)) = (__NR_##name); \
338  __asm__ __volatile__ (MOVE_ARG5 " %6,$" STR (ARG5_REG) "\n\t" \
339                        "move %7,$mof\n\t" \
340                        CRIS_SYSCALL \
341                        : "=r" (__a) \
342                        : "r" (__n_), "0" (__a), "r" (__b), \
343                          "r" (__c), "r" (__d), "g" (arg5), "g" (arg6) \
344                        COLON_ARG5_CLOBBER); \
345  if (__a >= 0) \
346     return (type) __a; \
347  errno = -__a; \
348  return -1; \
349}
350
351#define __NR__exit __NR_exit
352static inline _syscall0(int,idle)
353static inline _syscall0(int,fork)
354static inline _syscall2(int,clone,unsigned long,flags,char *,esp)
355static inline _syscall0(int,pause)
356static inline _syscall0(int,setup)
357static inline _syscall0(int,sync)
358static inline _syscall3(int,write,int,fd,const char *,buf,unsigned,count)
359static inline _syscall1(int,dup,int,fd)
360static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
361static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
362static inline _syscall1(int,close,int,fd)
363static inline _syscall1(int,_exit,int,exitcode)
364static inline _syscall1(int,exit,int,exitcode)
365static inline _syscall3(int,waitpid,int,pid,int *,wait_stat,int,options)
366static inline _syscall3(int,read,int,fd,char *,buf,unsigned,count)
367static inline _syscall2(int,socketcall,int,call,unsigned long *,args)
368static inline _syscall3(int,ioctl,unsigned int,fd,unsigned int,cmd,unsigned long,arg)
369static inline _syscall3(int,fcntl,unsigned int,fd,unsigned int,cmd,unsigned long,arg)
370static inline _syscall5(int,mount,const char *,a,const char *,b,const char *,c,unsigned long,rwflag,const void *,data)
371static inline _syscall2(int,rename,const char *,a,const char*,b)
372
373#ifndef __elinux__
374/* Make sure these are only used where they are supported.  */
375static inline _syscall6(int,mmap2,unsigned long, addr, unsigned long, len,
376                        unsigned long, prot, unsigned long, flags,
377                        unsigned long, fd, unsigned long, pgoff)
378static inline _syscall1(long,brk,long,addr)
379#endif
380
381/* This structure is ripped from asm-etrax100/stat.h: beware of updates.  */
382struct new_stat {
383        unsigned short st_dev;
384        unsigned short __pad1;
385        unsigned long st_ino;
386        unsigned short st_mode;
387        unsigned short st_nlink;
388        unsigned short st_uid;
389        unsigned short st_gid;
390        unsigned short st_rdev;
391        unsigned short __pad2;
392        unsigned long  st_size;
393        unsigned long  st_blksize;
394        unsigned long  st_blocks;
395        unsigned long  st_atime;
396        unsigned long  __unused1;
397        unsigned long  st_mtime;
398        unsigned long  __unused2;
399        unsigned long  st_ctime;
400        unsigned long  __unused3;
401        unsigned long  __unused4;
402        unsigned long  __unused5;
403};
404
405static inline _syscall2(int,stat,const char *,path,struct new_stat *,statbuf)
406static inline _syscall2(int,fstat,int,fd,struct new_stat *,statbuf)
407static inline _syscall0(int,getpid)
408static inline _syscall2(int,kill,int,pid,int,sig)
409static inline _syscall3(int,lseek,int,fd,int,offset,int,whence)
410struct tms;
411static inline _syscall1(long,times,struct tms *,tbuf)
412static inline _syscall1(long,mmap,long *, buf)
413struct timeval;
414struct timezone;
415static inline _syscall2(int,gettimeofday,struct timeval *,tp,
416                        void *, tzp)
417static inline _syscall2(int,link,const char *,old,const char *,new)
418static inline _syscall1(int,unlink,const char *, f)
419struct rusage;
420static inline _syscall4(int,wait4,int,pid,int *,sa,int,op,struct rusage *,ru)
421#endif /* _ASM_ELINUX_UNISTD_H_ */
Note: See TracBrowser for help on using the repository browser.