OSDN Git Service

1fcb8ff86800445246211b36be1690205236c6e6
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / shared_info.h
1 /* shared_info.h: shared info for cygwin
2
3    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #include "tty.h"
12 #include "security.h"
13 #include "mtinfo.h"
14 #include "limits.h"
15 #include "mount.h"
16
17 class user_info
18 {
19 public:
20   DWORD version;
21   DWORD cb;
22   bool warned_msdos;
23   mount_info mountinfo;
24 };
25 /******** Shared Info ********/
26 /* Data accessible to all tasks */
27
28 #define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
29                                   cygwin_version.api_minor)
30 #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
31
32 #define SHARED_INFO_CB 31136
33
34 #define CURR_SHARED_MAGIC 0x18da899eU
35
36 #define USER_VERSION    1       // increment when mount table changes and
37 #define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION)
38 #define CURR_USER_MAGIC 0xb2232e71U
39
40 /* NOTE: Do not make gratuitous changes to the names or organization of the
41    below class.  The layout is checksummed to determine compatibility between
42    different cygwin versions. */
43 class shared_info
44 {
45   DWORD version;
46   DWORD cb;
47  public:
48   unsigned heap_chunk;
49   bool heap_slop_inited;
50   unsigned heap_slop;
51   DWORD sys_mount_table_counter;
52   tty_list tty;
53   LONG last_used_bindresvport;
54   DWORD obcaseinsensitive;
55   mtinfo mt;
56
57   void initialize ();
58   void init_obcaseinsensitive ();
59   unsigned heap_chunk_size ();
60   unsigned heap_slop_size ();
61 };
62
63 extern shared_info *cygwin_shared;
64 extern user_info *user_shared;
65 #define mount_table (&(user_shared->mountinfo))
66 extern HANDLE cygwin_user_h;
67
68 enum shared_locations
69 {
70   SH_CYGWIN_SHARED,
71   SH_USER_SHARED,
72   SH_SHARED_CONSOLE,
73   SH_MYSELF,
74   SH_TOTAL_SIZE,
75   SH_JUSTCREATE,
76   SH_JUSTOPEN
77
78 };
79
80 void memory_init (bool) __attribute__ ((regparm(1)));
81 void __stdcall shared_destroy ();
82
83 #define shared_align_past(p) \
84   ((char *) (system_info.dwAllocationGranularity * \
85              (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
86               system_info.dwAllocationGranularity)))
87
88 #ifdef _FHANDLER_H_
89 struct console_state
90 {
91   tty_min tty_min_state;
92   dev_console dev_state;
93 };
94 #endif
95
96 HANDLE get_shared_parent_dir ();
97 HANDLE get_session_parent_dir ();
98 char *__stdcall shared_name (char *, const char *, int);
99 WCHAR *__stdcall shared_name (WCHAR *, const WCHAR *, int);
100 void *__stdcall open_shared (const WCHAR *name, int n, HANDLE &shared_h,
101                              DWORD size, shared_locations&,
102                              PSECURITY_ATTRIBUTES psa = &sec_all,
103                              DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);
104 extern void user_shared_create (bool reinit);
105 extern void user_shared_initialize ();
106 extern void init_installation_root ();
107 extern WCHAR installation_root[PATH_MAX];
108 extern UNICODE_STRING installation_key;