* syscalls.cc (_link): Make sure that newpath does not exist. Set errno if it

does.
* cygheap.cc (init_cheap): Don't specify a load address for the heap.  It
doesn't work on #!*& Windows 9x.
(cygheap_init): Move GetUserName to memory_init.
* dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call to
heap_init.
* heap.cc (heap_init): Improve error output.
* heap.h: Correct some declarations.
* shared.cc (mount_table_init): Remove.
(memory_init): Renamed from shared_init.  Reorganize to accomodate strange
Windows 9x problems with cygheap/heap interaction.
* shared_info.h: Rename shared_init to memory_init.
This commit is contained in:
Christopher Faylor 2001-01-29 00:46:25 +00:00
parent 39d871d66d
commit 6a4878cf16
8 changed files with 88 additions and 59 deletions

View File

@ -1,3 +1,22 @@
Sun Jan 28 19:40:40 2001 Christopher Faylor <cgf@cygnus.com>
* syscalls.cc (_link): Make sure that newpath does not exist. Set
errno if it does.
Sun Jan 28 19:29:08 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (init_cheap): Don't specify a load address for the heap.
It doesn't work on #!*& Windows 9x.
(cygheap_init): Move GetUserName to memory_init.
* dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call
to heap_init.
* heap.cc (heap_init): Improve error output.
* heap.h: Correct some declarations.
* shared.cc (mount_table_init): Remove.
(memory_init): Renamed from shared_init. Reorganize to accomodate
strange Windows 9x problems with cygheap/heap interaction.
* shared_info.h: Rename shared_init to memory_init.
Sun Jan 28 01:25:33 2001 Christopher Faylor <cgf@cygnus.com> Sun Jan 28 01:25:33 2001 Christopher Faylor <cgf@cygnus.com>
* include/cygwin/version.h: Bump API version. * include/cygwin/version.h: Bump API version.
@ -30,24 +49,29 @@ Sun Jan 28 00:28:30 2001 Christopher Faylor <cgf@cygnus.com>
initialization. initialization.
* fhandler_console.cc (console_shared_h): Eliminate. * fhandler_console.cc (console_shared_h): Eliminate.
(get_tty_stuff): Use cygheap->console_h rather than console_shared_h. (get_tty_stuff): Use cygheap->console_h rather than console_shared_h.
* heap.cc (heap_init): Use page size constant calculated earlier in initialization. * heap.cc (heap_init): Use page size constant calculated earlier in
initialization.
* shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h. * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h.
(mount_table_init): New function for initializing a user mount table. (mount_table_init): New function for initializing a user mount table.
(open_shared_file_map): Use constant for shared memory region. Initialize cygheap and mount table here. (open_shared_file_map): Use constant for shared memory region.
Initialize cygheap and mount table here.
(open_shared): Improve debugging output. (open_shared): Improve debugging output.
(shared_info::initialize): Eliminate call to mount.init. (shared_info::initialize): Eliminate call to mount.init.
(shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h. (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h.
(open_shared_file_map): Eliminate. (open_shared_file_map): Eliminate.
* shared_info.h (mount_info): Add a version field. * shared_info.h (mount_info): Add a version field.
(shared_align_past): New macro for calculating location for shared memory regions. (shared_align_past): New macro for calculating location for shared
memory regions.
* sigproc.cc (init_child_info): Eliminate shared_h, console_h. * sigproc.cc (init_child_info): Eliminate shared_h, console_h.
* spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user. * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different
user.
* syscalls.cc (system_info): New global holding system memory defaults. * syscalls.cc (system_info): New global holding system memory defaults.
(getpagesize): Use system_info. (getpagesize): Use system_info.
* uinfo.cc (internal_getlogin): Only fill in user name if nonexistent. * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent.
* winsup.h: Declare system_info. * winsup.h: Declare system_info.
* passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving the name again. * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than
retrieving the name again.
Sat Jan 27 10:18:02 2001 Christopher Faylor <cgf@cygnus.com> Sat Jan 27 10:18:02 2001 Christopher Faylor <cgf@cygnus.com>
@ -176,11 +200,13 @@ Fri Jan 12 00:35:15 2001 Christopher Faylor <cgf@cygnus.com>
* signal.cc (sigaction): Don't treat SIGCONT specially. * signal.cc (sigaction): Don't treat SIGCONT specially.
* exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal for later use. * exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal
for later use.
(sig_handler): Default any stopping signal to SIGSTOP. (sig_handler): Default any stopping signal to SIGSTOP.
(call_signal_handler): New function. (call_signal_handler): New function.
(sigdelayed0): New function. (sigdelayed0): New function.
* sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special behavior. * sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special
behavior.
* sigproc.h: Define call_signal_handler. * sigproc.h: Define call_signal_handler.
* syscalls.cc (_read): Allow restartable signal behavior. * syscalls.cc (_read): Allow restartable signal behavior.
@ -192,9 +218,10 @@ Thu Jan 11 13:17:00 2001 Corinna Vinschen <corinna@vinschen.de>
* fhandler_mem.cc (fhandler_dev_mem::open): Set OBJ_INHERIT attribute * fhandler_mem.cc (fhandler_dev_mem::open): Set OBJ_INHERIT attribute
for device\physicalmemory handle. for device\physicalmemory handle.
(fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::mmap): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New method. * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New
* mmap.cc (mmap_record): Add private `fdesc_' member. Change constructor method.
accordingly. * mmap.cc (mmap_record): Add private `fdesc_' member. Change
constructor accordingly.
(get_fd): New method. (get_fd): New method.
(mmap): Use new mmap_record constructor. (mmap): Use new mmap_record constructor.
(fhandler_base::fixup_mmap_after_fork): New method. (fhandler_base::fixup_mmap_after_fork): New method.

View File

@ -27,8 +27,7 @@ static NO_COPY muto *cygheap_protect = NULL;
inline static void inline static void
init_cheap () init_cheap ()
{ {
void *addr = cygheap_address; cygheap = (init_cygheap *) VirtualAlloc (NULL, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS);
cygheap = (init_cygheap *) VirtualAlloc (addr, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS);
if (!cygheap) if (!cygheap)
api_fatal ("Couldn't reserve space for cygwin's heap, %E"); api_fatal ("Couldn't reserve space for cygwin's heap, %E");
cygheap_max = cygheap + 1; cygheap_max = cygheap + 1;
@ -67,14 +66,6 @@ cygheap_init ()
{ {
cygheap_protect = new_muto (FALSE, "cygheap_protect"); cygheap_protect = new_muto (FALSE, "cygheap_protect");
_csbrk (0); _csbrk (0);
char username[MAX_USER_NAME];
DWORD username_len = MAX_USER_NAME;
if (!GetUserName (username, &username_len))
cygheap->user.set_name ("unknown");
else
cygheap->user.set_name (username);
} }
/* Copyright (C) 1997, 2000 DJ Delorie */ /* Copyright (C) 1997, 2000 DJ Delorie */

View File

@ -723,14 +723,11 @@ dll_crt0_1 ()
host_dependent.init (); host_dependent.init ();
/* Initialize the cygwin subsystem if this is the first process, /* Initialize the cygwin subsystem if this is the first process,
or attach to the shared data structure if it's already running. */ or attach to shared data structures if it's already running. */
shared_init (); memory_init ();
(void) SetErrorMode (SEM_FAILCRITICALERRORS); (void) SetErrorMode (SEM_FAILCRITICALERRORS);
/* Initialize the heap. */
heap_init ();
/* Initialize events. */ /* Initialize events. */
events_init (); events_init ();

View File

@ -52,8 +52,8 @@ heap_init ()
break; break;
} }
if (p == NULL) if (p == NULL)
api_fatal ("1. unable to allocate heap, heap_chunk_size %d, pid %d, %E", api_fatal ("1. unable to allocate heap %p, heap_chunk_size %d, pid %d, %E",
brkchunk, myself->pid); brkbase, brkchunk, myself->pid);
if (p != brkbase) if (p != brkbase)
api_fatal ("heap allocated but not at %p", brkbase); api_fatal ("heap allocated but not at %p", brkbase);
if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE))

View File

@ -11,8 +11,8 @@ details. */
#include "perprocess.h" #include "perprocess.h"
/* Heap management. */ /* Heap management. */
void heap_init (void); void heap_init ();
void malloc_init (void); void malloc_init ();
#define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop)) #define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop))

View File

@ -18,6 +18,7 @@ details. */
#include "sigproc.h" #include "sigproc.h"
#include "pinfo.h" #include "pinfo.h"
#include "cygheap.h" #include "cygheap.h"
#include "heap.h"
#include "shared_info.h" #include "shared_info.h"
#include "registry.h" #include "registry.h"
#include "cygwin_version.h" #include "cygwin_version.h"
@ -48,26 +49,6 @@ shared_name (const char *str, int num)
return buf; return buf;
} }
static void
mount_table_init ()
{
void *addr = mount_table_address;
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
mount_table_address);
mount_table = (mount_info *) open_shared (cygheap->user.name (),
cygwin_mount_h, sizeof (mount_info),
addr);
ProtectHandle (cygwin_mount_h);
debug_printf ("mount table version %x at %p", mount_table->version, mount_table);
if (!mount_table->version)
{
mount_table->version = MOUNT_VERSION;
debug_printf ("initializing mount table");
mount_table->init (); /* Initialize the mount table. */
}
}
void * __stdcall void * __stdcall
open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr) open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr)
{ {
@ -143,11 +124,11 @@ shared_info::initialize ()
reg_key reg (KEY_READ, NULL); reg_key reg (KEY_READ, NULL);
/* Note that reserving a huge amount of heap space does not result in /* Note that reserving a huge amount of heap space does not result in
swapping since we are not committing it. */ the use of swap since we are not committing it. */
/* FIXME: We should not be restricted to a fixed size heap no matter /* FIXME: We should not be restricted to a fixed size heap no matter
what the fixed size is. */ what the fixed size is. */
heap_chunk_in_mb = reg.get_int ("heap_chunk_in_mb", 128); heap_chunk_in_mb = reg.get_int ("heap_chunk_in_mb", 1024);
if (heap_chunk_in_mb < 4) if (heap_chunk_in_mb < 4)
{ {
heap_chunk_in_mb = 4; heap_chunk_in_mb = 4;
@ -158,21 +139,47 @@ shared_info::initialize ()
} }
void __stdcall void __stdcall
shared_init () memory_init ()
{ {
/* Initialize general shared memory */
HANDLE shared_h = cygheap ? cygheap->shared_h : NULL; HANDLE shared_h = cygheap ? cygheap->shared_h : NULL;
cygwin_shared = (shared_info *) open_shared ("shared", cygwin_shared = (shared_info *) open_shared ("shared",
shared_h, shared_h,
sizeof (*cygwin_shared), sizeof (*cygwin_shared),
cygwin_shared_address); cygwin_shared_address);
cygwin_shared->initialize ();
heap_init ();
/* Allocate memory for the per-user mount table */
char user_name[MAX_USER_NAME];
DWORD user_name_len = MAX_USER_NAME;
if (!GetUserName (user_name, &user_name_len))
strcpy (user_name, "unknown");
mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h,
sizeof (mount_info), 0);
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
mount_table_address);
ProtectHandle (cygwin_mount_h);
debug_printf ("mount table version %x at %p", mount_table->version, mount_table);
/* Initialize the Cygwin heap, if necessary */
if (!cygheap) if (!cygheap)
{
cygheap_init (); cygheap_init ();
cygheap->user.set_name (user_name);
mount_table_init (); }
cygheap->shared_h = shared_h; cygheap->shared_h = shared_h;
ProtectHandle (cygheap->shared_h); ProtectHandle (cygheap->shared_h);
cygwin_shared->initialize ();
/* Initialize the Cygwin per-user mount table, if necessary */
if (!mount_table->version)
{
mount_table->version = MOUNT_VERSION;
debug_printf ("initializing mount table");
mount_table->init (); /* Initialize the mount table. */
}
} }
void __stdcall void __stdcall

View File

@ -153,7 +153,7 @@ extern shared_info *cygwin_shared;
extern mount_info *mount_table; extern mount_info *mount_table;
extern HANDLE cygwin_mount_h; extern HANDLE cygwin_mount_h;
void __stdcall shared_init (void); void __stdcall memory_init (void);
void __stdcall shared_terminate (void); void __stdcall shared_terminate (void);
#define shared_align_past(p) \ #define shared_align_past(p) \

View File

@ -531,6 +531,13 @@ _link (const char *a, const char *b)
set_errno (real_b.error); set_errno (real_b.error);
goto done; goto done;
} }
if (real_b.file_attributes () != (DWORD)-1)
{
syscall_printf ("file '%s' exists?", (char *)real_b);
set_errno (EEXIST);
goto done;
}
if (real_b.get_win32 ()[strlen (real_b.get_win32 ()) - 1] == '.') if (real_b.get_win32 ()[strlen (real_b.get_win32 ()) - 1] == '.')
{ {
syscall_printf ("trailing dot, bailing out"); syscall_printf ("trailing dot, bailing out");