newlib/winsup/cygwin/shared_info.h
Christopher Faylor cef5dfd75a * shared_info.h (user_info): Add dll_crt0_1 as a friend.
(user_info::version): Make LONG to accommodate spinlock use.
(user_info::create): New static function renamed from user_info_create.
(user_info::initialize): New private function renamed from
user_info_initialize.
(SHARED_VERSION): Delete.
(SHARED_VERSION_MAGIC): Ditto.
(USER_VERSION_MAGIC): Ditto.
(SHARED_INFO_CB): Ditto.
(USER_VERSION): Ditto.
(USER_VERSION_MAGIC): Ditto.
(CURR_SHARED_MAGIC): Update.
(CURR_USER_MAGIC): Ditto.
(shared_info::version): Make LONG to accommodate spinlock use.
(shared_info::create): New static function mirroring user_info::create.
(dll_crt0_1): Accommodate change to user_info::initialize.
* spinlock.h (spinlock::setto): New variable member.
(spinlock::done): New function.
(spinlock::spinlock): Generalize to allow arbitrary values and timeouts.  Call
done() when lock is not needed.
* ntdll.h: Make multiple-inclusion safe.
(NtQuerySystemTime): Declare.
* shared.cc (installation_root_inited): Rename from shared_mem_inited.
(init_installation_root): Make inline.  Use a spinlock to ensure that this is
initialized only once per session.
(user_info::initialize): Rename from user_shared_initialize.  Protect with
spinlock on sversion and remove other spinlock-like things.  Remove reference
to user_shared since it is now implicit.  Refer to spinlock version of
multiple_cygwin_problem to ensure that any spinlock is released.
(user_info::create): Rename from user_shared_create.  Accommodate change from
user_shared_initialize to user_info::initialize.
(shared_info::create): New inline function.
(shared_info::initialize): Protect with spinlock on sversion.  Move heap_init
back under specific control of shared_info spinlock.  Remove reference to
SHARED_INFO_CB and just use sizeof(*this).
(memory_init): Move all locking into respective functions where it is needed.
Accommodate name changes.  Remove call to heap_init().
* syscalls.cc (seteuid32): Accommodate name change to user_info::create().
* mount.cc (mount_info::create_root_entry): Report on errors from add_item
since they should be nonexistent.
(mount_info::init): Don't initialize nmounts.  It should already be zero.  Give
more verbose error when root_idx < 0.  Implicitly use this pointer rather than
explicitly referencing mount_table->.
(mount_info::add_item): Minor whitespace fix.
2010-03-15 21:29:15 +00:00

108 lines
2.7 KiB
C++

/* shared_info.h: shared info for cygwin
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "tty.h"
#include "security.h"
#include "mtinfo.h"
#include "limits.h"
#include "mount.h"
class user_info
{
void initialize ();
public:
LONG version;
DWORD cb;
bool warned_msdos;
mount_info mountinfo;
friend void dll_crt0_1 (void *);
static void create (bool);
};
/******** Shared Info ********/
/* Data accessible to all tasks */
#define CURR_SHARED_MAGIC 0xcebb78fcU
#define USER_VERSION 1
#define CURR_USER_MAGIC 0x6112afb3U
/* NOTE: Do not make gratuitous changes to the names or organization of the
below class. The layout is checksummed to determine compatibility between
different cygwin versions. */
class shared_info
{
LONG version;
DWORD cb;
public:
unsigned heap_chunk;
bool heap_slop_inited;
unsigned heap_slop;
DWORD sys_mount_table_counter;
tty_list tty;
LONG last_used_bindresvport;
DWORD obcaseinsensitive;
mtinfo mt;
void initialize ();
void init_obcaseinsensitive ();
unsigned heap_chunk_size ();
unsigned heap_slop_size ();
static void create ();
};
extern shared_info *cygwin_shared;
extern user_info *user_shared;
#define mount_table (&(user_shared->mountinfo))
extern HANDLE cygwin_user_h;
enum shared_locations
{
SH_CYGWIN_SHARED,
SH_USER_SHARED,
SH_SHARED_CONSOLE,
SH_MYSELF,
SH_TOTAL_SIZE,
SH_JUSTCREATE,
SH_JUSTOPEN
};
void memory_init (bool) __attribute__ ((regparm(1)));
void __stdcall shared_destroy ();
#define shared_align_past(p) \
((char *) (system_info.dwAllocationGranularity * \
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
system_info.dwAllocationGranularity)))
#ifdef _FHANDLER_H_
struct console_state
{
tty_min tty_min_state;
dev_console dev_state;
};
#endif
HANDLE get_shared_parent_dir ();
HANDLE get_session_parent_dir ();
char *__stdcall shared_name (char *, const char *, int);
WCHAR *__stdcall shared_name (WCHAR *, const WCHAR *, int);
void *__stdcall open_shared (const WCHAR *, int, HANDLE&, DWORD,
shared_locations, PSECURITY_ATTRIBUTES = &sec_all,
DWORD = FILE_MAP_READ | FILE_MAP_WRITE);
void *__stdcall open_shared (const WCHAR *, int, HANDLE&, DWORD,
shared_locations *, PSECURITY_ATTRIBUTES = &sec_all,
DWORD = FILE_MAP_READ | FILE_MAP_WRITE);
extern void user_shared_create (bool reinit);
extern void init_installation_root ();
extern WCHAR installation_root[PATH_MAX];
extern UNICODE_STRING installation_key;