Indentation fix, cleanup.
[AROS.git] / arch / all-unix / filesys / emul_handler / emul_unix.h
blob8d09471dac669e9e8e260131bae869c32fd1d01d
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifdef HOST_LONG_ALIGNED
7 #pragma pack(4)
8 #endif
10 #include <sys/stat.h>
11 #include <sys/time.h>
12 #include <dirent.h>
13 #include <poll.h>
14 #include <pwd.h>
15 #include <time.h>
16 #include <utime.h>
18 #ifdef HOST_OS_linux
19 #include <sys/vfs.h>
20 #else
21 #include <sys/mount.h>
22 #endif
24 /* Android is not a true Linux ;-) */
25 #ifdef HOST_OS_android
26 #undef HOST_OS_linux
27 #endif
29 #pragma pack()
31 struct LibCInterface
33 int (*open)(char *path, int oflag, ...);
34 int (*close)(int filedes);
35 int (*closedir)(DIR *dirp);
36 DIR *(*opendir)(char *dirname);
37 struct dirent *(*readdir)(DIR *dirp);
38 void (*rewinddir)(DIR *dirp);
39 ssize_t (*read)(int fildes, void *buf, size_t nbyte);
40 ssize_t (*write)(int fildes, const void *buf, size_t nbyte);
41 #ifdef HOST_LONG_ALIGNED
42 off_t (*lseek)(int fildes, unsigned long offset_l, unsigned long offset_h, int whence);
43 int (*ftruncate)(int fildes, unsigned long length_l, unsigned long length_h);
44 #else
45 off_t (*lseek)(int fildes, off_t offset, int whence);
46 int (*ftruncate)(int fildes, off_t length);
47 #endif
48 int (*mkdir)(char *path, mode_t mode);
49 int (*rmdir)(const char *path);
50 int (*unlink)(const char *path);
51 int (*link)(char *path1, char *path2);
52 int (*symlink)(char *path1, char *path2);
53 ssize_t (*readlink)(char *path, char *buf, size_t bufsize);
54 int (*rename)(char *old, char *new);
55 int (*chmod)(char *path, mode_t mode);
56 int (*isatty)(int fildes);
57 int (*statfs)(char *path, struct statfs *buf);
58 int (*utime)(char *path, const struct utimbuf *times);
59 struct tm *(*localtime)(const time_t *clock);
60 time_t (*mktime)(struct tm *timeptr);
61 char *(*getcwd)(char *buf, size_t size);
62 char *(*getenv)(const char *name);
63 int (*poll)(struct pollfd *fds, nfds_t nfds, int timeout);
64 #ifdef HOST_OS_linux
65 int (*__xstat)(int ver, char *path, struct stat *buf);
66 int (*__lxstat)(int ver, const char *path, struct stat *buf);
67 int (*__fxstat)(int ver, const int fd, struct stat *buf);
68 #define stat(path, buf) __xstat(_STAT_VER, path, buf)
69 #define lstat(path, buf) __lxstat(_STAT_VER, path, buf)
70 #define fstat(fd, buf) __fxstat(_STAT_VER, fd, buf)
71 #else
72 int (*stat)(char *path, struct stat *buf);
73 int (*lstat)(const char *path, struct stat *buf);
74 int (*fstat)(int fd, struct stat *buf);
75 #endif
76 #ifndef HOST_OS_android
77 void (*seekdir)(DIR *dirp, long loc);
78 long (*telldir)(DIR *dirp);
79 struct passwd *(*getpwent)(void);
80 void (*endpwent)(void);
81 #endif
84 #ifdef HOST_LONG_ALIGNED
86 * Somewhat dirty hack to adjust data packing to iOS ARM ABI.
87 * Perhaps this can be done in a cleaner and more CPU-abstract way.
88 * FIXME: Always assuming little-endian CPU
90 #define LSeek(fildes, offset, whence) emulbase->pdata.SysIFace->lseek(fildes, (ULONG)offset, (ULONG)((UQUAD)offset >> 32), whence)
91 #define FTruncate(fildes, length) emulbase->pdata.SysIFace->ftruncate(fildes, (ULONG)length, (ULONG)((UQUAD)length >> 32))
92 #else
93 #define LSeek(fildes, offset, whence) emulbase->pdata.SysIFace->lseek(fildes, offset, whence)
94 #define FTruncate(fildes, length) emulbase->pdata.SysIFace->ftruncate(fildes, length)
95 #endif