OSDN Git Service

* include/sys/cygwin.h: Protect class definitions.
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / include / sys / cygwin.h
1 #ifndef _SYS_CYGWIN_H
2 #define _SYS_CYGWIN_H
3
4 #include <sys/types.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 extern pid_t cygwin32_winpid_to_pid (int);
11 extern void cygwin32_win32_to_posix_path_list (const char *, char *);
12 extern int cygwin32_win32_to_posix_path_list_buf_size (const char *);
13 extern void cygwin32_posix_to_win32_path_list (const char *, char *);
14 extern int cygwin32_posix_to_win32_path_list_buf_size (const char *);
15 extern int cygwin32_conv_to_win32_path (const char *, char *);
16 extern int cygwin32_conv_to_full_win32_path (const char *, char *);
17 extern void cygwin32_conv_to_posix_path (const char *, char *);
18 extern void cygwin32_conv_to_full_posix_path (const char *, char *);
19 extern int cygwin32_posix_path_list_p (const char *);
20 extern void cygwin32_split_path (const char *, char *, char *);
21
22 extern pid_t cygwin_winpid_to_pid (int);
23 extern int cygwin_win32_to_posix_path_list (const char *, char *);
24 extern int cygwin_win32_to_posix_path_list_buf_size (const char *);
25 extern int cygwin_posix_to_win32_path_list (const char *, char *);
26 extern int cygwin_posix_to_win32_path_list_buf_size (const char *);
27 extern int cygwin_conv_to_win32_path (const char *, char *);
28 extern int cygwin_conv_to_full_win32_path (const char *, char *);
29 extern int cygwin_conv_to_posix_path (const char *, char *);
30 extern int cygwin_conv_to_full_posix_path (const char *, char *);
31 extern int cygwin_posix_path_list_p (const char *);
32 extern void cygwin_split_path (const char *, char *, char *);
33
34 extern void cygwin_premain0 (int argc, char **argv);
35 extern void cygwin_premain1 (int argc, char **argv);
36 extern void cygwin_premain2 (int argc, char **argv);
37 extern void cygwin_premain3 (int argc, char **argv);
38
39 struct __cygwin_perfile
40 {
41   char *name;
42   unsigned flags;
43 };
44
45 #ifdef _PATH_PASSWD
46 extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
47 #endif
48
49 /* External interface stuff */
50
51 typedef enum
52   {
53     CW_LOCK_PINFO,
54     CW_UNLOCK_PINFO,
55     CW_GETTHREADNAME,
56     CW_GETPINFO,
57     CW_SETPINFO,
58     CW_SETTHREADNAME,
59     CW_GETVERSIONINFO,
60     CW_READ_V1_MOUNT_TABLES,
61     CW_USER_DATA,
62     CW_PERFILE,
63     CW_GET_CYGDRIVE_PREFIXES,
64     CW_GETPINFO_FULL
65   } cygwin_getinfo_types;
66
67 #define CW_NEXTPID 0x80000000   // or with pid to get next one
68
69 /* Flags associated with process_state */
70 enum
71 {
72   PID_NOT_IN_USE       = 0x0000, // Free entry.
73   PID_IN_USE           = 0x0001, // Entry in use.
74   PID_ZOMBIE           = 0x0002, // Child exited: no parent wait.
75   PID_STOPPED          = 0x0004, // Waiting for SIGCONT.
76   PID_TTYIN            = 0x0008, // Waiting for terminal input.
77   PID_TTYOU            = 0x0010, // Waiting for terminal output.
78   PID_ORPHANED         = 0x0020, // Member of an orphaned process group.
79   PID_ACTIVE           = 0x0040, // Pid accepts signals.
80   PID_CYGPARENT        = 0x0080, // Set if parent was a cygwin app.
81   PID_SPLIT_HEAP       = 0x0100, // Set if the heap has been split,
82                                  //  which means we can't fork again.
83   PID_CLEAR            = 0x0200, // Flag that pid should be cleared from parent's
84                                  //  wait list
85   PID_SOCKETS_USED     = 0x0400, // Set if process uses Winsock.
86   PID_INITIALIZING     = 0x0800, // Set until ready to receive signals.
87   PID_USETTY           = 0x1000, // Setting this enables or disables cygwin's
88                                  //  tty support.  This is inherited by
89                                  //  all execed or forked processes.
90   PID_REPARENT         = 0x2000, // child has execed
91   PID_EXECED           = 0x4000, // redirect to original pid info block
92   PID_NOREDIR          = 0x8000  // don't redirect if execed
93 };
94
95 #ifdef WINVER
96 /* This lives in the app and is initialized before jumping into the DLL.
97    It should only contain stuff which the user's process needs to see, or
98    which is needed before the user pointer is initialized, or is needed to
99    carry inheritance information from parent to child.  Note that it cannot
100    be used to carry inheritance information across exec!
101
102    Remember, this structure is linked into the application's executable.
103    Changes to this can invalidate existing executables, so we go to extra
104    lengths to avoid having to do it.
105
106    When adding/deleting members, remember to adjust {public,internal}_reserved.
107    The size of the class shouldn't change [unless you really are prepared to
108    invalidate all existing executables].  The program does a check (using
109    SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
110 */
111
112 #ifdef __cplusplus
113 class ResourceLocks;
114 class MTinterface;
115 #endif
116
117 struct per_process
118 {
119   char *initial_sp;
120
121   /* The offset of these 3 values can never change. */
122   /* magic_biscuit is the size of this class and should never change. */
123   unsigned long magic_biscuit;
124   unsigned long dll_major;
125   unsigned long dll_minor;
126
127   struct _reent **impure_ptr_ptr;
128   char ***envptr;
129
130   /* Used to point to the memory machine we should use.  Usually these
131      point back into the dll, but they can be overridden by the user. */
132   void *(*malloc)(size_t);
133   void (*free)(void *);
134   void *(*realloc)(void *, size_t);
135
136   int *fmode_ptr;
137
138   int (*main)(int, char **, char **);
139   void (**ctors)(void);
140   void (**dtors)(void);
141
142   /* For fork */
143   void *data_start;
144   void *data_end;
145   void *bss_start;
146   void *bss_end;
147
148   void *(*calloc)(size_t, size_t);
149   /* For future expansion of values set by the app. */
150   void (*premain[4]) (int, char **);
151
152   /* The rest are *internal* to cygwin.dll.
153      Those that are here because we want the child to inherit the value from
154      the parent (which happens when bss is copied) are marked as such. */
155
156   /* non-zero of ctors have been run.  Inherited from parent. */
157   int run_ctors_p;
158
159   DWORD unused[3];
160
161   /* Heap management.  Inherited from parent. */
162   void *heapbase;               /* bottom of the heap */
163   void *heapptr;                /* current index into heap */
164   void *heaptop;                /* current top of heap */
165
166   DWORD unused1;                /* unused */
167
168   /* Non-zero means the task was forked.  The value is the pid.
169      Inherited from parent. */
170   int forkee;
171
172   HMODULE hmodule;
173
174   DWORD api_major;              /* API version that this program was */
175   DWORD api_minor;              /*  linked with */
176   /* For future expansion, so apps won't have to be relinked if we
177      add an item. */
178   DWORD unused2[5];
179
180 #ifdef __INSIDE_CYGWIN__
181   ResourceLocks *resourcelocks;
182   MTinterface *threadinterface;
183 #else
184   void *resourcelocks;
185   void *threadinterface;
186 #endif
187   struct _reent *impure_ptr;
188 };
189 #define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->resourcelocks))
190
191 extern void cygwin_set_impersonation_token (const HANDLE);
192
193 /* included if <windows.h> is included */
194 extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
195 extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
196
197 #include <sys/resource.h>
198
199 struct external_pinfo
200   {
201   pid_t pid;
202   pid_t ppid;
203   HANDLE hProcess;
204   DWORD dwProcessId, dwSpawnedProcessId;
205   uid_t uid;
206   gid_t gid;
207   pid_t pgid;
208   pid_t sid;
209   int ctty;
210   mode_t umask;
211
212   long start_time;
213   struct rusage rusage_self;
214   struct rusage rusage_children;
215
216   char progname[MAX_PATH];
217
218   DWORD strace_mask;
219   HANDLE strace_file;
220
221   DWORD process_state;
222 };
223
224 DWORD cygwin_internal (cygwin_getinfo_types, ...);
225 #endif /*WINVER*/
226
227 #ifdef __cplusplus
228 };
229 #endif
230
231 #endif /* _SYS_CYGWIN_H */