diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-11-12 15:30:20 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-11-12 15:30:20 +0000 |
commit | 7bb651a9ea165bbf3df3fee31c82ec6acb2b93f0 (patch) | |
tree | 69492285348ed8c1c9fb35da38fff07c5fe1b372 /winsup | |
parent | c4096b53e6b4b27e0f1a349ac63f1ea31d0b0dad (diff) | |
download | newlib-7bb651a9ea165bbf3df3fee31c82ec6acb2b93f0.zip newlib-7bb651a9ea165bbf3df3fee31c82ec6acb2b93f0.tar.gz newlib-7bb651a9ea165bbf3df3fee31c82ec6acb2b93f0.tar.bz2 |
2007-11-08 Christopher Faylor <me+cygwin@cgf.cx>
* dllfixdbg: Eliminate extra objcopy step.
2007-11-07 Pedro Alves <pedro_alves@portugalmail.pt>
* dllfixdbg: Pass --only-keep-debug to objcopy, instead of
selecting the sections manually.
2007-11-06 Corinna Vinschen <corinna@vinschen.de>
* thread.cc (pthread_key_create): Drop check for incoming valid object.
2007-11-06 Corinna Vinschen <corinna@vinschen.de>
* shm.cc: Include sync.h
(struct shm_shmid_list): Add ref_count member.
(struct shm_attached_list): Remove hdl and size members. Add a parent
member pointing to referenced shm_shmid_list entry.
(shm_guard): New muto.
(SLIST_LOCK): Define.
(SLIST_UNLOCK): Define.
(fixup_shms_after_fork): Use hdl and size members of parent
shm_shmid_list entry.
(shmat): Access sequential bookkeeping lists in a thread safe way.
Accommodate change in list element layout. Align comments.
(shmctl): Ditto.
(shmdt): Ditto.
(shmget): Ditto.
2007-11-05 Corinna Vinschen <corinna@vinschen.de>
* shm.cc (shmctl): On IPC_RMID don't unmap views and don't close handle
if the map is still referenced to emulate Linux and BSD behaviour.
2007-11-05 Corinna Vinschen <corinna@vinschen.de>
* shm.cc (shmctl): On IPC_RMID also unmap all views on shared mem
as well as connected shm_attached_list entry.
2007-10-30 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't remove
write bits for directories with R/O attribute.
(fhandler_base::fhaccess): Don't shortcircuit R/O attribute with W_OK
scenarios for directories.
2007-09-26 Corinna Vinschen <corinna@vinschen.de>
* termios.cc (setspeed): Support new baud rates introduced 2007-02-05.
2007-09-18 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc (fh_disk_file): Delete as global static variable and...
(mmap64): ...define as local pointer to make mmap thread-safe.
Accommodate throughout. Only initialize fh_disk_file after file could
be opened with GENERIC_EXECUTE access.
2007-09-06 Brian Dessent <brian@dessent.net>
* include/sys/stdio.h (_flockfile): Don't try to lock a FILE
that has the __SSTR flag set.
(_ftrylockfile): Likewise.
(_funlockfile): Likewise.
2007-08-24 Corinna Vinschen <corinna@vinschen.de>
* syscalls.cc (open): Don't follow symlinks if O_EXCL is given.
2007-08-09 Ernie Coskrey <Ernie.Coskrey@steeleye.com>
* gendef (sigbe): Reset "incyg" while the stack lock is active to avoid
a potential race.
2007-08-01 Corinna Vinschen <corinna@vinschen.de>
* localtime.cc (tzsetwall): Don't set TZ.
2007-07-17 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::fhaccess): Add check for R/O file system.
2007-07-14 Christopher Faylor <me+cygwin@cgf.cx>
* init.cc (in_dllentry): Delete.
(dll_entry): Remove assignment to deleted variable.
* winsup.h (in_dllentry): Delete declaration.
* exceptions.cc (inside_kernel): Use another method to see if we are in
dll_entry phase.
2007-07-14 Christopher Faylor <me+cygwin@cgf.cx>
* init.cc (in_dllentry): Make NO_COPY to avoid spurious false positives.
2007-07-09 Christopher Faylor <me+cygwin@cgf.cx>
* dlfcn.cc (dlclose): Don't close handle returned from
GetModuleHandle(NULL).
2007-07-06 Corinna Vinschen <corinna@vinschen.de>
* times.cc (gettimeofday): Align definition to POSIX.
2007-07-04 Corinna Vinschen <corinna@vinschen.de>
* times.cc: Define __timezonefunc__ before including time.h to protect
definition of timezone function.
2007-07-04 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/time.h: Switch to timezone variable by default. Add
comment.
2007-06-27 Corinna Vinschen <corinna@vinschen.de>
* shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info.
(CURR_SHARED_MAGIC): Ditto.
(class shared_info): Add heap_slop_inited member.
* shared.cc (shared_info::heap_slop_size): Use heap_slop_inited to
track initializing heap_slop since 0 is a valid value for heap_slop.
Drop useless < 0 consideration.
2007-06-12 Christopher Faylor <me+cygwin@cgf.cx>
* signal.cc (usleep): Use useconds_t for the type as per POSIX.
2007-06-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::fstat): Set pipe permission bits more
correctly.
2007-05-29 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (dtable::set_file_pointers_for_exec): Call SetFilePointer
correctly for 64 bit file access. Comment out functionality.
* fhandler.cc (fhandler_base::open): Don't set append_mode.
(fhandler_base::write): Check for O_APPEND instead of append_mode.
Call SetFilePointer correctly for 64 bit file access. Handle
errors from SetFilePointer.
* fhandler.h (class fhandler_base): Drop append_mode status flag.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Handle
seeking correctly for 64 bit file access.
2007-05-21 Christian Franke <franke@computer.org>
* fhandler_floppy.cc (fhandler_dev_floppy::lseek): Don't invalidate
devbuf if new position is within buffered range.
2007-05-21 Eric Blake <ebb9@byu.net>
* include/search.h (hsearch_r): Provide declaration.
2007-05-21 Christian Franke <franke@computer.org>
Corinna Vinschen <corinna@vinschen.de>
* fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to
sector size. Simplify non-sector aligned case. Handle errors from
raw_read.
2007-05-15 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (adjust_socket_file_mode): New inline function.
(fhandler_socket::fchmod): Squeeze mode through adjust_socket_file_mode
before using it.
(fhandler_socket::bind): Ditto.
2007-04-18 Brian Dessent <brian@dessent.net>
* cygwin.sc: Remove duplicated .debug_macinfo section.
* dllfixdbg: Also copy DWARF-2 sections into .dbg file.
2007-04-06 Eric Blake <ebb9@byu.net>
* include/stdint.h (WINT_MIN): Fix sign.
2007-04-04 Eric Blake <ebb9@byu.net>
* include/stdint.h (WINT_MIN, WINT_MAX): Fix definition.
2007-03-28 Christopher Faylor <me@cgf.cx>
* spawn.cc (spawn_guts): Start pure-windows processes in a suspended
state to avoid potential DuplicateHandle problems.
2007-03-07 Christopher Faylor <me@cgf.cx>
* signal.cc (handle_sigprocmask): Remove extraneous
sig_dispatch_pending.
2007-02-26 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::fstat): Set all file times to arbitrary
fixed value.
2007-02-20 Christopher Faylor <me@cgf.cx>
* exceptions.cc (_cygtls::signal_exit): Only call myself.exit when when
exit_state indicates that we've visited do_exit.
* sync.h (lock_process::lock_process): Use renamed exit_state -
ES_PROCESS_LOCKED.
* winsup.h: Rename ES_MUTO_SET to ES_PROCESS_LOCKED.
2007-02-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::bind): Remove printing wrong
errno in debug output.
2007-02-05 Corinna Vinschen <corinna@vinschen.de>
* fhandler_serial.cc (fhandler_serial::tcsetattr): Add support for
baud rates up to 3000000 baud. Add missing 128K and 256K cases.
(fhandler_serial::tcgetattr): Ditto.
* include/sys/termios.h: Add baud rate definitions from B460800 up to
B3000000.
2007-01-04 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (PREFERRED_IO_BLKSIZE): Define as 64K.
* fhandler.cc (fhandler_base::fstat): Set st_blksize to
PREFERRED_IO_BLKSIZE.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Ditto.
* fhandler_mailslot.cc (fhandler_mailslot::fstat): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::fstat): Ditto.
2006-11-08 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the local
group to the token.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Create logon_id group SID by copying it from
incoming group list.
Diffstat (limited to 'winsup')
36 files changed, 551 insertions, 124 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ee87bbf..68ec045 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,116 @@ +2007-11-08 Christopher Faylor <me+cygwin@cgf.cx> + + * dllfixdbg: Eliminate extra objcopy step. + +2007-11-07 Pedro Alves <pedro_alves@portugalmail.pt> + + * dllfixdbg: Pass --only-keep-debug to objcopy, instead of + selecting the sections manually. + +2007-11-06 Corinna Vinschen <corinna@vinschen.de> + + * thread.cc (pthread_key_create): Drop check for incoming valid object. + +2007-11-06 Corinna Vinschen <corinna@vinschen.de> + + * shm.cc: Include sync.h + (struct shm_shmid_list): Add ref_count member. + (struct shm_attached_list): Remove hdl and size members. Add a parent + member pointing to referenced shm_shmid_list entry. + (shm_guard): New muto. + (SLIST_LOCK): Define. + (SLIST_UNLOCK): Define. + (fixup_shms_after_fork): Use hdl and size members of parent + shm_shmid_list entry. + (shmat): Access sequential bookkeeping lists in a thread safe way. + Accommodate change in list element layout. Align comments. + (shmctl): Ditto. + (shmdt): Ditto. + (shmget): Ditto. + +2007-11-05 Corinna Vinschen <corinna@vinschen.de> + + * shm.cc (shmctl): On IPC_RMID don't unmap views and don't close handle + if the map is still referenced to emulate Linux and BSD behaviour. + +2007-11-05 Corinna Vinschen <corinna@vinschen.de> + + * shm.cc (shmctl): On IPC_RMID also unmap all views on shared mem + as well as connected shm_attached_list entry. + +2007-10-30 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't remove + write bits for directories with R/O attribute. + (fhandler_base::fhaccess): Don't shortcircuit R/O attribute with W_OK + scenarios for directories. + +2007-09-26 Corinna Vinschen <corinna@vinschen.de> + + * termios.cc (setspeed): Support new baud rates introduced 2007-02-05. + +2007-09-18 Corinna Vinschen <corinna@vinschen.de> + + * mmap.cc (fh_disk_file): Delete as global static variable and... + (mmap64): ...define as local pointer to make mmap thread-safe. + Accommodate throughout. Only initialize fh_disk_file after file could + be opened with GENERIC_EXECUTE access. + +2007-09-06 Brian Dessent <brian@dessent.net> + + * include/sys/stdio.h (_flockfile): Don't try to lock a FILE + that has the __SSTR flag set. + (_ftrylockfile): Likewise. + (_funlockfile): Likewise. + +2007-08-24 Corinna Vinschen <corinna@vinschen.de> + + * syscalls.cc (open): Don't follow symlinks if O_EXCL is given. + +2007-08-09 Ernie Coskrey <Ernie.Coskrey@steeleye.com> + + * gendef (sigbe): Reset "incyg" while the stack lock is active to avoid + a potential race. + +2007-08-01 Corinna Vinschen <corinna@vinschen.de> + + * localtime.cc (tzsetwall): Don't set TZ. + +2007-07-17 Corinna Vinschen <corinna@vinschen.de> + + * fhandler.cc (fhandler_base::fhaccess): Add check for R/O file system. + +2007-07-14 Christopher Faylor <me+cygwin@cgf.cx> + + * init.cc (in_dllentry): Delete. + (dll_entry): Remove assignment to deleted variable. + * winsup.h (in_dllentry): Delete declaration. + * exceptions.cc (inside_kernel): Use another method to see if we are in + dll_entry phase. + +2007-07-14 Christopher Faylor <me+cygwin@cgf.cx> + + * init.cc (in_dllentry): Make NO_COPY to avoid spurious false positives. + +2007-07-09 Christopher Faylor <me+cygwin@cgf.cx> + + * dlfcn.cc (dlclose): Don't close handle returned from + GetModuleHandle(NULL). + +2007-07-06 Corinna Vinschen <corinna@vinschen.de> + + * times.cc (gettimeofday): Align definition to POSIX. + +2007-07-04 Corinna Vinschen <corinna@vinschen.de> + + * times.cc: Define __timezonefunc__ before including time.h to protect + definition of timezone function. + +2007-07-04 Corinna Vinschen <corinna@vinschen.de> + + * include/cygwin/time.h: Switch to timezone variable by default. Add + comment. + 2007-06-29 Brian Dessent <brian@dessent.net> * posix.sgml: List resolver functions in BSD section with reference @@ -11,9 +124,111 @@ 2007-06-28 Brian Dessent <brian@dessent.net> Backport documentation changes from HEAD. - * ansi.sgml: Delete. - * misc-std.sgml: Delete. - * posix.sgml: Rework entirely. + * ansi.sgml: Delete. + * misc-std.sgml: Delete. + * posix.sgml: Rework entirely. + +2007-06-27 Corinna Vinschen <corinna@vinschen.de> + + * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. + (CURR_SHARED_MAGIC): Ditto. + (class shared_info): Add heap_slop_inited member. + * shared.cc (shared_info::heap_slop_size): Use heap_slop_inited to + track initializing heap_slop since 0 is a valid value for heap_slop. + Drop useless < 0 consideration. + +2007-06-12 Christopher Faylor <me+cygwin@cgf.cx> + + * signal.cc (usleep): Use useconds_t for the type as per POSIX. + +2007-06-12 Corinna Vinschen <corinna@vinschen.de> + + * fhandler.cc (fhandler_base::fstat): Set pipe permission bits more + correctly. + +2007-05-29 Corinna Vinschen <corinna@vinschen.de> + + * dtable.cc (dtable::set_file_pointers_for_exec): Call SetFilePointer + correctly for 64 bit file access. Comment out functionality. + * fhandler.cc (fhandler_base::open): Don't set append_mode. + (fhandler_base::write): Check for O_APPEND instead of append_mode. + Call SetFilePointer correctly for 64 bit file access. Handle + errors from SetFilePointer. + * fhandler.h (class fhandler_base): Drop append_mode status flag. + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Handle + seeking correctly for 64 bit file access. + +2007-05-21 Christian Franke <franke@computer.org> + + * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Don't invalidate + devbuf if new position is within buffered range. + +2007-05-21 Eric Blake <ebb9@byu.net> + + * include/search.h (hsearch_r): Provide declaration. + +2007-05-21 Christian Franke <franke@computer.org> + Corinna Vinschen <corinna@vinschen.de> + + * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to + sector size. Simplify non-sector aligned case. Handle errors from + raw_read. + +2007-05-15 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_socket.cc (adjust_socket_file_mode): New inline function. + (fhandler_socket::fchmod): Squeeze mode through adjust_socket_file_mode + before using it. + (fhandler_socket::bind): Ditto. + +2007-04-18 Brian Dessent <brian@dessent.net> + + * cygwin.sc: Remove duplicated .debug_macinfo section. + * dllfixdbg: Also copy DWARF-2 sections into .dbg file. + +2007-04-06 Eric Blake <ebb9@byu.net> + + * include/stdint.h (WINT_MIN): Fix sign. + +2007-04-04 Eric Blake <ebb9@byu.net> + + * include/stdint.h (WINT_MIN, WINT_MAX): Fix definition. + +2007-03-28 Christopher Faylor <me@cgf.cx> + + * spawn.cc (spawn_guts): Start pure-windows processes in a suspended + state to avoid potential DuplicateHandle problems. + +2007-03-07 Christopher Faylor <me@cgf.cx> + + * signal.cc (handle_sigprocmask): Remove extraneous + sig_dispatch_pending. + +2007-02-26 Corinna Vinschen <corinna@vinschen.de> + + * fhandler.cc (fhandler_base::fstat): Set all file times to arbitrary + fixed value. + +2007-02-20 Christopher Faylor <me@cgf.cx> + + * exceptions.cc (_cygtls::signal_exit): Only call myself.exit when when + exit_state indicates that we've visited do_exit. + * sync.h (lock_process::lock_process): Use renamed exit_state - + ES_PROCESS_LOCKED. + * winsup.h: Rename ES_MUTO_SET to ES_PROCESS_LOCKED. + +2007-02-20 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_socket.cc (fhandler_socket::bind): Remove printing wrong + errno in debug output. + +2007-02-05 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support for + baud rates up to 3000000 baud. Add missing 128K and 256K cases. + (fhandler_serial::tcgetattr): Ditto. + * include/sys/termios.h: Add baud rate definitions from B460800 up to + B3000000. 2007-01-30 Corinna Vinschen <corinna@vinschen.de> @@ -68,6 +283,16 @@ * mmap.cc: Do bookkeeping in 4K pages, rather than in 64K chunks. +2007-01-04 Brian Ford <Brian.Ford@FlightSafety.com> + Corinna Vinschen <corinna@vinschen.de> + + * fhandler.h (PREFERRED_IO_BLKSIZE): Define as 64K. + * fhandler.cc (fhandler_base::fstat): Set st_blksize to + PREFERRED_IO_BLKSIZE. + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Ditto. + * fhandler_mailslot.cc (fhandler_mailslot::fstat): Ditto. + * fhandler_raw.cc (fhandler_dev_raw::fstat): Ditto. + 2007-01-01 Christopher Faylor <me@cgf.cx> * spawn.cc (spawn_guts): Don't expect synchronization from a non-cygwin @@ -166,6 +391,11 @@ * include/cygwin/version.h: Bump DLL minor version number to 23. +2006-11-08 Corinna Vinschen <corinna@vinschen.de> + + * security.cc (get_token_group_sidlist): Always add the local + group to the token. + 2006-11-06 Corinna Vinschen <corinna@vinschen.de> * dtable.cc (build_fh_pc): Add missing DEV_SD1_MAJOR case (Thanks to @@ -348,6 +578,12 @@ * dllfixdbg: Accommodate newer binutils which put the gnu_debuglink at the end rather than at the beginning. +2006-07-14 Corinna Vinschen <corinna@vinschen.de> + + * security.cc (get_token_group_sidlist): Always add the interactive + group to the token. Create logon_id group SID by copying it from + incoming group list. + 2006-07-13 Christopher Faylor <cgf@timesys.com> * sigproc.cc (waitq_head): Don't initialize to zero. diff --git a/winsup/cygwin/cygwin.sc b/winsup/cygwin/cygwin.sc index 6247e86..30b7b69 100644 --- a/winsup/cygwin/cygwin.sc +++ b/winsup/cygwin/cygwin.sc @@ -138,6 +138,5 @@ SECTIONS .debug_str ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_str) } .debug_loc ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_loc) } .debug_macinfo ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_macinfo) } - .debug_macinfo ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_macinfo) } .debug_ranges ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_ranges) } } diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 5bea774..3893045 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -145,12 +145,10 @@ int dlclose (void *handle) { int ret = -1; - void *temphandle = (void *) GetModuleHandle (NULL); - if (temphandle == handle || FreeLibrary ((HMODULE) handle)) + if (handle == GetModuleHandle (NULL) || FreeLibrary ((HMODULE) handle)) ret = 0; if (ret) set_dl_error ("dlclose"); - CloseHandle ((HMODULE) temphandle); return ret; } diff --git a/winsup/cygwin/dllfixdbg b/winsup/cygwin/dllfixdbg index 4ffc4e6..f97be0c 100755 --- a/winsup/cygwin/dllfixdbg +++ b/winsup/cygwin/dllfixdbg @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2006 Red Hat, Inc. +# Copyright 2006, 2007 Red Hat, Inc. # # This file is part of Cygwin. # @@ -16,7 +16,7 @@ my $objdump = shift; my @objcopy = ((shift)); my $dll = shift; my $dbg = shift; -xit 0, @objcopy, '-j', '.stab', '-j', '.stabstr', $dll, $dbg; +xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', '--only-keep-debug', $dll, $dbg; xit 0, @objcopy, '-g', '--add-gnu-debuglink=' . $dbg, $dll; open(OBJDUMP, '-|', "$objdump --headers $dll"); my %section; diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index e2fc34c..8948033 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -681,12 +681,16 @@ dtable::fixup_before_exec (DWORD target_proc_id) void dtable::set_file_pointers_for_exec () { +/* This is not POSIX-compliant. */ +#if 0 + LONG off_high = 0; lock (); fhandler_base *fh; for (size_t i = 0; i < size; i++) if ((fh = fds[i]) != NULL && fh->get_flags () & O_APPEND) - SetFilePointer (fh->get_handle (), 0, 0, FILE_END); + SetFilePointer (fh->get_handle (), 0, &off_high, FILE_END); unlock (); +#endif } void diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index e5345f1..c05151d 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1,7 +1,7 @@ /* exceptions.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Red Hat, Inc. + 2005, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -297,7 +297,7 @@ inside_kernel (CONTEXT *cx) int res; MEMORY_BASIC_INFORMATION m; - if (in_dllentry) + if (!_my_tls.isinitialized ()) return true; memset (&m, 0, sizeof m); @@ -1287,7 +1287,7 @@ _cygtls::signal_exit (int rc) stackdump (thread_context.ebp, 1, 1); lock_process until_exit (true); - if (hExeced || exit_state) + if (hExeced || exit_state > ES_PROCESS_LOCKED) myself.exit (rc); /* Starve other threads in a vain attempt to stop them from doing something diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 4c8e431..505c8db 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1,7 +1,7 @@ /* fhandler.cc. See console.cc for fhandler_console functions. Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005 Red Hat, Inc. + 2005, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -365,7 +365,8 @@ fhandler_base::fhaccess (int flags) if (is_fs_special ()) /* short circuit */; - else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK)) + else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK) + && !pc.isdir ()) goto eaccess_done; else if (has_acls () && allow_ntsec) { @@ -431,6 +432,15 @@ fhandler_base::fhaccess (int flags) eaccess_done: set_errno (EACCES); done: +#ifndef FILE_READ_ONLY_VOLUME +#define FILE_READ_ONLY_VOLUME 0x80000 +#endif + if (!res && (flags & W_OK) && get_device () == FH_FS + && (pc.fs_flags () & FILE_READ_ONLY_VOLUME)) + { + set_errno (EROFS); + res = -1; + } debug_printf ("returning %d", res); return res; } @@ -483,9 +493,6 @@ fhandler_base::open_9x (int flags, mode_t mode) if ((flags & O_EXCL) && (flags & O_CREAT)) creation_distribution = CREATE_NEW; - if (flags & O_APPEND) - append_mode (true); - /* These flags are host dependent. */ shared = wincap.shared (); @@ -647,9 +654,6 @@ fhandler_base::open (int flags, mode_t mode) if ((flags & O_EXCL) && (flags & O_CREAT)) create_disposition = FILE_CREATE; - if (flags & O_APPEND) - append_mode (true); - if (flags & O_CREAT && get_device () == FH_FS) { file_attributes = FILE_ATTRIBUTE_NORMAL; @@ -817,8 +821,17 @@ fhandler_base::write (const void *ptr, size_t len) { int res; - if (append_mode ()) - SetFilePointer (get_output_handle (), 0, 0, FILE_END); + if (get_flags () & O_APPEND) + { + LONG off_high = 0; + DWORD ret = SetFilePointer (get_output_handle (), 0, &off_high, FILE_END); + if (ret == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) + { + debug_printf ("Seeking to EOF in append mode failed"); + __seterrno (); + return -1; + } + } else if (did_lseek ()) { _off64_t actual_length, current_position; @@ -1239,13 +1252,13 @@ fhandler_base::fstat (struct __stat64 *buf) switch (get_device ()) { case FH_PIPE: - buf->st_mode = S_IFIFO | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH; + buf->st_mode = S_IFIFO | S_IRUSR | S_IWUSR; break; case FH_PIPEW: - buf->st_mode = S_IFIFO | STD_WBITS | S_IWGRP | S_IWOTH; + buf->st_mode = S_IFIFO | S_IWUSR; break; case FH_PIPER: - buf->st_mode = S_IFIFO | STD_RBITS; + buf->st_mode = S_IFIFO | S_IRUSR; break; case FH_FULL: buf->st_mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; @@ -1258,8 +1271,9 @@ fhandler_base::fstat (struct __stat64 *buf) buf->st_uid = geteuid32 (); buf->st_gid = getegid32 (); buf->st_nlink = 1; - buf->st_blksize = S_BLKSIZE; - time_as_timestruc_t (&buf->st_ctim); + buf->st_blksize = PREFERRED_IO_BLKSIZE; + buf->st_ctim.tv_sec = 1164931200L; /* Arbitrary value: 2006-12-01 */ + buf->st_ctim.tv_nsec = 0L; buf->st_atim = buf->st_mtim = buf->st_ctim; return 0; } diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 9aa991f..afdaf0b 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1,7 +1,7 @@ /* fhandler.h Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Red Hat, Inc. + 2005, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -25,6 +25,11 @@ details. */ both flags are set. */ #define O_NONBLOCK_MASK (O_NONBLOCK | OLD_O_NDELAY) +/* It appears that 64K is the block size used for buffered I/O on NT. + Using this blocksize in read/write calls in the application results + in a much better performance than using smaller values. */ +#define PREFERRED_IO_BLKSIZE ((blksize_t) 65536) + extern const char *windows_device_names[]; extern struct __cygwin_perfile *perfile_table; #define __fmode (*(user_data->fmode_ptr)) @@ -95,7 +100,6 @@ class fhandler_base unsigned wbinset : 1; /* binary write mode explicitly set */ unsigned nohandle : 1; /* No handle associated with fhandler. */ unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */ - unsigned append_mode : 1; /* always append */ unsigned did_lseek : 1; /* set when lseek is called as a flag that _write should check if we've moved beyond EOF, zero filling or making @@ -109,7 +113,7 @@ class fhandler_base public: status_flags () : rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0), - uninterruptible_io (0), append_mode (0), did_lseek (0), + uninterruptible_io (0), did_lseek (0), query_open (no_query), close_on_exec (0), need_fork_fixup (0), has_changed (0) {} @@ -187,7 +191,6 @@ class fhandler_base IMPLEMENT_STATUS_FLAG (bool, rbinset) IMPLEMENT_STATUS_FLAG (bool, nohandle) IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io) - IMPLEMENT_STATUS_FLAG (bool, append_mode) IMPLEMENT_STATUS_FLAG (bool, did_lseek) IMPLEMENT_STATUS_FLAG (query_state, query_open) IMPLEMENT_STATUS_FLAG (bool, close_on_exec) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index d068114..82510c0 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1,7 +1,7 @@ /* fhandler_disk_file.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Red Hat, Inc. + 2005, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -428,7 +428,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, else buf->st_ino = get_namehash (); - buf->st_blksize = S_BLKSIZE; + buf->st_blksize = PREFERRED_IO_BLKSIZE; if (nAllocSize >= 0LL) /* A successful NtQueryInformationFile returns the allocation size @@ -470,7 +470,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, { /* If read-only attribute is set, modify ntsec return value */ if (::has_attribute (dwFileAttributes, FILE_ATTRIBUTE_READONLY) - && !pc.issymlink ()) + && !pc.isdir () && !pc.issymlink ()) buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); if (buf->st_mode & S_IFMT) @@ -489,7 +489,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, buf->st_mode |= STD_RBITS; if (!::has_attribute (dwFileAttributes, FILE_ATTRIBUTE_READONLY) - && !pc.issymlink ()) + && !pc.isdir () && !pc.issymlink ()) buf->st_mode |= STD_WBITS; /* | S_IWGRP | S_IWOTH; we don't give write to group etc */ @@ -509,13 +509,14 @@ fhandler_base::fstat_helper (struct __stat64 *buf, if (pc.exec_state () == dont_know_if_executable) { DWORD cur, done; + LONG curhigh = 0; char magic[3]; /* First retrieve current position, set to beginning of file if not already there. */ - cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT); - if (cur != INVALID_SET_FILE_POINTER - && (!cur || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN) + cur = SetFilePointer (get_handle (), 0, &curhigh, FILE_CURRENT); + if ((cur != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR) + && ((!cur && !curhigh) || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)) { /* FIXME should we use /etc/magic ? */ @@ -526,7 +527,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, pc.set_exec (); buf->st_mode |= STD_XBITS; } - SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN); + SetFilePointer (get_handle (), cur, &curhigh, FILE_BEGIN); } } } diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index c4ebcc0..bcd0c7d 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -408,10 +408,11 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len) _off64_t fhandler_dev_floppy::lseek (_off64_t offset, int whence) { - char buf[512]; + char buf[bytes_per_sector]; _off64_t lloffset = offset; + _off64_t current_pos = (_off64_t) -1; LARGE_INTEGER sector_aligned_offset; - _off64_t bytes_left; + size_t bytes_left; if (whence == SEEK_END) { @@ -420,7 +421,8 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence) } else if (whence == SEEK_CUR) { - lloffset += get_current_position () - (devbufend - devbufstart); + current_pos = get_current_position (); + lloffset += current_pos - (devbufend - devbufstart); whence = SEEK_SET; } @@ -430,6 +432,18 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence) return -1; } + /* If new position is in buffered range, adjust buffer and return */ + if (devbufstart < devbufend) + { + if (current_pos == (_off64_t) -1) + current_pos = get_current_position (); + if (current_pos - devbufend <= lloffset && lloffset <= current_pos) + { + devbufstart = devbufend - (current_pos - lloffset); + return lloffset; + } + } + sector_aligned_offset.QuadPart = (lloffset / bytes_per_sector) * bytes_per_sector; bytes_left = lloffset - sector_aligned_offset.QuadPart; @@ -453,9 +467,11 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence) if (bytes_left) { - size_t len = bytes_left; - raw_read (buf, len); + raw_read (buf, bytes_left); + if (bytes_left == (size_t) -1) + return -1; } + return sector_aligned_offset.QuadPart + bytes_left; } diff --git a/winsup/cygwin/fhandler_mailslot.cc b/winsup/cygwin/fhandler_mailslot.cc index 07babd2..133df04 100644 --- a/winsup/cygwin/fhandler_mailslot.cc +++ b/winsup/cygwin/fhandler_mailslot.cc @@ -1,6 +1,6 @@ /* fhandler_mailslot.cc. See fhandler.h for a description of the fhandler classes. - Copyright 2005 Red Hat, Inc. + Copyright 2005, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -42,7 +42,7 @@ fhandler_mailslot::fstat (struct __stat64 *buf) buf->st_uid = geteuid32 (); buf->st_gid = getegid32 (); buf->st_nlink = 1; - buf->st_blksize = S_BLKSIZE; + buf->st_blksize = PREFERRED_IO_BLKSIZE; time_as_timestruc_t (&buf->st_ctim); buf->st_atim = buf->st_mtim = buf->st_ctim; } diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 77ee252..9478ee7 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -1,6 +1,6 @@ /* fhandler_raw.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, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -55,7 +55,7 @@ fhandler_dev_raw::fstat (struct __stat64 *buf) buf->st_uid = geteuid32 (); buf->st_gid = getegid32 (); buf->st_nlink = 1; - buf->st_blksize = S_BLKSIZE; + buf->st_blksize = PREFERRED_IO_BLKSIZE; time_as_timestruc_t (&buf->st_ctim); buf->st_atim = buf->st_mtim = buf->st_ctim; } diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 7378b3c..c7a905f 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -635,9 +635,45 @@ fhandler_serial::tcsetattr (int action, const struct termios *t) case B115200: state.BaudRate = CBR_115200; break; + case B128000: + state.BaudRate = CBR_128000; + break; case B230400: state.BaudRate = 230400 /* CBR_230400 - not defined */; break; + case B256000: + state.BaudRate = CBR_256000; + break; + case B460800: + state.BaudRate = 460800 /* CBR_460800 - not defined */; + break; + case B500000: + state.BaudRate = 500000 /* CBR_500000 - not defined */; + break; + case B576000: + state.BaudRate = 576000 /* CBR_576000 - not defined */; + break; + case B921600: + state.BaudRate = 921600 /* CBR_921600 - not defined */; + break; + case B1000000: + state.BaudRate = 1000000 /* CBR_1000000 - not defined */; + break; + case B1152000: + state.BaudRate = 1152000 /* CBR_1152000 - not defined */; + break; + case B1500000: + state.BaudRate = 1500000 /* CBR_1500000 - not defined */; + break; + case B2000000: + state.BaudRate = 2000000 /* CBR_2000000 - not defined */; + break; + case B2500000: + state.BaudRate = 2500000 /* CBR_2500000 - not defined */; + break; + case B3000000: + state.BaudRate = 3000000 /* CBR_3000000 - not defined */; + break; default: /* Unsupported baud rate! */ termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed); @@ -942,9 +978,45 @@ fhandler_serial::tcgetattr (struct termios *t) case CBR_115200: t->c_ospeed = t->c_ispeed = B115200; break; + case CBR_128000: + t->c_ospeed = t->c_ispeed = B128000; + break; case 230400: /* CBR_230400 - not defined */ t->c_ospeed = t->c_ispeed = B230400; break; + case CBR_256000: + t->c_ospeed = t->c_ispeed = B256000; + break; + case 460800: /* CBR_460000 - not defined */ + t->c_ospeed = t->c_ispeed = B460800; + break; + case 500000: /* CBR_500000 - not defined */ + t->c_ospeed = t->c_ispeed = B500000; + break; + case 576000: /* CBR_576000 - not defined */ + t->c_ospeed = t->c_ispeed = B576000; + break; + case 921600: /* CBR_921600 - not defined */ + t->c_ospeed = t->c_ispeed = B921600; + break; + case 1000000: /* CBR_1000000 - not defined */ + t->c_ospeed = t->c_ispeed = B1000000; + break; + case 1152000: /* CBR_1152000 - not defined */ + t->c_ospeed = t->c_ispeed = B1152000; + break; + case 1500000: /* CBR_1500000 - not defined */ + t->c_ospeed = t->c_ispeed = B1500000; + break; + case 2000000: /* CBR_2000000 - not defined */ + t->c_ospeed = t->c_ispeed = B2000000; + break; + case 2500000: /* CBR_2500000 - not defined */ + t->c_ospeed = t->c_ispeed = B2500000; + break; + case 3000000: /* CBR_3000000 - not defined */ + t->c_ospeed = t->c_ispeed = B3000000; + break; default: /* Unsupported baud rate! */ termios_printf ("Invalid baud rate %d", state.BaudRate); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 7ca4ed1..db4d550 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -47,6 +47,18 @@ int sscanf (const char *, const char *, ...); fhandler_dev_random* entropy_source; +static inline mode_t +adjust_socket_file_mode (mode_t mode) +{ + /* Kludge: Don't allow to remove read bit on socket files for + user/group/other, if the accompanying write bit is set. It would + be nice to have exact permissions on a socket file, but it's + necessary that somebody able to access the socket can always read + the contents of the socket file to avoid spurious "permission + denied" messages. */ + return mode | ((mode & (S_IWUSR | S_IWGRP | S_IWOTH)) << 1); +} + /* cygwin internal: map sockaddr into internet domain address */ static int get_inet_addr (const struct sockaddr *in, int inlen, @@ -541,7 +553,7 @@ fhandler_socket::fchmod (mode_t mode) { fhandler_disk_file fh (pc); fh.get_device () = FH_FS; - int ret = fh.fchmod (mode); + int ret = fh.fchmod (adjust_socket_file_mode (mode)); SetFileAttributes (pc, GetFileAttributes (pc) | FILE_ATTRIBUTE_SYSTEM); return ret; } @@ -625,13 +637,13 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen) sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (::bind (get_socket (), (sockaddr *) &sin, len)) { - syscall_printf ("AF_LOCAL: bind failed %d", get_errno ()); + syscall_printf ("AF_LOCAL: bind failed"); set_winsock_errno (); goto out; } if (::getsockname (get_socket (), (sockaddr *) &sin, &len)) { - syscall_printf ("AF_LOCAL: getsockname failed %d", get_errno ()); + syscall_printf ("AF_LOCAL: getsockname failed"); set_winsock_errno (); goto out; } @@ -650,7 +662,8 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen) set_errno (EADDRINUSE); goto out; } - mode_t mode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask; + mode_t mode = adjust_socket_file_mode ((S_IRWXU | S_IRWXG | S_IRWXO) + & ~cygheap->umask); DWORD attr = FILE_ATTRIBUTE_SYSTEM; if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH))) attr |= FILE_ATTRIBUTE_READONLY; diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef index 4f60ea6..0d7df4b 100755 --- a/winsup/cygwin/gendef +++ b/winsup/cygwin/gendef @@ -158,9 +158,9 @@ __sigbe: # return here after cygwin syscall xorl %edx,%edx xchgl %edx,-4(%eax) # get return address from signal stack xchgl %edx,8(%esp) # restore edx/real return address + decl $tls::incyg(%ebx) decl $tls::stacklock(%ebx) # release lock popl %eax - decl $tls::incyg(%ebx) popl %ebx ret diff --git a/winsup/cygwin/include/cygwin/time.h b/winsup/cygwin/include/cygwin/time.h index 83a8e62..61d385e 100644 --- a/winsup/cygwin/include/cygwin/time.h +++ b/winsup/cygwin/include/cygwin/time.h @@ -30,8 +30,10 @@ time_t timegm (struct tm *); # define daylight _daylight # endif -# ifndef timezonevar -char *timezone (void); +/* The timezone function is only kept for backward compatibility. + POSIX expects the timezone variable as XSI extension. */ +# ifdef __timezonefunc__ +char __cdecl *timezone (void); # elif !defined(timezone) # define timezone _timezone # endif diff --git a/winsup/cygwin/include/search.h b/winsup/cygwin/include/search.h index a1ccfe2..bfadb23 100644 --- a/winsup/cygwin/include/search.h +++ b/winsup/cygwin/include/search.h @@ -57,6 +57,7 @@ void hdestroy (void); ENTRY *hsearch (ENTRY, ACTION); int hcreate_r (size_t, struct hsearch_data *); void hdestroy_r (struct hsearch_data *); +int hsearch_r (ENTRY, ACTION, ENTRY **, struct hsearch_data *); void *tdelete (const void * __restrict, void ** __restrict, int (*) (const void *, const void *)); void tdestroy (void *, void (*)(void *)); diff --git a/winsup/cygwin/include/stdint.h b/winsup/cygwin/include/stdint.h index 8b040c3..1411581 100644 --- a/winsup/cygwin/include/stdint.h +++ b/winsup/cygwin/include/stdint.h @@ -1,6 +1,6 @@ /* stdint.h - integer types - Copyright 2003, 2006 Red Hat, Inc. + Copyright 2003, 2006, 2007 Red Hat, Inc. This file is part of Cygwin. @@ -158,8 +158,8 @@ typedef unsigned long long uintmax_t; #endif #ifndef WINT_MIN -#define WINT_MIN (-2147483647 - 1) -#define WINT_MAX (2147483647) +#define WINT_MIN 0U +#define WINT_MAX UINT_MAX #endif /* Macros for minimum-width integer constant expressions */ diff --git a/winsup/cygwin/include/sys/stdio.h b/winsup/cygwin/include/sys/stdio.h index 7cc6f09..40b18b3 100644 --- a/winsup/cygwin/include/sys/stdio.h +++ b/winsup/cygwin/include/sys/stdio.h @@ -14,15 +14,21 @@ details. */ #include <sys/cdefs.h> #include <sys/lock.h> +/* These definitions should be kept in sync with those in the newlib + header of the same name (newlib/libc/include/sys/stdio.h). */ + #if !defined(__SINGLE_THREAD__) # if !defined(_flockfile) -# define _flockfile(fp) __cygwin_lock_lock ((_LOCK_T *)&(fp)->_lock) +# define _flockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \ + __cygwin_lock_lock ((_LOCK_T *)&(fp)->_lock); }) # endif # if !defined(_ftrylockfile) -# define _ftrylockfile(fp) __cygwin_lock_trylock ((_LOCK_T *)&(fp)->_lock) +# define _ftrylockfile(fp) (((fp)->_flags & __SSTR) ? 0 : \ + __cygwin_lock_trylock ((_LOCK_T *)&(fp)->_lock)) # endif # if !defined(_funlockfile) -# define _funlockfile(fp) __cygwin_lock_unlock ((_LOCK_T *)&(fp)->_lock) +# define _funlockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \ + __cygwin_lock_unlock ((_LOCK_T *)&(fp)->_lock); }) # endif #endif diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h index 5032ddd..e2fd132 100644 --- a/winsup/cygwin/include/sys/termios.h +++ b/winsup/cygwin/include/sys/termios.h @@ -177,12 +177,25 @@ POSIX commands */ #define PARODD 0x00200 #define HUPCL 0x00400 #define CLOCAL 0x00800 + +/* Extended baud rates above 37K. */ #define CBAUDEX 0x0100f #define B57600 0x01001 #define B115200 0x01002 #define B128000 0x01003 #define B230400 0x01004 #define B256000 0x01005 +#define B460800 0x01006 +#define B500000 0x01007 +#define B576000 0x01008 +#define B921600 0x01009 +#define B1000000 0x0100a +#define B1152000 0x0100b +#define B1500000 0x0100c +#define B2000000 0x0100d +#define B2500000 0x0100e +#define B3000000 0x0100f + #define CRTSXOFF 0x04000 #define CRTSCTS 0x08000 diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 6a1575d..08deb56 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -118,15 +118,12 @@ respawn_wow64_process () extern void __stdcall dll_crt0_0 (); HMODULE NO_COPY cygwin_hmodule; -bool in_dllentry; extern "C" BOOL WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load) { BOOL wow64_test_stack_marker; - in_dllentry = true; - switch (reason) { case DLL_PROCESS_ATTACH: @@ -162,6 +159,5 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) break; } - in_dllentry = false; return TRUE; } diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc index b8b1a60..1dab627 100644 --- a/winsup/cygwin/localtime.cc +++ b/winsup/cygwin/localtime.cc @@ -1456,7 +1456,11 @@ tzsetwall P((void)) settzname(); lcl_is_set = 1; strlcpy(lcl_TZname, buf, sizeof (lcl_TZname)); +#if 0 + /* Huh? POSIX doesn't mention anywhere that tzset should + set $TZ. That's not right. */ setenv("TZ", lcl_TZname, 1); +#endif return; } } diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index d7eed33..88b9852 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -49,8 +49,6 @@ details. */ /* Used for anonymous mappings. */ static fhandler_dev_zero fh_anonymous; -/* Used for reopening a disk file when necessary. */ -static fhandler_disk_file fh_disk_file; /* Small helpers to avoid having lots of flag bit tests in the code. */ static inline bool @@ -983,6 +981,8 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) caddr_t ret = (caddr_t) MAP_FAILED; fhandler_base *fh = NULL; + fhandler_disk_file *fh_disk_file = NULL; /* Used for reopening a disk file + when necessary. */ list *map_list = NULL; size_t orig_len = 0; caddr_t base = NULL; @@ -992,7 +992,6 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); - fh_disk_file.set_io_handle (NULL); SetResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); @@ -1078,12 +1077,13 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) set_errno (EACCES); goto out; } - fh_disk_file.set_io_handle (h); - fh_disk_file.set_access (fh->get_access () | GENERIC_WRITE); + fh_disk_file = new (alloca (sizeof *fh_disk_file)) fhandler_disk_file; path_conv pc; pc.set_name (fh->get_win32_name (), ""); - fh_disk_file.set_name (pc); - fh = &fh_disk_file; + fh_disk_file->set_name (pc); + fh_disk_file->set_io_handle (h); + fh_disk_file->set_access (fh->get_access () | GENERIC_WRITE); + fh = fh_disk_file; } /* On NT you can't create mappings with PAGE_EXECUTE protection if @@ -1096,9 +1096,13 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) OPEN_EXISTING, 0, NULL); if (h != INVALID_HANDLE_VALUE) { - fh_disk_file.set_io_handle (h); - fh_disk_file.set_access (fh->get_access () | GENERIC_EXECUTE); - fh = &fh_disk_file; + fh_disk_file = new (alloca (sizeof *fh_disk_file)) fhandler_disk_file; + path_conv pc; + pc.set_name (fh->get_win32_name (), ""); + fh_disk_file->set_name (pc); + fh_disk_file->set_io_handle (h); + fh_disk_file->set_access (fh->get_access () | GENERIC_EXECUTE); + fh = fh_disk_file; } else if (prot & PROT_EXEC) { @@ -1294,8 +1298,8 @@ out: ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); - if (fh_disk_file.get_handle ()) - CloseHandle (fh_disk_file.get_handle ()); + if (fh_disk_file) + CloseHandle (fh_disk_file->get_handle ()); syscall_printf ("%p = mmap() ", ret); return ret; diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index cab8a2b..ad12975 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -465,16 +465,14 @@ get_token_group_sidlist (cygsidlist &grp_list, PTOKEN_GROUPS my_grps, auth_pos = -1; if (my_grps) { - if (sid_in_token_groups (my_grps, well_known_local_sid)) - grp_list += well_known_local_sid; + grp_list += well_known_local_sid; if (sid_in_token_groups (my_grps, well_known_dialup_sid)) grp_list += well_known_dialup_sid; if (sid_in_token_groups (my_grps, well_known_network_sid)) grp_list += well_known_network_sid; if (sid_in_token_groups (my_grps, well_known_batch_sid)) grp_list += well_known_batch_sid; - if (sid_in_token_groups (my_grps, well_known_interactive_sid)) - grp_list += well_known_interactive_sid; + grp_list += well_known_interactive_sid; if (sid_in_token_groups (my_grps, well_known_service_sid)) grp_list += well_known_service_sid; } @@ -485,11 +483,13 @@ get_token_group_sidlist (cygsidlist &grp_list, PTOKEN_GROUPS my_grps, } if (get_ll (auth_luid) != 999LL) /* != SYSTEM_LUID */ { - char buf[64]; - __small_sprintf (buf, "S-1-5-5-%u-%u", auth_luid.HighPart, - auth_luid.LowPart); - grp_list += buf; - auth_pos = grp_list.count - 1; + for (DWORD i = 0; i < my_grps->GroupCount; ++i) + if (my_grps->Groups[i].Attributes & SE_GROUP_LOGON_ID) + { + grp_list += my_grps->Groups[i].Sid; + auth_pos = grp_list.count - 1; + break; + } } } diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index c66912b..820c4cf 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -262,7 +262,7 @@ memory_init () unsigned shared_info::heap_slop_size () { - if (!heap_slop) + if (!heap_slop_inited) { /* Fetch from registry, first user then local machine. */ for (int i = 0; i < 2; i++) @@ -273,11 +273,8 @@ shared_info::heap_slop_size () break; heap_slop = wincap.heapslop (); } - - if (heap_slop < 0) - heap_slop = 0; - else - heap_slop <<= 20; + heap_slop <<= 20; + heap_slop_inited = true; } return heap_slop; diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index db9fc97..6711c2d 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -142,9 +142,9 @@ public: cygwin_version.api_minor) #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION) -#define SHARED_INFO_CB 19988 +#define SHARED_INFO_CB 19992 -#define CURR_SHARED_MAGIC 0x87c42d1eU +#define CURR_SHARED_MAGIC 0xb7048a88U /* NOTE: Do not make gratuitous changes to the names or organization of the below class. The layout is checksummed to determine compatibility between @@ -155,6 +155,7 @@ class shared_info DWORD cb; public: unsigned heap_chunk; + bool heap_slop_inited; unsigned heap_slop; DWORD sys_mount_table_counter; diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc index f6cc30b..3170fca 100644 --- a/winsup/cygwin/shm.cc +++ b/winsup/cygwin/shm.cc @@ -23,6 +23,7 @@ details. */ #include "cygserver_ipc.h" #include "cygserver_shm.h" #include "cygtls.h" +#include "sync.h" /* * client_request_shm Constructors @@ -99,6 +100,7 @@ struct shm_shmid_list { int shmid; vm_object_t hdl; size_t size; + int ref_count; }; static SLIST_HEAD (, shm_shmid_list) ssh_list; @@ -107,13 +109,16 @@ static SLIST_HEAD (, shm_shmid_list) ssh_list; struct shm_attached_list { SLIST_ENTRY (shm_attached_list) sph_next; vm_object_t ptr; - vm_object_t hdl; - size_t size; + shm_shmid_list *parent; int access; }; static SLIST_HEAD (, shm_attached_list) sph_list; +static NO_COPY muto shm_guard; +#define SLIST_LOCK() (shm_guard.init ("shm_guard")->acquire ()) +#define SLIST_UNLOCK() (shm_guard.release ()) + int __stdcall fixup_shms_after_fork () { @@ -133,8 +138,10 @@ fixup_shms_after_fork () /* Remove map from list... */ SLIST_FOREACH (sph_entry, &sph_list, sph_next) { - vm_object_t ptr = MapViewOfFileEx (sph_entry->hdl, sph_entry->access, - 0, 0, sph_entry->size, sph_entry->ptr); + vm_object_t ptr = MapViewOfFileEx (sph_entry->parent->hdl, + sph_entry->access, 0, 0, + sph_entry->parent->size, + sph_entry->ptr); if (ptr != sph_entry->ptr) api_fatal ("MapViewOfFileEx (%p), %E. Terminating.", sph_entry->ptr); } @@ -153,6 +160,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) syscall_printf ("shmat (shmid = %d, shmaddr = %p, shmflg = 0x%x)", shmid, shmaddr, shmflg); + SLIST_LOCK (); shm_shmid_list *ssh_entry; SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) { @@ -179,9 +187,16 @@ shmat (int shmid, const void *shmaddr, int shmflg) { /* Invalid shmid */ set_errno (EINVAL); + SLIST_UNLOCK (); return (void *) -1; } } + /* Early increment ref counter. This allows further actions to run with + unlocked lists, because shmdt or shmctl(IPC_RMID) won't delete this + ssh_entry. */ + ++ssh_entry->ref_count; + SLIST_UNLOCK (); + vm_object_t attach_va = NULL; if (shmaddr) { @@ -194,6 +209,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) if (!attach_va || (vm_offset_t)attach_va % SHMLBA) { set_errno (EINVAL); + --ssh_entry->ref_count; return (void *) -1; } } @@ -202,6 +218,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) if (!sph_entry) { set_errno (ENOMEM); + --ssh_entry->ref_count; return (void *) -1; } DWORD access = (shmflg & SHM_RDONLY) ? FILE_MAP_READ : FILE_MAP_WRITE; @@ -211,6 +228,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) { __seterrno (); delete sph_entry; + --ssh_entry->ref_count; return (void *) -1; } /* Use returned ptr address as is, so it's stored using the exact value @@ -222,15 +240,17 @@ shmat (int shmid, const void *shmaddr, int shmflg) UnmapViewOfFile (ptr); delete sph_entry; set_errno (request.error_code ()); + --ssh_entry->ref_count; if (request.error_code () == ENOSYS) raise (SIGSYS); return (void *) -1; } sph_entry->ptr = ptr; - sph_entry->hdl = ssh_entry->hdl; - sph_entry->size = ssh_entry->size; + sph_entry->parent = ssh_entry; sph_entry->access = access; + SLIST_LOCK (); SLIST_INSERT_HEAD (&sph_list, sph_entry, sph_next); + SLIST_UNLOCK (); return ptr; #else set_errno (ENOSYS); @@ -259,19 +279,25 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf) } if (cmd == IPC_RMID) { - /* The process must cleanup its own storage... */ + /* Cleanup */ shm_shmid_list *ssh_entry, *ssh_next_entry; + SLIST_LOCK (); SLIST_FOREACH_SAFE (ssh_entry, &ssh_list, ssh_next, ssh_next_entry) { if (ssh_entry->shmid == shmid) { - SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); - /* ...and close the handle. */ - CloseHandle (ssh_entry->hdl); - delete ssh_entry; + /* Remove this entry from the list and close the handle + only if it's not in use anymore. */ + if (ssh_entry->ref_count <= 0) + { + SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); + CloseHandle (ssh_entry->hdl); + delete ssh_entry; + } break; } } + SLIST_UNLOCK (); } return request.retval (); #else @@ -297,17 +323,28 @@ shmdt (const void *shmaddr) } shm_attached_list *sph_entry, *sph_next_entry; /* Remove map from list... */ + SLIST_LOCK (); SLIST_FOREACH_SAFE (sph_entry, &sph_list, sph_next, sph_next_entry) { if (sph_entry->ptr == shmaddr) { SLIST_REMOVE (&sph_list, sph_entry, shm_attached_list, sph_next); - /* ...and unmap view. */ + /* ...unmap view... */ UnmapViewOfFile (sph_entry->ptr); + /* ...and, if this was the last reference to this shared section... */ + shm_shmid_list *ssh_entry = sph_entry->parent; + if (--ssh_entry->ref_count <= 0) + { + /* ...delete parent entry and close handle. */ + SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); + CloseHandle (ssh_entry->hdl); + delete ssh_entry; + } delete sph_entry; break; } } + SLIST_UNLOCK (); return request.retval (); #else set_errno (ENOSYS); @@ -342,6 +379,7 @@ shmget (key_t key, size_t size, int shmflg) int shmid = request.retval (); /* Shared mem ID */ vm_object_t hdl = request.objval (); /* HANDLE associated with it. */ shm_shmid_list *ssh_entry; + SLIST_LOCK (); SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) { if (ssh_entry->shmid == shmid) @@ -352,6 +390,7 @@ shmget (key_t key, size_t size, int shmflg) delete it. */ CloseHandle (hdl); delete ssh_new_entry; + SLIST_UNLOCK (); return shmid; } } @@ -360,7 +399,9 @@ shmget (key_t key, size_t size, int shmflg) ssh_new_entry->shmid = shmid; ssh_new_entry->hdl = hdl; ssh_new_entry->size = size; + ssh_new_entry->ref_count = 0; SLIST_INSERT_HEAD (&ssh_list, ssh_new_entry, ssh_next); + SLIST_UNLOCK (); return shmid; #else set_errno (ENOSYS); diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index ff769e4..3765cff 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -135,7 +135,7 @@ sleep (unsigned int seconds) } extern "C" unsigned int -usleep (unsigned int useconds) +usleep (useconds_t useconds) { struct timespec req; req.tv_sec = useconds / 1000000; @@ -153,7 +153,6 @@ sigprocmask (int how, const sigset_t *set, sigset_t *oldset) int __stdcall handle_sigprocmask (int how, const sigset_t *set, sigset_t *oldset, sigset_t& opmask) { - sig_dispatch_pending (); /* check that how is in right range */ if (how != SIG_BLOCK && how != SIG_UNBLOCK && how != SIG_SETMASK) { diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 9eba126..4bc7594 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -39,7 +39,7 @@ details. */ #define WSSC 60000 // Wait for signal completion #define WPSP 40000 // Wait for proc_subproc mutex -#define no_signals_available(x) (!hwait_sig || hwait_sig == INVALID_HANDLE_VALUE || ((x) && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls || in_dllentry) +#define no_signals_available(x) (!hwait_sig || hwait_sig == INVALID_HANDLE_VALUE || ((x) && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls) #define NPROCS 256 diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 5be1014..d2749d5 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -460,8 +460,8 @@ spawn_guts (const char * prog_arg, const char *const *argv, So we have to start the child in suspend state, unfortunately, to avoid a race condition. */ if (!newargv.win16_exe - && (wincap.start_proc_suspended () || mode != _P_OVERLAY - || cygheap->fdtab.need_fixup_before ())) + && (wincap.start_proc_suspended () || !ch.iscygwin () + || mode != _P_OVERLAY || cygheap->fdtab.need_fixup_before ())) c_flags |= CREATE_SUSPENDED; runpath = null_app_name ? NULL : (const char *) real_path; diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h index f7ce7e1..dfe2c39 100644 --- a/winsup/cygwin/sync.h +++ b/winsup/cygwin/sync.h @@ -55,9 +55,9 @@ public: { locker.acquire (); skip_unlock = exiting; - if (exiting && exit_state < ES_SET_MUTO) + if (exiting && exit_state < ES_PROCESS_LOCKED) { - exit_state = ES_SET_MUTO; + exit_state = ES_PROCESS_LOCKED; muto::set_exiting_thread (); } } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 6637f0f..7ff99b5 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -602,8 +602,9 @@ open (const char *unix_path, int flags, ...) if (fd >= 0) { - if (!(fh = build_fh_name (unix_path, NULL, (flags & O_NOFOLLOW) ? - PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, + if (!(fh = build_fh_name (unix_path, NULL, + (flags & (O_NOFOLLOW | O_EXCL)) + ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, transparent_exe ? stat_suffixes : NULL))) res = -1; // errno already set else if ((flags & O_NOFOLLOW) && fh->issymlink ()) diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc index 6e0ab3e..34afe46 100644 --- a/winsup/cygwin/termios.cc +++ b/winsup/cygwin/termios.cc @@ -274,6 +274,16 @@ setspeed (speed_t &set_speed, speed_t from_speed) case B128000: case B230400: case B256000: + case B460800: + case B500000: + case B576000: + case B921600: + case B1000000: + case B1152000: + case B1500000: + case B2000000: + case B2500000: + case B3000000: set_speed = from_speed; res = 0; break; diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 08eb10d..12fe599 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -2421,11 +2421,6 @@ pthread_getschedparam (pthread_t thread, int *policy, extern "C" int pthread_key_create (pthread_key_t *key, void (*destructor) (void *)) { - /* The opengroup docs don't define if we should check this or not, - but creation is relatively rare. */ - if (pthread_key::is_good_object (key)) - return EBUSY; - *key = new pthread_key (destructor); if (!pthread_key::is_good_object (key)) diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 3922caf..0dfc316 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -10,6 +10,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" +#define __timezonefunc__ #include <time.h> #include <sys/times.h> #include <sys/timeb.h> @@ -161,8 +162,9 @@ hires_ms NO_COPY gtod; /* FIXME: Make thread safe */ extern "C" int -gettimeofday (struct timeval *tv, struct timezone *tz) +gettimeofday (struct timeval *tv, void *tzvp) { + struct timezone *tz = (struct timezone *) tzvp; static bool tzflag; LONGLONG now = gtod.usecs (); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 26c115b..a7a42d8 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -186,7 +186,7 @@ extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *); enum exit_states { ES_NOT_EXITING = 0, - ES_SET_MUTO, + ES_PROCESS_LOCKED, ES_GLOBAL_DTORS, ES_EVENTS_TERMINATE, ES_THREADTERM, @@ -349,7 +349,6 @@ extern bool display_title; extern bool transparent_exe; extern bool in_forkee; -extern bool in_dllentry; extern HANDLE hMainThread; extern HANDLE hMainProc; |