summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog19
-rw-r--r--winsup/cygwin/cygheap.h4
-rw-r--r--winsup/cygwin/fhandler_tape.cc33
-rw-r--r--winsup/cygwin/mtinfo.h5
-rw-r--r--winsup/cygwin/shared.cc42
-rw-r--r--winsup/cygwin/shared_info.h6
-rw-r--r--winsup/cygwin/tty.h3
7 files changed, 51 insertions, 61 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c0a4d956c..d66bf8694 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+2006-07-26 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygheap.h (struct init_cygheap): Remove shared_h and mt_h members.
+ * fhandler_tape.cc (mt): Define as DLL shared area in
+ .cygwin_dll_common instead of as dynamically allocated area.
+ Change referencing throughout.
+ * mtinfo.h (mt_h): Remove entirely.
+ (mt): Remove extern declaration.
+ * shared.cc (cygwin_shared_area): New global cygwin_shared
+ variable located in .cygwin_dll_common.
+ (offsets): Define shared region addresses descending from
+ cygwin_shared_address.
+ (open_shared): Replace usage of SH_CYGWIN_SHARED by SH_USER_SHARED.
+ (memory_init): Set cygwin_shared just by pointing to cygwin_shared_area.
+ * shared_info.h (shared_locations): Remove SH_CYGWIN_SHARED and
+ SH_MTINFO.
+ (cygwin_shared_address): Define as DLL start address.
+ * tty.h (tty_min::tty_min): Remove constructor.
+
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h: Guard in_port_t typedef more restrictive to
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 0afe1620d..35db5cad8 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -1,6 +1,6 @@
/* cygheap.h: Cygwin heap manager.
- Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -279,9 +279,7 @@ struct init_cygheap
cygheap_user user;
user_heap_info user_heap;
mode_t umask;
- HANDLE shared_h;
HANDLE console_h;
- HANDLE mt_h;
cwdstuff cwd;
dtable fdtab;
LUID luid[SE_NUM_PRIVS];
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index 055519be0..036407685 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -1,7 +1,7 @@
/* fhandler_tape.cc. See fhandler.h for a description of the fhandler
classes.
- Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -1159,15 +1159,12 @@ mtinfo::initialize ()
}
}
-mtinfo *mt;
+static mtinfo mt __attribute__((section (".cygwin_dll_common"), shared));
void __stdcall
mtinfo_init ()
{
- shared_locations sh_mtinfo = SH_MTINFO;
- mt = (mtinfo *) open_shared ("mtinfo", MTINFO_VERSION, cygheap->mt_h, sizeof (mtinfo), sh_mtinfo);
- ProtectHandleINH (cygheap->mt_h);
- mt->initialize ();
+ mt.initialize ();
}
/**********************************************************************/
@@ -1223,22 +1220,22 @@ fhandler_dev_tape::open (int flags, mode_t)
into O_SYNC, which controls the FILE_WRITE_THROUGH flag in the
NtCreateFile call in fhandler_base::open. */
flags &= ~O_SYNC;
- if (!mt->drive (driveno ())->buffer_writes ())
+ if (!mt.drive (driveno ())->buffer_writes ())
flags |= O_SYNC;
ret = fhandler_dev_raw::open (flags);
if (ret)
{
- mt->drive (driveno ())->open (get_handle ());
+ mt.drive (driveno ())->open (get_handle ());
/* In append mode, seek to beginning of next filemark */
if (flags & O_APPEND)
- mt->drive (driveno ())->set_pos (get_handle (),
+ mt.drive (driveno ())->set_pos (get_handle (),
TAPE_SPACE_FILEMARKS, 1, true);
if (!(flags & O_DIRECT))
{
- devbufsiz = mt->drive (driveno ())->dp ()->MaximumBlockSize;
+ devbufsiz = mt.drive (driveno ())->dp ()->MaximumBlockSize;
devbuf = new char [devbufsiz];
}
devbufstart = devbufend = 0;
@@ -1257,7 +1254,7 @@ fhandler_dev_tape::close ()
if (!hExeced)
{
lock (-1);
- ret = mt->drive (driveno ())->close (get_handle (), is_rewind_device ());
+ ret = mt.drive (driveno ())->close (get_handle (), is_rewind_device ());
if (ret)
__seterrno_from_win_error (ret);
cret = fhandler_dev_raw::close ();
@@ -1290,7 +1287,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
ulen = (size_t) -1;
return;
}
- block_size = mt->drive (driveno ())->mp ()->BlockSize;
+ block_size = mt.drive (driveno ())->mp ()->BlockSize;
if (devbuf)
{
if (devbufend > devbufstart)
@@ -1320,7 +1317,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
{
debug_printf ("read %d bytes from tape (rest %d)",
block_fit, len - block_fit);
- ret = mt->drive (driveno ())->read (get_handle (), mt_evt, buf,
+ ret = mt.drive (driveno ())->read (get_handle (), mt_evt, buf,
block_fit);
if (ret)
__seterrno_from_win_error (ret);
@@ -1342,7 +1339,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
if (!ret && len > 0)
{
debug_printf ("read %d bytes from tape (one block)", block_size);
- ret = mt->drive (driveno ())->read (get_handle (), mt_evt, devbuf,
+ ret = mt.drive (driveno ())->read (get_handle (), mt_evt, devbuf,
block_size);
if (ret)
__seterrno_from_win_error (ret);
@@ -1363,7 +1360,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
debug_printf ("Creating event failed, %E");
bytes_read = ulen;
- ret = mt->drive (driveno ())->read (get_handle (), mt_evt, ptr,
+ ret = mt.drive (driveno ())->read (get_handle (), mt_evt, ptr,
bytes_read);
}
ulen = (ret ? (size_t) -1 : bytes_read);
@@ -1376,7 +1373,7 @@ fhandler_dev_tape::raw_write (const void *ptr, size_t len)
lock (-1);
if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
debug_printf ("Creating event failed, %E");
- int ret = mt->drive (driveno ())->write (get_handle (), mt_evt, ptr, len);
+ int ret = mt.drive (driveno ())->write (get_handle (), mt_evt, ptr, len);
if (ret)
__seterrno_from_win_error (ret);
return unlock (ret ? -1 : (int) len);
@@ -1394,7 +1391,7 @@ fhandler_dev_tape::lseek (_off64_t offset, int whence)
debug_printf ("lseek (%s, %d, %d)", get_name (), offset, whence);
- block_size = mt->drive (driveno ())->mp ()->BlockSize;
+ block_size = mt.drive (driveno ())->mp ()->BlockSize;
if (block_size == 0)
{
set_errno (EIO);
@@ -1511,7 +1508,7 @@ fhandler_dev_tape::ioctl (unsigned int cmd, void *buf)
lock (-1);
if (cmd == MTIOCTOP || cmd == MTIOCGET || cmd == MTIOCPOS)
{
- ret = mt->drive (driveno ())->ioctl (get_handle (), cmd, buf);
+ ret = mt.drive (driveno ())->ioctl (get_handle (), cmd, buf);
if (ret)
__seterrno_from_win_error (ret);
return unlock (ret ? -1 : 0);
diff --git a/winsup/cygwin/mtinfo.h b/winsup/cygwin/mtinfo.h
index 66e74cc33..9b1cf2c7e 100644
--- a/winsup/cygwin/mtinfo.h
+++ b/winsup/cygwin/mtinfo.h
@@ -1,6 +1,6 @@
/* mtinfo.h: Defininitions for the Cygwin tape driver class.
- Copyright 2004 Red Hat, Inc.
+ Copyright 2004, 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -141,7 +141,4 @@ public:
mtinfo_drive *drive (int num) { return &_drive[num]; }
};
-extern HANDLE mt_h;
-extern mtinfo *mt;
-
extern void __stdcall mtinfo_init ();
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index c491708e3..c88706a12 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -1,7 +1,7 @@
/* shared.cc: shared data area support.
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
- Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -29,6 +29,7 @@ details. */
#include "child_info.h"
#include "mtinfo.h"
+static shared_info cygwin_shared_area __attribute__((section (".cygwin_dll_common"), shared));
shared_info NO_COPY *cygwin_shared;
user_info NO_COPY *user_shared;
HANDLE NO_COPY cygwin_user_h;
@@ -50,27 +51,16 @@ shared_name (char *ret_buf, const char *str, int num)
static char *offsets[] =
{
- (char *) cygwin_shared_address,
(char *) cygwin_shared_address
- + pround (sizeof (shared_info)),
+ - pround (sizeof (user_info))
+ - pround (sizeof (console_state))
+ - pround (sizeof (_pinfo)),
(char *) cygwin_shared_address
- + pround (sizeof (shared_info))
- + pround (sizeof (user_info)),
+ - pround (sizeof (console_state))
+ - pround (sizeof (_pinfo)),
(char *) cygwin_shared_address
- + pround (sizeof (shared_info))
- + pround (sizeof (user_info))
- + pround (sizeof (console_state)),
+ - pround (sizeof (_pinfo)),
(char *) cygwin_shared_address
- + pround (sizeof (shared_info))
- + pround (sizeof (user_info))
- + pround (sizeof (console_state))
- + pround (sizeof (_pinfo)),
- (char *) cygwin_shared_address
- + pround (sizeof (shared_info))
- + pround (sizeof (user_info))
- + pround (sizeof (console_state))
- + pround (sizeof (_pinfo))
- + pround (sizeof (mtinfo))
};
void * __stdcall
@@ -134,11 +124,11 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
if (!shared)
api_fatal ("MapViewOfFileEx '%s'(%p), %E. Terminating.", mapname, shared_h);
- if (m == SH_CYGWIN_SHARED && offsets[0] && wincap.needs_memory_protection ())
+ if (m == SH_USER_SHARED && offsets[0] && wincap.needs_memory_protection ())
{
unsigned delta = (char *) shared - offsets[0];
offsets[0] = (char *) shared;
- for (int i = SH_CYGWIN_SHARED + 1; i < SH_TOTAL_SIZE; i++)
+ for (int i = SH_USER_SHARED + 1; i < SH_TOTAL_SIZE; i++)
{
unsigned size = offsets[i + 1] - offsets[i];
offsets[i] += delta;
@@ -244,16 +234,8 @@ memory_init ()
cygheap->user.init ();
}
- /* Initialize general shared memory */
- shared_locations sh_cygwin_shared = SH_CYGWIN_SHARED;
- cygwin_shared = (shared_info *) open_shared ("shared",
- CYGWIN_VERSION_SHARED_DATA,
- cygheap->shared_h,
- sizeof (*cygwin_shared),
- sh_cygwin_shared);
-
+ cygwin_shared = &cygwin_shared_area;
cygwin_shared->initialize ();
- ProtectHandleINH (cygheap->shared_h);
user_shared_initialize (false);
mtinfo_init ();
diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h
index 821807641..ae80309cb 100644
--- a/winsup/cygwin/shared_info.h
+++ b/winsup/cygwin/shared_info.h
@@ -1,6 +1,6 @@
/* shared_info.h: shared info for cygwin
- Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -169,11 +169,9 @@ extern HANDLE cygwin_user_h;
enum shared_locations
{
- SH_CYGWIN_SHARED,
SH_USER_SHARED,
SH_SHARED_CONSOLE,
SH_MYSELF,
- SH_MTINFO,
SH_TOTAL_SIZE,
SH_JUSTCREATE,
SH_JUSTOPEN
@@ -186,7 +184,7 @@ void __stdcall memory_init ();
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
system_info.dwAllocationGranularity)))
-#define cygwin_shared_address ((void *) 0x60000000)
+#define cygwin_shared_address ((void *) 0x61000000)
#ifdef _FHANDLER_H_
struct console_state
diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h
index 2343a93f6..612ed3038 100644
--- a/winsup/cygwin/tty.h
+++ b/winsup/cygwin/tty.h
@@ -1,6 +1,6 @@
/* tty.h: shared tty info for cygwin
- Copyright 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
+ Copyright 2000, 2001, 2002, 2003, 2004, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -70,7 +70,6 @@ public:
int ioctl_retval;
int write_error;
- tty_min (int t = -1, pid_t s = -1) : sid (s), ntty (t) {}
void setntty (int n) {ntty = n;}
pid_t getpgid () {return pgid;}
void setpgid (int pid) {pgid = pid;}