]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/lxfuxlibc/include/lxfuxlc.h
update
[l4.git] / l4 / pkg / lxfuxlibc / include / lxfuxlc.h
1 /*
2  * (c) 2004-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU Lesser General Public License 2.1.
7  * Please see the COPYING-LGPL-2.1 file for details.
8  */
9
10 /*
11  * Header files for lxfuxlc.c
12  */
13 #ifndef __LXFUXLC_H__
14 #define __LXFUXLC_H__
15
16 #include <l4/sys/compiler.h>
17
18 EXTERN_C_BEGIN
19
20 /* -- sys/time.h -- */
21 struct lx_timeval {
22   long tv_sec;
23   long tv_usec;
24 };
25
26 struct lx_timezone {
27   int  tz_minuteswest;
28   int  tz_dsttime;
29 };
30
31
32 typedef struct {
33   unsigned long fds_bits[(1024/(8 * sizeof(unsigned long)))];
34 } lx_fd_set;
35
36 typedef long unsigned int lx_size_t;
37 typedef long int lx_ssize_t;
38
39 /* -- sys/poll.h */
40
41 typedef unsigned long int lx_nfds_t;
42
43 struct lx_pollfd {
44   int fd;
45   short int events;
46   short int revents;
47 };
48
49 struct lx_iovec {
50   void *iov_base;
51   lx_size_t iov_len;
52 };
53
54 #define LX_POLLIN       0x001
55 #define LX_POLLPRI      0x002
56 #define LX_POLLOUT      0x004
57 #define LX_POLLRDNORM   0x040
58 #define LX_POLLRDBAND   0x080
59 #define LX_POLLWRNORM   0x100
60 #define LX_POLLWRBAND   0x200
61 #define LX_POLLMSG      0x400
62
63 #define LX_POLLERR      0x008
64 #define LX_POLLHUP      0x010
65 #define LX_POLLNVAL     0x020
66
67 /* -- */
68
69 #ifndef NULL
70 #define NULL ((void *)0)
71 #endif
72
73 typedef signed int lx_pid_t;
74
75 /* see asm/stat.h */
76 struct lx_stat {
77         unsigned long  st_dev;
78         unsigned long  st_ino;
79         unsigned short st_mode;
80         unsigned short st_nlink;
81         unsigned short st_uid;
82         unsigned short st_gid;
83         unsigned long  st_rdev;
84         unsigned long  st_size;
85         unsigned long  st_blksize;
86         unsigned long  st_blocks;
87         unsigned long  st_atime_lxfux;
88         unsigned long  st_atime_nsec_lxfux;
89         unsigned long  st_mtime_lxfux;
90         unsigned long  st_mtime_nsec_lxfux;
91         unsigned long  st_ctime_lxfux;
92         unsigned long  st_ctime_nsec_lxfux;
93         unsigned long  __unused4;
94         unsigned long  __unused5;
95 };
96
97 struct lx_stat64 {
98         unsigned long long      st_dev;
99         unsigned char   __pad0[4];
100         unsigned long   __st_ino;
101         unsigned int    st_mode;
102         unsigned int    st_nlink;
103         unsigned long   st_uid;
104         unsigned long   st_gid;
105         unsigned long long      st_rdev;
106         unsigned char   __pad3[4];
107         long long       st_size;
108         unsigned long   st_blksize;
109         unsigned long long      st_blocks;
110         unsigned long   st_atime_lxfux;
111         unsigned long   st_atime_nsec_lxfux;
112         unsigned long   st_mtime_lxfux;
113         unsigned int    st_mtime_nsec_lxfux;
114         unsigned long   st_ctime_lxfux;
115         unsigned long   st_ctime_nsec_lxfux;
116         unsigned long long      st_ino;
117 };
118
119 struct lx_linux_dirent64 {
120         unsigned long long d_ino;
121         signed long long   d_off;
122         unsigned short     d_reclen;
123         unsigned char      d_type;
124         char               d_name[0];
125 };
126
127 /*
128  * socket/net defines
129  */
130 #define LX_SOCK_STREAM 1
131 #define LX_PF_LOCAL    1
132 #define LX_PF_UNIX     LX_PF_LOCAL
133 #define LX_AF_UNIX     LX_PF_LOCAL
134 #define LX_AF_LOCAL    LX_AF_UNIX
135
136 #define LX_SOCKADDR_COMMON_SIZE  (sizeof(unsigned short int))
137
138 struct lx_sockaddr {
139         unsigned short int sa_family;
140         char sa_data[14];
141 };
142
143 struct lx_sockaddr_un {
144         unsigned short int sun_family;
145         char sun_path[108];
146 };
147
148
149 /*
150  * fcntl defines
151  */
152 #define LX_O_RDONLY             00
153 #define LX_O_WRONLY             01
154 #define LX_O_RDWR               02
155 #define LX_O_CREAT            0100 /* not fcntl */
156 #define LX_O_EXCL             0200 /* not fcntl */
157 #define LX_O_NOCTTY           0400 /* not fcntl */
158 #define LX_O_TRUNC           01000 /* not fcntl */
159 #define LX_O_APPEND          02000
160 #define LX_O_NONBLOCK        04000
161 #define LX_O_NDELAY     O_NONBLOCK
162 #define LX_O_SYNC           010000
163 #define LX_FASYNC           020000 /* fcntl, for BSD compatibility */
164 #define LX_O_DIRECT         040000 /* direct disk access hint */
165 #define LX_O_LARGEFILE     0100000
166 #define LX_O_DIRECTORY     0200000 /* must be a directory */
167 #define LX_O_NOFOLLOW      0400000 /* don't follow links */
168
169 #define LX_S_IRUSR           00400
170 #define LX_S_IWUSR           00200
171
172 #define LX_S_IFMT         00170000
173 #define LX_S_IFDIR         0040000
174 #define LX_S_ISDIR(m)      (((m) & LX_S_IFMT) == LX_S_IFDIR)
175
176 /*
177  * Signal numbers
178  */
179
180 #define LX_SIGHUP       1
181 #define LX_SIGINT       2
182 #define LX_SIGQUIT      3
183 #define LX_SIGILL       4
184 #define LX_SIGTRAP      5
185 #define LX_SIGABRT      6
186 #define LX_SIGIOT       6
187 #define LX_SIGBUS       7
188 #define LX_SIGFPE       8
189 #define LX_SIGKILL      9
190 #define LX_SIGUSR1      10
191 #define LX_SIGSEGV      11
192 #define LX_SIGUSR2      12
193 #define LX_SIGPIPE      13
194 #define LX_SIGALRM      14
195 #define LX_SIGTERM      15
196 #define LX_SIGSTKFLT    16
197 #define LX_SIGCHLD      17
198 #define LX_SIGCONT      18
199 #define LX_SIGSTOP      19
200 #define LX_SIGTSTP      20
201 #define LX_SIGTTIN      21
202 #define LX_SIGTTOU      22
203 #define LX_SIGURG       23
204 #define LX_SIGXCPU      24
205 #define LX_SIGXFSZ      25
206 #define LX_SIGVTALRM    26
207 #define LX_SIGPROF      27
208 #define LX_SIGWINCH     28
209 #define LX_SIGIO        29
210 #define LX_SIGPOLL      LX_SIGIO
211 #define LX_SIGPWR       30
212 #define LX_SIGSYS       31
213 #define LX_SIGUNUSED    31
214
215
216 /*
217  * Syscall functions
218  */
219
220 /*   1 */ extern void          lx_exit(int status) __attribute__ ((noreturn));
221 /*   2 */ extern lx_pid_t      lx_fork(void);
222 /*   3 */ extern long          lx_read(unsigned int fd, void *buf, unsigned int count);
223 /*   4 */ extern long          lx_write(unsigned int fd, const void *buf, unsigned int count);
224 /*   5 */ extern long          lx_open(const char *filename, int flags, int mode);
225 /*   6 */ extern long          lx_close(unsigned int fd);
226 /*   7 */ extern lx_pid_t      lx_waitpid(lx_pid_t pid, int * wait_stat, int options);
227 /*  10 */ extern int           lx_unlink(const char *filename);
228 /*  12 */ extern int           lx_chdir(const char *filename);
229 /*  19 */ extern long          lx_lseek(unsigned int fd, unsigned long offset, unsigned int origin);
230 /*  20 */ extern long          lx_getpid(void);
231 /*  37 */ extern int           lx_kill(lx_pid_t pid, int sig);
232 /*  38 */ extern int           lx_rename(const char *oldpath, const char *newpath);
233 /*  39 */ extern int           lx_mkdir(const char *filename, int mode);
234 /*  40 */ extern int           lx_rmdir(const char *filename);
235 /*  42 */ extern int           lx_pipe(int filesdes[2]);
236 /*  54 */ extern long          lx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
237 /*  78 */ extern long          lx_gettimeofday(struct lx_timeval *tv, struct lx_timezone *tz);
238 /*  82 */ extern int           lx_select(int n, lx_fd_set *readfds, lx_fd_set *writefds, lx_fd_set *exceptfds, struct lx_timeval *timeout);
239 /*  93 */ extern int           lx_ftruncate(int fd, unsigned long ofs);
240 /* 102 */ extern int           lx_socketcall(int call, unsigned long *args);
241 /* 106 */ extern int           lx_stat(const char *filename, struct lx_stat *buf);
242 /* 107 */ extern int           lx_lstat(const char *filename, struct lx_stat *buf);
243 /* 108 */ extern int           lx_fstat(int filedes, struct lx_stat *buf);
244 /* 117 */ extern int           lx_ipc(unsigned int call, int first, int second, int third, const void *ptr, long fifth);
245 /* 118 */ extern int           lx_fsync(int fd);
246 /* 145 */ extern lx_ssize_t    lx_readv(int fd, const struct lx_iovec *iov, int cnt);
247 /* 146 */ extern lx_ssize_t    lx_writev(int fd, const struct lx_iovec *iov, int cnt);
248 /* 148 */ extern int           lx_fdatasync(int fd);
249 /* 168 */ extern int           lx_poll(struct lx_pollfd *fds, lx_nfds_t nfds, int timeout);
250 #ifdef __i386__
251 /* 194 */ extern int           lx_ftruncate64(int fd, unsigned long long length);
252 #else
253 /* 194 */ extern int           lx_ftruncate64(int fd, unsigned long length);
254 #endif
255 /* 195 */ extern int           lx_stat64(const char *path, struct lx_stat64 *buf);
256 /* 197 */ extern int           lx_fstat64(int fd, struct lx_stat64 *buf);
257 /* 220 */ extern long          lx_getdents64(int fd, char *buf, unsigned int nbytes);
258 /* 221 */ extern int           lx_fcntl64(int fd, unsigned int cmd, unsigned long arg);
259
260 /* 295 */ extern int           lx_openat(int fd, const char *filename, int flags, int mode);
261 /* 296 */ extern int           lx_mkdirat(int fd, const char *name, int mode);
262 /* 301 */ extern int           lx_unlinkat(int fd, const char *name, int flags);
263 /* 302 */ extern int           lx_renameat(int ofd, const char *oname, int nfd, const char *nname);
264 /* 307 */ extern int           lx_faccessat(int dfd, const char *filename, int mode);
265 /* 333 */ extern lx_ssize_t    lx_preadv(int fd, const struct lx_iovec *iov, int cnt, unsigned long pl, unsigned long ph);
266 /* 334 */ extern lx_ssize_t    lx_pwritev(int fd, const struct lx_iovec *iov, int cnt, unsigned long pl, unsigned long ph);
267 /*
268  * Wrapper functions
269  */
270
271 extern long lx_time(int *tloc);
272 extern unsigned int lx_sleep(unsigned int seconds);
273 extern unsigned int lx_msleep(unsigned int mseconds);
274 extern lx_pid_t lx_wait(int *wait_stat);
275
276 extern void *lx_shmat(int shmid, const void *shmaddr, int shmflg);
277
278 extern int  lx_socket(int family, int type, int protocol);
279 extern int  lx_connect(int sockfd, const struct lx_sockaddr *saddr, unsigned long addrlen);
280
281 extern void lx_outchar(unsigned char c);
282 extern void lx_outdec32(unsigned int i);
283
284 /*
285  * stdio.h
286  */
287
288 #ifndef SEEK_SET
289 #define SEEK_SET 0
290 #define SEEK_CUR 1
291 #define SEEK_END 2
292 #endif
293
294 #ifndef LX_EOF
295 #define LX_EOF (-1)
296 #endif
297
298 typedef struct {
299   int fd;
300   int flags;
301   int taken;
302 } LX_FILE;
303
304 LX_FILE *lx_fopen(const char *filename, const char *mode);
305 LX_FILE *lx_fdopen(int fildes, const char *mode);
306 int lx_fseek(LX_FILE *f, long offset, int whence);
307 lx_size_t lx_fread(void *ptr, lx_size_t size, lx_size_t nmemb, LX_FILE *f);
308 lx_size_t lx_fwrite(const void *ptr, lx_size_t size, lx_size_t nmemb, LX_FILE *f);
309 long lx_ftell(LX_FILE *f);
310 void lx_rewind(LX_FILE *f);
311 int lx_fclose(LX_FILE *f);
312 int lx_fflush(LX_FILE *f);
313 int lx_fputc(int c, LX_FILE *f);
314 int lx_fprintf(LX_FILE *f, const char *format, ...);
315
316
317 #define SHMAT           21
318
319 EXTERN_C_END
320
321 #endif /* __LXFUXLC_H__ */