Cygwin: /proc/<PID>/stat: set field (18) according to scheduling policy
[newlib-cygwin.git] / libgloss / visium / io.h
blob9cb76ea30bfb7bb78226368d46da637095e7e9f8
1 /*
2 * hosted io support.
4 * Copyright (c) 2006 CodeSourcery Inc
6 * The authors hereby grant permission to use, copy, modify, distribute,
7 * and license this software and its documentation for any purpose, provided
8 * that existing copyright notices are retained in all copies and that this
9 * notice is included verbatim in any distributions. No written agreement,
10 * license, or royalty fee is required for any of the authorized uses.
11 * Modifications to this software may be copyrighted by their authors
12 * and need not follow the licensing terms described here, provided that
13 * the new terms are clearly indicated on the first page of each file where
14 * they apply.
17 #include <stdint.h>
18 #include <sys/types.h>
19 #include <sys/time.h>
20 #include <sys/stat.h>
22 #define HOSTED_EXIT 0
23 #define HOSTED_INIT_SIM 1
24 #define HOSTED_OPEN 2
25 #define HOSTED_CLOSE 3
26 #define HOSTED_READ 4
27 #define HOSTED_WRITE 5
28 #define HOSTED_LSEEK 6
29 #define HOSTED_RENAME 7
30 #define HOSTED_UNLINK 8
31 #define HOSTED_STAT 9
32 #define HOSTED_FSTAT 10
33 #define HOSTED_GETTIMEOFDAY 11
34 #define HOSTED_ISATTY 12
35 #define HOSTED_SYSTEM 13
37 /* This function is provided by the board's BSP, because the precise
38 mechanism of informing gdb is board specific. */
39 extern int __io_hosted (int func, void *args);
41 /* Protocol specific representation of datatypes, as specified in D.9.11
42 * of the GDB manual.
43 * Note that since the m68k is big-endian, we can use native
44 * representations of integer datatypes in structured datatypes. */
46 typedef uint32_t gdb_mode_t;
47 typedef uint32_t gdb_time_t;
49 struct gdb_stat {
50 uint32_t st_dev; /* device */
51 uint32_t st_ino; /* inode */
52 gdb_mode_t st_mode; /* protection */
53 uint32_t st_nlink; /* number of hard links */
54 uint32_t st_uid; /* user ID of owner */
55 uint32_t st_gid; /* group ID of owner */
56 uint32_t st_rdev; /* device type (if inode device) */
57 uint64_t st_size; /* total size, in bytes */
58 uint64_t st_blksize; /* blocksize for filesystem I/O */
59 uint64_t st_blocks; /* number of blocks allocated */
60 gdb_time_t st_atim; /* time of last access */
61 gdb_time_t st_mtim; /* time of last modification */
62 gdb_time_t st_ctim; /* time of last change */
65 struct gdb_timeval {
66 gdb_time_t tv_sec; /* second */
67 uint64_t tv_usec; /* microsecond */
71 /* Parameters are passed between the library and the debugging stub
72 * in a fixed-size buffer.
75 typedef uint32_t gdb_parambuf_t[4];
77 /* open flags */
79 #define GDB_O_RDONLY 0x0
80 #define GDB_O_WRONLY 0x1
81 #define GDB_O_RDWR 0x2
82 #define GDB_O_APPEND 0x8
83 #define GDB_O_CREAT 0x200
84 #define GDB_O_TRUNC 0x400
85 #define GDB_O_EXCL 0x800
87 /* mode_t values */
89 #define GDB_S_IFREG 0100000
90 #define GDB_S_IFDIR 040000
91 #define GDB_S_IRUSR 0400
92 #define GDB_S_IWUSR 0200
93 #define GDB_S_IXUSR 0100
94 #define GDB_S_IRGRP 040
95 #define GDB_S_IWGRP 020
96 #define GDB_S_IXGRP 010
97 #define GDB_S_IROTH 04
98 #define GDB_S_IWOTH 02
99 #define GDB_S_IXOTH 01
101 /* errno values */
103 #define GDB_EPERM 1
104 #define GDB_ENOENT 2
105 #define GDB_EINTR 4
106 #define GDB_EBADF 9
107 #define GDB_EACCES 13
108 #define GDB_EFAULT 14
109 #define GDB_EBUSY 16
110 #define GDB_EEXIST 17
111 #define GDB_ENODEV 19
112 #define GDB_ENOTDIR 20
113 #define GDB_EISDIR 21
114 #define GDB_EINVAL 22
115 #define GDB_ENFILE 23
116 #define GDB_EMFILE 24
117 #define GDB_EFBIG 27
118 #define GDB_ENOSPC 28
119 #define GDB_ESPIPE 29
120 #define GDB_EROFS 30
121 #define GDB_ENAMETOOLONG 91
122 #define GDB_EUNKNOWN 9999
124 /* lseek flags */
126 #define GDB_SEEK_SET 0
127 #define GDB_SEEK_CUR 1
128 #define GDB_SEEK_END 2
131 /* conversion functions */
133 extern gdb_mode_t __hosted_to_gdb_mode_t (mode_t m);
134 extern int32_t __hosted_to_gdb_open_flags (int f);
135 extern int32_t __hosted_to_gdb_lseek_flags (int f);
137 extern void __hosted_from_gdb_stat (const struct gdb_stat *gs,
138 struct stat *s);
139 extern void __hosted_from_gdb_timeval (const struct gdb_timeval *gt,
140 struct timeval *t);
141 extern int __hosted_from_gdb_errno (int32_t err);