OSDN Git Service

Implement fhandler reference counting.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / ChangeLog
1 2011-12-16  Christopher Faylor  <me.cygwin2011@cgf.cx>
2
3         Implement fhandler reference counting.
4         * cygheap.h
5         (cygheap_fdmanip::release): Make virtual.
6         (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference
7         count when fd has been allocated.
8         (cygheap_fdget::fh): New (old?) field.
9         (cygheap_fdget::cygheap_fdget): Increment reference count when we've
10         found an active fd.  Set fh appropriately.
11         (cygheap_fdget::~cygheap_fdget): Decrement reference count when
12         appropriate.  Delete fh if reference count goes to zero.
13         (cygheap_fdget::release): New function.  Do more bookkeping on release.
14         * dtable.cc (dtable::release): Change from void to boolean return.
15         Only delete the fhandler when its reference count is <= 0 (this should
16         be a fairly unusual case).  Return true if fhandler has been deleted.
17         (cygwin_attach_handle_to_fd): Increment reference count when fh is
18         assigned.
19         (dtable::init_std_file_from_handle): Ditto.
20         * dtable.h (dtable::release): Change return to boolean.
21         * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to
22         false.  Set _refcnt to zero.
23         (fhandler_base::close): Simplify paranoid debugging output.  Set new
24         isclosed() flag.
25         (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to
26         avoid querying the exception handle.
27         * fhandler.h (fhandler_base::_refcnt): New field.
28         (fhandler_base::refcnt): New function.
29         (fhandler_base::isclosed): Implement.
30         (fhandler_base::fhandler_base): Set isclosed to false.
31
32         * syscalls.cc: Remove space after function before parentheses for
33         several strace printfs.
34         (dup): Add standard strace "leaver" code.
35         (dup2): Ditto.
36         (dup3): Ditto.
37         (remove): Ditto.
38         (getpid): Ditto.
39         (getppid): Ditto.
40         (lseek64): Fix strace debugging to correctly use %R.
41
42         * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending
43         signals to other processes if we're debugging since it can cause a
44         deadlock with the calling debugger.
45
46         * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only
47         strace output.
48
49 2011-12-16  Corinna Vinschen  <vinschen@redhat.com>
50
51         * dcrt0.cc (child_info_fork::alloc_stack): Correctly check if the
52         parent stack fits into the child stack.  Align comment.
53         * wow64.cc (wow64_eval_expected_main_stack): New function to fetch
54         expected addresses of main thread stack from PE/COFF image header
55         values.
56         (wow64_test_for_64bit_parent): Fix comment.  Check current stack
57         against real expected main thread stack addresses.
58         (wow64_revert_to_original_stack): Fix and add comments. Check memory
59         against real expected main thread stack addresses.  Use orignal stack
60         if reserved area is >= 256K.
61
62 2011-12-16  Christopher Faylor  <me.cygwin2011@cgf.cx>
63
64         * gendef (sigdelayed): Remember to pop all of the saved registers.
65         (sigreturn): Add "leave" label.
66
67 2011-12-16  Christopher Faylor  <me.cygwin2011@cgf.cx>
68
69         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Fix
70         unresolved access of wores in successful situations.
71
72 2011-12-16  Corinna Vinschen  <vinschen@redhat.com>
73
74         * Makefile.in (DLL_OFILES): Add wow64.o.
75         * dcrt0.cc (CYGWIN_GUARD): Drop execute permission for stack, it's
76         not used for stacks by the OS either.
77         (child_info_fork::alloc_stack_hard_way): Ditto.
78         (child_info_fork::alloc_stack): Don't alloc_stack_hard_way under WOW64
79         if forked from a 64 bit parent.  Set child's StackBase to parent's
80         StackBase.  Add comments to explain why.
81         (wow64_respawn): Move to wow64.cc.
82         (wow64_started_from_native64): Move to wow64.cc.
83         (respawn_wow64_process): Move to wow64.cc.
84         (dll_crt0_0): Drop wow64_test_stack_marker and move stack test into
85         wow64_test_for_64bit_parent function.  Don't return early if WOW64
86         process has been started from native 64 bit process.
87         (_dll_crt0): Implement moving stack for WOW64 processes started from
88         native 64 bit process.
89         * wow64.cc: New file.
90         (wow64_has_64bit_parent): Rename from wow64_respawn.
91         (wow64_test_for_64bit_parent): Rename from wow64_started_from_native64.
92         Change comment.
93         (wow64_revert_to_original_stack): New function.
94         (wow64_respawn_process): Rename from respawn_wow64_process for symmetry.
95         * wow64.h: New file.
96
97 2011-12-16  Christopher Faylor  <me.cygwin2011@cgf.cx>
98
99         * exceptions.cc (_cygtls::call_signal_handler): Fix debugging to not go
100         to console.
101         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Add temporary
102         kludge to work around problem of make closing a handler while it is
103         being read.
104         * gendef (sigdelayed): Don't call a function if sig has been cleared.
105
106         * sigproc.h (cygwait): Simplify slightly.
107
108 2011-12-14  Corinna Vinschen  <vinschen@redhat.com>
109
110         * autoload.cc (GetSystemWow64DirectoryW): Define.
111         (GetVolumePathNamesForVolumeNameW): Define.
112         * fhandler_process.cc (get_volume_path_names_for_volume_name): New
113         static function to workaround missing GetVolumePathNamesForVolumeNameW
114         function in Windows 2000.
115         (dos_drive_mappings::dos_drive_mappings): Call
116         get_volume_path_names_for_volume_name instead of
117         GetVolumePathNamesForVolumeNameW.
118
119 2011-12-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
120
121         * dcrt0.cc (init_windows_system_directory): Record
122         system_wow64_directory information.
123         * exceptions.cc (_cygtls::inside_kernel): Modernize comment.  Consider
124         executing a DLL from the Wow64 directory as being "in the kernel".
125         (_cygtls::call_signal_handler): For now, only deal with main_tls
126         signals if main_tls is known to be executing in the cygwin DLL.  To
127         more closely emulate linux, consider the operation to be restartable if
128         not executing in the main thread.
129         * globals.cc (windows_system_directory): Remove NO_COPY.
130         (windows_system_directory_length): Ditto.
131         (system_wow64_directory): New variable.
132         (system_wow64_directory_length): Ditto.
133
134         * select.cc (cygwin_select): Don't issue a EINTR on non-main threads
135         since that seems to be what Linux does.  Add missing break to signal
136         case/switch.
137         (select_stuff::wait): Don't issue a EINTR on non-main threads since
138         that seems to be what Linux does.  Remove now-unneeded accommodation
139         for WAIT_IO_COMPLETION.  Add a comment.
140         * sigproc.h (cygwait): Ditto.  Don't return if signal_received noticed
141         and it's not the main thread.
142
143         * signal.cc (sigprocmask): Add standard syscall debug stuff.
144         * thread.cc (pthread_sigmask): Ditto.
145
146 2011-12-13  Corinna Vinschen  <vinschen@redhat.com>
147
148         * netdb.cc (open_system_file): Avoid MS-DOS path warning.
149
150 2011-12-13  Corinna Vinschen  <vinschen@redhat.com>
151
152         * path.cc (conv_path_list): Fix a condition.
153         (cygwin_conv_path): Revert WIN_A conversion to current locale codeset.
154
155 2011-12-13  Corinna Vinschen  <vinschen@redhat.com>
156
157         * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Call
158         file_get_fnoi instead of NtQueryInformationFile.
159         * path.cc (file_get_fnoi): New helper function to collect a
160         FILE_NETWORK_OPEN_INFORMATION block.
161         (symlink_info::check): Call file_get_fnoi rather than
162         NtQueryInformationFile to collect a FILE_NETWORK_OPEN_INFORMATION block.
163         * path.h (file_get_fnoi): Declare.
164
165 2011-12-13  Dave Korn  <dave.korn.cygwin@gmail.com>
166
167         * times.cc (hires_ns::resolution): Don't return less than 1.
168
169 2011-12-12  Christopher Faylor  <me.cygwin2011@cgf.cx>
170
171         * cygthread.h (cygthread::name): Very minor formatting tweak.
172
173         * exceptions.cc (_cygtls::call_signal_handler): Add paranoid debugging
174         output.
175
176         * sigproc.h (cygwait): Call signal handler when signal is detected and
177         loop as appropriate.
178         * fhandler.h (fhandler_base_overlapped::wait_return): Remove
179         overlapped_signal.
180         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove
181         restartable signal accommodations in light of cygwait improvements.
182         (fhandler_base_overlapped::raw_read): Remove now-obsolete signal loop
183         behavior.
184         (fhandler_base_overlapped::raw_write): Ditto.
185         * fhandler_console.cc (fhandler_console::read): Ditto.
186         * fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
187         (fhandler_serial::raw_write): Ditto.
188         * fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
189
190         * ioctl.cc (ioctl): Add standard syscall introducer and leaver debug
191         output.
192
193 2011-12-12  Corinna Vinschen  <vinschen@redhat.com>
194
195         * fhandler_process.cc (dos_drive_mappings): Partially rewrite to
196         handle volumes mounted into juntion points correctly.
197
198 2011-12-12  Corinna Vinschen  <vinschen@redhat.com>
199
200         * fhandler_process.cc (dos_drive_mappings::dos_drive_mappings): Fully
201         resolve symbolic links returned by QueryDosDeviceW.  Explain why.
202
203 2011-12-12  Corinna Vinschen  <vinschen@redhat.com>
204
205         * mount.cc (fs_info::update): Set has_buggy_reopen for Netapps as well.
206
207 2011-12-12  Corinna Vinschen  <vinschen@redhat.com>
208             Christopher Faylor  <me.cygwin2011@cgf.cx>
209
210         * dcrt0.cc (wow64_respawn): New static variable.
211         (wow64_started_from_native64): New function to check if a WOW64
212         process got started from a native 64 bit process.
213         (respawn_wow64_process): New function to respawn process.
214         (dll_crt0_0): When started from a native parent, check if parent
215         is a 64 bit process.  If so, return early.
216         (_dll_crt0): Respawn WOW64 process here if required.
217         * init.cc (respawn_wow64_process): Remove.
218         (dll_entry): Rename wow64_test_stack_marker to test_stack_marker.
219         Drop WOW64 test here.
220
221 2011-12-11  Christopher Faylor  <me.cygwin2011@cgf.cx>
222
223         * pipe.cc (fhandler_pipe::create): Use debug_printf to print debugging
224         info since this isn't a "syscall".
225         (pipe_worker): New function created from _pipe().
226         (_pipe): Use pipe_worker to create a pipe.  Use standard syscall strace
227         reporting on exit.
228         (pipe): Ditto.
229         (pipe2): Ditto.
230
231 2011-12-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
232
233         * select.cc (select_stuff::wait): Very minor formatting fix.
234         (peek_windows): Report on HWND handle used in queries.
235         * select.h: Update copyright.
236         * sigproc.h (cygwait): Eliminate multi-argument variety since more
237         general implementation may cause odd problems in select.  Also force to
238         always be inline.
239
240 2011-12-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
241
242         * sigproc.h (cygwait): Delete duplicate va_start and add matching
243         va_end.
244
245 2011-12-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
246
247         * sigproc.h (cygwait): Tweak test for cancellable event to make it a
248         little more clear.
249
250 2011-12-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
251
252         * exceptions.cc (ctrl_c_handler): YA in a series or reversions.  Put
253         back _my_tls.remove along with a comment.
254         (sigpacket::process): Remove code which now causes a gdb deadlock.
255         * sigproc.cc (_cygtls::signal_exit): Signal debugger with signal number
256         earlier.
257
258 2011-12-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
259
260         * dllfixdbg: Work around annoying gdb warning about missing
261         .gnu_debuglink.
262
263 2011-12-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
264
265         Rename cygWFMO to cygwait throughout and use the magic of polymorphism
266         to "wait for stuff".
267         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use
268         simplified arg form of cygwait.
269         * fhandler_console.cc (fhandler_console::read): Ditto.
270         * fhandler_audio.cc (fhandler_dev_dsp::Audio_out::waitforspac): Ditto.
271         (fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
272         * fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
273         * fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
274         (fhandler_serial::raw_write): Ditto.
275         * select.cc (cygwin_select): Ditto.
276         * sigproc.h (cygwait): Rename from cygWFMO.  Define two argument and
277         single argument forms of this function.
278
279         * fhandler_tty.cc (fhandler_pty_slave::open): Use method to query if
280         tty is open.
281         (fhandler_pty_slave::read): Send SIGHUP when master is detected as
282         closed.
283         (fhandler_pty_common::close): Close input_available_event in callers
284         since master may need to signal it first.
285         (fhandler_pty_master::close): Lie and set input_available_event when
286         closing, then close input_available_event.
287         (fhandler_pty_slave::close): Close input_available_event explicitly
288         here.
289         * tty.h (tty::is_master_closed): Declare new method.
290
291 2011-12-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
292
293         * sigproc.cc (signal_exit): Revert reversion of 2011-12-04 change
294         since, otherwise, you see hangs when the signal pipe is closed.
295
296 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
297
298         * select.cc (cygwin_select): Fifth time is the charm.
299
300 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
301
302         * select.cc (cygwin_select): Make sure that 0 is returned when sel.wait
303         times out.
304
305 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
306
307         * include/sys/wait.h: Add in all c++ functions.
308
309 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
310
311         * select.cc (select_stuff::wait): Temporarily disallow APCS.
312
313 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
314
315         * include/sys/wait.h: Ensure that C++ functions are only used when
316         using C++.
317
318 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
319
320         * select.cc (cygwin_select): Make sure that poll is called when
321         appropriate.
322
323 2011-12-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
324
325         * dll_init.cc (dll_dllcrt0): Don't try to initialize dll data if we're
326         dynamically loaded since fork() doesn't work in that scenario anyway.
327         (dll_dllcrt0_1): Don't accommodate dynamically loaded dlls.
328         * exceptions.cc (ctrl_c_handler): Don't lock the process; there's too
329         much risk of deadlock.
330         * sigproc.cc (_cygtls::remove_wq): Don't try to remove anything from
331         the waitq if there is obviously nothing there.
332         * strace.cc (strace::activate): Allow stracing dynamically loaded
333         cygwin1.dll.
334
335 2011-12-07  Christopher Faylor  <me.cygwin2011@cgf.cx>
336
337         * fhandler_termios.cc (tty_min::kill_pgrp): Don't send __SIGSETPGRP
338         to ourselves since presumably we are already initialized.
339
340 2011-12-07  Christopher Faylor  <me.cygwin2011@cgf.cx>
341
342         * select.cc (cygwin_select): Add common introducer and leaver debug
343         output.
344         (select_stuff::poll): Remove unneeded debugging.
345
346 2011-12-07  Christopher Faylor  <me.cygwin2011@cgf.cx>
347
348         * exceptions.cc (ctrl_c_handler): Remove _my_tls.remove since it can
349         cause deadlocks during exec and will eventually be handled anyway.
350
351 2011-12-07  Corinna Vinschen  <vinschen@redhat.com>
352
353         * spawn.cc (child_info_spawn::worker): Add CREATE_BREAKAWAY_FROM_JOB
354         to all spawned processes.  Explain why.
355
356 2011-12-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
357
358         * fhandler_fifo.cc (fhandler_fifo::wait): Fix stupid typo and actually
359         wait for the handle.
360
361 2011-12-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
362
363         * sigproc.cc (close_my_readsig): New function.
364         (_cygtls::signal_exit): Close my_readsig via close_my_readsig(),
365         avoiding communication with the signal pipe.
366         (wait_sig): Close my_readsig via close_my_readsig().
367
368 2011-12-05  Corinna Vinschen  <vinschen@redhat.com>
369
370         * mmap.cc (mlock): Replace LOCK_VM_IN_WSL with correct MAP_PROCESS.
371         (munlock): Ditto.
372         * ntdll.h: Rearrange to have all preprocessor definitions at the start
373         of the file.  Add comments to each definition block.
374         (MAP_PROCESS): Rename from LOCK_VM_IN_WSL.
375         (MAP_SYSTEM): Rename from LOCK_VM_IN_RAM.
376
377 2011-12-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
378
379         * sigproc.h (cygWFMO): Don't assume that cancellable event is always
380         available.
381         * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use
382         cygWFMO instead of WaitForMultipleObjects.
383         (fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
384         * fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
385         * fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
386         (fhandler_serial::raw_write): Ditto.
387         * fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
388         * select.cc (cygwin_select): Ditto for degenerate case.
389
390 2011-12-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
391
392         * sigproc.h (cygWFMO): Move inside "INSIDE_CYGWIN" #ifdef.
393
394 2011-12-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
395
396         * exceptions.cc (exception::handle): Drop abbreviation for "exception"
397         since I never remember what it stands for.
398         (sig_handle_tty_stop): Remove obsolete call to reset_signal_arrived.
399         (_cygtls::call_signal_handler): Rework to grab signal information from
400         _main_tls if none is set for _my_tls.  Try harder to keep thread
401         locked.
402         (reset_signal_arrived): Delete.
403         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new
404         cygWFMO call to wait for an event + standard cygwin stuff.  Modify
405         debug output to acccomodate new function.
406         * fhandler_console.cc (fhandler_console::read): Replace
407         WaitForMultipleObjects with cygWFMO.
408         * fhandler_socket.cc (get_inet_addr): Add comment.
409         * gendef (_sigdelayed): Remove call to reset_signal_arrived.
410         * sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless
411         we're in the signal thread.
412         (create_signal_arrived): Create signal_arrived as auto-reset so that only
413         one thread is woken when a signal arrives.
414         * sigproc.h (cygWFMO): New function.
415         (reset_signal_arrived): Delete declaration.
416
417 2011-12-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
418
419         * mmap.cc (mlock): Add standard syscall return value debugging output.
420         (munlock): Ditto.
421         (posix_madvise): Ditto.
422
423         * signal.cc: Remove obsolete sigcatchers stuff throughout.
424         (sigaction_worker): Add function name parameter and use it to show
425         standard syscall return value debugging output.  Also add fault
426         protection.
427         (sigaction): Accommodate extra argument to sigaction_worker.
428         (siginterrupt): Ditto.
429         * syscalls.cc (read): Remove obsolete sigcatchers stuff.
430         (readv): Ditto.
431
432 2011-12-03  Corinna Vinschen  <vinschen@redhat.com>
433
434         * mmap.cc (mlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE.  Drop
435         outdated comment.  Call NtLockVirtualMemory with LOCK_VM_IN_WSL flag.
436         (munlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE.  Call
437         NtUnlockVirtualMemory with LOCK_VM_IN_WSL flag.
438
439 2011-12-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
440
441         Throughout, remove extra space after function name from debugging
442         output.
443         Throughout, change syscalls to report on return values using new %R
444         format option.
445         * smallprint.cc (__small_vsprintf): Add parsing for %R to report on
446         return values and possible errno from syscalls.
447
448         * errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
449
450         * fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread
451         use shorter name to reduce debuggging output.
452         * select.cc (start_thread_pipe): Ditto.
453         (start_thread_serial): Ditto.
454         (start_thread_socket): Ditto.
455         (start_thread_mailslot): Ditto.
456         * sigproc.cc (talktome): Ditto.
457
458 2011-12-03  Corinna Vinschen  <vinschen@redhat.com>
459
460         * fhandler.cc (fhandler_base::open): Fix comment a bit more.
461
462 2011-12-03  Corinna Vinschen  <vinschen@redhat.com>
463
464         * fhandler.cc (fhandler_base::open): Fix typos in comment.
465
466 2011-12-02  Corinna Vinschen  <vinschen@redhat.com>
467
468         * path.cc (conv_path_list): Take cygwin_conv_path_t as third parameter.
469         Allow all types of CCP conversions.  Accommodate throughout.
470         (cygwin_conv_path): Use current ANSI or OEM codepage for WIN_A
471         conversions, depending on current file API codepage setting.
472         (cygwin_conv_path_list): Allow all CCP conversion types.
473         * include/sys/cygwin.h (CCP_CONVTYPE_MASK): Add to cygwin_conv_path_t
474         enum for convenience.
475
476 2011-11-29  Christopher Faylor  <me.cygwin2011@cgf.cx>
477
478         * sigproc.cc (get_proc_lock): Remove extra NULL check.  Return false on
479         failure.
480
481 2011-11-29  Christopher Faylor  <me.cygwin2011@cgf.cx>
482
483         * sync.cc: Fix comment.
484
485 2011-11-29  Christopher Faylor  <me.cygwin2011@cgf.cx>
486
487         * dll_init.cc (dll_list::reserve_space): Use %p rather than %lx to show
488         reserved space.
489
490 2011-11-29  Christopher Faylor  <me.cygwin2011@cgf.cx>
491
492         * sigproc.cc (remove_proc): Don't terminate the currently executing
493         thread.
494
495 2011-11-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
496
497         * cygheap.cc (cygheap_fixup_in_child): Accommodate new HEAP_3*
498         classifications for cleanup-after-fork.
499         * cygheap_malloc.h (cygheap_types): Add HEAP_2_MAX, HEAP_3_FHANDLER.
500         * fhandler.h: Throughout, change clone to take a cmalloc id.
501         (fhandler_base::delete): Inline.
502         (fhandler_base_overlapped): Mark flush_async_io as a friend.
503         (fhandler_base_overlapped::asio_done): Declare new static member.
504         (fhandler_base_overlapped::asio_close_counter): Ditto.
505         (fhandler_base_overlapped::check_later): Declare new function.
506         (fhandler_base_overlapped::flush_all_async_io): Ditto.
507         * fhandler.cc (fhandler_base_overlapped::asio_done): Declare.
508         (fhandler_base_overlapped::asio_close_counter): Ditto.
509         (flush_async_io): Declare new thread function.
510         (fhandler_base_overlapped::flush_all_async_io): Declare new function.
511         (fhandler_base_overlapped::check_later): Ditto.
512         (fhandler_base_overlapped::close): Call check_later to close
513         nonblocking fd asynchronously.  Assume that this completed
514         successfully.
515         * select.cc (pipe_data_available): Don't consider data to be
516         "available" if fd still has unflushed I/O.
517         * syscalls.cc (close_all_files): Call
518         fhandler_base_overlapped::flush_all_async_io to make sure that all
519         nonblocking pipe I/O has completed.
520
521 2011-11-28  Corinna Vinschen  <vinschen@redhat.com>
522
523         * external.cc (fillout_pinfo): Store program name as POSIX path in
524         ep.progname_long.
525
526 2011-11-28  Corinna Vinschen  <vinschen@redhat.com>
527
528         * pinfo.cc (pinfo::exit): Call TerminateProcess to avoid potential
529         busy loop in ntdll.dll when calling ExitProcess. Only call ExitProcess
530         as a fallback.
531
532 2011-11-27  Christopher Faylor  <me.cygwin2011@cgf.cx>
533
534         * init.cc (dll_entry): Revert previous change since it caused
535         inexplicable fork problems.
536
537 2011-11-26  Christopher Faylor  <me.cygwin2011@cgf.cx>
538
539         * init.cc (dll_entry): Don't bother calling through thread removal
540         cleanup if we are exiting.
541
542 2011-11-26  Christopher Faylor  <me.cygwin2011@cgf.cx>
543
544         * exceptions.cc (stackdump): Make global.
545         (signal_exit): Move to sigproc.cc.
546         * sigproc.cc (signal_exit): Move here.  Declare stackdump extern.  Set
547         my_sendsig to indicate that signals are no longer available.
548         (my_readsig): Make Static again.
549         (sig_send): Interpret ERROR_BROKEN_PIPE as ESRCH.  Remove special-case
550         EACCESS errno setting, just setting errno generally, even for "its_me"
551         case.
552
553 2011-11-25  Christopher Faylor  <me.cygwin2011@cgf.cx>
554
555         * exceptions.cc (sigpacket::process): Move signal_exit processing
556         into...
557         (_cygtls::signal_exit): ...here.  Close my_readsig and comment on why.
558         * pinfo.cc (pinfo::exit): Move sigproc_terminate earlier.  Set exiting
559         flag in lock_process.
560         * sigproc.cc (my_readsig): Make global.
561         * sync.cc (muto::exiting_thread): Delete.
562         (muto::acquire): Delete #if 0'ed code.
563         * sync.h (muto::exiting_thread): Delete.
564         (set_exiting_thread): Ditto.
565         (lock_process::lock_process): Don't worry about setting the exiting
566         thread since it had no meaning.
567
568 2011-11-24  Christopher Faylor  <me.cygwin2011@cgf.cx>
569
570         * cygthread.cc (cygthread::name): Default name to "main" if we are early
571         in the process of setting up the DLL and no name is known.
572         * dcrt0.cc (initial_env): Remove CYGWIN_SLEEP stuff.
573         (get_cygwin_startup_info): Activate strace here as appropriate.
574         (dll_crt0_0): Move get_cygwin_startup_info as early as possible to
575         avoid missing strace output.
576         * fork.cc (frok::child): Move debugging statement to point where ppid
577         will be set.
578         * pinfo.cc (pinfo::thisproc): Remove obsolete call to strace.hello.
579         Tweak debug output slightly.
580         * select.cc (select_stuff::wait): Allow APCS to be triggered while
581         waiting since we use them now.  Report when that happens.
582         * sigproc.cc (child_info::child_info): Use strace.active() rather than
583         strace.attached().
584         * spawn.cc (child_info_spawn::worker): Only write strace child pid
585         when we know it's a cygwin process.  Accommodate change to write_child
586         argument list.
587         * strace.cc (strace::hello): Delete.  Move functionality...
588         (strace::activate): ...to here.
589         (mypid): Just use raw GetCurrentProcessId () if myself isn't set.
590         (strace::write_childpid): Don't wait for subproc_ready.  Remove arg
591         which was required for it.
592         * include/sys/strace.h (strace::hello): Delete.
593         (strace::write_childpid): Delete first argument.
594
595 2011-11-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
596
597         * child_info.h (CURR_CHILD_INFO_MAGIC): Reset for previous changes.
598
599         * dcrt0.cc (get_cygwin_startup_info): Signal readiness when stracing
600         since strace::write_child relies on it.  Use strace.activate to notify
601         strace process, passing in arg indicating whether we're forked.
602         * sigproc.cc (wait_sig): Accommodate new strace::activate argument.
603         * spawn.cc (child_info_spawn::worker): Oops.  Previous suspended test
604         was actually correct.  Revert and document.
605         * strace.cc (strace::activate): Send additional flag indicating whether
606         this is an attempt to activate a forked process.
607         (strace::hello): Report on windows pid.
608         * include/sys/strace.h (strace::strace): Make a dummy.
609         (strace::activate): Modify declaration to accept an argument.
610         (strace::write_childpid): Set regparm.
611
612 2011-11-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
613
614         * pipe.cc (fhandler_pipe::create): Avoid derefencing a NULL pointer.
615
616         * child_info.h (child_info): Reorganize some elements so that the ones
617         which are initialized in a constructor are all together.
618         * sigproc.cc (child_info::child_info): Initialize values via the
619         constructor rather than as C statements and make sure that flags is set
620         to zero initially.
621
622         * spawn.cc (child_info_spawn::worker): Use iscygwin() test for
623         determining when to send strace info since it is more foolproof than
624         checking the suspend state.
625
626 2011-11-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
627
628         * fhandler.h (fhandler_pipe::create): Rename from the misnamed
629         "create_selectable".  Change return to DWORD.
630         (fhandler_pty_common::pipesize): New constant.
631         * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Reflect
632         create_selectable name change.
633         * miscfuncs.cc (CreatePipeOverlapped): Ditto.
634         * pipe.cc (fhandler_pipe::create): Ditto.
635         (fhandler_pipe::create): Rename from the misnamed "create_selectable".
636         Return DWORD.  Only set pipe size to default when it is passed in as
637         zero.
638         * fhandler_tty.cc (fhandler_pty_master::setup): Ditto.  Use
639         fhandler_pty_common::pipesize rather than a raw constant.
640         * tty.cc (tty::not_allocated): Ditto.
641
642         * sigproc.cc (sigproc_init): Use fhandler_pipe::create to create the
643         signal pipe to get a more appropriate message based pipe.
644
645 2011-11-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
646
647         * sigproc.cc (remove_proc): Don't do busy loop when exiting since it
648         doesn't matter.
649
650 2011-11-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
651
652         * sigproc.cc (remove_proc): Don't do busy loop when execing since
653         thread could have been terminated prior to setting flag.
654
655         * signal.cc (sigwaitinfo): Zero event before closing to signal other
656         threads that it is no longer available.
657
658 2011-11-18  Corinna Vinschen  <corinna@vinschen.de>
659
660         * shared.cc (get_shared_parent_dir): Use global shared_parent_dir
661         instead of local dir variable and create handle not inheritable to
662         avoid accumulating stray handles in child processes.
663         (get_session_parent_dir): Ditto with session_parent_dir variable.
664
665 2011-11-17  Corinna Vinschen  <corinna@vinschen.de>
666
667         * shared.cc (shared_info::create): Open global shared data section
668         non-inheritable to avoid accumulating stray handles in child processes.
669
670 2011-11-15  Christopher Faylor  <me.cygwin2011@cgf.cx>
671
672         * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
673         (cygheap_exec_info::nchildren): Move from child_info_spawn.
674         (cygheap_exec_info::cchildren): Ditto.
675         (cygheap_exec_info::record_children): Declare new function.
676         (cygheap_exec_info::reattach_children): Ditto.
677         (cygheap_exec_info::alloc): Ditto.
678         (child_info_spawn::nchildren): Move to cygheap_exec_info.
679         (child_info_spawn::cchildren): Ditto.
680         * sigproc.cc (cygheap_exec_info::alloc): Define new function.
681         (child_info_spawn::cleanup): Accommodate move of children info to
682         cygheap_exec_info.
683         (cygheap_exec_info::record_children): Define new function.
684         (cygheap_exec_info::reattach_children): Ditto.
685         (child_info_spawn::record_children): Use
686         cygheap_exec_info function to accomplish this task.
687         (child_info_spawn::reattach_children): Ditto.
688         * spawn.cc (child_info_spawn::worker): Allocate moreinfo using
689         cygheap_exec_info::alloc.
690
691         * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Use abort for the
692         error to avoid a retry.
693
694 2011-11-14  Christopher Faylor  <me.cygwin2011@cgf.cx>
695
696         * pinfo.cc (_pinfo::dup_proc_pipe): Fatalize a warning when debugging.
697
698 2011-11-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
699
700         Remove erroneously checked-in debugging statements.
701         * cygheap.cc (cygheap_fixup_in_child): Here.
702         * debug.cc (delete_handle): Here.
703         * sigproc.cc (child_info_spawn::cleanup): Here.
704         * spawn.cc (child_info_spawn::worker): Here.
705
706 2011-11-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
707
708         Throughout, change "sig %d" in strace output to "signal %d" for
709         consistency.
710         * assert.cc (__assert_func): Output assertion string to strace too.
711         * fork.cc (frok::parent): Report ASAP on forked pid in debugging output.
712         * pinfo.cc (pinfo::_pinfo_release): Define new function.
713         (pinfo::init): Use _pinfo_release() rather than release() to release
714         shared memory stuff.
715         (pinfo::wait): Shorten name of process waiting thread for more concise
716         debugging.
717         (pinfo::release): Use pinfo_release to release shared memory part of
718         struct.
719         * pinfo.h (pinfo::__pinfo_release): Declare.
720
721 2011-11-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
722
723         Throughout use "have_execed" macro rather than "hExeced" global handle.
724         Throughout rename _PROC_* to _CH_*.
725         * child_info.h: Include "pinfo.h".
726         (child_info_types): Rename _PROC_* -> _CH_* to avoid confusion with
727         similarly named constants.
728         (_PROC_*): Delete unneeded aliases.
729         (PROC_*): Ditto.
730         (CURR_CHILD_INFO_MAGIC): Ditto.
731         (cchildren): Define using "pinfo_minimal".
732         (child_info::set_saw_ctrl_c): Move to
733         (child_info_spawn::set_saw_ctrl_c): Here.
734         (child_info_spawn::lock): New field.
735         (child_info_spawn::hExeced): Ditto.
736         (child_info_spawn::ev): Ditto.
737         (child_info_spawn::~child_info_spawn): Move to sigproc.cc.
738         (child_info_spawn::child_info_spawn): Ditto.
739         (child_info_spawn::cleanup): Declare new function.
740         (child_info_spawn::set_saw_ctrl_c): Move to this class.  Set flag only
741         when execed and return true when we have set the flag.
742         (child_info_spawn::child_info_spawn::signal_myself_exited): New function.
743         (child_info_spawn::wait_for_myself): Ditto.
744         (child_info_spawn::has_execed_cygwin): Ditto.
745         (child_info_spawn::has_execed): Ditto.  Replaces "hExeced" test.
746         (child_info_spawn::operator HANDLE&): New operator.
747         (child_info_spawn::worker): Define old "spawn_guts" as class member.
748         (ch_spawn): Declare.
749         (have_execed): Define.
750         (have_execed_cygwin): Ditto.
751         * cygheap.h: Update comment.
752         * dcrt0.cc (get_cygwin_startup_info): Use _CH_* enums.
753         (child_info_spawn::handle_spawn): Ditto.
754         (dll_crt0_0): Ditto.
755         (multiple_cygwin_problem): Ditto.
756         * exceptions.cc (chExeced): Delete obsolete declaration.
757         (ctrl_c_handler): Reference set_saw_ctrl_c via new ch_spawn global.
758         * globals.cc (hExeced): Delete.
759         * pinfo.cc (pinfo::thisproc): Refer to cygheap as ::cygheap for
760         consistency in handle naming when -DDEBUGGING.
761         (pinfo::init): Accommodate case where myself.h is known but h0 is
762         passed in.
763         (pinfo::pinfo): New constructor for setting up a pinfo passed in by
764         previous exec'or.
765         (pinfo::proc_waiter): Don't handle subprocess if we're in the process
766         of exiting due to an exec of a cygwin process.  Don't close
767         rd_proc_pipe here.  Close it when we actually are finished with the
768         process.  Use new ch_spawn.signal_myself_exited function to let exec
769         stub know that subprocess has exited.
770         (pinfo::wait): Clarify debugging output.
771         (pinfo::release): Use "close_h" to close all handles to avoid races.
772         (winpids::add): Assume that elements of the array do not need to be
773         zeroed and are properly initialized or suffer problems on
774         pinfo::release.  Don't close hProcess since release does that now.
775         * pinfo.h: Update comment.
776         (pinfo_minimal): Move some elements from pinfo here so that
777         child_info_spawn can use them.
778         (pinfo): Inherit from pinfo_minimal.
779         (pinfo::pinfo): Modify to accommodate new pinfo_minimal.
780         (pinfo::allow_remove): New function.
781         * sigproc.cc (proc_subproc): Use boolean values for true/false.
782         Implement PROC_EXEC_CLEANUP.
783         (proc_terminate): Set ppid = 1 since the procs list will only be
784         iterated when the process has not execed.  Don't do any cleanup here
785         since it is now handled in pinfo::release.
786         (sigproc_init): Initialize sync_proc_subproc earlier.
787         (child_info::child_info): Assume that all important fields are properly
788         initialized and avoid memset().
789         (child_info_spawn::child_info_spawn): Specifically test for execing and
790         then set up appropriate fields in the struct.
791         (child_info_spawn::cleanup): Define new function.
792         (child_info_spawn::record_children): Specifically test for being execed
793         here.  Fill in pinfo_minimal part of children array.
794         (child_info_spawn::reattach_children): Use constructor to duplicate
795         information for previous exec'or.  Add more debugging output.
796         (remove_proc): Force deletion of thread when exiting due to exec.  Rely
797         on pinfo::cleanup in release.
798         * sigproc.h (PROC_EXEC_CLEANUP): New enum.
799         (PROC_DETACHED_CHILD): Delete.
800         * spawn.cc (chExeced): Delete.
801         (child_info_spawn::worker): Rename from spawn_guts.  Use elements of
802         child_info_spawn throughout rather than ch.whatever.  Use ::cygheap to
803         refer to global rather than element of child_info.  Use
804         wait_for_myself() rather than waitpid().  Call
805         child_info_spawn::cleanup on function return.
806         (spawnve): Reflect movement of spawn_guts functionality into
807         child_info_spawn::worker.
808         * syscalls.cc (popen): Ditto.
809         * winsup.h (spawn_guts): Delete declaration.
810
811 2011-11-08  Corinna Vinschen  <corinna@vinschen.de>
812
813         * posix.sgml (std-gnu): Add ptsname_r.
814
815 2011-11-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
816
817         * fhandler.h (__ptsname): New macro.
818         * dtable.cc (decode_tty): Use __ptsname to generate the slave pty name.
819         * fhandler_tty.cc (fhandler_pty_master::ptsname_r): Ditto.
820         * bsdlib.cc: Add needed includes for openpty() changes.
821         (openpty): Use __ptsname to generate the slave pty name.  Close slave
822         fd when aslave == NULL.
823
824 2011-11-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
825
826         * include/cygwin/stdlib.h: Update copyright.
827
828 2011-11-07  Christopher Faylor  <me.cygwin2011@cgf.cx>
829
830         * cygwin.din (ptsname_r): Export.
831         * fhandler.cc (fhandler_base::ptsname_r): Define.
832         * fhandler.h (fhandler_base::ptsname): Delete.
833         (fhandler_base::ptsname_r): Declare.
834         (fhandler_pty_master::ptsname_r): Declare.
835         * fhandler_tty.cc (fhandler_pty_master::ptsname): Delete.
836         (fhandler_pty_master::ptsname_r): New reentrant function derived from
837         previous ptsname.
838         * syscalls.cc (ptsname_r): Implement new function with functionality
839         similar to Linux.
840         (ptsname): Use ptsname_r () to fill out buf.
841         * include/cygwin/stdlib.h (ptsname_r): Declare.
842         * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 255 to
843         reflect export of ptsname_r.
844
845         * pinfo.cc (pinfo::wait): Return bool rather than int.
846         * pinfo.h (info::wait): Ditto.
847         (pinfo::reattach): Define !defined(_SIGPROC_H) case for consistency.
848         * sigproc.cc (child_info_spawn::reattach_children): Use correct
849         dwProcessId rather than pid when duplicating handle.
850
851 2011-11-07  Corinna Vinschen  <corinna@vinschen.de>
852
853         * fhandler.cc (CHUNK_SIZE): Drop NO_COPY.
854
855 2011-11-07  Corinna Vinschen  <corinna@vinschen.de>
856
857         * syscalls.cc (check_dir_not_empty): Check surplus directory entries
858         by calling NtQueryAttributesFile.  Make STATUS_DIRECTORY_NOT_EMPTY
859         return value dependent on its status code.  Add long comment to explain.
860         (unlink_nt): Add comment to explain flaw in checking the sharing mode.
861         Set status to STATUS_SUCCESS instead of 0.  Add a retry loop to setting
862         the delete disposition and trying to move a directory to bin to
863         workaround rare cases of lingering, already deleted subdirectory
864         entries.  Add long comment to explain.
865         (rename): Set status to STATUS_SUCCESS instead of 0.
866
867 2011-11-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
868
869         * pinfo.cc (status_exit): Recognize STATUS_ILLEGAL_INSTRUCTION.
870         (child_info::proc_retry): Ditto.
871
872 2011-11-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
873
874         * pinfo.cc (status_exit): Return complete error code.  Handle
875         STATUS_ACCESS_VIOLATION correctly.
876         (pinfo::set_exit_code): Set self->exitcode directly from status_exit.
877
878 2011-11-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
879
880         * pinfo.h (pinfo::reattach): Only set destroy to false when
881         proc_subproc succeeds.  Return true for success.
882         * sigproc.cc (child_info_spawn::reattach_children): Try harder to clean
883         up on error by detecting reattach failures too.
884
885 2011-11-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
886
887         * sigproc.cc (child_info_spawn::reattach_children): Clean up handle
888         when can't open parent process or suffer handle leak.
889
890 2011-11-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
891
892         * sigproc.cc (child_info::sync): Report on exit code in strace output.
893         (child_info::proc_retry): Don't consider STATUS_ACCESS_VIOLATION as a
894         restartable event.
895
896 2011-11-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
897
898         * sigproc.cc (child_info_spawn::reattach_children): Avoid issuing an
899         error when we can't duplicate from "parent" since it is probably ok if
900         children of the previous owner of the pid disappear.
901
902 2011-11-03  Corinna Vinschen  <corinna@vinschen.de>
903
904         * fhandler.cc (off_current): Define local in fhandler_base::raw_write.
905         Drop erroneous NO_COPY, add _RDATA to make R/O.
906         (off_append): Ditto.
907         * globals.cc (_RDATA): Move definition from here...
908         * winsup.h: ...to here.
909
910 2011-10-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
911
912         * fhandler.h (fhandler_pipe::create_selectable): Remove optional
913         argument, take an options argument for CreateNamedPipe/CreateFile.
914         Change handle arguments to expect pointers.
915         (fhandler_fifo::fifo_state): Delete.
916         (fhandler_fifo::dummy_client): Ditto.
917         (fhandler_fifo::open_nonserver): Ditto.
918         (fhandler_fifo::wait_state): Ditto.
919         (fhandler_fifo::raw_write): Ditto.
920         (fhandler_fifo::read_ready): New field.
921         (fhandler_fifo::write_ready): Ditto.
922         (fhandler_fifo::wait): Modify argument.
923         (fhandler_fifo::fifo_name): Add a new argument.
924         (fhandler_fifo::fixup_after_fork): New function.
925         * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove
926         initialization of expunged elements.  Initialize new handles to NULL.
927         (fhandler_fifo::open_nonserver): Delete.
928         (fnevent): New macro for creating a named event.
929         (fnpipe): New macro for creating a unique named pipe name.
930         (create_pipe): New macro for simplification of named pipe creation.
931         (fhandler_fifo::fifo_name): Use new argument when creating a shared
932         name.
933         (fhandler_fifo::open): Rewrite.  Use events to synchronize.
934         (fhandler_fifo::wait): Rewrite to wait for new fifo events which are
935         supplied as a parameter.
936         (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect
937         client-side disconnect.
938         (fhandler_fifo::raw_write): Delete.
939         (fhandler_fifo::close): Remove accommodations for expunged fields.
940         Close event handles.
941         (fhandler_fifo::dup): Remove accommodations for expunged fields.
942         Duplicate event handles.
943         (fhandler_fifo::fixup_after_fork): New function.  Perform fixups on
944         event handles.
945         (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged
946         fields.  Set inheritance for new handle fields.
947         * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in
948         fhandler_pipe::create_selectable.
949         * tty.cc (tty::not_allocated): Ditto.
950         * pipe.cc (fhandler_pipe::create): Ditto.
951         (fhandler_pipe::create_selectable): Accept an extra open_mode argument.
952         Pass arguments by reference and allow opening one end of the pipe at a
953         time.
954
955         * sys/strace.h (debug_only_printf): Define new macro which calls
956         debug_printf only when DEBUGGING is defined.
957
958 2011-10-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
959
960         * exceptions.cc (sigpacket::process): Avoid a potential deadlock when
961         exiting due to a signal.
962
963 2011-10-28  Corinna Vinschen  <corinna@vinschen.de>
964
965         * cygwin.din (getgrouplist): Export.
966         * grp.cc (get_groups): New static function to run the core functionality
967         of initgroups and getgrouplist.
968         (initgroups32): Call get_groups and just create supplementary group
969         list in cygheap.  Rename name of first argument to "user".  Add an
970         assertion to test for a NULL user name.
971         (initgroups): Rename name of first argument to "user".
972         (getgrouplist): New function.
973         * posix.sgml (std-bsd): Add getgrouplist.
974         * include/cygwin/grp.h (getgrouplist): Declare.
975         * include/cygwin/version.h: Bump API minor number.
976
977 2011-10-25  Christopher Faylor  <me.cygwin2011@cgf.cx>
978
979         * child_info.h (cchildren): New struct.
980         (child_info_spawn::nchildren): Rename from nprocs.
981         (child_info_spawn::children): Change type to cchildren for more
982         bookkeeping possibilities.
983         (child_info_spawn::child_info_spawn): Clear nchildren.
984         (child_info_spawn::record_children): Declare new function.
985         (child_info_spawn::reattach_children): Ditto.
986         * dcrt0.cc (child_info_spawn::handle_spawn): Call reattach_children to
987         gather list of processes we are potentially waiting for.
988         * pinfo.h (pinfo::pinfo): Make sure that rd_proc_pipe is always cleared.
989         (pinfo::reattach): New function.
990         * sigproc.cc: Move pinfo.h earlier so that it can be used in sigproc.h.
991         (get_proc_lock): Don't bother with a lock during DLL initialization.
992         (proc_subproc): Handle PROC_REATTACH_CHILD.
993         (proc_terminate): Orphan children only when we are not an execed
994         process or when the pid is about to be occupied by a non-cygwin
995         process.
996         (child_info_spawn::record_children): Define new function.
997         (child_info_spawn::reattach_children): Ditto.
998         * sigproc.h (procstuff): Define PROC_REATTACH_CHILD and renumber other
999         elements.
1000         * spawn.cc (spawn_guts): Record any to-be-waited-for subprocesses if
1001         about to exec a cygwin process.
1002
1003         * sigproc.cc (sig_send): Fix harmless transposition of fifth and six
1004         arguments to DuplicateHandle().
1005         (child_info::child_info): Ditto.
1006
1007         * globals.cc (hExeced): Make NO_COPY.
1008
1009 2011-10-25  Corinna Vinschen  <corinna@vinschen.de>
1010
1011         * hookapi.cc (hook_or_detect_cygwin): Take additional handle
1012         to a file mapping as parameter.  If this handle is not NULL,
1013         create another file mapping for the IAT.
1014         * spawn.cc (av::fixup): Only map the first 64K of an image and
1015         keep the mapping handle to use as argument to hook_or_detect_cygwin.
1016         * winsup.h (hook_or_detect_cygwin): Add mapping handle as default
1017         parameter in declaration.
1018
1019 2011-10-24  Corinna Vinschen  <corinna@vinschen.de>
1020
1021         * syscalls.cc (unlink_nt): Fix a bug which overwrites the NT status
1022         value in case setting the delete disposition returns with
1023         STATUS_DIRECTORY_NOT_EMPTY.
1024
1025 2011-10-24  Corinna Vinschen  <corinna@vinschen.de>
1026
1027         * shared.cc (open_shared): Fix memory reservation of essential shared
1028         memory regions.  Drop delta computations since delta is always 0 in
1029         non-relocated case.  Add a comment.
1030
1031 2011-10-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
1032
1033         * fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for
1034         testing ReadFile return.
1035         * pipe.cc (fhandler_pipe::create_selectable): Open the write side of
1036         the pipe in message-mode to force writing as "chunks".  Explain why.
1037
1038 2011-10-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
1039
1040         * path.cc (path_conv::get_nt_native_path): Avoid dereferencing path
1041         when it is NULL.
1042
1043 2011-10-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
1044
1045         * dtable.cc (dtable::delete_archetype): Improve debugging output.
1046         (dtable::init_std_file_from_handle): Close console handle early, before
1047         initialization.  Build up openflags for passing to open_setup, just to
1048         be safe.
1049         (last_tty_dev): New variable.
1050         (fh_last_tty_dev): New macro.
1051         (fh_alloc): Try again to keep track of previously opened tty, this time
1052         by just saving the device and using that to potentially open an
1053         archetype.  Avoid setting the "/dev/tty" name if the creation of the
1054         fhandler failed.
1055         (build_fh_pc): Remove unused second argument.  Reorganize how and where
1056         the name is set.  Set last_tty_dev as appropriate.  Avoid a NULL
1057         dereference in a debug printf.
1058         * dtable.h (build_fh_pc): Reflect removal of second parameter.
1059         * fhandler.cc (fhandler_base::reset): Use new '<<' operator to copy pc
1060         since it preserves any potentially previously set name.
1061         (fhandler_base::set_name): Ditto.
1062         * fhandler.h (fhandler_*::clone): Throughout use ccalloc to allocate
1063         new fhandler, primarily to make sure that pc field is properly zeroed.
1064         (fhandler_termios::last): Eliminate.
1065         (fhandler_termios): Remove setting of last.
1066         (fhandler_base::~fhandler_termios): Ditto.
1067         * fhandler_console.cc (fhandler_console::open): Don't make decisions
1068         about opening close-on-exec handles here since it makes no sense for
1069         archetypes.
1070         (fhandler_console::init): Assume that input handle has already been
1071         opened.
1072         * fhandler_termios.cc (fhandler_termios::last): Delete.
1073         * path.h (path_conv::eq_worker): New function.  Move bulk of operator =
1074         here.
1075         (operator <<): New function.
1076         (operator =): Use eq_worker to perform old functionality.
1077
1078         * child_info.h (NPROCS): Move here from sigproc.cc.
1079         (child_info::nprocs): New field.  Not used yet.
1080         (child_info::children):: Ditto.
1081
1082 2011-10-21  Corinna Vinschen  <corinna@vinschen.de>
1083
1084         * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Check invalid
1085         success only on Samba shares.
1086         * mount.cc (fs_info::update): Drop has_buggy_basic_info flag for
1087         NcFsd.
1088         * syscalls.cc (unlink_nt): Fix typo in comment.
1089
1090 2011-10-21  Corinna Vinschen  <corinna@vinschen.de>
1091
1092         * globals.cc (ro_u_ncfsd): New R/O unicode string.
1093         * mount.cc (fs_info::update): Check for "NcFsd" FS.  Set flags and
1094         change comments accordingly.
1095         (fs_names): Add entry for NcFsd FS.
1096         * mount.h (enum fs_info_type): Add ncfsd.
1097         (class fs_info): Add ncfsd flag and accessor methods.
1098         * path.h (class path_conv): Add fs_is_ncfsd method.
1099         * syscalls.cc (unlink_nt): Experimentally try delete-on-close on NcFsd
1100         in STATUS_CANNOT_DELETE case.
1101
1102 2011-10-20  Christopher Faylor  <me.cygwin2011@cgf.cx>
1103
1104         * fhandler.h (fhandler*::copyto): Free path_conv strings first.
1105         * path.h (cfree_and_null): Rename and expand from cfree_maybe.
1106         (path_conv &operator =): Call free_strings rather than freeing strings
1107         directly.
1108
1109 2011-10-20  Christopher Faylor  <me.cygwin2011@cgf.cx>
1110
1111         Throughout change TTY_* to PTY_*, tty_* to pty_*, and ttym_* to ptmx_*.
1112         * devices.cc: Regenerate.
1113         * dtable.cc: (fh_alloc): Preserve /dev/tty name when that's what we
1114         opened.
1115         (build_fh_pc): Preserve any existing name.
1116         * fhandler.cc (fhandler_base::open_with_arch): Ditto.
1117         * fhandler_tty.cc (fhandler_pty_master::fhandler_pty_master): Force the
1118         name to /dev/ptmx while preserving other pty master device information.
1119         * path.h (cfree_maybe): New macro.
1120         (path_conv::operator =): Free any allocated strings in target.
1121         (path_conv::free_strings): Delete unused function.
1122
1123         * sigproc.cc (proc_terminate): Remove previous accommodation for execed
1124         processes since it didn't have the desired effect.  Change comment to a
1125         FIXME.
1126
1127         * spawn.cc (chExeced): Mark NO_COPY.
1128         (exe_suffixes): Ditto.
1129
1130 2011-10-20  Corinna Vinschen  <corinna@vinschen.de>
1131
1132         * syscalls.cc (try_to_bin): Improve debug output.
1133         (check_dir_not_empty): Take additional path_conv argument.  Improve
1134         debug output.  Change syscall_printf to debug_printf.
1135         (unlink_nt): Improve debug output.  Change syscall_printf to
1136         debug_printf.
1137         (unlink): Change syscall_printf to debug_printf.
1138
1139         * cygthread.h: Fix copyright dates.
1140
1141 2011-10-18  Corinna Vinschen  <corinna@vinschen.de>
1142
1143         * path.cc: Extend two comments.  Mention the name RtlpCurDirRef
1144         for reference.
1145
1146 2011-10-17  Christopher Faylor  <me.cygwin2011@cgf.cx>
1147
1148         * dcrt0.cc (dll_crt0_1): Copy argv before passing to main().
1149
1150 2011-10-17  Christopher Faylor  <me.cygwin2011@cgf.cx>
1151
1152         * sigproc.cc (proc_terminate): Avoid setting ppid to 1 if we're execing.
1153
1154 2011-10-15  Christopher Faylor  <me.cygwin2011@cgf.cx>
1155
1156         * cygerrno.h (__set_errno): Modify debugging output to make searching
1157         strace logs easier.
1158
1159         Throughout, change /dev/tty* to /dev/pty*.
1160         Throughout, add flags argument to fhandler_*::dup methods.
1161         * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN.  Add
1162         /dev/ptymN devices for pty masters.
1163         * devices.cc: Regenerate.
1164         * devices.h (MAX_CONSOLES): Set to max number supported by devices.in.
1165         (fh_devices::FH_PTMX): Rename from FH_PTYM.
1166         (device::operator int): Return by reference.
1167         * dtable.cc (fh_alloc): Take pc as an argument rather than just the
1168         device.  This makes debugging easier since more information is
1169         available.  Actually implement handling for already-allocated pty
1170         master devices.  Make different decisions when generating fhandler for
1171         not-opened devices.  Add kludge to deal with opening /dev/tty.
1172         (cnew_no_ctor): New macro.
1173         (build_fh_pc): Make debugging output more verbose.  Use new clone()
1174         fhandler interface to duplicate archetypes.  Reset last term opened.
1175         (dtable::dup_worker): Use Use new clone() fhandler interface to
1176         duplicate archetypes.  Pass flags to child dup handler.
1177         (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr.
1178         * fhandler.cc (fhandler_base::reset): Rename from operator =() and
1179         reduce functionality and sense of copy direction.
1180         (fhandler_base::open_with_arch): Use published interface to query
1181         io_handle().  Use new copyto() fhandler method to copy from/to found
1182         archetype.
1183         * fhandler.h: Throughout, delete size(), add copyout, clone, and
1184         fhandler_* (void *) methods.
1185         (fhandler_base::reset): Rename from operator =().
1186         (fhandler_termios::is_dev_tty): Delete.
1187         (fhandler_termios): change "protected" region to "private".
1188         (fhandler_termios::is_dev_tty): Delete.
1189         (fhandler_termios): Rearrange protected/public.
1190         (fhandler_termios::fhandler_termios): Remember last fhandler_termios
1191         "opened".
1192         (fhandler_termios::~fhandler_termios): Forget last fhandler_termios
1193         opened.
1194         (ioctl): Rename from ioctl_termios.  Take a void * argument.  Reflect
1195         argument change in pinfo::set_ctty.
1196         (fhandler_console::dup): Declare new function.  Set ctty here if
1197         appropriate.
1198         (fhandler_pty_master::from_master): Privatize.
1199         (fhandler_pty_master::to_master): Ditto.
1200         (fhandler_pty_master::dwProcessId): Ditto.
1201         (fhandler_pty_master::fhandler_pty_master): Add an `int' argument.
1202         (fhandler_pty_master::open_setup): Declare new function.
1203         (fhandler_pty_master::~fhandler_pty_master): Declare new method.
1204         (fhandler_nodevice): Remove commented out function declaration.
1205         * fhandler_console.cc: Use get_ttyp() instead of tc() throughout.
1206         (fhandler_console::dup): Define new function to set controlling ctty on
1207         dup, as appropriate.
1208         (fhandler_console::ioctl): Reflect ioctl_termios name change.
1209         (fhandler_console::setup): Rename from get_tty_stuff.
1210         (fhandler_console::open_setup): Reflect argument change in
1211         pinfo::set_ctty.
1212         (fhandler_console::fhandler_console): Set _tc here.
1213         * fhandler_termios.cc (handler_termios::ioctl): Rename.  Take a void *
1214         arg like other ioctl functions.
1215         * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to
1216         potentially reset the controlling terminal.
1217         (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios.
1218         (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument.  Call
1219         setup() here so that we will know the unit number of this fhandler as
1220         soon as possible.  Set the unit as appropriate.
1221         (handler_pty_master::open): Move most stuff to constructor and
1222         open_setup.
1223         (handler_pty_slave::open_setup): Reflect argument change in
1224         pinfo::set_ctty.
1225         (handler_pty_master::open_setup): Define new function.
1226         (fhandler_pty_master::cleanup): Clear handles as a flag that the
1227         destructor does not have to do "close" operations.
1228         (fhandler_pty_master::close): Ditto.
1229         (fhandler_pty_master::~fhandler_pty_master): Define new method.
1230         (fhandler_pty_master::ioctl): Reflect name/arg change for
1231         ioctl_termios.
1232         (fhandler_pty_master::setup): Allocate tty here.  Rely on handles being
1233         returned from allocated test rather than opening them here.  Avoid
1234         setting _need_nl here since it is already zeroed in the constructor.
1235         Set up device information with DEV_TTYM_MAJOR.
1236         * path.h (path_conv &operator =): Take a const argument.
1237         (path_conv::dup): Ditto.
1238         (pathconv_arg::PC_OPEN): New enum.
1239         (pathconv_arg::PC_CTTY): Ditto.
1240         (path_types::PATH_CTTY): Ditto.
1241         (path_types::PATH_OPEN): Ditto.
1242         (path_conv::isopen): New method.
1243         (path_conv::isctty_capable): Ditto.
1244         * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as
1245         appropriate.
1246         * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle.
1247         * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty
1248         on non-std* handles.
1249         * tty.cc (tty_list::allocate): Pass out handles for allocated tty.  use
1250         `not_allocated' to find unallocated ttys.  Avoid keeping the lock since
1251         the allocation of the tty should be sufficient to prevent multiple
1252         access.
1253         (tty::not_allocated): Clarify comment.  Rename.  Return handles when an
1254         unused tty is found.  Simply test for existing tty.
1255         (tty::exists): Rewrite to use `not_allocated'.
1256         * tty.h (NTTYS): Reset down to actual number supported by devices.in.
1257         (tty::not_allocated): Declare new function.
1258         (tty_list::allocate): Pass out read/write tty handles.  Zero them when
1259         not found.
1260         * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX.
1261         * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in.
1262         * pinfo.cc (pinfo::set_ctty): Ditto.  Just use tc() built into the
1263         passed-in fhandler_termios pointer.  Return true if ctty is assigned.
1264         * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag.  Set PC_CTTY
1265         if appropriate.
1266         (stat_worker): Remove is_dev_tty () stuff.
1267
1268 2011-10-15  Corinna Vinschen  <corinna@vinschen.de>
1269
1270         * fhandler_process.cc (dos_drive_mappings::fixup_if_match): Convert
1271         native NT network paths into DOS UNC paths.
1272
1273 2011-10-15  Corinna Vinschen  <corinna@vinschen.de>
1274
1275         * sec_auth.cc (get_token_group_sidlist): Add CONSOLE LOGON SID on
1276         systems supporting it.  Never add SERVICE SID but keep code in for
1277         future reference.  Explain why.
1278         (get_priv_list): Add cygpsid pointer parameter.  Point it to the
1279         mandatory integrity SID which matches account and privileges.
1280         (create_token): Fetch mandatory integrity SID from call to
1281         get_priv_list.
1282         (lsaauth): Call get_priv_list with additional NULL pointer.  Change
1283         comment accordingly.
1284         * sec_helper.cc (well_known_console_logon_sid): New static SID.
1285         (cygpriv): Change to structure containing extra flag to store info
1286         about required integrity level.
1287         (privilege_luid): Accommodate changes to cygpriv.  Return integrity
1288         level in new high_integrity parameter.
1289         (privilege_name): Accommodate changes to cygpriv.
1290         (set_privilege): Drop trailing \n from debug output.
1291         (set_cygwin_privileges): Don't set SE_CREATE_GLOBAL_PRIVILEGE anymore
1292         since it's just not needed, but keep code in for future reference.
1293         Change comment accordingly.
1294         * security.h (well_known_console_logon_sid): Declare.
1295         (privilege_luid): Align declaration to above change.
1296         * wincap.h (wincaps::has_console_logon_sid): New element.
1297         * wincap.cc: Implement above element throughout.
1298
1299 2011-10-13  Corinna Vinschen  <corinna@vinschen.de>
1300
1301         * path.cc (find_fast_cwd_pointer): Allow 'push crit-sect-addr' instead
1302         of 'mov edi, crit-sect-addr; push edi' and set rcall accordingly.
1303
1304 2011-10-13  Corinna Vinschen  <corinna@vinschen.de>
1305
1306         * path.cc (copy_cwd_str): Move up in file to be accessible from
1307         class fcwd_access_t.
1308         (class fcwd_access_t): New class to consolidate and hide the details
1309         of the various FAST_CWD implementations.  Add implementation for
1310         Windows 8 Developer Preview.
1311         (fast_cwd_version): Make static private member of fcwd_access_t.
1312         (fast_cwd_ptr): Change base type to fcwd_access_t.
1313         (find_fast_cwd_pointer): Return fcwd_access_t**.
1314         (find_fast_cwd): Ditto.  Rip out all FAST_CWD implementations and use
1315         fcwd_access_t methods instead.
1316         (cwdstuff::override_win32_cwd): Ditto.
1317
1318 2011-10-12  Corinna Vinschen  <corinna@vinschen.de>
1319
1320         * fhandler_console.cc (fhandler_console::cursor_set): Disable forcing
1321         y to the current winBottom position.  Explain why.
1322
1323 2011-10-11  Christopher Faylor  <me.cygwin2011@cgf.cx>
1324
1325         * cygwin.din: Remove some _tc* exports.  Add tcgetsid().
1326         * dtable.cc (fh_alloc): Revert ill-advised setting of major/minor.  Use
1327         new is_dev_tty to remember that this device was opened as /dev/tty.
1328         * fhandler.cc (fhandler_base::fstat): Remove leftover debugging
1329         statement.
1330         (fhandler_base::tcgetsid): New function.
1331         * fhandler.h ((fhandler_base::tcgetsid): Declare new function.
1332         (fhandler_base::is_dev_tty): Ditto.
1333         (fhandler_termios): Rearrange protected/public.
1334         (fhandler_termios::fhandler_termios): Remember last fhandler_termios
1335         "opened".
1336         (fhandler_termios::~fhandler_termios): Forget last fhandler_termios
1337         opened.
1338         (fhandler_termios::opened_as_dev_tty): Declare new field.
1339         (fhandler_termios::is_dev_tty): Declare new function.
1340         (fhandler_termios::tcgetsid): Ditto.
1341         (fhandler_pty_common::use_archetype): Move here from subclass.
1342         (fhandler_pty_slave::use_archetype): Move up.
1343         (fhandler_pty_master::use_archetype): Ditto.
1344         * fhandler_console.cc (fhandler_console::ioctl): Rename second argument
1345         from `buf' to `arg' for consistency.  Call ioctl_termios for common
1346         fhandler_termios ioctl handling.
1347         * fhandler_tty.cc (fhandler_pty_slave::ioctl): Call ioctl_termios for
1348         common fhandler_termios ioctl handling.
1349         (fhandler_pty_master::ioctl): Ditto.
1350         * fhandler_termios.cc (fhandler_termios::tcgetsid): Implement new
1351         function.
1352         (fhandler_termios::ioctl_termios): Ditto.  Implements TIOCSCTTY
1353         handling.
1354         * syscalls.cc (stat_worker): Set /dev/tty device info when appropriate.
1355         * termios.cc (tcgetpgrp): Avoid extraneous "isatty" check.
1356         (tcgetsid): Implement new function.
1357         * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 253.
1358         * include/sys/termios.h (TIOCSCTTY): Define.
1359
1360 2011-10-11  Christopher Faylor  <me.cygwin2011@cgf.cx>
1361
1362         * dtable.cc (fh_alloc): Don't parse /dev/tty if ctty is < 0.  Reset
1363         major/minor from the specific tty to those for /dev/tty.
1364
1365 2011-10-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
1366
1367         * syscalls.cc (open): Add temporary kludge to avoid assigning the
1368         controlling tty on open unless the open is for stdin/stdout/stderr.
1369         * tty.cc (tty_list::connect): Set ENXIO when can't find a tty.
1370
1371 2011-10-10  Corinna Vinschen  <corinna@vinschen.de>
1372
1373         * fhandler.h (fhandler_process::closedir): Declare.
1374         * fhandler_process.cc (fhandler_process::closedir): New function to
1375         avoid a SEGV in fhandler_proc::closedir.
1376
1377 2011-10-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
1378
1379         * fhandler_tty.cc (fhandler_pty_slave::open): Clarify debugging output.
1380         (fhandler_pty_slave::open): Change ENOENT to ENXIO when can't open a
1381         tty.
1382
1383 2011-10-07  Corinna Vinschen  <corinna@vinschen.de>
1384             Christopher Faylor  <me.cygwin2011@cgf.cx>
1385
1386         * fhandler.h (fhandler_console::tc_getpgid): New function.
1387         * spawn.cc (spawn_guts): Add logic to put pure-windows processes "in
1388         the background" when they are started that way.
1389
1390 2011-10-07  Corinna Vinschen  <corinna@vinschen.de>
1391
1392         * include/sys/cygwin.h (cygwin_getinfo_types): Define values
1393         additionally as preprocessor symbols.
1394
1395 2011-10-06  Corinna Vinschen  <corinna@vinschen.de>
1396
1397         * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Send __SIGSETPGRP
1398         pseudo signal to process group instead of just calling
1399         init_console_handler.
1400         * sigproc.cc (wait_sig): Call init_console_handler here on __SIGSETPGRP
1401         signal.
1402         * sigproc.h (__SIGSETPGRP): Define.
1403
1404 2011-10-06  Christian Franke  <franke@computer.org>
1405
1406         * include/cygwin/wait.h: Use new __wait_status_to_int()
1407         macro to access status value in W*() status checks.
1408         Fix status description.
1409         * include/sys/wait.h: Allow `int' and `union wait' as
1410         wait status parameter.  Change __wait_status_to_int()
1411         macro and wait () prototypes accordingly.  Add inline
1412         functions for C++.  Remove extra `;'.
1413
1414 2011-10-05  Corinna Vinschen  <corinna@vinschen.de>
1415
1416         * external.cc (create_winenv): Rename from sync_winenv.  Take
1417         environment pointer as parameter and return pointer to corresponding
1418         win32 environment block if != NULL.  Otherwise just sync as before.
1419         (cygwin_internal): Add CW_CVT_ENV_TO_WINENV case.
1420         * include/cygwin/version.h: Bump API minor number.
1421         * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_CVT_ENV_TO_WINENV.
1422
1423 2011-10-04  Corinna Vinschen  <corinna@vinschen.de>
1424
1425         * net.cc (socketpair): Bind first socket to loopback only as well.
1426
1427 2011-09-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
1428
1429         * tty.cc (grantpt): Check for valid fd.
1430         (unlockpt): Ditto.
1431
1432 2011-09-02  Corinna Vinschen  <corinna@vinschen.de>
1433
1434         * net.cc (cygwin_getsockopt): Drop erroneous double conversion of error
1435         code returned by SOL_SOCKET/SO_ERROR.  Fix error handling.
1436
1437 2011-09-01  Corinna Vinschen  <corinna@vinschen.de>
1438
1439         * lc_msg.h: Regenerate.
1440
1441 2011-09-01  Corinna Vinschen  <corinna@vinschen.de>
1442
1443         * dlfcn.cc (gfpod_helper): Helper function to search DLL using
1444         a given DLL name.  Change default search path to allow /usr/bin.
1445         (get_full_path_of_dll): Find DLLs even if the caller used a ".so"
1446         suffix or a "lib" prefix for the DLL.
1447
1448 2011-08-31  Corinna Vinschen  <corinna@vinschen.de>
1449
1450         * flock.cc (inode_t::unlock_and_remove_if_unused): Rename from
1451         unlock_and_remove.
1452
1453 2011-08-29  Corinna Vinschen  <corinna@vinschen.de>
1454
1455         * flock.cc (LOCK_OBJ_NAME_LEN): Change to accommodate extra lf_ver
1456         field.
1457         (class lockf_t): Add lf_ver field.
1458         (lockf_t::lockf_t): Initialize lf_ver to 0.
1459         (class inode_t): Change i_wait to i_cnt.  Change comment to explain
1460         change in usage.
1461         (inode_t:use): Rename from wait.  Make private.
1462         (inode_t::unuse): Rename from unwait.  Make private.
1463         (inode_t::inuse): Rename from waiting.  Make private.
1464         (inode_t::notused): New public method to set use count to 0.
1465         (inode_t::unlock_and_remove): New method to unlock node and to delete
1466         it if it's unused in current process.
1467         (fhandler_base::del_my_locks): Drop global list lock.  Drop variable
1468         no_locks_left.  Simpify unlocking and removing node by just calling
1469         unlock_and_remove.
1470         (fixup_lockf_after_exec): Call notused method for each node.
1471         (inode_t::get): Call use method.  Lock node only if outside of list
1472         lock.
1473         (inode_t::get_all_locks_list): Accommodate additional lf_ver field
1474         when creating lockf_t structure from object name.
1475         (lockf_t::create_lock_obj_attr): Accommodate additional lf_ver field
1476         when creating object name from lockf_t structure.  Handle
1477         STATUS_OBJECT_NAME_COLLISION gracefully in F_POSIX case as well.
1478         Change comment accordingly.  Increment lf_ver field rather than high
1479         byte of lf_wid field.  Simplify comment.
1480         (fhandler_disk_file::lock): Always call unlock_and_remove rather than
1481         just UNLOCK on node.
1482         (lf_setlock): Move ret definition where it's used.  Drop unneeded
1483         tests for obj being not NULL.  Only check for deadlock condition if the
1484         lock we're trying to establish is a POSIX lock.  Revamp object
1485         collecting and wait code to cover all cases.  Don't return with EDEADLK
1486         if blocking process can't be opened for synchronization in F_POSIX case,
1487         rather just wait like in F_FLOCK case.  Change system_printf to
1488         debug_printf in that case.  Only run WaitForMultipleObjects with high
1489         priority.  Close obj and process handles prior to locking node.
1490
1491 2011-08-27  Corinna Vinschen  <corinna@vinschen.de>
1492
1493         * fhandler.cc (fhandler_base::open): Fix typo in comment.
1494         (fhandler_base::close): Move call to del_my_locks from here...
1495         * fhandler_disk_file.cc (fhandler_disk_file::open): ...to here.
1496         * flock.cc (struct lockfattr_t): New type.
1497         (lockf_t::close_lock_obj): New method, use throughout.
1498         (lockf_t::create_lock_obj_attr): New method.
1499         (lockf_t::create_lock_obj): Use create_lock_obj_attr method.  Handle
1500         STATUS_OBJECT_NAME_COLLISION in F_FLOCK case gracefully.  Add lengthy
1501         comments to explain why and how.
1502         (lockf_t::open_lock_obj): Use create_lock_obj_attr method.
1503         (lockf_t::del_lock_obj): Call NtSetEvent rather than SetEvent for
1504         symmetry.
1505         (fhandler_disk_file::lock): Define n only where it's used.  Call
1506         need_fork_fixup only if call was successful.  Handle EINTR and
1507         ECANCELED return values from lf_setlock.
1508         (lf_setlock): Drop WAIT_UNLOCKED and WAIT_PROC_EXITED.  Don't wait
1509         for event object handle count to become <= 1 in F_LOCK case.
1510         Simplify WFMO return value handling.  Don't handle signal and cancel
1511         events here; just return with appropriate error code instead.
1512         (lf_getblock): Ignore locks for which the handle can't be opened.
1513         Use IsEventSignalled.
1514         * ntdll.h (STATUS_INVALID_INFO_CLASS): Undef if defined elsewhere to
1515         make sure the definition is casted to NTSTATUS.
1516         (STATUS_INVALID_HANDLE): Define and ditto.
1517         (STATUS_OBJECT_NAME_COLLISION): Define.
1518         (NtSetEvent): Declare.
1519
1520 2011-08-25  Rafal Zwierz  <rzwierz@googlemail.com>
1521
1522         * cygthread.cc (cygthread::simplestub): Notify that the thread has
1523         detached also in freerange thread case.
1524
1525 2011-08-25  Corinna Vinschen  <corinna@vinschen.de>
1526
1527         * fhandler.cc (fhandler_base::open): Never open files with
1528         FILE_OVERWITE/FILE_OVERWRITE_IF.  Set file size to 0 explicitely if
1529         regular, existing file has been opened for writing with O_TRUNC flag
1530         set.  Explain why.
1531
1532 2011-08-24  Corinna Vinschen  <corinna@vinschen.de>
1533
1534         * thread.cc (pthread::pthread): Drop setting parent_tls.  Call
1535         sigprocmask to copy parent thread signal mask into new parent_sigmask
1536         member.
1537         (pthread::thread_init_wrapper): Copy _my_tls.sigmask from new
1538         parent_sigmask member.
1539         * thread.h (class pthread): Drop parent_tls.  Add parent_sigmask.
1540
1541 2011-08-24  Christopher Faylor  <me.cygwin2011@cgf.cx>
1542
1543         * thread.cc (pthread::exit): Create dummy tls structure to hold
1544         _main_tls contents if we've asked _main_tls to exit.
1545
1546 2011-08-23  Corinna Vinschen  <corinna@vinschen.de>
1547
1548         * poll.cc (poll): Don't return prematurely if invalid fds have been
1549         encountered.  Enforce timeout set to 0 in case of invalid fds.  Take
1550         number of invalid fds into account when returning.
1551
1552 2011-08-23  Corinna Vinschen  <corinna@vinschen.de>
1553
1554         * fhandler_socket.cc (fhandler_socket::send_internal): Fix setting
1555         nosignal flag.  Convert ECONNABORTED on connection-oriented socket
1556         to EPIPE, too.
1557
1558 2011-08-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
1559
1560         * dtable.cc (conv_start_chars): Remove unneeded section attribute.
1561
1562 2011-08-20  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1563
1564         * include/paths.h (_PATH_MAILDIR): Define.
1565         (_PATH_SHELLS): Define.
1566
1567 2011-08-20  Corinna Vinschen  <corinna@vinschen.de>
1568
1569         * fhandler_process.cc (format_process_maps): Define page protection
1570         shortcuts RO, X, and WC.  Use in creating access flag string.  Don't
1571         set type flag to 's' for copy-on-write pages, as on Linux.
1572
1573 2011-08-19  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1574
1575         * devices.h (fh_devices): Define DEV_MISC_MAJOR, DEV_MEM_MAJOR,
1576         DEV_SOUND_MAJOR.  Use throughout.
1577         * fhandler_proc.cc (proc_tab): Add /proc/devices and /proc/misc
1578         virtual files.
1579         (format_proc_devices): New function.
1580         (format_proc_misc): New function.
1581
1582 2011-08-19  Christopher Faylor  <me.cygwin2011@cgf.cx>
1583
1584         * dtable.cc: Mark some const variables as static.
1585         * environ.cc (conv_start_chars): Move to shared cygwin region and
1586         initialize at compile time.
1587         (match_first_char): New generic function for querying conv_start_chars.
1588         (posify_maybe): Rename from posify.
1589         (environ_init): Remove conv_envvars initialization.  Don't check
1590         conv_start_chars, just allow posify_maybe to make the decision.
1591         * fhandler_console.cc (__vt100_conv): Fix formatting.  Mark as const.
1592
1593 2011-08-19  Corinna Vinschen  <corinna@vinschen.de>
1594
1595         * fhandler_console.cc (fhandler_console::read): Recognize backspace key
1596         using the device independent key code, rather than the device dependent
1597         scan code.
1598
1599 2011-08-18  Christopher Faylor  <me.cygwin2011@cgf.cx>
1600
1601         * dcrt0.cc (dll_crt0_0): Remove unneeded __stdcall decoration.
1602         * init.cc: Reflect change to dll_crt0_0 in declaration.
1603
1604 2011-08-18  Corinna Vinschen  <corinna@vinschen.de>
1605
1606         * dtable.cc (dtable::get_debugger_info): Add missing braces.
1607         (dtable::stdio_init): Fix incorrect negation of not_open(2) condition.
1608
1609 2011-08-16  Pierre Humblet <Pierre.Humblet@ieee.org>
1610
1611         * net.cc (gethostby_helper): Remove DEBUGGING code from and
1612         streamline the second pass.
1613
1614 2011-08-16  Corinna Vinschen  <corinna@vinschen.de>
1615
1616         * dlfcn.cc (dlopen): Reimplement RTLD_NODELETE for Windows 2000 using
1617         internal datastructures.  Explain the code.
1618         * ntdll.h (struct _LDR_DATA_TABLE_ENTRY): Define.
1619         (struct _PEB_LDR_DATA): Define.
1620         (struct _PEB): Change PVOID LoaderData to PPEB_LDR_DATA Ldr.
1621
1622         * fhandler_process.cc (format_process_maps): Call NtQueryVirtualMemory
1623         with valid return length pointer.  Explain why.
1624
1625 2011-08-16  Corinna Vinschen  <corinna@vinschen.de>
1626
1627         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
1628
1629 2011-08-16  Corinna Vinschen  <corinna@vinschen.de>
1630
1631         * autoload.cc (GetModuleHandleExW): Define.
1632         * dlfcn.cc: Throughout mark exported symbols as extern "C".
1633         (dlopen): Unignore flags argument.  Define ret to NULL.  Fix typo in
1634         comment.  Support Glibc flags RTLD_NOLOAD and RTLD_NODELETE.
1635         * include/dlfcn.h:  Clean up comments.
1636         (RTLD_NODELETE): Define.
1637         (RTLD_NOLOAD): Define.
1638         (RTLD_DEEPBIND): Define.
1639
1640 2011-08-15  Corinna Vinschen  <corinna@vinschen.de>
1641
1642         * pipe.cc (pipe): Just call _pipe with O_BINARY mode.  Move code to
1643         generate normalized pathnames from here...
1644         (_pipe): ...to here.
1645
1646 2011-08-13  Corinna Vinschen  <corinna@vinschen.de>
1647
1648         * miscfuncs.cc (CreatePipeOverlapped): New function.
1649         (ReadPipeOverlapped): Ditto.
1650         (WritePipeOverlapped): Ditto.
1651         * miscfuncs.h: Declare new functions.
1652         * pinfo.cc (commune_process): Call WritePipeOverlapped instead of
1653         WriteFile.  Set timeout to 1 sec.
1654         (_pinfo::commune_request): Call ReadPipeOverlapped instead of ReadFile.
1655         Set timeout to 0.5 secs.
1656         * sigproc.cc (sig_send): Create pipe using CreatePipeOverlapped.
1657
1658 2011-08-12  Christopher Faylor  <me.cygwin2011@cgf.cx>
1659
1660         * miscfuncs.cc (create_pipe): Delete obsolete function.
1661         * miscfuncs.h (create_pipe): Delete define.
1662
1663         * pipe.c (fhandler_pipe::create_selectable): Delete obsolete comment.
1664
1665 2011-08-12  Corinna Vinschen  <corinna@vinschen.de>
1666
1667         * fhandler_proc.cc (fhandler_proc::closedir): Don't free, but delete
1668         instead.
1669
1670 2011-08-12  Corinna Vinschen  <corinna@vinschen.de>
1671
1672         * fhandler.h (fhandler_proc::opendir): Declare.
1673         (fhandler_proc::closedir): Declare.
1674         * fhandler_proc.cc (fhandler_proc::opendir): New method.  Fetch list
1675         of active processes here once to avoid potential duplicates and store
1676         in dir->__handle.
1677         (fhandler_proc::closedir): New method.  Free dir->__handle.
1678         (fhandler_proc::readdir): Convert pinfo into a reference to the winpids
1679         entry in dir->__handle.
1680
1681 2011-08-11  Corinna Vinschen  <corinna@vinschen.de>
1682
1683         * fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Don't allow to
1684         access process info by using the Windows PID.
1685         * fhandler_process.cc (fhandler_process::fstat): Ditto.
1686         (fhandler_process::fill_filebuf): Ditto.
1687
1688 2011-08-11  Corinna Vinschen  <corinna@vinschen.de>
1689
1690         * (winpids::add): Make sure to store always a Windows PID in
1691         pidlist, even if pid is a Cygwin PID.
1692         (winpids::enum_processes): Fetch Cygwin processes from listing of
1693         shared cygwin object dir in the native NT namespace.  Only if winpid
1694         is true, fetch Windows processes using an additional call to
1695         NtQuerySystemInformation.
1696
1697 2011-08-10  Corinna Vinschen  <corinna@vinschen.de>
1698
1699         * fhandler_process.cc (format_process_status): Always print process name
1700         even for zombies.
1701         (get_mem_values): Fix loop fetching working set list to avoid out of
1702         memory conditions.  Return all mem values set to 0 for zombies.
1703         * ntdll.h (STATUS_PROCESS_IS_TERMINATING): Define.
1704
1705 2011-08-09  Corinna Vinschen  <corinna@vinschen.de>
1706
1707         * heap.cc (eval_initial_heap_size): New function fetching the heap
1708         size from the LoaderFlags field in the PE/COFF header.
1709         (heap_init): Call eval_initial_heap_size rather than
1710         cygwin_shared->heap_chunk_size to fetch the initial heap size.
1711         * shared.cc (shared_info::heap_chunk_size): Remove.
1712         * shared_info.h (class shared_info): Drop heap_chunk member.
1713         (CURR_SHARED_MAGIC): Update.
1714
1715 2011-08-09  Corinna Vinschen  <corinna@vinschen.de>
1716
1717         * ntdll.h (STATUS_NOT_FOUND): Define.
1718         * ntea.cc (read_ea): Return correct ENOTSUP rather than EOPNOTSUPP.
1719         Handle STATUS_INVALID_DEVICE_REQUEST and STATUS_NOT_FOUND.  Explain
1720         why.  Convert conditional to switch statement.
1721         (write_ea): Return correct ENOTSUP rather than EOPNOTSUPP.  Handle
1722         STATUS_INVALID_DEVICE_REQUEST.  Convert conditional to switch statement.
1723
1724 2011-08-07  Corinna Vinschen  <corinna@vinschen.de>
1725
1726         * resource.cc (getrlimit): Just return RLIM_INFINITY in a request for
1727         RLIMIT_AS.
1728
1729 2011-08-07  Corinna Vinschen  <corinna@vinschen.de>
1730
1731         * fhandler_process.cc (format_process_maps): Actually print info about
1732         the application heap of the printed process, not of the current process.
1733
1734 2011-08-04  Corinna Vinschen  <corinna@vinschen.de>
1735
1736         * net.cc (socketpair): Release sb0 if there's no space left for sb1.
1737
1738 2011-08-03  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1739
1740         * cygwin.din (clock_nanosleep): Export.
1741         * posix.sgml (std-notimpl): Move clock_nanosleep from here...
1742         (std-susv4): ... to here.
1743         (std-notes): Note limitations of clock_nanosleep.
1744         * signal.cc (clock_nanosleep): Renamed from nanosleep, adding clock_id
1745         and flags arguments and changing return values throughout.
1746         Improve checks for illegal rqtp values.  Add support for
1747         CLOCK_MONOTONIC and TIMER_ABSTIME.
1748         (nanosleep): Rewrite in terms of clock_nanosleep.
1749         (sleep): Ditto.
1750         (usleep): Ditto.
1751         * thread.cc: Mark clock_nanosleep in list of cancellation points.
1752         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
1753
1754 2011-08-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
1755
1756         * dll_init.cc: Use fabort in favor of api_fatal and fork_info->abort
1757         where appropriate throughout.
1758         (fabort): Define.
1759         (dll_list::topsort): Don't print sorting information.  Fix formatting.
1760         (dll_list::topsort_visit): Fix formatting.
1761         (dll_list::load_after_fork_impl): Perform comment fixups.
1762         * sigproc.cc (child_info_fork::abort): (for now?) Always print cause of
1763         fork failure.
1764         * include/sys/strace.h (strace_vprintf): Remove _STRACE_NOTALL when
1765         printing.  We really do want to see this.
1766
1767 2011-08-03  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1768
1769         * cygtls.h (struct _local_storage): Add cw_timer member.
1770         * cygtls.cc (_cygtls::init_thread): Initialize locals.cw_timer.
1771         (_cygtls::fixup_after_fork): Ditto.
1772         * tlsoffsets.h: Regenerate.
1773         * ntdll.h (enum _TIMER_INFORMATION_CLASS): Define.
1774         (struct _TIMER_BASIC_INFORMATION): Define.
1775         (NtQueryTimer): Declare function.
1776         * thread.h (cancelable_wait): Change timeout argument to
1777         PLARGE_INTEGER and provide NULL default.
1778         (fast_mutex::lock): Adjust accordingly.
1779         (pthread_cond::wait): Change timeout argument to PLARGE_INTEGER
1780         and default to NULL.
1781         * thread.cc (cancelable_wait): Change timeout argument to
1782         PLARGE_INTEGER.  Initialize _cygtls.locals.cw_timer if needed.
1783         Use NT waitable timers for handling timeout.  Return remaining time
1784         to timeout argument if timeout was relative.
1785         (pthread_cond::wait): Change timeout argument to PLARGE_INTEGER.
1786         Adjust to change in cancelable_wait.
1787         (pthread_mutex::lock): Adjust to change in cancelable_wait.
1788         (pthread_spinlock::lock): Ditto.
1789         (pthread::join): Ditto.
1790         (__pthread_cond_dowait): Change waitlength argument to PLARGE_INTEGER.
1791         Adjust to changes in cancelable_wait and pthread_cond::wait.
1792         (pthread_cond_timedwait): Adjust to change in __pthread_cond_dowait.
1793         (pthread_cond_wait): Ditto.
1794         (semaphore::_timedwait): Adjust to change in cancelable_wait.
1795         (semaphore::_wait): Ditto.
1796         * exceptions.cc (handle_sigsuspend): Ditto.
1797         * signal.cc (nanosleep): Ditto.
1798         * wait.cc (wait4): Ditto. Fix copyright dates.
1799         * times.cc (FACTOR, NSPERSEC): Move from here...
1800         * hires.h (FACTOR, NSPERSEC): ...to here.
1801
1802 2011-08-01  Corinna Vinschen  <corinna@vinschen.de>
1803
1804         * syscalls.cc (faccessat): Fix parens in flag expression when calling
1805         build_fh_name.
1806
1807         * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Fix typo in
1808         comment.
1809         * fhandler_socket.cc (fhandler_socket::bind): Ditto.
1810         * path.cc (symlink_worker): Ditto.
1811
1812 2011-07-31  Christopher Faylor  <me.cygwin2011@cgf.cx>
1813
1814         * dll_init.cc (dll_list::load_after_fork_impl): Add a hint to an error
1815         message.
1816
1817 2011-07-31  Christopher Faylor  <me.cygwin2011@cgf.cx>
1818
1819         * sigproc.cc (pending_signals::pending): Define new function.
1820         (sig_dispatch_pending): Avoid calling sig_send if there are no pending
1821         signals.
1822
1823 2011-07-31  Corinna Vinschen  <corinna@vinschen.de>
1824
1825         * fhandler.h (class fhandler_dev_mem): Remove dup method declaration.
1826         * fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Accommodate the
1827         fact that the entire fhandler gets copied over to the child in
1828         operator =.
1829         * fhandler_floppy.cc (fhandler_dev_floppy::dup): Ditto.
1830         * fhandler_raw.cc (fhandler_dev_raw::dup): Ditto.
1831         * fhandler_serial.cc (fhandler_serial::dup): Ditto.
1832         * fhandler_socket.cc (fhandler_socket::dup): Ditto.
1833         * fhandler_virtual.cc (fhandler_virtual::dup): Ditto.
1834         * fhandler_mem.cc (fhandler_dev_mem::dup): Ditto.  Remove entirely.
1835
1836 2011-07-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
1837
1838         * cygthread.cc (cygthread::async_create): Define new function.
1839         * cygthread.h (cygthread::create): Use correct regparm.
1840         (cygthread::standalone): Delete from class and from all constructors.
1841         (cygthread::cygthread): Use three only arguments for detached threads,
1842         (cygthread::async_create): Declare.
1843         and start the thread via QueueUserAPC/async_create.
1844         * dcrt0.cc (dll_crt0_0): Remove handling for
1845         wincap.has_buggy_thread_startup.
1846         (dll_crt0_1): Ditto.
1847         * wincap.cc: Ditto throughout.
1848         * wincap.h: Ditto.
1849
1850 2011-07-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
1851
1852         * fhandler.h (fhandler_base_overlapped::size): Declare/define size()
1853         function for consistency.
1854         (fhandler_termios::size): Ditto.
1855         (fhandler_pty_common::size): Ditto.
1856
1857 2011-07-30  Corinna Vinschen  <corinna@vinschen.de>
1858
1859         * fhandler_registry.cc (fhandler_registry::dup): Duplicate value_name.
1860
1861 2011-07-29  Corinna Vinschen  <corinna@vinschen.de>
1862
1863         Throughout change "WinSock" to "Winsock" in comments.
1864         * fhandler_socket.cc (fhandler_socket::sendmsg): Add missing call to
1865         get_inet_addr to convert AF_LOCAL to AF_INET sockets.
1866         * net.cc (cygwin_socket): Workaround UDP Winsock problem.  Add comment
1867         to explain why.
1868         * select.cc: Include winsock2.h rather than winsock.h.
1869
1870 2011-07-26  Corinna Vinschen  <corinna@vinschen.de>
1871
1872         * fhandler_disk_file.cc (__DIR_mounts::eval_ino): Create path_conv
1873         with PC_KEEP_HANDLE flag.
1874         * path.h (path_conv::operator =): Duplicate UNICODE path as well.
1875         * security.cc (check_file_access): Use path_conv handle if available.
1876         * syscalls.cc (access): Create fhandler with PC_KEEP_HANDLE flag set.
1877         (euidaccess): Ditto.
1878         (faccessat): Ditto.
1879
1880 2011-07-26  Corinna Vinschen  <corinna@vinschen.de>
1881
1882         * ntdll.h: Fix typo in comment.
1883         * path.cc: Ditto.
1884
1885 2011-07-25  Corinna Vinschen  <corinna@vinschen.de>
1886
1887         * fhandler_console.cc (fhandler_console::ioctl): Fetch console events
1888         using PeekConsoleInput and return only key down events in buf.
1889         * fhandler_tty.cc (fhandler_pty_slave::ioctl): Always return EINVAL
1890         if PeekNamedPipe fails.
1891         (fhandler_pty_master::ioctl): Ditto.
1892
1893 2011-07-22  Corinna Vinschen  <corinna@vinschen.de>
1894
1895         * fhandler_tty.cc (fhandler_pty_slave::ioctl): Drop FIONBIO case.
1896         Handle FIONREAD.
1897         (fhandler_pty_master::ioctl): Ditto.  Call fhandler_base::ioctl to
1898         decode default condition.
1899         * fhandler_console.cc (fhandler_console::ioctl): Handle FIONREAD.
1900
1901 2011-07-21  Christopher Faylor  <me.cygwin2011@cgf.cx>
1902             Corinna Vinschen  <corinna@vinschen.de>
1903
1904         * fhandler.cc: Add #include for asm/socket.h for dealing with FIONREAD.
1905         (fhandler_base::ioctl): Special-case errno for FIONREAD.
1906         * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Rename parameter for
1907         consistency.  Call fhandler_base::ioctl to decode default condition.
1908         * fhandler_serial.cc (fhandler_serial::ioctl): Ditto.
1909         * fhandler_tty.cc (fhandler_pty_slave::ioctl): Call
1910         fhandler_base::ioctl to decode default condition.
1911         * fhandler_windows.cc (fhandler_windows::ioctl): Ditto.
1912
1913 2011-07-21  Corinna Vinschen  <corinna@vinschen.de>
1914
1915         * heap.cc (eval_start_address): Simplify test for large address
1916         awareness of executable, which works for 32 and 64 bit systems.
1917         Change comment accordingly.
1918
1919 2011-07-21  Corinna Vinschen  <corinna@vinschen.de>
1920
1921         * heap.cc (eval_start_address): New static function to evaluate the
1922         best start address for the application heap.
1923         (heap_init): Call eval_start_address to fetch the start value for
1924         start_address.  Move preceeding comment to eval_start_address.
1925
1926 2011-07-21  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1927
1928         * cygwin.din (pthread_condattr_getclock): Export.
1929         (pthread_condattr_setclock): Export.
1930         * posix.sgml (std-notimpl): Move pthread_condattr_getclock and
1931         pthread_condattr_setclock from here...
1932         (std-susv4): ... to here.
1933         * sysconf.cc (sca): Set _SC_CLOCK_SELECTION to _POSIX_CLOCK_SELECTION.
1934         * thread.cc: (pthread_condattr::pthread_condattr): Initialize clock_id.
1935         (pthread_cond::pthread_cond): Initialize clock_id.
1936         (pthread_cond_timedwait): Use clock_gettime() instead of gettimeofday()
1937         in order to support all allowed clocks.
1938         (pthread_condattr_getclock): New function.
1939         (pthread_condattr_setclock): New function.
1940         * thread.h (class pthread_condattr): Add clock_id member.
1941         (class pthread_cond): Ditto.
1942         * include/pthread.h: Remove obsolete comment.
1943         (pthread_condattr_getclock): Declare.
1944         (pthread_condattr_setclock): Declare.
1945         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
1946
1947 2011-07-18  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
1948
1949         * sysconf.cc (sca): Return -1 for _SC_THREAD_ROBUST_PRIO_INHERIT,
1950         _SC_THREAD_ROBUST_PRIO_PROTECT, and _SC_XOPEN_UUCP.
1951         (SC_MAX): Redefine accordingly.
1952         (csa): Return strings for _CS_POSIX_V7_THREADS_CFLAGS,
1953         _CS_POSIX_V7_THREADS_LDFLAGS, and _CS_V7_ENV.
1954         (CS_MAX): Redefine accordingly.
1955         * include/limits.h (LONG_BIT): Define.
1956         (WORD_BIT): Define.
1957
1958 2011-07-18  Corinna Vinschen  <corinna@vinschen.de>
1959
1960         * heap.cc (heap_init): Change type of largest_found to PVOID.  Start
1961         querying memory at 0x20000000.  Use largest_found pointer when trying
1962         to allocate largest free memory area found.
1963
1964 2011-07-14  Corinna Vinschen  <corinna@vinschen.de>
1965
1966         * fhandler_console.cc (fhandler_console::input_tcsetattr): Revert to
1967         setting ENABLE_PROCESSED_INPUT depending on ISIG and IGNBRK.
1968         (fhandler_console::tcgetattr): Set ISIG depending on
1969         ENABLE_PROCESSED_INPUT as well.
1970
1971 2011-07-13  Corinna Vinschen  <corinna@vinschen.de>
1972
1973         * fhandler_serial.cc (fhandler_serial::raw_read): Handle non-blocking
1974         case more thoroughly.
1975
1976 2011-07-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
1977
1978         * setup_handler (setup_handler): Change break to goto out, missed in
1979         2011-07-06 changes.
1980
1981 2011-07-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
1982
1983         * fhandler_tty.cc (fhandler_pty_slave::ioctl): Remove erroneous support
1984         for TIOCLINUX for pty.  Get rid of unneeded EINVAL handling in wake of
1985         tty removal.  Remove now-unneeded variable.
1986
1987 2011-07-10  Corinna Vinschen  <corinna@vinschen.de>
1988
1989         * include/netdb.h (gethostbyname2): Declare.
1990
1991 2011-07-09  Eric Blake  <eblake@redhat.com>
1992
1993         * signal.cc (handle_sigprocmask): Return error rather than setting
1994         errno, for pthread_sigmask.
1995         (sigprocmask): Adjust caller.
1996
1997 2011-07-07  Corinna Vinschen  <corinna@vinschen.de>
1998
1999         * miscfuncs.cc (yield): Drop thread priority only once.
2000
2001 2011-07-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
2002
2003         * exceptions.cc (_cygtls::interrupt_now): Back out previous change
2004         since it could theoretically cause a non-CTRL-C-able program if a
2005         program has suffered memory corruption.
2006         (setup_handler): Ditto.
2007
2008 2011-07-06  Corinna Vinschen  <corinna@vinschen.de>
2009
2010         * sched.c (sched_yield): Just call SwitchToThread because yield now
2011         potentially switches CPU.
2012
2013 2011-07-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
2014
2015         * exceptions.cc (_cygtls::interrupt_now): Don't check for spinning
2016         here.
2017         (setup_handler): Check for spinning here, assuming that it is
2018         transitory and should not affect the retry loop.
2019
2020 2011-07-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
2021
2022         * exceptions.cc (CALL_HANDLER_RETRY_INNER): Rename to reflect different
2023         functionality.
2024         (CALL_HANDLER_RETRY_OUTER): New define.
2025         (setup_handler): Add outer loop to signal handler to try harder to
2026         deliver the signal.
2027         * miscfuncs.cc (yield): Drop priority and use SleepEx() to force thread
2028         rescheduling rather than relying on SwitchToThread().
2029
2030 2011-07-06  Corinna Vinschen  <corinna@vinschen.de>
2031
2032         * sigproc.cc (wait_sig): Fix debug output.
2033
2034 2011-07-05  Corinna Vinschen  <corinna@vinschen.de>
2035
2036         * fhandler_console.cc (fhandler_console::input_tcsetattr): Make
2037         ENABLE_PROCESSED_INPUT flag only depending on value of IGNBRK.
2038         (fhandler_console::tcgetattr): Don't set ISIG depending on
2039         ENABLE_PROCESSED_INPUT, set IGNBRK instead.
2040
2041 2011-07-05  Corinna Vinschen  <corinna@vinschen.de>
2042
2043         * security.cc (get_file_sd): Fix comment.
2044
2045 2011-07-05  Corinna Vinschen  <corinna@vinschen.de>
2046
2047         * fhandler.cc (fhandler_base::open): Never create files with WRITE_DAC
2048         access.  Explain why.
2049         * fhandler_disk_file.cc (fhandler_base::fstat_helper): Improve debug
2050         output.
2051
2052 2011-07-05  Corinna Vinschen  <corinna@vinschen.de>
2053
2054         * fhandler.cc (fhandler_base::open): Don't open file with WRITE_DAC
2055         access on remote filesystem.  Explain why.
2056         * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
2057         directories.
2058         * fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
2059         * path.cc (symlink_worker): Ditto for symlinks.
2060
2061 2011-07-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
2062
2063         * environ.cc (tty_is_gone): Wrap warning at 80 characters.
2064
2065 2011-07-04  Corinna Vinschen  <corinna@vinschen.de>
2066
2067         Throughout, open console handles with sharing for reading and writing.
2068         * dcrt0.cc (insert_file): Open file with full sharing allowed.
2069         * hookapi.cc (find_first_notloaded_dll): Ditto.
2070         * spawn.cc (av::fixup): Ditto.
2071
2072 2011-07-04  Corinna Vinschen  <corinna@vinschen.de>
2073
2074         * dtable.cc (dtable::init_std_file_from_handle): Change test for console
2075         device in call to fh->init to avoid conhost crash on W7.
2076
2077 2011-07-04  Corinna Vinschen  <corinna@vinschen.de>
2078
2079         * environ.cc (environ_init): Reinstantiate on-the-fly CYGWIN variable
2080         test and call to parse_options if found.
2081
2082 2011-07-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
2083
2084         * fhandler.cc (fhandler_base::open_with_arch): Call close_on_exec last
2085         to avoid setting close_on_exec for archetype.
2086         * fhandler_tty.cc (fhandler_pty_master::setup): Protect {from,to}_pty
2087         handles.  Use consistent naming in debug output.  Use inheritable
2088         handles and...
2089         (fhandler_pty_master::fixup_after_fork): ...avoid duplicating handles
2090         here.
2091         (fhandler_pty_slave::open): Don't set close_on_exec flag here.
2092
2093 2011-07-01  Christopher Faylor  <me.cygwin2011@cgf.cx>
2094
2095         * dtable.cc (cnew): Fix whitespace.
2096
2097 2011-07-01  Corinna Vinschen  <corinna@vinschen.de>
2098
2099         * include/sys/param.h (NGROUPS): Redefine as NGROUPS_MAX.
2100         (MAXHOSTNAMELEN): Redefine with same value as MAX_HOSTNAME_LEN.  Change
2101         comment.
2102         (MAXPATHLEN): Improve comment.
2103         (MAXSYMLINKS): Define and add comment.
2104
2105 2011-07-01  Corinna Vinschen  <corinna@vinschen.de>
2106
2107         * fhandler.cc (fhandler_base::open): Move NFS-specific code into the
2108         code block handling FH_FS stuff.
2109
2110 2011-06-30  Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
2111
2112         * dtable.cc (fh_oom): Remove.
2113         (fh_calloc): Remove.
2114         (cnew): Redefine to handle NULL returns from cmalloc.
2115         (build_fh_name): Accommodate new definition of cnew.  Remove unneeded
2116         test for fh_oom.
2117         (fh_alloc): Ditto.
2118
2119 2011-06-30  Corinna Vinschen  <corinna@vinschen.de>
2120
2121         * fhandler_console.cc (fhandler_console::read): Add comment.
2122         (fhandler_console::input_tcsetattr): Don't set ENABLE_PROCESSED_INPUT
2123         if IGNBRK flag is set.
2124
2125 2011-06-30  Corinna Vinschen  <corinna@vinschen.de>
2126
2127         * dtable.cc (fh_oom): New static fhandler storage.
2128         (fh_calloc): New static function.  Add a comment to explain why this
2129         is needed.
2130         (cnew): Call fh_calloc as placement argument.
2131         (build_fh_name): Check return code from cnew against address of
2132         fh_oom to test for out of memory condition.
2133         (fh_alloc): Ditto.
2134         (build_fh_pc): Avoid a crash due to useing a NULL fhandler.
2135         * pipe.cc (fhandler_pipe::create): Check if build_fh_dev returned a
2136         valid pointer before using it.
2137
2138 2011-06-28  Corinna Vinschen  <corinna@vinschen.de>
2139
2140         * fhandler_process.cc (heap_info::fill_if_match): Rename info to
2141         note that this heap is a Windows heap.
2142         (format_process_maps): Print info about application heap.
2143
2144 2011-06-24  Corinna Vinschen  <corinna@vinschen.de>
2145
2146         * fhandler_console.cc (fhandler_console::read): Don't generate ^@ on
2147         Ctrl+Alt+Space.
2148
2149 2011-06-22  Corinna Vinschen  <corinna@vinschen.de>
2150
2151         * fhandler_tty.cc (fhandler_pty_master::setup): Create pty pipes
2152         non-inheritable.
2153
2154 2011-06-22  Corinna Vinschen  <corinna@vinschen.de>
2155
2156         * fhandler_tty.cc (fhandler_pty_master::setup): Fix crash in debug
2157         output.
2158
2159 2011-06-18  Corinna Vinschen  <corinna@vinschen.de>
2160
2161         * path.cc (normalize_win32_path): Skip all slashes after recognizing
2162         a ".." path component.  Add comment.
2163
2164 2011-06-17  Corinna Vinschen  <corinna@vinschen.de>
2165
2166         * fhandler.cc (fhandler_base::open): Drop local create_options variable.
2167         Use options member instead.
2168         * fhandler.h (class fhandler_base): Change type of access member to
2169         ACCESS_MASK.  Change get_access and set_access methods accordingly.
2170         Add options member.  Add get_options and set_options methods.
2171         (class fhandler_disk_file): Add prw_handle.
2172         (fhandler_disk_file::prw_open): Declare.
2173         (fhandler_disk_file::close): Declare.
2174         (fhandler_disk_file::dup): Declare.
2175         (fhandler_disk_file::fixup_after_fork): Declare.
2176         * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file):
2177         Initialize prw_handle to NULL.
2178         (fhandler_disk_file::close): Close prw_handle.
2179         (fhandler_disk_file::dup): New method.
2180         (fhandler_disk_file::fixup_after_fork): Set prw_handle to NULL since
2181         prw_handle is not inherited.
2182         (fhandler_disk_file::prw_open): New method.  Add long comment to
2183         explain current behaviour.
2184         (fhandler_disk_file::pread): Revert previous change.  Change to use
2185         prw_handle if possible.
2186         (fhandler_disk_file::pwrite): Change to use prw_handle if possible.
2187
2188 2011-06-17  Corinna Vinschen  <corinna@vinschen.de>
2189
2190         * dcrt0.cc (dll_crt0_1): Call strace.dll_info after call to pinfo_init.
2191         * strace.cc (strace::hello): Drop printing DLL information here since
2192         application info is not always available at this point.
2193         (strace::dll_info): New method to print DLL info.
2194         * include/sys/strace.h (strace::dll_info): Declare.
2195
2196 2011-06-17  Corinna Vinschen  <corinna@vinschen.de>
2197
2198         * dtable.cc (handle_to_fn): Accommodate name change of pty named pipes,
2199         otherwise ptys are not recognized.
2200
2201 2011-06-16  Christopher Faylor  <me.cygwin2011@cgf.cx>
2202
2203         * fhandler_console.cc (fhandler_console::set_unit): Set
2204         pc.file_attributes() to reflect existence.
2205         * fhandler.h (fhandler_pty_common::fhandler_pty_common): Ditto.
2206         * pinfo.cc (_pinfo::set_ctty): Output device numbers in hex.
2207
2208 2011-06-15  Christopher Faylor  <me.cygwin2011@cgf.cx>
2209
2210         * errno.cc (EIO): Lowercase "o" representative string.
2211
2212 2011-06-14  Christopher Faylor  <me.cygwin2011@cgf.cx>
2213
2214         * cygheap.h (init_cygheap::ctty_on_hold): Remove conditionalized
2215         variable.
2216         * dcrt0.cc (do_exit): Remove code which handled CYGWIN=tty style ttys.
2217         * devices.in: Remove "/dev/ttym".
2218         * dtable.cc: Rename tty to pty where appropriate throughout.
2219         (dtable::stdio_init): Use new t->is_console rather than using
2220         now-deleted hwnd element in tty structure.
2221         (dtable::init_std_file_from_handle): Remove code which handled
2222         CYGWIN=tty style ttys.
2223         (fh_alloc): Ditto.
2224         * fhandler.h: Rename tty to pty where appropriate.
2225         (fhandler_pty_common): Delete output_done_event, ioctl_request_event,
2226         ioctl_done_event.
2227         (fhandler_pty_master::setup): Delete argument.
2228         (fhandler_tty_master): Delete.
2229         (fhandler_union): Delete __tty_master.
2230         * fhandler_console.cc (use_tty): Delete.
2231         (fhandler_console::get_tty_stuff): Set is_console to true rather than
2232         calling sethwnd.
2233         (fhandler_console::send_winch_maybe): Remove CYGWIN=tty considerations.
2234         (fhandler_console::input_tcsetattr): Ditto.
2235         * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Use new
2236         t->is_console rather than using now-deleted hwnd element in tty
2237         structure.
2238         * fhandler_tty.cc: Rename tty to pty where appropriate throughout.
2239         (tty_master): Delete.
2240         (process_input): Ditto.
2241         (process_output): Ditto.
2242         (process_ioctl): Ditto.
2243         (fhandler_tty_master::*): Ditto.
2244         (fhandler_pty_master::process_slave_output): Remove CYGWIN=tty
2245         considerations.
2246         (fhandler_pty_slave::open): Ditto for *_done_event.
2247         (fhandler_pty_slave::write): Ditto.
2248         (fhandler_pty_slave::ioctl): Ditto.
2249         (fhandler_pty_slave::fch_open_handles): Ditto.
2250         (fhandler_pty_slave::fch_set_sd): Ditto.
2251         (fhandler_pty_slave::fch_close_handles): Ditto.
2252         (fhandler_pty_common::close): Ditto.
2253         (fhandler_pty_master::setup): Ditto.  Remove now-unneeded ispty
2254         parameter.
2255         (fhandler_pty_master::open): Reflect argument removal for
2256         tty::allocate.
2257         * select.cc: Rename tty to pty where appropriate throughout.
2258         * sigproc.cc (proc_subproc): Remove CYGWIN=tty considerations.
2259         * tty.cc (ttyslot): Accommodate CYGWIN=tty removal.
2260         (tty_list::init_session): Ditto.
2261         (tty_list::attach): Ditto.
2262         (tty::create_master): Delete.
2263         (tty_list::terminate): Ditto.
2264         (tty_list::allocate): Delete "with_console" parameter.  Remove
2265         CYGWIN=tty considerations.
2266         (tty::init): Set is_console = false.  Use 'false' for was_opened since
2267         it is a boolean.
2268         * tty.h (*_{DONE,REQUEST}_EVENT): Delete.
2269         (tty_min::is_console): Declare new field which replaces hwnd.
2270         (tty_min::gethwnd): Delete.
2271         (tty_min::sethwnd): Ditto.
2272         (tty_list::allocate): Delete parameter.
2273         (tty_list::terminate): Delete declaration.
2274         * include/sys/cygwin.h (PID_USETTY): Redefine to PID_UNUSED1 and change
2275         comment to reflect its availability.
2276
2277 2011-06-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
2278
2279         * fhandler_tty_slave.cc (fhandler_tty_slave::fhandler_tty_slave):
2280         Revert previous change since unit 0 is perfectly valid.
2281
2282 2011-06-12  Christopher Faylor  <me.cygwin2011@cgf.cx>
2283
2284         Rename FH_BAD to FH_NADA throughout.
2285         * devices.h (FH_ERROR): New value.
2286         (iscons_dev): Extend to detect all the console device types.
2287         * devices.in: Set aside storage for FH_ERROR.
2288         * dtable.cc (dtable::init_std_file_from_handle): Use iscons_dev to
2289         detect when device is a console.
2290         (fh_alloc): Pass device to console constructor.
2291         (build_fh_pc): Short circuit when we detect that the constructor saw an
2292         error.
2293         * fhandler.h (fhandler_console::fhandler_console): Accept fh_devices
2294         parameter.
2295         (get_tty_stuff): Change to void.
2296         * fhandler_console (fhandler_console::set_unit): Set device to FH_ERROR
2297         on attempt to access anything other than the current console.
2298         (fhandler_console::get_tty_stuff): Change to void return.
2299         (fhandler_console::open): Return EPERM on FH_ERROR device type.
2300         (fhandler_console::fhandler_console): Set the device type appropriately
2301         before calling get_tty_stuff and rely on that function to reset it if
2302         necessary.
2303
2304 2011-06-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
2305
2306         * environ.cc (create_upcaseenv): Delete.
2307         (ucenv): Don't honor create_upcaseenv.
2308         (environ_init): Remove early retrieval of CYGWIN environment variable.
2309         Change comment to reflect new behavior.
2310
2311 2011-06-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
2312
2313         * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
2314         (child_info::old_title): Delete.
2315         (child_info::~child_info_spawn): Remove recording of old_title.
2316         * dcrt0.cc (title_buf): Delete.
2317         (child_info_spawn::handle_spawn): Remove recording of old_title.
2318         (dll_crt0_1): Get rid of all title handling.
2319         (do_exit): Ditto.
2320         * environ.cc (known): Delete strip_title and title.
2321         * fhandler_console.cc (fhandler_console::write): Remove recording of
2322         old_title.
2323         * globals.cc (exit_states): Remove ES_TITLE.
2324         (display_title): Delete.
2325         (strip_title_path): Delete.
2326         (old_title): Delete.
2327         * spawn.cc (spawn_guts): Remove old_title accommodation.
2328
2329 2011-06-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
2330
2331         * environ.cc (envcache): Delete.
2332         (known): Remove envcache.
2333         (getwinenv): Don't honor envcache setting.
2334
2335 2011-06-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
2336
2337         * environ.c: Move code earlier to allow:
2338         (_addenv): Call parse_options() when CYGWIN environment variable is
2339         being changed.
2340         (parse_options): Change parameter to 'const'.
2341
2342 2011-06-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
2343
2344         * environ.cc (tty_is_gone): Add missing space to message.
2345
2346 2011-06-08  Christopher Faylor  <me.cygwin2011@cgf.cx>
2347
2348         * environ.cc (settings::set_process_state): Delete.
2349         (tty_is_gone): New function.
2350         (known): Change "tty" to call tty_is_gone().  Remove unneeded '&' from
2351         beginning of function address.
2352         (parse_options): Remove set_process_state handling.
2353         * shared_info.h (CURR_USER_MAGIC): Reset.
2354         (user_info::warned_notty): New member.
2355
2356 2011-06-07  Christopher Faylor  <me.cygwin2011@cgf.cx>
2357
2358         * fhandler_console.cc (fhandler_console::open_shared_console):
2359         Semi-revert to using fixed location for console stuff.
2360         * shared.cc (offsets): Ditto.  Comment.
2361         * shared_info (shared_locations): Re-add SH_SHARED_CONSOLE.
2362
2363 2011-06-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
2364
2365         * fhandler_disk_file.cc (fhandler_disk_file::pread): Reset windows file
2366         position pointer back to previous location after successful read.
2367
2368 2011-06-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
2369
2370         * fhandler_console.cc (fhandler_console::open_shared_console): Don't
2371         zero handle to open_shared since it is supposed to be an input.
2372         (enum_windows): Set handle input to open_shared to NULL since it does
2373         not represent any previously opened shared region.
2374         * shared.cc (open_shared): Tweak debugging output.
2375
2376 2011-06-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
2377
2378         * ntdll.h (FILE_PIPE_*): Define constants.
2379         * select.cc (pipe_data_available): Detect closing state.
2380
2381 2011-06-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
2382
2383         * pinfo.cc (_pinfo::set_ctty): Don't reset myself->{pgid,sid} if
2384         terminal has no pgid or sid settings.
2385
2386 2011-06-03  Christopher Faylor  <me.cygwin2011@cgf.cx>
2387
2388         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise
2389         SIGPIPE when writing.
2390
2391         * fhandler.h: Include "tty.h".
2392         (fhandler_termios::_tc): Rename from tc.
2393         (fhandler_termios::tc): New method.
2394         (fhandler_termios::tcinit): Remove an argument.
2395         (fhandler_termios::get_ttyp): Use method to retrieve value.
2396         (fhandler_console::console_state): Move here.
2397         (fhandler_console::dev_state): Delete.
2398         (fhandler_console::shared_console_info): Define.
2399         (fhandler_console::open_shared_console): Move this function under
2400         fhandler_console umbrella.
2401         (fhandler_console::tc): Define.  Return static value.
2402         (fhandler_console::focus_aware): Accommodate deletion of dev_state.
2403         (fhandler_console): Add tty_list::get_cttyp as a friend.
2404         * fhandler_console.cc (dev_state): Redefine as a pointer within
2405         shared_console_info and change dev-> to dev. throughout.
2406         (fhandler_console::shared_console_info): Move into fhandler_console.
2407         (fhandler_console::open_shared_console): Move into fhandler_console
2408         change argument to simple bool.
2409         (enum_windows): Accommodate changes to console_state and
2410         open_shared_console.
2411         (console_unit::console_unit): Ditto.
2412         (fhandler_console::get_tty_stuff): Accommodate change to dev_state.
2413         (tty_list::get_cttyp): Accommodate change to
2414         handler_console::shared_console_info.
2415         (fhandler_console::read): Accommodate change from tc to tc ().
2416         (fhandler_console::set_input_state): Ditto.
2417         (fhandler_console::open): Accommodate tcinit argument change and change
2418         from tc to tc().
2419         (fhandler_console::input_tcsetattr): Accomodate change from tc to tc().
2420         (fhandler_console::input_tcsetattr): Ditto.
2421         (fhandler_console::write_normal): Ditto.
2422         (fhandler_console::init): Ditto.
2423         (fhandler_console::igncr_enabled): Ditto.
2424         * fhandler_termios.cc (fhandler_termios::tcinit): Remove first argument.
2425         Expect tc() to have been set up first.  Use tc() rather than tc.
2426         (fhandler_termios::tcsetpgrp): Accomodate change from tc to tc().
2427         (fhandler_termios::tcgetpgrp): Ditto.
2428         (fhandler_termios::bg_check): Ditto.
2429         (fhandler_termios::line_edit: Ditto.
2430         (fhandler_tty_master::set_winsize): Ditto.
2431         (fhandler_tty_slave::open): Ditto.
2432         (fhandler_tty_slave::init): Ditto.
2433         (fhandler_pty_master::write): Ditto.
2434         (fhandler_pty_master::setup): Ditto.  Accommodate change in arguments
2435         to tcinit.
2436         (fhandler_tty_slave::fch_open_handles): Set _tc directly.
2437         (tty_min::is_orphaned_process_group): Don't assume that parent pid
2438         exists.
2439         * pinfo.cc (_pinfo::set_ctty): Reset myself->{pgid,sid} here if we were
2440         started by a non-Cygwin process but the tty exists.
2441         * shared_info.h (console_state): Delete from here.
2442         * tty.h: Make multiple inclusion safe.
2443
2444 2011-05-31  Christopher Faylor  <me.cygwin2011@cgf.cx>
2445
2446         * exceptions.cc (ctrl_c_handler): Simplify test for no parent tty.
2447         * fhandler_console.cc (fhandler_console::get_tty_stuff): Return NULL if
2448         ctty is not tty/console.  Improve test for slave tty/pty device.
2449
2450 2011-05-31  Christopher Faylor  <me.cygwin2011@cgf.cx>
2451
2452         * external.cc (fillout_pinfo): Don't truncate ctty if it's < 0.
2453
2454         * select.cc (pipe_data_available): Avoid printing debug info by default
2455         or suffer very large strace files.
2456
2457 2011-05-31  Christopher Faylor  <me.cygwin2011@cgf.cx>
2458
2459         * select.cc (pipe_data_available): New function - uses
2460         NtQueryInformationFile to return information about pipes.
2461         (peek_pipe): Rewrite to use pipe_data_available for both read and write
2462         tests.
2463
2464 2011-05-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
2465
2466         * dtable.cc (dtable::select_write): Add missing argument to
2467         debug_printf.
2468
2469         * fhandler.cc (fhandler_base_overlapped::setup_overlapped): Explicitly
2470         set io_pending to false.
2471         (fhandler_base_overlapped::has_ongoing_io): Call GetOverlappedResult
2472         to force completion of I/O.
2473         (fhandler_base_overlapped::wait_overlapped): Rewrite to correctly deal
2474         with nonblocking reads and to make more race proof.
2475         (fhandler_base_overlapped::raw_write): Deal with new enum values.
2476         (fhandler_base_overlapped::raw_read): Ditto.  Don't deal with ongoing
2477         I/O here since it makes no sense in the read context.
2478         * fhandler.h (enum wait_return): Add overlapped_unknown,
2479         overlapped_nonblocking_no_data.
2480         * pipe.cc (pipe): Add debugging output.
2481
2482 2011-05-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
2483
2484         * dll_init.cc (dll_list::append): Eliminate increment of unused tot
2485         variable.
2486         * dll_init.h (dll_list::tot): Delete.
2487         (dll_list::populate_all_deps): Delete undefined function.
2488
2489         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Move EPIPE
2490         handling under error condition.
2491
2492 2011-05-30  Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
2493
2494         * dll_init.cc (reserve_upto): Remove.
2495         (release_upto): Ditto.
2496         (dll_list::reserve_space): New function to reserve space needed by
2497         DLL_LOAD dlls early in the fork process.
2498         (dll_list::load_after_fork): Rewrite to use recursion to
2499         track reservations it makes while trying to make dlls land where they
2500         belong.
2501         (dll_list::load_after_fork_impl): New function used by load_after_fork.
2502         (dll_list::alloc): Initialize image base field.
2503         * dll_init.h (dll_list::prefered_base): New field.
2504         (dll_list::reserve_space): Declare new function.
2505         (dll_list::load_after_fork): Declare new function.
2506         * fork.cc (frok::child): call dll_list::reserve_space early, so we can
2507         retry if it fails.
2508
2509 2011-05-30  Tor Perkins  <cygwin@noid.net>
2510
2511         * fhandler_termios.cc (fhandler_termios::bg_check): Do not return EIO
2512         when a process group has no leader as this is allowed and does not
2513         imply an orphaned process group.  Add a test for orphaned process
2514         groups.
2515         (tty_min::is_orphaned_process_group): Define new function.
2516         * tty.h (tty_min::is_orphaned_process_group): Define new function.
2517
2518 2011-05-30  Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
2519
2520         * dll_init.cc (dll_list::find_by_modname): New function to search the
2521         dll list for a module name only (no path).
2522         (dll_list::alloc): Initialize newly-added members of struct dll.
2523         (dll_list::append): New function to factor out the append operation
2524         (used by dll_list::topsort).
2525         (dll_list::populate_deps): New function to identify dll dependencies.
2526         (dll_list::topsort): New function to sort the dll list topologically by
2527         dependencies.
2528         (dll_list::topsort_visit): New helper function for the above.
2529         * dll_init.h (dll::ndeps): New class member.
2530         (dll::deps): Ditto.
2531         (dll::modname): Ditto.
2532         (dll_list::find_by_modname): New function related to topsort.
2533         (dll_list::populate_all_deps): Ditto.
2534         (dll_list::populate_deps): Ditto.
2535         (dll_list::topsort): Ditto.
2536         (dll_list::topsort_visit): Ditto.
2537         (dll_list::append): Ditto.
2538         (pefile): New struct allowing simple introspection of dll images.
2539         * fork.cc (fork): Topologically sort the dll list before forking
2540
2541 2011-05-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
2542
2543         * child_info.h (CURR_CHILD_INFO_MAGIC): Refresh.
2544         (child_info::refresh_cygheap): New function.
2545         * spawn.cc (spawn_guts): Call refresh_cygheap before creating a new
2546         process to ensure that cygheap_max is up-to-date.
2547         * fork.cc (frok::parent): Ditto.
2548
2549 2011-05-30  Christopher Faylor  <me.cygwin2011@cgf.cx>
2550
2551         * cygheap.cc (cygheap_dummy): Rename from cygheap_at_start.
2552         (cygheap): Accommodate name change to cygheap_dummy.
2553         (cygheap_init): Ditto.
2554         (cygheap_fixup_in_child): Simplify slightly.
2555         * fork.cc (fork): Add an advisory comment.
2556
2557 2011-05-29  Christopher Faylor  <me.cygwin2011@cgf.cx>
2558
2559         * fhandler.cc (fhandler_overlapped::wait_overlapped): Make sure that
2560         I/O is cancelled on signal.
2561
2562 2011-05-28  Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
2563
2564         * dll_init.cc (dll_list::alloc): Initialize dll::image_size.
2565         (reserve_at): Don't reserve space needed by the target dll if the
2566         latter overlaps the free region to be blocked.
2567         (dll_list::load_after_fork): Use new version of reserve_at.
2568         * dll_init.h (dll::image_size): New member.
2569         (pefile): New struct.
2570
2571 2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
2572             Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
2573
2574         * dll_init.c (dll_list::load_after_fork): Don't clear in_forkee here.
2575         * fork.cc (frok::errmsg): Rename from 'error'.
2576         (frok::error): New function.  Handle conditional printing of error
2577         messages.
2578         (frok::parent): Record hchild handle for use by error function.  Use
2579         throughout.  Use error function rather than setting error pointer
2580         directly.
2581         (fork): Clear is_forkee here.  Accommodate rename of 'error' to
2582         'errmsg'.
2583         * sigproc.cc (child_info::proc_retry): Detect EXITCODE_FORK_FAILED.
2584
2585 2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
2586
2587         * fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to
2588         attempt to properly set errno and bytes read for non-blocking case.
2589         Change to just rely on res to indicate error conditions.
2590
2591 2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
2592
2593         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set
2594         io_pending unless ReadFile has returned an error.  (this is a partial fix,
2595         accidentally checked in)
2596
2597 2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
2598
2599         * autoload.cc: Call _api_fatal in asm.
2600         * child_info.h: Redefine CURR_CHILD_INFO_MAGIC.
2601         (child_info_fork::abort): Rename from handle_failure.  Change
2602         arguments.
2603         * cygtls.h (_local_storage::ttybuf): New field.
2604         * dcrt0.cc (vapi_fatal): Split api_fatal.  Add "in forked process" to
2605         message when appropriate.
2606         (api_fatal): Use vapi_fatal.
2607         * devices.h: Make multiple inclusion safe.
2608         (fh_devices): Add FH_CONS* stuff.  Reorder slightly.
2609         (device): Eliminate anonymous union.  Add more ways to access
2610         minor/major.
2611         (device::setunit): Accommodate no-longer-anonymous union.
2612         (device::is_fs): Ditto.
2613         (device::is_fs_special): Ditto.
2614         (device::major): New function.
2615         (device::minor): Ditto.
2616         (device::is_device): New function.
2617         (device::not_device): Ditto.
2618         (device::operator int): New operator.
2619         (device::operator fh_devices): Ditto.
2620         (device::operator bool): Ditto.
2621         (device::operator DWORD): Ditto.
2622         (device::operator =): Ditto.
2623         (isproc_dev): New function.
2624         (isprocsys_dev): Ditto.
2625         (iscons_dev): Ditto.
2626         (istty_slave_dev): Ditto.
2627         * devices.in: Add new "/dev/cons*" strings.  Accommodate
2628         no-longer-anonymous union throughout.
2629         (BRACK): Use more precise method for initialization.
2630         * devices.cc: Regenerate.
2631         * dtable.cc (dtable::stdio_init): Use get_cttyp instead of get_tty.
2632         (dtable::find_archetype): Use new DWORD operator in device to test
2633         archetypes.
2634         (dtable::init_std_file_from_handle): Use different method to initialize
2635         'dev'.  Adapt to different ctty handling and accommodate /dev/cons*.
2636         (fh_alloc): Accommodate no-longer-anonymous union.  Adapt to new
2637         /dev/cons*.
2638         (build_fh_pc): Make debugging output more useful.
2639         * exceptions.cc (ctrl_c_handler): Use get_cttyp instead of get_tty.
2640         * external.cc (fillout_pinfo): Accommodate new cons* stuff.
2641         * fhandler.cc (fhandler_base::read): Eliminate is_slow() test.
2642         * fhandler.h (fhandler_base::*): Adapt to changes in device.h.
2643         (fhandler_*::is_slow): Delete.
2644         ( fhandler_proc::get_proc_fhandler): Return fh_devices type.
2645         * fhandler_console.cc (open_shared_console): New function.
2646         (console_unit): New class.
2647         (console_unit::console_unit): New constructor.
2648         (enum_windows): New function.  Declare as friend to console_unit.
2649         (fhandler_console::set_unit): New function.
2650         (fhandler_console::get_tty_stuff): Call set_unit to set the unit number
2651         and determine if initialization is needed.  Eliminate flags parameter.
2652         (tty_list::get_cttyp): Rename (sorta) from get_tty.  Return pointer to
2653         correct tty_min.
2654         (fhandler_console::open): Adapt to elimination of argument to
2655         get_tty_stuff.
2656         (fhandler_console::output_tcsetattr): Properly detect error condition.
2657         (fhandler_console::fixup_after_fork_exec): Adapt to get_tty_stuff()
2658         setting tc automatically.
2659         * fhandler_proc.cc: Use FH_BAD rather than 0 throughout where using
2660         fh_devices enum.
2661         (fhandler_proc::get_proc_fhandler): Return fh_devices.  Adapt to
2662         devices.h changes.
2663         * fhandler_process.cc: Adapt to devices.h changes.  Use FH_BAD rather
2664         than 0 throughout where using fh_devices enum.
2665         * fhandler_procnet.cc: Ditto.
2666         * fhandler_procsys.cc: Ditto.
2667         * fhandler_procsysvipc.cc: Ditto.
2668         * fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): Ditto.
2669         * fhandler_termios.cc (handler_termios::bg_check): Use tc->ttyname()
2670         rather than assuming that we can construct a tty.
2671         * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Just
2672         return get_minor() of dev.
2673         (fhandler_pty_master::process_slave_output): Add slightly more
2674         debugging info.
2675         (fhandler_tty_slave::fhandler_tty_slave): Change name from ntty to
2676         unit.
2677         (fhandler_pty_master::open): Ditto.
2678         (fhandler_tty_slave::ioctl): Adapt to change which causes ctty to
2679         represent a complete device.
2680         (fhandler_tty_master::init_console): Add debugging for failure path.
2681         (fhandler_pty_master::setup): Use get_unit() to retrieve unit number
2682         rather than relying on raw ntty.
2683         (fhandler_pty_master::setup): Ditto.
2684         * fhandler_virtual.h (virt_tab_t): Redefine fhandler as fh_devices.
2685         * fork.cc: Remove obsolete vfork stuff.
2686         (frok::child): Don't assume that a ctty == 0 is valid.
2687         * mount.cc (mount_info::conv_to_win32_path): Adapt to device struct
2688         changes.
2689         (mount_info::conv_to_win32_path): Ditto.
2690         * path.cc (path_conv::check): Retrive major/minor numbers via a method
2691         rather than accessing them directly from device.  Rely on dev operators
2692         to set/retrieve device information as required by device struct change.
2693         * path.h (isproc_dev): Move to devices.h.
2694         (isprocsys_dev): Ditto.
2695         (isvirtual_dev): Ditto.
2696         (path_conv:{isdevice,isfifo,isspecial,iscygdrive,issocket,get_devn,get_unitn}):
2697         Use device methods to access/manipulate devices.
2698         * pinfo.cc (pinfo::exit): Don't assume that ctty == 0 is valid.  Use
2699         iscons_dev to determine if a device is a console.
2700         (_pinfo::_ctty): Use device::parse to generate tty/cons name.
2701         (_pinfo::set_ctty): Don't assume that ctty == 0 is valid.  Remove
2702         redundant info from debugging.
2703         * shared.cc (offsets): Remove console offset.
2704         * shared_info.h (shared_locations): Ditto.
2705         * syscalls.cc (umask): Use device methods to manipulate device
2706         information.
2707         (ctermid): Use device::parse to generate term device name.
2708         * tlsoffsets.h: Regenerate.
2709         * tty.cc (ttyslot): Return minor number of ctty since ctty now
2710         represents a full device.
2711         (tty::create_master): Set ctty to a complete device.
2712         (tty_list::attach): Rework to detect new /dev/cons* stuff.
2713         (tty_list::terminate): Adapt to changes to ctty.
2714         (tty_list::init): Adapt to change to setntty - pass in device major
2715         number.
2716         (tty::exists): Use get_unit() to retrive tty unit number.
2717         (tty::open_mutex): Ditto.
2718         (tty::open_inuse): Ditto.
2719         (tty::create_inuse): Ditto.
2720         (tty::get_event): Ditto.
2721         (tty_min::ttyname): Define new function.
2722         * tty.h (tty_min::ntty): Redefine as fh_devices.
2723         (tty::exists): Use get_unit() to retrive tty unit number.
2724         (tty::open_mutex): Ditto.
2725         (tty::open_inuse): Ditto.
2726         (tty::create_inuse): Ditto.
2727         (tty::get_event): Ditto.
2728         (tty_min::ttyname): Declare new function.
2729         (tty::getntty): Declare as const.
2730         (tty_list::operator []): Assure that only minor part of argument is
2731         used.
2732
2733         * dll_init.cc (dll_list::alloc): Detect mismatch of data segments early
2734         issuing an explicit error message if necessary.
2735         * heap.cc (heap_init): Adapt to changes from fork->handle_failure to
2736         fork->abort.
2737         * pinfo.h (EXITCODE_FORK_FAILED): New enum.  (from Ryan Johnson)
2738         * sigproc.cc (child_info_fork::abort): Rename from handle_failure.
2739         Change arguments to allow passing in a printf-like message.
2740         * winsup.h (api_fatal): Delete macro definition.
2741         (api_fatal): Redefine from __api_fatal.
2742         (vapi_fatal): Declare new function.
2743         * include/sys/strace.h (strace_vprintf): Define new macro.
2744
2745         * ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemHandleInformation.
2746
2747 2011-05-27  Corinna Vinschen  <corinna@vinschen.de>
2748
2749         * shared.cc (offsets): Reorder so that console_state is lowest in
2750         memory.  Explain why.
2751         (open_shared): Accommodate reordering of offsets array.
2752         * shared_info.h (shared_locations): Reorder SH_SHARED_CONSOLE after
2753         SH_MYSELF.
2754
2755 2011-05-26  Corinna Vinschen  <corinna@vinschen.de>
2756
2757         * mount.h (MAX_MOUNTS): Raise to 64.
2758
2759 2011-05-25  Eric Blake  <eblake@redhat.com>
2760
2761         * cygtls.h (strerror_r_buf): New buffer.
2762         * errno.cc (strerror): Move guts...
2763         (_strerror_r): ...to new function demanded by newlib.
2764         (strerror_r): Don't clobber strerror buffer.
2765         (_user_strerror): Drop unused declaration.
2766         * tlsoffsets.h: Regenerate.
2767
2768 2011-05-25  Corinna Vinschen  <corinna@vinschen.de>
2769
2770         * init.cc (dll_entry): Reinstantiate wow64_test_stack_marker and
2771         previous stack tests.
2772
2773 2011-05-25  Corinna Vinschen  <corinna@vinschen.de>
2774
2775         * posix.sgml (std-notes): Add missing <para>.
2776
2777 2011-05-24  Corinna Vinschen  <corinna@vinschen.de>
2778
2779         * mount.cc (mount_info::conv_to_win32_path): Remove unused code.
2780         * mount.h (class mount_info): Remove sys_mount_table_counter member.
2781         * shared_info.h (class shared_info): Ditto.
2782         (CURR_SHARED_MAGIC): Update.
2783
2784 2011-05-24  Corinna Vinschen  <corinna@vinschen.de>
2785
2786         * pinfo.h (struct _pinfo): Reduce size of progname array slightly.
2787         Explain why.
2788
2789 2011-05-23  Eric Blake  <eblake@redhat.com>
2790
2791         * errno.cc (strerror): Print unknown errno as int.
2792         (__xpg_strerror_r): Likewise, and don't clobber strerror buffer.
2793         * cygtls.h (strerror_buf): Resize to allow '-'.
2794
2795 2011-05-23  Corinna Vinschen  <corinna@vinschen.de>
2796
2797         * fhandler_process.cc (thread_info::fill_if_match): Reformat.
2798         (format_process_maps): Ditto.  Fetch pointer to procinfo structure
2799         from mapped process.  Print info about global shared Cygwin regions.
2800
2801 2011-05-21  Corinna Vinschen  <corinna@vinschen.de>
2802
2803         * fhandler_process.cc (struct dos_drive_mappings): Use malloc/free
2804         rather than cmalloc/cfree.  Check return value from malloc before
2805         using it.
2806         (struct heap_info): Ditto.
2807         (struct thread_info): Ditto.  Rename from stack_info.  Rename members
2808         and local variables accordingly.
2809         (thread_info::thread_info): Store stack and TEB addresses.
2810         (thread_info::fill_if_match): Print "teb" if a TEB address has been
2811         found.  Special case for WOW64, explain why.
2812         (format_process_maps): Fetch PEB address.  Print MEM_RESERVE regions
2813         with equal signs to distinguish them from PAGE_NOACCESS regions.  Fix
2814         printing of 'p' and 's' to differ between MEM_PRIVATE and MEM_MAPPED
2815         pages, as on Linux.  Print 'g' instead of 'p for PAGE_GUARD pages.
2816         Print PEB and SharedUserData area if recognized.
2817
2818 2011-05-20  Corinna Vinschen  <corinna@vinschen.de>
2819
2820         * miscfuncs.cc (CygwinCreateThread): Fix condition for adding the
2821         guardsize to the stacksize.  Fix accompanying comment.
2822
2823 2011-05-20  Corinna Vinschen  <corinna@vinschen.de>
2824
2825         * miscfuncs.cc (CygwinCreateThread): Add accidentally missing comment.
2826
2827 2011-05-20  Corinna Vinschen  <corinna@vinschen.de>
2828
2829         * fhandler_process.cc (struct heap_info): Change type of base and end
2830         members to char *.  Print "shared" rather than "share".
2831         (struct stack_info): New class to fetch process stack information.
2832         (format_process_maps): Initialize and check for stack information.
2833
2834 2011-05-20  Corinna Vinschen  <corinna@vinschen.de>
2835
2836         * miscfuncs.cc (thread_wrapper): Remove statements added for debugging
2837         purposes.
2838
2839 2011-05-20  Corinna Vinschen  <corinna@vinschen.de>
2840
2841         * child_info.h (CURR_CHILD_INFO_MAGIC): Update.
2842         (class child_info_fork): Remove stacksize, add stackaddr and guardsize
2843         members.
2844         * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Partial rewrite
2845         to regenerate the stack exactly as in the parent.
2846         (child_info_fork::alloc_stack): Set stackaddr to 0, rather than
2847         stacksize.
2848         (dll_crt0_1): Check for stackaddr before changing the stack addresses
2849         in the TEB.
2850         * fork.cc (frok::child): Check for stackaddr here.
2851         (frok::parent): Set ch.stackaddr and ch.guardsize if not called from
2852         the main thread.
2853         * init.cc (dll_entry): Replace pointer to NT_TIB with pointer to TEB.
2854         Fix incorrectly changed address test before removing _my_tls.
2855         Set StackLimit to NULL on Windows 2000.  Explain why.
2856         * miscfuncs.cc (struct thread_wrapper_arg): Store stackbase rather
2857         than stacksize, store commitaddr, remove guardsize.  Store all pointers
2858         as char * for easier address arithmetic.
2859         (thread_wrapper): Rewrite to remove OS stack before calling thread
2860         function.  Add lots of comments to explain what we do.
2861         (CygwinCreateThread): Reserve our own stack in case we got no
2862         application stack.  Add comments.
2863         * ntdll.h (struct _TEB): Extend defintion up to DeallocationStack
2864         member.
2865         * thread.cc (pthread_attr::pthread_attr): Use "(size_t) -1"
2866         rather then 0xffffffff.
2867         * wincap.h (wincaps::has_stack_size_param_is_a_reservation): New
2868         element.
2869         * wincap.cc: Implement above element throughout.
2870
2871 2011-05-19  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
2872
2873         * thread.cc: Mark psiginfo and psignal as available in list of
2874         optional cancellation points.
2875
2876 2011-05-19  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
2877
2878         * cygwin.din (__fpurge): Export.
2879         * posix.sgml (std-solaris): Add __fpurge.
2880         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2881
2882 2011-05-18  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
2883
2884         * posix.sgml (std-susv4): Remove chroot, futimes, hstrerror.
2885         (std-deprec): Add chroot.
2886         (std-bsd): Add futimes, hstrerror.
2887         (std-notimpl): Add clock_nanosleep, nexttoward, nexttowardf.
2888         Remove initstate, which is implemented and listed in std-susv4.
2889
2890 2011-05-17  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
2891
2892         * cygwin.din (error): Export.
2893         (error_at_line): Export.
2894         (error_message_count): Export.
2895         (error_one_per_line): Export.
2896         (error_print_progname): Export.
2897         * errno.cc (error_message_count): Define.
2898         (error_one_per_line): Define.
2899         (error_print_progname): Define.
2900         (_verror): New static function.
2901         (error): New function.
2902         (error_at_line): New function.
2903         * posix.sgml (std-gnu): Add error, error_at_line.
2904         * include/error.h: New header.
2905         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2906
2907 2011-05-17  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
2908
2909         * cygwin.din (clock_getcpuclockid): Export.
2910         (pthread_getcpuclockid): Export.
2911         * hires.h (PID_TO_CLOCKID): New macro.
2912         (CLOCKID_TO_PID): New macro.
2913         (CLOCKID_IS_PROCESS): New macro.
2914         (THREADID_TO_CLOCKID): New macro.
2915         (CLOCKID_TO_THREADID): New macro.
2916         (CLOCKID_IS_THREAD): New macro.
2917         * ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadTimes.
2918         * posix.sgml (std-notimpl): Add clock_getcpuclockid and
2919         pthread_getcpuclockid from here...
2920         (std-susv4): ... to here.
2921         (std-notes): Remove limitations of clock_getres and clock_gettime.
2922         Note limitation of timer_create to CLOCK_REALTIME.
2923         * sysconf.cc (sca): Set _SC_CPUTIME to _POSIX_CPUTIME, and
2924         _SC_THREAD_CPUTIME to _POSIX_THREAD_CPUTIME.
2925         * thread.cc (pthread_getcpuclockid): New function.
2926         * timer.cc (timer_create): Set errno to ENOTSUP for CPU-time clocks.
2927         * times.cc (clock_gettime): Handle CLOCK_PROCESS_CPUTIME_ID and
2928         CLOCK_THREAD_CPUTIME_ID.
2929         (clock_getres): Ditto.
2930         (clock_settime): Set errno to EPERM for CPU-time clocks.
2931         (clock_getcpuclockid): New function.
2932         * include/pthread.h (pthread_getcpuclockid): Declare.
2933         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2934
2935 2011-05-17  Corinna Vinschen  <corinna@vinschen.de>
2936
2937         * miscfuncs.cc (thread_wrapper): Remove unused _cygtls record.
2938         * mmap.cc (is_mmapped_region): Avoid crash if no mmaps exist.
2939
2940 2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
2941
2942         * globals.cc (__getlogin_username): Remove.
2943         * uinfo.cc (getlogin_r): Fetch username from cygheap.
2944         (getlogin): Add static buffer username and fetch username from
2945         getlogin_r.
2946
2947 2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
2948
2949         * cygtls.h (struct _local_storage): Remove unused members rarg and
2950         _localtime_buf.  Remove username in favor of a global buffer.  Reorder
2951         slightly to keep the net.cc stuff together.
2952         * globals.cc (__getlogin_username): New global char buffer.
2953         * tlsoffsets.h: Regenerate.
2954         * uinfo.cc (getlogin): Copy username into __getlogin_username.
2955
2956 2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
2957
2958         * heap.cc (heap_init): Rewrite initial heap allocation to use addresses
2959         beyond 0x20000000.  Explain why and how.
2960         * shared.cc (shared_info::heap_slop_size): Remove.
2961         * shared_info.h (class shared_info): Remove heap_slop_inited and
2962         heap_slop members.  Remove heap_slop_size declaration.
2963         (CURR_SHARED_MAGIC): Update.
2964         * wincap.cc: Throughout, drop heapslop.
2965         * wincap.h (struct wincaps): Drop heapslop.
2966
2967 2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
2968
2969         * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Check if the
2970         requested stack is application-provided within the user heap or an
2971         mmapped region.  If so, just use it.  Add comment to explain why.
2972         * miscfuncs.cc (thread_wrapper): If an application-provided stack
2973         has been given, implement cygtls area at the stackbase.  Fix comment.
2974         * mmap.cc (is_mmapped_region): New function.
2975         * winsup.h (is_mmapped_region): Declare.
2976
2977 2011-05-15  Corinna Vinschen  <corinna@vinschen.de>
2978
2979         * miscfuncs.cc (thread_wrapper): Add comments to assembler code.
2980
2981 2011-05-15  Corinna Vinschen  <corinna@vinschen.de>
2982
2983         * cygwin.din (pthread_attr_getguardsize): Export.
2984         (pthread_attr_setguardsize): Export.
2985         (pthread_attr_setstack): Export.
2986         (pthread_attr_setstackaddr): Export.
2987         * init.cc (dll_entry): Remove wow64_test_stack_marker.  Check for
2988         unusual stack address by testing stack addresses from current TEB.
2989         Check validity of _my_tls by testing if it's within the stack as
2990         given in current TEB.
2991         * miscfuncs.cc (struct thread_wrapper_arg): New structure used to
2992         push all required information to thread_wrapper function.
2993         (thread_wrapper): Wrapper function for actual thread function.
2994         If an application stack has been given, change %ebp and %esp so that
2995         the thread function runs on that stack.  If the thread has been created
2996         by CygwinCreateThread, set up the POSIX guard pages if necessary.
2997         (CygwinCreateThread): New function.
2998         * miscfuncs.h (CygwinCreateThread): Declare.
2999         * ntdll.h (struct _TEB): Define all members up to Peb.
3000         * posix.sgml (std-susv4): Move pthread_attr_getguardsize,
3001         pthread_attr_setguardsize and pthread_attr_setstack here.
3002         (std-deprec): Add pthread_attr_setstackaddr.
3003         * sysconf.cc (sca): Set _SC_THREAD_ATTR_STACKADDR to
3004         _POSIX_THREAD_ATTR_STACKADDR.
3005         * thread.cc (pthread::precreate): Copy pthread_attr stackaddr and
3006         guardsize members.
3007         (pthread::create): Call CygwinCreateThread.
3008         (pthread_attr::pthread_attr): Initialize guardsize.
3009         (pthread_attr_setstack): New function.
3010         (pthread_attr_setstackaddr): New function.
3011         (pthread_attr_setguardsize): New function.
3012         (pthread_attr_getguardsize): New function.
3013         (pthread_getattr_np): Copy attr.guardsize.
3014         * thread.h (pthread_attr): Add member guardsize.
3015         * include/pthread.h (pthread_attr_getguardsize): Declare.
3016         (pthread_attr_setguardsize): Declare.
3017         * include/cygwin/version.h: Bump API minor number.
3018
3019 2011-05-13  Corinna Vinschen  <corinna@vinschen.de>
3020
3021         * fhandler_process.cc (struct heap_info::heap): Convert base to
3022         uintptr_t.  Add heap_id, end, flags members.
3023         (heap_info::heap_vm_chunks): Rename from heaps.
3024         (heap_info::heap_info): Rearrange using RtlQueryProcessDebugInformation
3025         to get information of heap virtual memory blocks.  Store heap id and
3026         flags, as well as end address of each block.
3027         (heap_info::fill_if_match): Check incoming base address against full
3028         address range of heap chunks.  Convert flag values in extra heap
3029         information.
3030         (format_process_maps): Change order so that heap check is done before
3031         MEM_MAPPED check since there are shareable heaps.
3032         * ntdll.h (PDI_HEAP_BLOCKS): Define.
3033         (HEAP_FLAG_NOSERIALIZE): Define.
3034         (HEAP_FLAG_GROWABLE): Define.
3035         (HEAP_FLAG_EXCEPTIONS): Define.
3036         (HEAP_FLAG_NONDEFAULT): Define.
3037         (HEAP_FLAG_SHAREABLE): Define.
3038         (HEAP_FLAG_EXECUTABLE): Define.
3039         (HEAP_FLAG_DEBUGGED): Define.
3040         (struct _DEBUG_HEAP_ARRAY): Define.
3041         (struct _DEBUG_HEAP_BLOCK): Define.
3042
3043 2011-05-12  Corinna Vinschen  <corinna@vinschen.de>
3044
3045         Based on newlib patch to strptime by Peter Rosin <peda@lysator.liu.se>:
3046         * libc/time/strptime.c (is_leap_year): New static function.
3047         (first_day): Ditto.
3048         (__strptime): Fill in tm_yday when all of tm_year, tm_mon and tm_mday
3049         are updated. Fill in tm_mon, tm_mday and tm_wday when both of tm_year
3050         and tm_yday are updated.
3051
3052 2011-05-12  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3053
3054         * fhandler_proc.cc (format_proc_meminfo): Rewrite to use sysinfo().
3055         Support RAM and swap space larger than 4GB.
3056         Remove output elements not found with modern Linux kernels.
3057         (format_proc_swaps): Support paging files larger than 4GB.
3058
3059 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3060
3061         * autoload.cc: Remove useless comment.
3062
3063 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3064
3065         * autoload.cc (EnumProcessModules): Remove.
3066         * dlfcn.cc (dlopen): Make sure errno is set if an error occurs.
3067         (dlsym): Rewrite using RtlQueryProcessDebugInformation instead of
3068         EnumProcessModules.
3069         * ntdll.h (struct _DEBUG_MODULE_ARRAY): Define.
3070         (RtlCreateQueryDebugBuffer): Declare.
3071         (RtlDestroyQueryDebugBuffer): Declare.
3072         (RtlQueryProcessDebugInformation): Declare.
3073
3074 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3075
3076         * autoload.cc (GetModuleFileNameExW): Remove.
3077         * autoload.cc (GetModuleInformation): Remove.
3078
3079 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3080
3081         * autoload.cc (QueryWorkingSet): Remove.
3082
3083 2011-05-11  Ryan Johnson  <ryan.johnson@cs.utoronto.ca>
3084
3085         * fhandler_process.cc (format_process_maps): Rework to report
3086         all mapped address space in a process (committed or reserved),
3087         identifying the nature of the mapping (mapped file/image, heap,
3088         shared memory) when possible.
3089         (dos_drive_mappings): New helper classes.
3090         (heap_info): Ditto.
3091         * ntdll.h (struct _MEMORY_SECTION_NAME): Define.
3092
3093 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3094
3095         * autoload.cc (GetProcessMemoryInfo): Remove.
3096         * resource.cc (fill_rusage): Call NtQueryInformationProcess rather than
3097         GetProcessMemoryInfo to drop a psapi dependency.
3098
3099 2011-05-11  Corinna Vinschen  <corinna@vinschen.de>
3100
3101         * fhandler_socket.cc (get_inet_addr): Rearrange for better readability.
3102         Make waiting loop interruptible and cancelable.  Check for SYSTEM DOS
3103         flag before reading the file.  Change return value to return 0 on
3104         success, SOCKET_ERROR on failure.
3105         (fhandler_socket::bind): Only set R/O DOS flag on filesystems not
3106         supporting ACLs.
3107         (fhandler_socket::connect): Accommodate changed return values from
3108         get_inet_addr.  Use SOCKET_ERROR instead of -1.
3109         (fhandler_socket::sendto): Accommodate changed return values from
3110         get_inet_addr.
3111         * syslog.cc (connect_syslogd): Ditto.
3112
3113 2011-05-10  Christian Franke  <franke@computer.org>
3114
3115         * security.cc (check_registry_access): Handle missing
3116         security descriptor of HKEY_PERFORMANCE_DATA.
3117
3118 2011-05-10  Corinna Vinschen  <corinna@vinschen.de>
3119
3120         * lc_msg.h: Regenerate.
3121
3122 2011-05-10  Corinna Vinschen  <corinna@vinschen.de>
3123
3124         * fhandler_proc.cc (format_proc_uptime): Don't call GetSystemInfo.
3125         Fetch CPU count from wincap.
3126         (format_proc_stat): Ditto.
3127         * globals.cc (system_info): Move to wincap.
3128         * heap.cc (heap_init): Fetch page size from wincap.
3129         * syscalls.cc (getpagesize): Fetch allocation granularity from wincap.
3130         (getsystempagesize): Fetch page size from wincap.
3131         * wincap.cc (wincap_2003): Default is_server to false.
3132         (wincapc::init): Call GetSystemInfo here.  Always set is_server value.
3133         * wincap.h (class wincapc): Add system_info as private member.
3134         (wincapc::cpu_count): New public method.
3135         (wincapc::page_size): Ditto.
3136         (wincapc::allocation_granularity): Ditto.
3137
3138 2011-05-10  Corinna Vinschen  <corinna@vinschen.de>
3139
3140         * environ.cc (set_chunksize): Remove.
3141         (parse_thing): Remove forkchunk entry.
3142         * fork.cc (child_copy): Drop handling external chunksize setting.
3143         * wincap.cc: Througout, drop chunksize.
3144         (wincapc::set_chunksize): Remove.
3145         * wincap.h (struct wincaps): Drop chunksize and declaration of
3146         set_chunksize.
3147
3148 2011-05-08  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3149
3150         * times.cc (settimeofday): Add EFAULT handler.
3151         Set errno to EINVAL if tv.tv_nsec is invalid, and to EPERM if
3152         SetSystemTime fails.  Return -1 in case of failure, all for
3153         compatibility with BSD and Linux.
3154         (clock_settime): New function.
3155         * cygwin.din (clock_settime): Export.
3156         * posix.sgml (std-susv4): Add clock_settime.
3157         Move clock_setres from here...
3158         (std-deprec): ... to here.
3159         (std-notes): Correct limitation of clock_setres to only CLOCK_REALTIME.
3160         Add limitation of clock_settime to only CLOCK_REALTIME.
3161         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
3162
3163 2011-05-07  Corinna Vinschen  <corinna@vinschen.de>
3164
3165         * registry.cc (get_registry_hive_path): Change system_printf to
3166         debug_printf.
3167         (load_registry_hive): Ditto.
3168
3169 2011-05-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
3170
3171         * fhandler.h (fhandler_base::close_with_arch): Make non-virtual.
3172         (fhandler_base::open_fs): Move closer to it's close counterpart.
3173
3174 2011-05-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
3175
3176         * fhandler.cc (fhandler_base::dup): Avoid duping a handle when an
3177         fhandler has an archetype.
3178         * fhandler_console.cc (fhandler_console::invisible_console): Move to
3179         the top.
3180         (fhandler_console::set_close_on_exec): Don't set close-on-exec on
3181         handle since it's an archetype and you don't know how many things could
3182         be using it.
3183
3184 2011-05-06  Christopher Faylor  <me.cygwin2011@cgf.cx>
3185
3186         * fhandler.h (fhandler_dev_dsp): Cosmetic change.
3187
3188         * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Put back
3189         Sleep(10) for tty_master case.
3190
3191         * sigproc.cc (stopped_or_terminated): Don't consider a pid which has
3192         been reaped to be terminated.
3193
3194 2011-05-06  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3195
3196         * sysconf.cc (sysinfo): New function.
3197         * cygwin.din (sysinfo): Export.
3198         * posix.sgml (std-gnu): Add sysinfo.
3199         * include/sys/sysinfo.h (struct sysinfo): Define.
3200         (sysinfo): Declare.
3201         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
3202
3203 2011-05-06  Corinna Vinschen  <corinna@vinschen.de>
3204
3205         * libc/minires-os-if.c (get_dns_info): Drop printing uninitialized
3206         value of dwRetVal in debug output.
3207
3208 2011-05-06  Corinna Vinschen  <corinna@vinschen.de>
3209
3210         * fhandler.h (fhandler_socket::read): Declare.
3211         (fhandler_socket::write): Declare.
3212         * fhandler_procsys.cc (fhandler_procsys::read): Add FIXME comment.
3213         (fhandler_procsys::write): Ditto.
3214         * fhandler_socket.cc (fhandler_socket::read): New method.
3215         (fhandler_socket::write): New method.
3216         * syscalls.cc: Rearrange order of read/write functions.
3217         (read): Call fhandler read method directly instead of just readv.
3218         (readv): Remove EINTR loop.  This is done in all affected fhandler's
3219         now.
3220         (write): Call fhandler write method directly instead of just writev.
3221         Fix debug output.
3222
3223 2011-05-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
3224
3225         * cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch().
3226         * debug.cc (close_handle): Call debugger on failure.
3227         * devices.in (device::tty_to_real_device): Delete.
3228         * devices.h (device::tty_to_real_device): Ditto.
3229         * devices.cc: Regenerate.
3230         * dtable.cc: Delete old ifdef'ed vfork code.
3231         (dtable::release): Don't handle archetype here.
3232         (dtable::init_std_file_from_handle): Consolidate console tests.
3233         Generate major/minor for tty ASAP.  Fix incorrect setting of DEV_TTYS*
3234         for serial.
3235         (fh_alloc): New function derived from build_fh_pc.  Pass current tty
3236         when building tty.
3237         (build_pc_pc): Use fh_alloc to create.  Set name from fh->dev if
3238         appropriate.  Generate an archetype or point to one here.
3239         (dtable::dup_worker): Deal with archetypes.  Rely on = operator copying
3240         whole class rather than just fhandler_base.
3241         (dtable::fixup_after_exec): Call close_with_arch to handle closing of
3242         fhandlers with archetypes.
3243         * fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's
3244         size() rather than sizeof fhandler_base.
3245         (fhandler_base::open_with_arch): New function.  Handles opening of
3246         fhandler's with archetypes, dealing with usecounts, etc.
3247         (fhandler_base::close_with_arch): Ditto for close.
3248         * fhandler.h: Many changes for archetypes.
3249         (fhandler_base::set_name): Set both normalized path and regular path.
3250         (fhandler_base::open_with_arch): New function.
3251         (fhandler_base::open_setup): Ditto.
3252         (fhandler_base::use_archetype): Ditto.
3253         (fhandler_base::_archetype_usecount): Ditto.
3254         (fhandler_*::size): Ditto.
3255         (fhandler_dev_tape::open): Remove virtual decoration.
3256         (fhandler_console::use_archetype): New function.  Return true.
3257         (fhandler_console::open_setup): New function.
3258         (fhandler_console::dup): Delete.
3259         (fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an
3260         argument.
3261         (fhandler_tty_slave::use_archetype): New function.  Return true.
3262         (fhandler_tty_slave::cleanup): New function.
3263         (fhandler_pty_master::use_archetype): New function.  Return true.
3264         (fhandler_pty_master::cleanup): New function.
3265         (fhandler_pty_master::is_tty_master): New function.  Return false.
3266         (fhandler_tty_master::is_tty_master): New function.  Return true.
3267         (fhandler_dev_dsp::fhandler_dev_dsp): New function.  Return true.
3268         (report_tty_counts): Only report on archetype's usecount if there is
3269         one.
3270         * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove
3271         handling of setsid, set_ctty, set_flags, and manage_console_count.
3272         (fhandler_console::open_setup): New function.  Implement functionality
3273         removed from get_tty_stuff.
3274         (fhandler_console::dup): Delete.
3275         (fhandler_console::output_tcsetattr): Set errno on error.
3276         (fhandler_console::fhandler_console): Set device early.
3277         (fhandler_console::init): Use open_with_arch to open console handles.
3278         (fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for
3279         dealing with console handles.
3280         * fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling.
3281         (fhandler_dev_dsp::write): Ditto.
3282         (fhandler_dev_dsp::read): Ditto.
3283         (fhandler_dev_dsp::close): Ditto.
3284         (fhandler_dev_dsp::dup): Ditto.
3285         (fhandler_dev_dsp::ioctl): Ditto.
3286         (fhandler_dev_dsp::fixup_after_fork): Ditto.
3287         (fhandler_dev_dsp::fixup_after_exec): Ditto.
3288         * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a
3289         little more debugging.
3290         (fhandler_tty_common::__release_output_mutex): Ditto.
3291         (fhandler_pty_master::process_slave_output): Ditto.  Don't do signal
3292         handling or pthread_cancel handling in the tty master thread.
3293         (process_output): Minor reorg.
3294         (fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty
3295         argument.
3296         (fhandler_tty_slave::open): Remove archetype handling.  Move some
3297         processing into open_setup().
3298         (fhandler_tty_slave::open_setup): New function.
3299         (fhandler_tty_slave::cleanup): New function.
3300         (fhandler_tty_slave::close): Remove archetype handling.  Move some
3301         processing into cleanup().
3302         (fhandler_tty_slave::init): Rename argument from f to h.  Open device
3303         using open_with_arch().  Remove archetype handling.
3304         (fhandler_pty_master::dup): Ditto.
3305         (fhandler_pty_master::open): Ditto.
3306         (fhandler_pty_master::close): Ditto.  Move some handling to cleanup().
3307         (fhandler_pty_master::cleanup): New function.
3308         (fhandler_tty_master::init_console): Give unique name to captive
3309         console fhandler.
3310         * pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh.
3311         Eliminate archetype assumption.
3312         * syscalls.cc (close_all_files): Use close_with_arch for closing.
3313         (open): Use open_with_arch() rather than open().
3314         (close): Use close_with_arch() rather than close().
3315
3316 2011-05-05  Corinna Vinschen  <corinna@vinschen.de>
3317
3318         * pinfo.h (class push_process_state): New class to push a process state
3319         flag temporarily into myself->process_state.
3320         * fhandler_console.cc (fhandler_console::read): Add push_process_state
3321         handler.
3322         (fhandler_console::write): Call bg_check from here.  Add
3323         push_process_state handler.
3324         * fhandler_tty.cc (fhandler_tty_slave::write): Ditto.
3325         (fhandler_tty_slave::read): Ditto.
3326         (fhandler_pty_master::write): Ditto.
3327         (fhandler_pty_master::read): Ditto.
3328         * syscalls.cc (readv): Remove bg_check call and setting process state.
3329         (writev): Ditto.
3330
3331 2011-05-05  Corinna Vinschen  <corinna@vinschen.de>
3332
3333         * syscalls.cc (readv): Add myfault handler.  Don't check repeatedly
3334         open state of file handler.  Streamline loop.
3335         (writev): Add myfault handler.
3336
3337 2011-05-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
3338
3339         * fhandler.cc (fhandler_base_overlapped::raw_read): Rename from
3340         read_overlapped.
3341         (fhandler_base_overlapped::raw_e): Rename from write_overlapped.
3342         * fhandler.h (fhandler_*::raw_read): Add reparm decoration.
3343         (fhandler_*::raw_write): Ditto.
3344         (fhandler_base_overlapped::raw_read): Rename from read_overlapped.
3345         (fhandler_base_overlapped::raw_write): Rename from write_overlapped.
3346         (fhandler_pipe::raw_read): Delete.
3347         (fhandler_pipe::raw_write): Ditto.
3348         (fhandler_mailslot::raw_read): Ditto.
3349         * fhandler_fifo.cc (fhandler_fifo::raw_read): Reflect read_overlapped
3350         -> raw_read rename.
3351         (fhandler_fifo::raw_write): Ditto.
3352         * fhandler_mailslot.cc (fhandler_mailslot::raw_read): Delete.
3353         (fhandler_mailslot::raw_write): Reflect read_overlapped -> raw_read
3354         rename.
3355         * pipe.cc (fhandler_pipe::raw_read): Delete.
3356         (fhandler_pipe::raw_write): Ditto.
3357
3358 2011-05-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
3359
3360         * fork.cc (fork): Clear PID_REAPED.
3361         * pinfo.cc (pinfo_init): Ditto.
3362         (pinfo::init): Check for PID_REAPED.
3363         * sigproc.cc (stopped_or_terminated): Ditto.
3364
3365 2011-05-05  Christopher Faylor  <me.cygwin2011@cgf.cx>
3366
3367         * pinfo.cc (_pinfo::exists): Check for PID_REAPED.
3368
3369 2011-05-05  Corinna Vinschen  <corinna@vinschen.de>
3370
3371         * fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return
3372         with errno set to EBADF if file open mode is incorrect.
3373         (fhandler_disk_file::pwrite): Ditto.
3374
3375 2011-05-05  Corinna Vinschen  <corinna@vinschen.de>
3376
3377         * fhandler.cc (is_at_eof): Drop static storage class.  Drop err
3378         parameter since we don't change the Win32 error here anymore.
3379         (fhandler_base::raw_read): Accommodate change to is_at_eof.
3380
3381         * fhandler_disk_file.cc (fhandler_disk_file::pread): In binary mode use
3382         direct call to NtReadFile, rather than lseek/read.
3383         (fhandler_disk_file::pwrite): In binary mode use direct call to
3384         NtWriteFile, rather than lseek/write.
3385
3386 2011-05-05  Corinna Vinschen  <corinna@vinschen.de>
3387
3388         * dcrt0.cc (dll_crt0_1): Reset locale to "C" even when dynamically
3389         loaded.
3390
3391 2011-05-05  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3392
3393         * posix.sgml (std-notimpl): Remove bsd_signal, setcontext, and
3394         swapcontext, marked obsolete in SUSv3 and not present in SUSv4.
3395
3396 2011-05-05  Christian Franke  <franke@computer.org>
3397
3398         * fhandler_registry.cc (fhandler_registry::exists): Fix regression
3399         in EACCES handling.
3400         (fhandler_registry::open): Fix "%val" case.
3401
3402 2011-05-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
3403
3404         * signal.cc (_pinfo::kill): Return success on kill(0) only if pid
3405         exists or is in PID_EXITED state.  Report pid 0 when pid does not exist
3406         rather than pid -1.  Make debug output reflect actual function call.
3407         * sigproc.cc (stopped_or_terminated): Set process state to reaped when
3408         we've finished waiting for it.
3409         * include/sys/cygwin.h (PID_REAPED): New enum.
3410
3411 2011-05-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3412
3413         * cygwin.din (psiginfo): Export.
3414         (psignal): Export.
3415         (sys_siglist): Export.
3416         * posix.sgml (std-notimpl): Move psiginfo and psignal from here...
3417         (std-susv4): ... to here.
3418         (std-deprec): Add sys_siglist.
3419         * strsig.cc (sys_siglist): New array.
3420         (psiginfo): New function.
3421         * include/cygwin/signal.h (sys_siglist): Declare.
3422         (psiginfo): Declare.
3423         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
3424
3425 2011-05-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
3426
3427         * dll_list::detach (dll_list::detach): Avoid doing anything with detach
3428         during a failing fork.
3429
3430 2011-05-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
3431
3432         * dll_init.cc (dll_global_dtors): Avoid calling destructors during
3433         failing fork().
3434
3435 2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
3436
3437         * fhandler.h (class fhandler_base): Remove uninterruptible_io status
3438         flag.
3439         (fhandler_base::ready_for_read): Remove declaration.
3440         (fhandler_socket::ready_for_read): Ditto.
3441         (fhandler_pipe::ready_for_read): Ditto.
3442         (fhandler_tty_master::is_slow): Remove.
3443         * fhandler_console.cc (fhandler_console::open): Drop setting
3444         uninterruptible_io.
3445         * fhandler_serial.cc (fhandler_serial::open): Ditto.
3446         * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto.
3447         (fhandler_tty_master::init_console): Ditto.
3448         * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto.
3449         (fhandler_pipe::open): Ditto.
3450         (_pipe): Ditto.
3451         * select.cc (fhandler_pipe::ready_for_read): Remove.
3452         (fhandler_base::ready_for_read): Remove.
3453         * syscalls.cc (readv): Drop unneeded wait variable.  Remove entire test
3454         which might lead to calling ready_for_read.  Remove now unused label
3455         out.
3456
3457 2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
3458
3459         * fhandler.h (class fhandler_mailslot): Move down in file and change
3460         parent class to fhandler_base_overlapped.  Remove declaration of
3461         method write.  Add declaraiotns for raw_read and raw_write.
3462         * fhandler_mailslot.cc (fhandler_mailslot::fhandler_mailslot): Call
3463         fhandler_base_overlapped constructor.
3464         (fhandler_mailslot::fstat): Call fhandler_base_overlapped::fstat.
3465         (fhandler_mailslot::open): Drop FILE_SYNCHRONOUS_IO_NONALERT flag from
3466         call to NtOpenFile.
3467         (fhandler_mailslot::raw_read): New method.
3468         (fhandler_mailslot::raw_write): Ditto.  Take over length algorithm from
3469         former write method.
3470         (fhandler_mailslot::write): Remove.
3471         (fhandler_mailslot::ioctl): Call fhandler_base_overlapped::ioctl.
3472
3473 2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
3474
3475         * fhandler.h (fhandler_dev_tape::_lock): Add bool parameter.
3476         * fhandler_tape.cc (lock): Call _lock with false argument.
3477         (_lock): Take bool cancelable parameter.  Handle O_NONBLOCK.
3478         Make cancelable if cancelabe parameter is true.
3479         (fhandler_dev_tape::raw_read): Call _lock with true argument.
3480         (fhandler_dev_tape::raw_write): Ditto.
3481
3482 2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
3483
3484         * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member.
3485         (fhandler_dev_dsp::Audio_out::Audio_out): Take pointer to encapsulating
3486         fhandler_dev_dsp as parameter.
3487         (fhandler_dev_dsp::Audio_in::Audio_in): Ditto.
3488         (fhandler_dev_dsp::Audio::Audio): Take pointer to encapsulating
3489         fhandler_dev_dsp as parameter and store in fh.
3490         (fhandler_dev_dsp::Audio_out::write): Change return type to int and
3491         return number of bytes written.  Return -1 if waitforspace returns false
3492         and no bytes have been written so far.
3493         (fhandler_dev_dsp::Audio_out::waitforspace): Change return type to bool.
3494         Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
3495         Return false in any of these cases, otherwise true.
3496         (fhandler_dev_dsp::Audio_in::read): Set returned nBytes to -1 if
3497         waitfordata returns false and nothing has been read so far.
3498         (fhandler_dev_dsp::Audio_in::waitfordata): Change return type to bool.
3499         Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
3500         Return false in any of these cases, otherwise true.
3501         (fhandler_dev_dsp::write): Call Audio_out constructor with this as
3502         parameter.
3503         (fhandler_dev_dsp::read): Call Audio_in constructor with this as
3504         parameter.
3505
3506 2011-05-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
3507
3508         * thread.h (pthread::static_cancel_self): Mark as noreturn.
3509         (pthread::cancel_self): Ditto.
3510         * thread.cc (pthread::cancel_self): Explicitly use pthread::exit to
3511         avoid a "function returns" error.
3512
3513 2011-05-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
3514
3515         * pinfo.h (pinfo::pinfo): Set procinfo to NULL to avoid potential
3516         cleanup of uninitialized garbage.  (Suggested by Ryan Johnson)
3517
3518 2011-05-03  Corinna Vinschen  <corinna@vinschen.de>
3519
3520         * select.cc (cygwin_select): Make degenerate case cancelable.
3521         (select_stuff::destroy): New inline method to delete memory taken
3522         by select_stuff.
3523         (select_stuff::~select_stuff): Call destroy.
3524         (select_stuff::wait): Add case to allow canceling select.
3525         * select.h (select_stuff::destroy): Declare.
3526         * thread.cc: Mark poll, pselect and poll as cancelable.
3527
3528 2011-05-03  Corinna Vinschen  <corinna@vinschen.de>
3529
3530         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Make
3531         cancelable.  Remove test for main thread, always add signal_arrived
3532         to waited objects.
3533
3534 2011-05-03  Corinna Vinschen  <corinna@vinschen.de>
3535
3536         * fhandler_tty.cc (fhandler_tty_slave::read): Set WFMO timeout to 0 for
3537         nonblocking case.  Drop useless waiter variable.  Rewrite wait for
3538         input_available_event to use a switch statement.  Handle timeout and
3539         failure more gracefully.  Make restartable and cancelable.  Rewrite
3540         wait for input_mutex to use WFMO and a switch statement.  Handle
3541         timeout and failure more gracefully.  Make restartable and cancelable.
3542
3543 2011-05-02  Christopher Faylor  <me.cygwin2011@cgf.cx>
3544
3545         * signal.cc (_pinfo::kill): Avoid referencing 'pid' after ESRCH.
3546
3547 2011-05-02  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3548
3549         * cygwin.din (pthread_attr_getstack): Export.
3550         (pthread_attr_getstackaddr): Export.
3551         (pthread_getattr_np): Export.
3552         * ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadBasicInformation.
3553         (struct _THREAD_BASIC_INFORMATION): Define.
3554         (NtQueryInformationThread): Declare.
3555         * posix.sgml (std-susv4): Add pthread_attr_getstack.
3556         (std-gnu): Add pthread_getattr_np.
3557         (std-deprec): Add pthread_attr_getstackaddr.
3558         (std-notimpl): Remove pthread_attr_[gs]etstackaddr, as they were
3559         removed from SUSv4.
3560         * thread.cc (pthread_attr::pthread_attr): Initialize stackaddr.
3561         (pthread_attr_getstack): New function.
3562         (pthread_attr_getstackaddr): New function.
3563         (pthread_attr_setstacksize): Return EINVAL if passed size less than
3564         PTHREAD_STACK_MIN, as required by POSIX.
3565         (pthread_getattr_np): New function.
3566         * thread.h (class pthread_attr): Add stackaddr member.
3567         * include/pthread.h (pthread_attr_getstack): Declare.
3568         (pthread_attr_getstackaddr): Declare unconditionally.
3569         (pthread_attr_setstack): Declare inside false conditional for reference.
3570         (pthread_getattr_np): Declare.
3571         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
3572
3573 2011-05-02  Christopher Faylor  <me.cygwin2011@cgf.cx>
3574
3575         * Makefile.in: Allow CFLAGS to be overridden from the environment.
3576
3577 2011-05-02  Corinna Vinschen  <corinna@vinschen.de>
3578
3579         * thread.cc (cancelable_wait): Remove test for main thread.
3580         * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
3581
3582 2011-05-02  Corinna Vinschen  <corinna@vinschen.de>
3583
3584         * fhandler_tty.cc (andler_pty_master::process_slave_output): Make
3585         interruptible and cancelable.  Fix nonblocking case.
3586
3587 2011-05-02  Corinna Vinschen  <corinna@vinschen.de>
3588
3589         * fhandler_console.cc (fhandler_console::read): Make restartable and
3590         cancelable.
3591
3592 2011-05-02  Christopher Faylor  <me.cygwin2011@cgf.cx>
3593
3594         * strace.cc (strace::vprntf): Avoid closing unopened handle.
3595
3596 2011-05-02  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
3597
3598         * sysconf.cc (sca): Set _SC_SPIN_LOCKS to _POSIX_SPIN_LOCKS.
3599
3600 2011-05-02  Christopher Faylor  <me.cygwin2011@cgf.cx>
3601
3602         * dll_init.cc (dll_list::alloc): Reset 'p' in forked process.
3603
3604         * select.cc (select_stuff::wait): Move cleanup() closer to WFMO to
3605         minimize unavoidable (?) race.
3606
3607 2011-05-02  Corinna Vinschen  <corinna@vinschen.de>
3608
3609         * fhandler_serial.cc (fhandler_serial::raw_read): Add restartability
3610         after a signal.  Add cancelability.
3611         (fhandler_serial::raw_write): Wait for write to succeed if O_NONBLOCK
3612         is not set.  Add signal handling and cancelability.
3613
3614 2011-05-01  Corinna Vinschen  <corinna@vinschen.de>
3615
3616         * fhandler_windows.cc (fhandler_windows::read): Use
3617         pthread::get_cancel_event to fetch thread's cancel event.
3618         * flock.cc (lf_setlock): Ditto.
3619         * posix_ipc.cc (ipc_cond_timedwait): Ditto.
3620         * thread.cc (pthread::get_cancel_event): New static method.
3621         * thread.h (pthread::get_cancel_event): Declare.
3622
3623 2011-05-01  Corinna Vinschen  <corinna@vinschen.de>
3624
3625         * libc/minires-os-if.c (get_dns_info): Remove unnecessary test for
3626         existence of DnsQuery_A.
3627
3628 2011-05-01  Corinna Vinschen  <corinna@vinschen.de>
3629
3630         Throughout, use user32 UNICODE functions rather than ANSI functions.
3631         * autoload.cc: Convert all definitions for ANSI user32 functions to
3632         definitions for the corresponding UNICODE function.
3633         (SendMessageA): Remove.
3634         (SendNotifyMessageW): Define.
3635         * fhandler.h (fhandler_windows::is_slow): Remove.
3636         * fhandler_windows.cc (fhandler_windows::write): Use SendNotifyMessageW
3637         call rather than SendMessage to make function always return immediately.
3638         (fhandler_windows::read): Make function interruptible and a cancellation
3639         point.  Handle O_NONBLOCK.
3640         * select.cc (peek_serial): Don't wait for signal_arrived here.
3641         * window.cc (wininfo::winthread): Call CreateWindowExW directly rather
3642         than CreateWindow wrapper.
3643
3644 2011-05-01  Corinna Vinschen  <corinna@vinschen.de>
3645
3646         * net.cc (fdsock): Drop setting uninterruptible_io to true.
3647
3648 2011-05-01  Corinna Vinschen  <corinna@vinschen.de>
3649
3650         * fhandler.h (fhandler_socket::is_slow): Remove.
3651
3652 2011-04-30  Corinna Vinschen  <corinna@vinschen.de>
3653
3654         * fcntl.cc (fcntl64): Call pthread_testcancel.
3655         * fhandler_socket.cc (fhandler_socket::connect): Ditto.
3656         (fhandler_socket::accept4): Ditto.
3657         (fhandler_socket::recvfrom): Ditto.
3658         (fhandler_socket::recvmsg): Ditto.
3659         (fhandler_socket::sendto): Ditto.
3660         (fhandler_socket::sendmsg): Ditto.
3661         * flock.cc (lf_setlock): Allow to cancel thread running blocking
3662         file lock.  Try to make code more readable.
3663         (lockf): Call pthread_testcancel.
3664         * mmap.cc (msync): Ditto.
3665         * posix_ipc.cc (ipc_cond_timedwait): Call pthread::static_cancel_self
3666         rather than pthread_testcancel.
3667         * select.cc (cygwin_select): Call pthread_testcancel.
3668         * syscalls.cc (pread): Ditto.
3669         (pwrite): Ditto.
3670         (readv): Ditto.
3671         (writev): Ditto.
3672         (open): Ditto.
3673         (close): Ditto.
3674         (fsync): Ditto.
3675         * termios.cc (tcdrain): Ditto.
3676         * thread.cc: Align list of cancellation points with above changes.
3677         Mark not-implemented functions, too.
3678         (cancelable_wait): Don't set unused object indices to WAIT_FAILED
3679         since that could result in wrong behaviour.  Set them to the invalid
3680         value WAIT_TIMEOUT + 1 instead.
3681
3682 2011-04-30  Corinna Vinschen  <corinna@vinschen.de>
3683
3684         * thread.h (class pthread): Add bool member canceled.
3685         * thread.cc (pthread::pthread): Initialize canceled to false.
3686         (pthread::cancel): Set canceled before setting cancel_event.
3687         (pthread::testcancel): Check for canceled.  Only wait for cancel_event
3688         if canceled is true.  Explain why.
3689         (pthread::_fixup_after_fork): Set canceled to false.
3690
3691 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3692
3693         * errno.cc (errmap): Sort.  Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
3694         ENOEXEC.
3695
3696 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3697
3698         * thread.cc: Update comment listing cancellation points per POSIX.
3699
3700 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3701
3702         * advapi32.cc: Add comment.
3703         (EqualSid): Remove.
3704         (CopySid): Remove.
3705         (AddAccessAllowedAce): Remove.
3706         (AddAccessDeniedAce): Remove.
3707         (MakeSelfRelativeSD): Remove.
3708         * flock.cc: Replace above functions throughout with their ntdll.dll
3709         equivalent.
3710         * sec_acl.cc: Ditto.
3711         * sec_auth.cc: Ditto.
3712         * sec_helper.cc: Ditto.
3713         * security.cc: Ditto.
3714         * security.h: Ditto.
3715         (RtlEqualSid): Declare.  Explain why.
3716         (RtlCopySid): Ditto.
3717
3718 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3719
3720         * advapi32.cc (AccessCheck): Remove.
3721         (PrivilegeCheck): Remove.
3722         (OpenThreadToken): Remove.
3723         * fhandler_tty.cc: Replace above functions throughout with their
3724         ntdll.dll equivalent.
3725         * security.cc: Ditto.
3726
3727 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3728
3729         * ntdll.h (IsEventSignalled): New inline function.
3730         * cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in
3731         place of WaitForSingleObject on event with 0 timeout.
3732         * fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto.
3733         * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
3734         (fhandler_fifo::wait): Ditto.
3735         * fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
3736         * select.cc (verify_tty_slave): Ditto.
3737         * thread.cc (pthread::testcancel): Ditto.
3738
3739 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3740
3741         * advapi32.cc (GetTokenInformation): Remove.
3742         (SetTokenInformation): Remove.
3743         * grp.cc: Replace above functions throughout with their ntdll.dll
3744         equivalent.
3745         * sec_auth.cc: Ditto.
3746         * syscalls.cc: Ditto.
3747         * uinfo.cc: Ditto.
3748
3749 2011-04-29  Corinna Vinschen  <corinna@vinschen.de>
3750
3751         * posix_ipc.cc (ipc_cond_timedwait): Only wait for pthread's
3752         cancel_event if thread's cancelability isn't disabled.
3753
3754 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3755
3756         * advapi32.cc (SetSecurityDescriptorDacl): Remove.
3757         (SetSecurityDescriptorGroup): Remove.
3758         (SetSecurityDescriptorOwner): Remove.
3759         * pinfo.cc: Replace above functions throughout with their ntdll.dll
3760         equivalent.
3761         * sec_acl.cc: Ditto.
3762         * sec_helper.cc: Ditto.
3763         * security.cc: Ditto.
3764
3765         * sec_helper.cc (__sec_user): Remove old comment.
3766
3767 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3768
3769         * posix_ipc.cc (ipc_cond_timedwait): Also wait for pthread's
3770         cancel_event, if any.  Call pthread_testcancel if cancel_event has been
3771         signalled.
3772
3773 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3774
3775         * posix_ipc.cc (ipc_cond_timedwait): Remove pthread_testcancel calls.
3776         (_mq_send): Add pthread_testcancel call at start of function.
3777         (_mq_receive): Ditto.
3778
3779 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3780
3781         * cygerrno.h (geterrno_from_nt_status): Declare.
3782         * errno.cc (geterrno_from_nt_status): Define.
3783         * flock.cc: Fix copyright dates.
3784         * ntdll.h (enum _TIMER_TYPE): Define.
3785         (PTIMER_APC_ROUTINE): Define.
3786         (NtCancelTimer): Declare.
3787         (NtCreateTimer): Declare.
3788         (NtSetTimer): Declare.
3789         * posix_ipc.cc (ipc_cond_timedwait): Rewrite to make interruptible and
3790         restartable.  Call pthread_testcancel in case of timeout to enable
3791         pthread_cancel on waiting thread.  Replace WFMO timeout with waiting
3792         for a waitable timer.  Explain why.  Replace single call to WFMO with
3793         two calls, one for the event, one for the mutex.  Don't lock mutex in
3794         case of error.
3795         (ipc_cond_signal): Make void function.
3796         (ipc_cond_close): Ditto.
3797         (_mq_send): Immediately return -1 in case of error from
3798         ipc_cond_timedwait.
3799         (_mq_receive): Ditto.
3800
3801 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3802
3803         * advapi32.cc (GetSecurityDescriptorDacl): Remove.
3804         (GetSecurityDescriptorGroup): Remove.
3805         (GetSecurityDescriptorOwner): Remove.
3806         * sec_acl.cc: Replace above functions throughout with their ntdll.dll
3807         equivalent.  Remove redundant debug output.
3808         * sec_auth.cc: Ditto.
3809         * security.cc: Ditto.
3810         * uinfo.cc: Ditto.
3811
3812 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3813
3814         * advapi32.cc (InitializeAcl): Remove.
3815         (AddAce): Remove.
3816         (FindFirstFreeAce): Remove.
3817         (GetAce): Remove.
3818         (InitializeSecurityDescriptor): Remove.
3819         (OpenProcessToken): Remove.
3820         * dcrt0.cc: Replace above functions throughout with their ntdll.dll
3821         equivalent.
3822         * fhandler_tty.cc: Ditto.
3823         * flock.cc: Ditto.
3824         * pinfo.cc: Ditto.  Drop unnecessary error handling.
3825         * sec_acl.cc: Ditto.
3826         * sec_auth.cc: Ditto.
3827         * sec_helper.cc: Ditto.
3828         * security.cc: Ditto.
3829
3830 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3831
3832         * advapi32.cc (InitializeSid): Remove.
3833         (EqualPrefixSid): Remove.
3834         (GetLengthSid): Remove.
3835         (GetSidSubAuthority): Remove.
3836         (GetSidSubAuthorityCount): Remove.
3837         (GetSidIdentifierAuthority): Remove.
3838         * fhandler_disk_file.cc: Replace above functions throughout with their
3839         ntdll.dll equivalent.
3840         * sec_auth.cc: Ditto.
3841         * sec_helper.cc: Ditto.
3842         * security.cc: Ditto.
3843
3844 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3845
3846         * advapi32.cc (AllocateLocallyUniqueId): Remove.
3847         * fhandler_disk_file.cc (fhandler_base::open_fs): Replace call to
3848         AllocateLocallyUniqueId with call to NtAllocateLocallyUniqueId;
3849         * posix_ipc.cc (mq_open): Ditto.  Drop error handling for that call.
3850         (sem_open): Ditto.
3851
3852 2011-04-28  Corinna Vinschen  <corinna@vinschen.de>
3853
3854         * autoload.cc (GetSecurityInfo): Remove.
3855         * ntdll.h (RtlConvertToAutoInheritSecurityObject): Declare.
3856         (RtlDeleteSecurityObject): Declare.
3857         (RtlGetControlSecurityDescriptor): Declare.
3858         (RtlLengthSecurityDescriptor): Declare.
3859         * security.cc (file_mapping): New global variable.
3860         (get_file_sd): Rewrite.  Clean up code.  Get rid of GetSecurityInfo
3861         call.
3862         (alloc_sd): Call RtlSetControlSecurityDescriptor to set
3863         SE_DACL_PROTECTED flag.
3864         (check_file_access): Remove mapping.  Use file_mapping instead.
3865         (check_registry_access): Rename mapping to reg_mapping.
3866         * wincap.cc: Througout, drop use_get_sec_info_on_dirs,
3867         * wincap.h (struct wincaps): Drop use_get_sec_info_on_dirs.
3868
3869 2011-04-24  Corinna Vinschen  <corinna@vinschen.de>
3870
3871         * include/fenv.h: Add missing _FENV_H_ define.
3872
3873 2011-04-23  Corinna Vinschen  <corinna@vinschen.de>
3874
3875         * registry.cc (reg_key::get_dword): Rename from get_int, use DWORD
3876         rather than int type.  Avoid compiler warning.
3877         (reg_key::set_dword): Rename from set_int, use DWORD rather than int
3878         type.  Change return type to NTSTATUS.
3879         (reg_key::get_string): Change return type to NTSTATUS.
3880         (reg_key::set_string): Ditto.
3881         * registry.h: Accommodate above changes.
3882         * environ.cc (regopt): Test return value of reg_key::get_string as
3883         NTSTATUS.
3884         * sched.cc (sched_rr_get_interval): Change local int vars to DWORD.
3885         Call reg_key::get_dword instead of reg_key::get_int.
3886         * shared.cc (init_installation_root): Test return value of
3887         reg_key::get_string as NTSTATUS.
3888         (shared_info::heap_slop_size): Call reg_key::get_dword rather than
3889         reg_key::get_int.
3890         (shared_info::heap_chunk_size): Ditto.
3891         * shared_info.h (CURR_SHARED_MAGIC): Update.
3892         (class shared_info): Change heap_chunk and heap_slop to DWORD  values.
3893
3894 2011-04-21  Corinna Vinschen  <corinna@vinschen.de>
3895
3896         * cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask.
3897         * cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on
3898         thread exit.  Drop freeing locals.process_ident.
3899         * cygtls.h (struct _local_storage): Remove syslog-related members.
3900         * syslog.cc (syslog_globals): New static storage for global syslog
3901         settings.  Use throughout instead of _my_tls.locals.
3902         (openlog): Set new syslog_globals.process_ident value more carefully.
3903         * tlsoffsets.h: Regenerate.
3904
3905 2011-04-21  Thomas Stalder <cygwinml@gmail.com>
3906
3907         * include/sys/poll.h: Include signal.h to get definition of sigset_t.
3908
3909 2011-04-20  Christopher Faylor  <me.cygwin2011@cgf.cx>
3910
3911         * cygheap.cc (init_cygheap::close_ctty): Avoid closing console-cttys
3912         since they don't use archetypes and this will just result in double
3913         frees.
3914         * dll_init.cc (dll_list::protect): Define.
3915         (dll_list::alloc): Guard list access.
3916         (dll_list::detach): Ditto.
3917         * dll_init.h (dll_list::protect): Declare new muto.
3918         (dll_list::guard): Define/declare function to guard list access.
3919         * fhandler_termios.cc (fhandler_termios::sigflush): Avoid SEGV in
3920         pathological condition of get_ttyp() == NULL.
3921
3922 2011-04-20  Christopher Faylor  <me.cygwin2011@cgf.cx>
3923
3924         * select.cc (serial_cleanup): Make sure that device_specific_pipe is
3925         always deleted regardless of whether it has a unique thread associated
3926         with it
3927         (socket_cleanup): Ditto.
3928         (mailslot_cleanup): Ditto.
3929
3930 2011-04-20  Corinna Vinschen  <corinna@vinschen.de>
3931
3932         * devices.h: Renumber internal devices so that FH_PROCESS is part of
3933         the /proc family of virtual devices.
3934         (FH_PROC_MAX_MINOR): Define.
3935         * path.h (isproc_dev): Use FH_PROC_MAX_MINOR rather than FH_PROC.
3936
3937 2011-04-19  Peter Rosin  <peda@lysator.liu.se>
3938
3939         * select.cc (pipe_cleanup): Make sure that device_specific_pipe is
3940         always deleted regardless of whether it has a unique thread associated
3941         with it.
3942
3943 2011-04-19  Jon TURNEY  <jon.turney@dronecode.org.uk>
3944
3945         * thread.cc (semaphore::init): We cannot reliably infer anything from
3946         the existing contents of sem, so merely warn rather than return EBUSY
3947         if it looks like we are reinitialising a semaphore.
3948
3949 2011-04-19  Corinna Vinschen  <corinna@vinschen.de>
3950
3951         * autoload.cc (GetConsoleWindow): Drop.
3952         (GetSystemWindowsDirectoryW): Drop.
3953         * fhandler_console.cc (beep): Call GetSystemWindowsDirectoryW instead of
3954         GetWindowsDirectoryW.
3955         * uinfo.cc (cygheap_user::env_systemroot): Call
3956         GetSystemWindowsDirectoryW and convert to multibyte on the fly.
3957         * winlean.h (GetWindowsDirectoryW): Redefine to something invalid.
3958         Explain why.
3959
3960 2011-04-19  Corinna Vinschen  <corinna@vinschen.de>
3961
3962         * Makefile.in (DLL_IMPORTS): Drop advapi32.dll.
3963         * autoload.cc: Enable autoloading advapi32 functions.
3964         * environ.cc (regopt): Use wide char arguments in reg_key functions.
3965         * fhandler_console.cc (beep): Ditto.  Use WCHAR throughout.
3966         * registry.cc (reg_key): Rewrite reg_key class to use native NT registry
3967         functions.  Use WCHAR string parameters throughout.  Use PCWSTR rather
3968         than const WCHAR.  Drop multibyte char functionality.  Drop unused
3969         methods.
3970         (get_registry_hive_path): Use RtlQueryRegistryValues to fetch path from
3971         registry.
3972         (load_registry_hive): Drop useless check for user hive being available.
3973         Load hive using NtLoadKey.
3974         * registry.h: Accommodate above changes.
3975         * sched.cc (sched_rr_get_interval): Use wide char arguments in reg_key
3976         functions.
3977         * shared.cc (init_installation_root): Ditto.
3978         (shared_info::init_obcaseinsensitive): Use RtlQueryRegistryValues to
3979         fetch obcaseinsensitive value.
3980         (shared_info::heap_slop_size): Use wide char arguments in reg_key
3981         functions.
3982         (shared_info::heap_chunk_size): Ditto.
3983         * syscalls.cc (gethostid): Ditto.
3984         * winsup.h (__WIDE): Define.
3985         (_WIDE): Define.
3986         * libc/minires-os-if.c (get_registry_dns_items): Don't fetch values
3987         from registry.  Just extract them from given UNICODE_STRING parameter.
3988         (get_registry_dns): Fetch all registry values at once using
3989         RtlQueryRegistryValues.
3990
3991 2011-04-19  Corinna Vinschen  <corinna@vinschen.de>
3992
3993         * net.cc (get_ipv4fromreg_ipcnt): Rearrange to fetch all registry
3994         values at once using RtlQueryRegistryValues.
3995         (get_ipv4fromreg): Ditto.
3996
3997 2011-04-19  Corinna Vinschen  <corinna@vinschen.de>
3998
3999         * fhandler_registry.cc (fhandler_registry::fstat): Use RegQueryInfoKeyW.
4000
4001 2011-04-19  Corinna Vinschen  <corinna@vinschen.de>
4002
4003         * fhandler_proc.cc (read_value): Remove definition.
4004         (print): Simplify.
4005         (format_proc_cpuinfo): Drop useless call to GetSystemInfo.  Rearrange
4006         to use Rtl registry functions.  Rename dwOldThreadAffinityMask to
4007         orig_affinity_mask.
4008
4009 2011-04-18  Corinna Vinschen  <corinna@vinschen.de>
4010
4011         * localtime.cc (tzload): Don't change global timezone information
4012         when called from gmtime or gmtime_r.
4013         (tzparse): Ditto.
4014
4015 2011-04-18  Corinna Vinschen  <corinna@vinschen.de>
4016
4017         * cygtls.cc (_cygtls::remove): Always close sockevt handle.
4018
4019 2011-04-18  Corinna Vinschen  <corinna@vinschen.de>
4020
4021         * cygwin.din (ppoll): Export.
4022         * poll.cc (ppoll): Implement.
4023         * posix.sgml (std-gnu): Add ppoll.
4024         * include/cygwin/version.h: Bump API minor number.
4025         * include/sys/poll.h (ppoll): Declare.
4026
4027 2011-04-18  Corinna Vinschen  <corinna@vinschen.de>
4028
4029         * fhandler_socket.cc (fhandler_socket::evaluate_events): Handle the
4030         FD_CLOSE event specially when called from accept.  Explain why.
4031         (fhandler_socket::shutdown): Fake success on not-connected socket and
4032         trigger socket event if the read side of a socket is affected.  Explain
4033         why.
4034         * poll.cc (poll): Check for saw_shutdown_read on sockets to generate
4035         POLLHUP as well.
4036
4037 2011-04-18  Corinna Vinschen  <corinna@vinschen.de>
4038
4039         * Fix various copyrights.
4040
4041 2011-04-17  Christopher Faylor  <me.cygwin2011@cgf.cx>
4042
4043         * signal.cc (_pinfo::kill): Set this_process_state when process
4044         exists.
4045
4046 2011-04-17  Christopher Faylor  <me.cygwin2011@cgf.cx>
4047
4048         * signal.cc (_pinfo::kill): Return 0 when attempting to test for
4049         existence of an existed process which has not yet been reaped.
4050
4051 2011-04-17  Christopher Faylor  <me.cygwin2011@cgf.cx>
4052
4053         * cygheap.h (init_cygheap::ctty): Use base class so that console can
4054         join in the fun.
4055         * dtable.cc (dtable::stdio_init): Remove special-case call to
4056         set_console_ctty ().
4057         * exceptions.cc (sigpacket::process): Conditionally flush terminal
4058         input on certain signals.
4059         * fhandler.h (fhandler_console::get_tty_stuff): Make non-static.
4060         (fhandler_termios::get_ttyp): Move here.
4061         (fhandler_termios::sigflush): Declare.
4062         (fhandler_tty_common::get_ttyp): Delete.
4063         * fhandler_console.cc (fhandler_console::get_tty_stuff): Pass this as
4064         "arch" argument.
4065         (set_console_ctty): Delete.
4066         (tty_list::get_tty): Just return pointer to shared console region,
4067         delaying get_tty_stuff until open().
4068         (fhandler_console::init): Treat NULL handle as signifying that console
4069         should be opened with O_NOCTTY flag.  Rename handle argument to the
4070         more common 'h'.
4071         * fhandler_termios.cc (fhandler_termios::sigflush): Define.
4072         * fhandler_tty.cc (handler_tty_master::init_console): Pass NULL as
4073         first argument to fhandler_console::init.
4074         * pinfo.cc (_pinfo::set_ctty): Change third parameter to
4075         fhandler_termios *.  Add extra debugging.
4076         * pinfo.h (_pinfo::set_ctty): Change third parameter to
4077         fhandler_termios *.
4078
4079         * exceptions.cc (handle_sigsuspend): Don't special-case non-main threads.
4080
4081 2011-04-15  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4082
4083         * thread.cc (pthread_setschedprio): New function.
4084         * include/pthread.h (pthread_setschedprio): Declare.
4085         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
4086         * cygwin.din (pthread_setschedprio): Export.
4087         * posix.sgml (std-notimpl) Move pthread_setschedprio from here...
4088         (std-susv4) ...to here.
4089
4090 2011-04-10  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4091
4092         * fhandler_proc.cc (proc_tab): Add /proc/swaps virtual file.
4093         (format_proc_swaps): New function.
4094
4095 2011-04-06  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4096
4097         * Makefile.in: Move srcdir definition before others which uses it.
4098
4099 2011-04-06  Jon TURNEY  <jon.turney@dronecode.org.uk>
4100
4101         * dll_init.cc (reserve_at, release_at): New functions.
4102         (load_after_fork): If the DLL was loaded higher than the required
4103         address, assume that it loaded at it's base address and also reserve
4104         memory there to force it to be relocated.
4105
4106 2011-04-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4107
4108         * include/cygwin/types.h: Move #include <sys/sysmacros.h> to
4109         end of header so that it gets the dev_t typedef.
4110         * include/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor,
4111         gnu_dev_makedev): Prototype and define as inline functions.
4112         (major, minor, makedev): Redefine in terms of gnu_dev_*.
4113
4114 2011-04-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4115
4116         * include/cygwin/types.h: Move multiple inclusion guards to
4117         beginning and end of header.
4118
4119 2011-04-04  Christopher Faylor  <me.cygwin2011@cgf.cx>
4120
4121         * Makefile.in: Move Makefile.common include earlier to fix problems
4122         with relative ${srcdir} path which confuses make.
4123
4124 2011-04-04  Corinna Vinschen  <corinna@vinschen.de>
4125
4126         Drop NT4 support.
4127         * autoload.cc (DnsQuery_A): Fatal if not available.
4128         (DnsRecordListFree): Ditto.
4129         (DsGetDcNameW): Ditto.
4130         (NetGetAnyDCName): Remove.
4131         (NetGetDCName): Remove.
4132         (EnumProcessModules): Fatal if not available.
4133         (GetModuleFileNameExW): Ditto.
4134         (GetModuleInformation): Ditto.
4135         (GetProcessMemoryInfo): Ditto.
4136         (QueryWorkingSet): Ditto.
4137         (LsaRegisterLogonProcess): Ditto.
4138         * fenv.cc (_feinitialise): Drop supports_sse condition.
4139         * fhandler_disk_file.cc (path_conv::isgood_inode): Fix comment.
4140         (fhandler_base::fstat_by_name): Drop has_fileid_dirinfo condition.
4141         (fhandler_disk_file::opendir): Ditto.
4142         * fhandler_netdrive.cc (fhandler_netdrive::readdir): Fix comment.
4143         * fhandler_proc.cc (format_proc_partitions): Drop NT4-only code.
4144         * fhandler_process.cc (get_process_state): Ditto.
4145         * kernel32.cc (GetWindowsDirectoryW): Remove.
4146         (GetWindowsDirectoryA): Remove.
4147         * miscfuncs.cc (nice_to_winprio): Drop NT4-only code.
4148         * mount.cc (fs_info::update): Fix comments.
4149         * net.cc (get_2k_ifs): Drop NT4-only code.
4150         * sec_auth.cc (get_logon_server): Ditto.
4151         (lsaauth): Drop NT4-specific error handling.
4152         * security.cc (alloc_sd): Set SE_DACL_PROTECTED unconditionally.
4153         * select.cc (select_stuff::wait): Always use MWMO_INPUTAVAILABLE.
4154         (peek_windows): Drop NT4-only condition in call to PeekMessage.
4155         * syscalls.cc (gethostid): Remove NT4-only workaround.
4156         * wincap.cc: Througout, drop has_dacl_protect,
4157         has_broken_if_oper_status, has_process_io_counters,
4158         has_terminal_services, has_extended_priority_class, has_guid_volumes,
4159         has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse from
4160         wincaps.
4161         (wincap_nt4sp4): Remove.
4162         (wincap_minimal): Set to wincap_2000.
4163         (wincapc::init): Rely on availability of OSVERSIONINFOEX structure.
4164         Treat error from GetVersionEx as fatal.  Treat NT4 as fatal.
4165         * wincap.h (struct wincaps): Drop has_dacl_protect,
4166         has_broken_if_oper_status, has_process_io_counters,
4167         has_terminal_services, has_extended_priority_class, has_guid_volumes,
4168         has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse flags
4169         and methods.
4170         * winlean.h (GetWindowsDirectoryW) Define as GetSystemWindowsDirectoryW.
4171         (GetWindowsDirectoryA): Define as GetSystemWindowsDirectoryA.
4172
4173 2011-04-04  Corinna Vinschen  <corinna@vinschen.de>
4174
4175         * dtable.cc (dtable::init_std_file_from_handle): Fix a comment to
4176         reflect the current state.
4177
4178 2011-04-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4179
4180         * Makefile.in (fhandler_proc_CFLAGS): Define USERNAME, HOSTNAME,
4181         and GCC_VERSION.
4182         * fhandler_proc.cc (format_proc_version):  Add build machine and GCC
4183         version information as on Linux.
4184
4185 2011-04-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4186             Corinna Vinschen  <corinna@vinschen.de>
4187
4188         * devices.h (fh_devices): Define FH_PROC_MIN_MINOR.
4189         Reorder major-0 devices so that all /proc directories fall
4190         between FH_PROC and FH_PROC_MIN_MINOR.
4191         * path.h (isproc_dev): Redefine accordingly.
4192
4193 2011-04-04  Corinna Vinschen  <corinna@vinschen.de>
4194
4195         * cygserver_setpwd.h (setlsapwd): Add username parameter to declaration.
4196         * external.cc (cygwin_internal): In the CW_SET_PRIV_KEY case, fetch
4197         additional username parameter.
4198         * setlsapwd.cc (setlsapwd): Add username parameter.  Allow admin to
4199         set the hidden password for other users.
4200
4201 2011-04-04  Corinna Vinschen  <corinna@vinschen.de>
4202
4203         * sec_auth.cc (get_user_groups): Mark well-known groups as well-known.
4204         (get_user_local_groups): Ditto.
4205         (verify_token): Drop useless label.
4206         * sec_helper.cc (cygsid::get_sid): Check for well-known SID if
4207         well_known isn't set.
4208         * security.h (well_known_sid_type): New inline function.
4209
4210 2011-04-02  Corinna Vinschen  <corinna@vinschen.de>
4211
4212         * autoload.cc (FindFirstVolumeA): Remove.
4213         (FindNextVolumeA): Remove.
4214         (FindVolumeClose): Remove.
4215         (GetVolumeNameForVolumeMountPointA): Remove.
4216         * ntdll.h (NtFlushBuffersFile): Declare.
4217         * syscalls.cc (sync_worker): Rewrite using native NT functions.
4218         (sync): Ditto.
4219
4220 2011-04-02  Corinna Vinschen  <corinna@vinschen.de>
4221
4222         * fhandler_proc.cc (format_proc_partitions): Express length in WCHAR
4223         size.
4224
4225 2011-04-02  Corinna Vinschen  <corinna@vinschen.de>
4226
4227         * autoload.cc (GetExtendedTcpTable): Remove.
4228         (GetTcpTable): Remove.
4229         (CharNextExA): Remove.
4230         (FindWindowA): Remove.
4231         (ShowWindowAsync): Remove.
4232         * dcrt0.cc (disable_dep): Remove unused function.
4233         (dll_crt0_0): Drop comment babbling about TS & DEP.
4234         * fhandler_socket.cc (address_in_use): Remove unused function.
4235         * wincap.cc: Throughout, drop ts_has_dep_problem from wincaps.
4236         (wincapc::init): Drop code setting ts_has_dep_problem flag.
4237         * wincap.h (struct wincaps): Drop ts_has_dep_problem flags and method.
4238
4239 2011-04-01  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4240
4241         Implement /proc/sysvipc/*
4242         * devices.in (dev_procsysvipc_storage): Add.
4243         * devices.cc: Regenerate.
4244         * devices.h (fh_devices): Add FH_PROCSYSVIPC.
4245         * dtable.cc (build_fh_pc): Add case FH_PROCSYSVIPC.
4246         * fhandler.h (class fhandler_procsysvipc): Declare.
4247         (fhandler_union): Add __procsysvipc.
4248         * fhandler_proc.cc (proc_tab): Add sysvipc virt_directory.
4249         * fhandler_procsysvipc.cc: New file.
4250         * Makefile.in (DLL_OFILES): Add fhandler_procsysvipc.o.
4251         * path.h (isproc_dev): Add FH_PROCSYSVIPC to conditional.
4252
4253 2011-04-01  Corinna Vinschen  <corinna@vinschen.de>
4254
4255         * Makefile.in (DLL_OFILES): Add avapi32.o.
4256         * advapi32.cc: New file.
4257         * autoload.cc: Add block of remaining advapi32 functions used by
4258         Cygwin.  Keep commented out.  Explain why.
4259
4260 2011-04-01  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4261
4262         * fhandler_proc.cc (format_proc_loadavg): Add running/total
4263         processes as fourth component of output.
4264         * fhandler_process.cc (get_process_state): Make non-static.
4265         Add FIXME about generating an 'O' flag.
4266
4267 2011-04-01  Corinna Vinschen  <corinna@vinschen.de>
4268
4269         * fhandler_random.cc (fhandler_dev_random::crypt_gen_random):
4270         Use CryptAcquireContextW.
4271         * ntdll.h (STATUS_PROCEDURE_NOT_FOUND): Define.
4272         * sec_auth.cc (open_local_policy): Rename NTSTATUS variable ret to
4273         status.  Drop usage of LsaNtStatusToWinError.
4274         (verify_token): Call NtQuerySecurityObject instead of
4275         GetKernelObjectSecurity.
4276         (create_token): Rename NTSTATUS variable ret to status.  Rename ret2 to
4277         sub_status.  Drop usage of LsaNtStatusToWinError.  In case LsaLogonUser
4278         fails, report the sub_status as well.
4279
4280 2011-04-01  Corinna Vinschen  <corinna@vinschen.de>
4281
4282         * libc/strptime.c: Remove misleading comment.
4283
4284 2011-03-31  Corinna Vinschen  <corinna@vinschen.de>
4285
4286         * ntdll.h: Allow usage from plain C code.
4287         (FSCTL_PIPE_IMPERSONATE): Define.
4288         (enum _THREAD_INFORMATION_CLASS): Define.
4289         (RTL_QUERY_REGISTRY_xxx): Define.
4290         (RTL_REGISTRY_xxx): Define.
4291         (PRTL_QUERY_REGISTRY_ROUTINE): Define.
4292         (struct _RTL_QUERY_REGISTRY_TABLE): Define.
4293         (enum _KEY_VALUE_INFORMATION_CLASS): Define.
4294         (struct _KEY_VALUE_PARTIAL_INFORMATION): Define.
4295         (NtAccessCheck): Declare.
4296         (NtAllocateLocallyUniqueId): Declare.
4297         (NtCreateKey): Declare.
4298         (NtDuplicateToken): Declare.
4299         (NtLoadKey): Declare.
4300         (NtOpenKey): Declare.
4301         (NtOpenProcessToken): Declare.
4302         (NtOpenThreadToken): Declare.
4303         (NtPrivilegeCheck): Declare.
4304         (NtQueryInformationToken): Declare.
4305         (NtQueryValueKey): Declare.
4306         (NtSetInformationThread): Declare.
4307         (NtSetInformationToken): Declare.
4308         (NtSetValueKey): Declare.
4309         (RtlAbsoluteToSelfRelativeSD): Declare.
4310         (RtlAddAccessAllowedAce): Declare.
4311         (RtlAddAccessDeniedAce): Declare.
4312         (RtlAddAce): Declare.
4313         (RtlCheckRegistryKey): Declare.
4314         (RtlCopySid): Declare.
4315         (RtlCreateAcl): Declare.
4316         (RtlCreateRegistryKey): Declare.
4317         (RtlCreateSecurityDescriptor): Declare.
4318         (RtlEqualPrefixSid): Declare.
4319         (RtlEqualSid): Declare.
4320         (RtlFirstFreeAce): Declare.
4321         (RtlGetAce): Declare.
4322         (RtlGetDaclSecurityDescriptor): Declare.
4323         (RtlGetGroupSecurityDescriptor): Declare.
4324         (RtlGetOwnerSecurityDescriptor): Declare.
4325         (RtlIdentifierAuthoritySid): Declare.
4326         (RtlInitializeSid): Declare.
4327         (RtlLengthSid): Declare.
4328         (RtlQueryRegistryValues): Declare.
4329         (RtlSetControlSecurityDescriptor): Declare.
4330         (RtlSetDaclSecurityDescriptor): Declare.
4331         (RtlSetGroupSecurityDescriptor): Declare.
4332         (RtlSetOwnerSecurityDescriptor): Declare.
4333         (RtlSubAuthorityCountSid): Declare.
4334         (RtlSubAuthoritySid): Declare.
4335         (RtlWriteRegistryValue): Declare.
4336
4337 2011-03-31  Corinna Vinschen  <corinna@vinschen.de>
4338
4339         * uinfo.cc (cygheap_user::init): Don't call GetUserName.  Fetch username
4340         from Windows environment instead.  Explain why.
4341         (cygheap_user::env_domain): Use MAX_DOMAIN_NAME_LEN rather than DNLEN
4342         to specify the size of the domain name buffer.
4343
4344 2011-03-30  Corinna Vinschen  <corinna@vinschen.de>
4345
4346         * hires.h: Fix copyright.
4347         * times.cc: Ditto.
4348         (FACTOR): Add comment.
4349         (NSPERSEC): Ditto.
4350         (JITTER): New definition.  Comment.
4351         (systime_ns): Avoid gratuitous copying of the value returned by
4352         GetSystemTimeAsFileTime.
4353         (corelocaltime, localtime, gmtime): Remove very old, unused code block.
4354         (cygwin_tzset): Remove.
4355         (hires_ms::timeGetTime_ns): Add missing semicolon in comment.
4356         (hires_ms::nsecs): Redefine check for difference between internal
4357         timer value and system time.
4358
4359 2011-03-30  Corinna Vinschen  <corinna@vinschen.de>
4360
4361         * times.cc (hires_ms::resolution): Make sure resolution is never 0.
4362         (clock_setres): Ditto.
4363
4364 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4365
4366         * cygtls.h (struct _local_storage): Redefine process_ident as wchar_t
4367         pointer.
4368         * syslog.cc (CYGWIN_LOG_NAME): Convert to wide char constant.
4369         (openlog): Convert incoming ident string to wide char.  Fix formatting.
4370         (vsyslog): Print ident string as wide char string.  Convert message
4371         string to wide char and call UNICODE Win32 Event functions to make sure
4372         to use correct codeset.
4373         * tlsoffset.h: Regenerate.
4374
4375 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4376
4377         * fhandler_socket.cc (get_inet_addr): Make externally available.
4378         * autoload.cc (GetUdpTable): Define.
4379         * syslog.cc (connect_syslogd): Use get_inet_addr rather than _stat64
4380         to check for local socket file.  Create socket with type returned by
4381         get_inet_addr.  If connect on UDP socket works, test if there's
4382         really a listening peer, otherwise fall back to Windows event log.
4383         (try_connect_syslogd): Use syslogd_inited flag to check if syslogd
4384         is available.
4385
4386 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4387
4388         * uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and
4389         convert user and domain to multibyte strings to make sure to use
4390         correct codeset.
4391
4392 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4393
4394         * autoload.cc (UuidCreate): Remove.
4395         (UuidCreateSequential): Remove.
4396         * passwd.cc (internal_getpwsid): Avoid a strict-aliasing compiler
4397         error with gcc 4.5.1.
4398         * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Ditto.
4399         * ntdll.h (NtAllocateUuids): Declare.
4400         * syscalls.cc (gethostid): Use NtAllocateUuids function rather than
4401         UuidCreateSequential/UuidCreate to get rid of rpcrt4 dependency.
4402
4403 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4404
4405         * cygwin.din (pthread_spin_destroy): Export.
4406         (pthread_spin_init): Export.
4407         (pthread_spin_lock): Export.
4408         (pthread_spin_trylock): Export.
4409         (pthread_spin_unlock): Export.
4410         * posix.sgml (std-susv4): Add pthread_spin_destroy, pthread_spin_init,
4411         pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock.
4412         (std-notimpl): Remove pthread_spin_[...].
4413         * pthread.cc (pthread_spin_init): New function.
4414         * thread.cc (pthread_spinlock::is_good_object): New function.
4415         (pthread_mutex::pthread_mutex): Rearrange initializers to accommodate
4416         protected data in pthread_mutex.
4417         (pthread_spinlock::pthread_spinlock): New constructor.
4418         (pthread_spinlock::lock): New method.
4419         (pthread_spinlock::unlock): New method.
4420         (pthread_spinlock::init): New method.
4421         (pthread_spin_lock): New function.
4422         (pthread_spin_trylock): New function.
4423         (pthread_spin_unlock): New function.
4424         (pthread_spin_destroy): New function.
4425         * thread.h (PTHREAD_SPINLOCK_MAGIC): Define.
4426         (class pthread_mutex): Change access level of members shared with
4427         derived classes to protected.
4428         (pthread_mutex::set_shared): New protected method.
4429         (class pthread_spinlock): New class, derived class of pthread_mutex.
4430         * include/pthread.h (pthread_spin_destroy): Declare.
4431         (pthread_spin_init): Declare.
4432         (pthread_spin_lock): Declare.
4433         (pthread_spin_trylock): Declare.
4434         (pthread_spin_unlock): Declare.
4435         * include/cygwin/types.h (pthread_spinlock_t): New typedef.
4436         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
4437
4438 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4439
4440         * net.cc (SIO_BASE_HANDLE): Define.
4441         (fdsock): If we got an LSP handle, try to create a copy of the base
4442         handle instead.  Change comment to explain.
4443
4444 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4445
4446         * include/cygwin/version.h: Bump CYGWIN_VERSION_DLL_MINOR to 10.
4447
4448 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
4449
4450         * autoload.cc (winmm): Remove time functions.  Don't treat
4451         unloadable wave functions as fatal.
4452         * hires.h (hires_ms::timeGetTime_ns): New private method.
4453         (hires_ms::dmsecs): Call timeGetTime_ns here.
4454         * ntdll.h (struct _KSYSTEM_TIME): Define.
4455         (KUSER_SHARED_DATA): Redefine to allow access to InterruptTime.
4456         (SharedUserData): Define here.
4457         (NtQueryTimerResolution): Declare.
4458         (NtSetTimerResolution): Declare.
4459         * path.cc (SharedUserData): Move to ntdll.h.
4460         * times.cc (hires_ms::timeGetTime_ns): New private method.
4461         Use throughout instead of timeGetTime.  Document entire functionality
4462         of timeGetTime in case we need it.
4463         (hires_ms::resolution): Try a call to NtQueryTimerResolution
4464         to fetch current period.  Fall back to heuristic if that fails.
4465         Cast to DWORD in assignments to minperiod.
4466         (clock_setres): Align period to possible values per a call to
4467         NtQueryTimerResolution.  Explain why.  Replace calls to timeBeginPeriod
4468         and timeEndPeriod with underlying call to NtSetTimerResolution.  Use
4469         status code from NtSetTimerResolution to compute errno.
4470         Convert period to ULONGLONG and store 100ns value to simplify code.
4471
4472 2011-03-29  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4473             Corinna Vinschen  <corinna@vinschen.de>
4474
4475         * include/sys/xattr.h: New file.
4476
4477 2011-03-28  Jon TURNEY  <jon.turney@dronecode.org.uk>
4478
4479         * thread.cc (semaphore::init, destroy, close): Standards conformance
4480         fix.  On a failure, return -1 and set errno.
4481         * thread.h (semaphore::terminate): Save errno since semaphore::close()
4482         may now modify it.
4483
4484 2011-03-27  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4485
4486         * cygwin.din (strchrnul): Export.
4487         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
4488         * posix.sgml (std-gnu): Add strchrnul.
4489
4490 2011-03-27  Christopher Faylor  <me.cygwin2011@cgf.cx>
4491
4492         * dll_init.cc (dll::init): Accommodate ill-behaved dlls who don't fill
4493         out p.envptr.
4494
4495 2011-03-25  Corinna Vinschen  <corinna@vinschen.de>
4496
4497         * mmap.cc (mmap64): Add a cheat to let a certain autoconf test succeed
4498         on 64 bit systems.  Explain why.
4499
4500 2011-03-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
4501
4502         * wincap.cc (wincap_2003): Set use_dont_resolve_hack to true.
4503
4504 2011-03-23  Christopher Faylor  <me.cygwin2011@cgf.cx>
4505
4506         * autoload.cc (dll_load): Change error message to make it clear if a
4507         newer DLL is being run.
4508
4509 2011-03-20  Corinna Vinschen  <corinna@vinschen.de>
4510
4511         * fenv.cc (_feinitialise): Don't use SSE instructions on systems not
4512         supporting them.
4513         * wincap.h (wincaps::supports_sse): New element.
4514         * wincap.cc: Implement above element throughout.
4515
4516 2011-03-18  Corinna Vinschen  <corinna@vinschen.de>
4517
4518         * cygwin.sc: Raise default cygheap size to 2 Megs.
4519
4520 2011-03-18  Christopher Faylor  <me.cygwin2011@cgf.cx>
4521
4522         * fhandler.h (DEFAULT_PIPEBUFSIZE): Reset to 64K.
4523
4524 2011-03-18  Corinna Vinschen  <corinna@vinschen.de>
4525
4526         * mmap.cc (mmap_record::alloc_fh): Initialize name strings in fdev to
4527         empty strings or suffer a SEGV.  Drop second parameter in call to
4528         build_fh_dev.
4529
4530 2011-03-18  Corinna Vinschen  <corinna@vinschen.de>
4531
4532         * mmap.cc (class mmap_record): Pack 4 byte-aligned.  Convert member dev
4533         to plain int.
4534         (mmap_record::alloc_fh): Create temporary device from dev and use in
4535         call to build_fh_dev.
4536
4537 2011-03-18  Corinna Vinschen  <corinna@vinschen.de>
4538
4539         * mmap.cc (mmap_record::page_map): Define as variable array rather than
4540         as pointer.
4541         (mmap_record::alloc_page_map): Remove.
4542         (mmap_record::free_page_map): Remove.
4543         (mmap_record::init_page_map): New method.
4544         (mmap_record::add_record): Take mmap_record parameter by reference
4545         rather than by value.
4546         (mmap_record::map_pages): Fix comment.
4547         (mmap_list::add_record): Allocate space for mmap_record including the
4548         page_map in a single ccalloc call.  Call init_page_map afterwards.
4549         (mmap_list::del_record): Remove call to mmap_record::free_page_map.
4550
4551 2011-03-16  Corinna Vinschen  <corinna@vinschen.de>
4552
4553         * crt0.c (mainCRTStartup): Move call to _feinitialise from here...
4554         * dcrt0.cc (_dll_crt0): ...to here.
4555
4556 2011-03-16  Corinna Vinschen  <corinna@vinschen.de>
4557
4558         * winver.rc: Fix copyright dates.
4559
4560 2011-03-14  Corinna Vinschen  <corinna@vinschen.de>
4561
4562         * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Only use
4563         file id as inode number if it masters the isgood_inode check.
4564
4565 2011-03-13  Christopher Faylor  <me.cygwin2011@cgf.cx>
4566
4567         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove
4568         special treatment for ERROR_NO_SYSTEM_RESOURCES.  Cancel I/O and reset
4569         the overlapped handle on error.
4570         (fhandler_base_overlapped::write_overlapped): Limit writes to
4571         max_atomic_write bytes in blocking case.  Incorporate code from
4572         now-defunct write_overlapped_fallback.  Fix serious oversight where ptr
4573         was not advanced as buffer was written.
4574         (fhandler_base_overlapped::write_overlapped_fallback): Eliminate.
4575         * fhandler.h (fhandler_base_overlapped::write_overlapped_fallback):
4576         Ditto for declaration.
4577         (DEFAULT_PIPEBUFSIZE): Lower size to slightly less than documented
4578         worst-case atomic write size.
4579         (fhandler_overlapped::wait_return): Remove unused element.
4580
4581 2011-03-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
4582
4583         * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Handle
4584         overlapped_fallback error condition like other error conditions.  Set
4585         res carefully and specifically for each condition rather than resorting
4586         to a default.
4587         (fhandler_base_overlapped::write_overlapped): Preserve errno in
4588         overlapped_fallback condition.  Correct write_overlapped_fallback to
4589         avoid inappropriate looping.
4590         (fhandler_base_overlapped::write_overlapped_fallback): Add some more
4591         comments.
4592
4593 2011-03-09  Christopher Faylor  <me.cygwin2011@cgf.cx>
4594
4595         * fhandler.cc (fhandler_base_overlapped::write_overlapp): Oops!
4596         Accommodate change in arguments to wait_overlapped.
4597
4598 2011-03-09  Christopher Faylor  <me+cygwin@cgf.cx>
4599
4600         * errno.cc (errmap): Change mapping of NO_SYSTEM_RESOURCES to EFBIG.
4601         * fhandler.cc (MAX_OVERLAPPED_WRITE_LEN): New constant.
4602         (MIN_OVERLAPPED_WRITE_LEN): Ditto.
4603         (fhandler_base_overlapped::close): Accommodate change in arguments to
4604         wait_overlapped.
4605         (fhandler_base_overlapped::setup_overlapped): Add __stdcall and regparm
4606         modifiers.
4607         (fhandler_base_overlapped::destroy_overlapped): Ditto.
4608         (fhandler_base_overlapped::has_ongoing_io): Ditto.
4609         (fhandler_base_overlapped::wait_overlapped): Modify to return an enum
4610         returning various states.  Accept nonblocking parameter.
4611         (fhandler_base_overlapped::read_overlapped): Add __stdcall and regparm
4612         modifiers.  Rework to attempt to be smarter about reacting to states
4613         returned by wait_overlapped.
4614         (fhandler_base_overlapped::write_overlapped): Ditto.  Add fallback
4615         option for when wait_overlapped detects that smaller chunks must be
4616         written.
4617         (fhandler_base_overlapped::write_overlapped_fallback): Ditto.
4618         * fhandler.h (DEFAULT_PIPEBUFSIZE): Move definition here from pipe.cc.
4619         (fhandler_base::has_ongoing_io): Define with __stdcall and regparm
4620         modifiers.
4621         (fhandler_base_overlapped::wait_return): New enum.
4622         (fhandler_base_overlapped::max_atomic_write): New variable.
4623         (fhandler_base_overlapped:: wait_overlapped): Accommodate changes
4624         mentioned above to arguments and modifiers.
4625         (fhandler_base_overlapped::setup_overlapped): Ditto for modifiers.
4626         (fhandler_base_overlapped::read_overlapped): Ditto.
4627         (fhandler_base_overlapped::write_overlapped): Ditto.
4628         (fhandler_base_overlapped::destroy_overlapped): Ditto.
4629         (fhandler_base_overlapped::has_ongoing_io): Ditto.
4630         (fhandler_base_overlapped::fhandler_base_overlapped): Zero
4631         max_atomic_write.
4632         * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Set max_atomic_write
4633         to the size of the DEFAULT_PIPEBUFSIZE.
4634         (fhandler_fifo::wait): Accommodate change in arguments to
4635         wait_overlapped.
4636         * pipe.cc (fhandler_pipe::fhandler_pipe): Set max_atomic_write to the
4637         size of the DEFAULT_PIPEBUFSIZE.
4638         (fhandler_pipe::create_selectable): Allow minimum size of DEFAULT_PIPEBUFSIZE.
4639         (DEFAULT_PIPEBUFSIZE): Delete here, move to fhandler.h.
4640
4641 2011-03-08  Corinna Vinschen  <corinna@vinschen.de>
4642
4643         * security.cc: Fix copyright dates.
4644
4645 2011-03-08  Corinna Vinschen  <corinna@vinschen.de>
4646
4647         * fhandler.cc (fhandler_base::open): When creating a file on a
4648         filesystem supporting ACLs, create the file with WRITE_DAC access.
4649         Explain why.
4650         * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
4651         directories.
4652         * fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
4653         * path.cc (symlink_worker): Ditto for symlinks.
4654         * security.cc (get_file_sd): Always call GetSecurityInfo for directories
4655         on XP and Server 2003.  Improve comment to explain why.
4656         (set_file_attribute): Explicitely cast mode_t value to bool in call to
4657         get_file_sd.
4658         * wincap.h (wincaps::use_get_sec_info_on_dirs): New element.
4659         * wincap.cc: Implement above element throughout.
4660
4661 2011-03-04  Corinna Vinschen  <corinna@vinschen.de>
4662
4663         * fhandler_procsys.cc (fhandler_procsys::exists): Rewrite.
4664         (fhandler_procsys::fill_filebuf): Fill buffer with valid string even if
4665         reading the symlink fails.
4666
4667 2011-03-03  Corinna Vinschen  <corinna@vinschen.de>
4668
4669         * posix_ipc.cc (ipc_cond_timedwait): If ipc_mutex_unlock fails, return
4670         actual error number.
4671         (_mq_send): Break loop if ipc_cond_timedwait returns with error.
4672         (_mq_receive): Ditto.
4673
4674 2011-03-03  Corinna Vinschen  <corinna@vinschen.de>
4675
4676         * errno.cc (__xpg_strerror_r): Add accidentally missing condition.
4677
4678 2011-03-02  Corinna Vinschen  <corinna@vinschen.de>
4679
4680         * fhandler_procsys.cc (fhandler_procsys::open): Call worker exists
4681         method, rather than wrapper.
4682
4683 2011-03-01  Christopher Faylor  <me+cygwin@cgf.cx>
4684
4685         * autoload.cc (dll_load): Avoid in_forkee test since this apparently
4686         fails even when not forked.
4687
4688 2011-03-01  Christopher Faylor  <me+cygwin@cgf.cx>
4689
4690         * include/cygwin/version.h: Bump CYGWIN_VERSION_DLL_MINOR to 9.
4691
4692 2011-02-28  Christopher Faylor  <me+cygwin@cgf.cx>
4693
4694         * autoload.cc (dll_load): Only perform DONT_RESOLVE_DLL_REFERENCES hack
4695         on systems which need it.
4696         * wincap.cc (use_dont_resolve_hack): Set as appropriate.
4697         * wincap.h (use_dont_resolve_hack): Define.
4698
4699 2011-02-28  Christopher Faylor  <me+cygwin@cgf.cx>
4700
4701         * autoload.cc (dll_load): Make inline.  Clarify logic.
4702
4703 2011-02-27  Corinna Vinschen  <corinna@vinschen.de>
4704
4705         * autoload.cc (dll_load): Only call LoadLibraryExW with
4706         DONT_RESOLVE_DLL_REFERENCES if a normal LoadLibrary call failed with
4707         ERROR_INVALID_ADDRESS.
4708         (LsaRegisterLogonProcess): Align comment to previous change.
4709
4710 2011-02-26  Christopher Faylor  <me+cygwin@cgf.cx>
4711
4712         * autoload.cc: Use LoadDLLfuncEx3 for all winmm functions.  Accommodate
4713         changes to LoadDLLprime.
4714         (LoadDLLprime): Take an extra argument indicating whether this dll
4715         needs special handling on fork.  Place this information in the "handle"
4716         location.
4717         (LoadDLLfuncEx3): Eliminate "func" handling.  Pass new
4718         no_resolve_on_fork argument to LoadDLLprime.
4719         (dll_load): New function.
4720         (std_dll_init): Accommodate changes to dll_info::handle.  Use dll_load
4721         to load DLL in both cases where it is used.
4722
4723 2011-02-26  Corinna Vinschen  <corinna@vinschen.de>
4724
4725         * autoload.cc: Make autoloaded ntdll function non-optional.  Ditto for
4726         secur32 functions, except for LsaRegisterLogonProcess.  Change return
4727         value to ERROR_PROC_NOT_FOUND.  Explain why.
4728         * sec_auth.cc (lsaauth): Handle ERROR_PROC_NOT_FOUND from call to
4729         LsaRegisterLogonProcess when generating the errno value.
4730
4731 2011-02-22  Corinna Vinschen  <corinna@vinschen.de>
4732
4733         * dcrt0.cc: Fix copyright dates.
4734         * winsup.h: Ditto.
4735         * syscalls.cc (_read): Move EXPORT_ALIAS to its rightful place.
4736
4737 2011-02-21  Christopher Faylor  <me+cygwin@cgf.cx>
4738
4739         * cygwin.din: Mark __assert* and _abort as NOSIGFE.
4740
4741 2011-02-21  Corinna Vinschen  <corinna@vinschen.de>
4742
4743         * fhandler_socket (fhandler_socket::readv): Call recv_internal directly,
4744         rather than recvmsg.
4745         (fhandler_socket::writev): Call send_internal directly, rather than
4746         sendmsg.
4747         * net.cc (cygwin_recv): Call fhandler_socket::recvfrom directly, rather
4748         than cygwin_recvfrom.
4749         (cygwin_send): Call fhandler_socket::sendto directly, rather than
4750         cygwin_sendto.
4751
4752 2011-02-20  Christopher Faylor  <me+cygwin@cgf.cx>
4753
4754         * fhandler.cc (fhandler_base_overlapped::close): Finish any pending I/O
4755         before closing.
4756         (fhandler_base_overlapped::wait_overlapped): Defensively zero bytes
4757         read.  Add more info to debugging output.
4758
4759 2011-02-18  Christopher Faylor  <me+cygwin@cgf.cx>
4760
4761         * dcrt0.cc (dll_crt0_1): Add a CYGHEAP_DEBUG conditional for debugging
4762         which allocates a lot of space at startup.
4763
4764 2011-02-18  Corinna Vinschen  <corinna@vinschen.de>
4765
4766         * cygwin.sc: Set alignment of .cygheap section to 64K.
4767
4768 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4769
4770         * spawn.cc (spawn_guts): Only set PID_NOTCYGWIN in _P_OVERLAY mode.
4771         Drop flag if creating new process failed.
4772
4773 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4774
4775         * Throughout fix copyright dates.
4776
4777 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4778
4779         * devices.in: Throughout use slashes instead of backslashes in the
4780         native path of devices not backed by native NT devices.
4781         * devices.cc: Regenerate.
4782         * globals.cc (ro_u_pmem): Use correct case.
4783         (ro_u_globalroot): New R/O unicode string.
4784         * path.cc (path_conv::check): Fix incorrect handling of /proc/sys
4785         block devices if they are just visited due to a component check.
4786         (symlink_info::posixify): Fix typo in comment.
4787         (cygwin_conv_path): Use ro_u_globalroot instead of string constant.
4788         (fast_cwd_version): New shared variable to store FAST_CWD version
4789         used on the system.
4790         (find_fast_cwd_pointer): Rename from find_fast_cwd_pointers.  Don't
4791         set global fast_cwd_ptr pointer here.  Return pointer value instead.
4792         (find_fast_cwd): New function to set fast_cwd_ptr and fast_cwd_version.
4793         (cwdstuff::override_win32_cwd): Call find_fast_cwd from here.
4794         Check for fast_cwd_version to differ between old and new FAST_CWD
4795         structure.  Check old_cwd for NULL to avoid SEGV.  Don't set CWD if
4796         we have neitehr a valid fast_cwd_ptr, nor a valid CWD handle in the
4797         process parameter block.
4798         (cwdstuff::set): Create Win32 path taking /proc/sys paths into account.
4799         * spawn.cc (spawn_guts): Recode creating runpath.  Also take /proc/sys
4800         paths into account.  Drop special CWD handling when starting non-Cygwin
4801         processes.
4802
4803 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4804
4805         * fhandler_procsys.cc (fhandler_procsys::opendir): Avoid SEGV if
4806         opening object directory fails.
4807         * fhandler_virtual.cc (fhandler_virtual::opendir): Don't leak memory.
4808
4809 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4810
4811         * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Don't
4812         append slash if there is one already.
4813
4814 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4815
4816         Revert change from 2010-08-31:
4817         * path.cc (normalize_posix_path): Drop support for //./ and //?/
4818         prefixes.
4819         (path_conv::check): Ditto.
4820
4821 2011-02-15  Corinna Vinschen  <corinna@vinschen.de>
4822
4823         * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Use POSIX
4824         path to check for symlink.
4825
4826 2011-02-14  Corinna Vinschen  <corinna@vinschen.de>
4827
4828         * config/i386/profile.h: Sync with Mingw.
4829
4830 2011-02-13  Corinna Vinschen  <corinna@vinschen.de>
4831
4832         * path.cc (struct _FAST_CWD): Redefine to new layout used since patch
4833         for KB 2393802.  Adjust comments throughout.
4834         (struct _FAST_CWD_OLD): Rename former definition.
4835         (cwdstuff::override_win32_cwd): Check if the OS is using the old or the
4836         new FAST_CWD structure layout and handle accordingly.
4837
4838 2011-02-11  Christopher Faylor  <me+cygwin@cgf.cx>
4839
4840         * mkstatic: Make sure that we are not cd'ed to temporary directory on
4841         exit to avoid bogus warnings on directory cleanup.
4842         * speclib: Ditto.
4843         * mkimport: Ditto.
4844
4845 2011-02-11  Christopher Faylor  <me+cygwin@cgf.cx>
4846
4847         * cygwin.sc: Eliminate __cygheap_mid.
4848         * cygheap.cc: Ditto.
4849
4850 2011-02-11  Christopher Faylor  <me+cygwin@cgf.cx>
4851
4852         * cygheap.cc (_cygheap_mid): Drop unneeded section attribute.
4853         (cygheap_init): Just zero cygheap structure.
4854         * cygwin.sc: Keep 16 byte alignment but drop all other alignments
4855         related to cygheap.  Eliminate unused __cygheap_end1.
4856
4857 2011-02-11  Corinna Vinschen  <corinna@vinschen.de>
4858
4859         * cygwin.sc: Raise default cygheap size to 1 Meg.  Set alignment to
4860         standard 64K.
4861
4862 2011-02-11  Corinna Vinschen  <corinna@vinschen.de>
4863
4864         * include/endian.h: Move definitions of __BIG_ENDIAN, __LITTLE_ENDIAN,
4865         and __BYTE_ORDER into ...
4866         * include/bits/endian.h: New file.
4867         * include/arpa/nameser_compat.h: Include endian.h rather than defining
4868         BYTE_ORDER here.
4869         * include/asm/byteorder.h: Include bits/endian.h.  Drop definition of
4870         __LITTLE_ENDIAN.
4871         * include/netinet/ip.h: Include bits/endian.h.  Drop definitions of
4872         BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER.  Use underscored variants
4873         of aforementioned constants.
4874         * include/netinet/tcp.h: Ditto.
4875         * include/sys/param.h: Drop disabled definitions of BIG_ENDIAN,
4876         LITTLE_ENDIAN, and BYTE_ORDER.
4877
4878         * include/netinet/ip.h: Reformat.  Define setsockopt IP_TOS options
4879         matching recent RFCs.  Tweak comments.
4880
4881 2011-02-10  Eric Blake  <eblake@redhat.com>
4882
4883         * errno.cc (includes): Avoid compilation failure if <string.h>
4884         settles on wrong strerror_r signature.
4885
4886         * errno.cc (__xpg_strerror_r): New function.
4887         (strerror_r): Update to copy newlib's fixes.
4888         (strerror): Set errno on failure.
4889         (_sys_errlist): Cause EINVAL failure for reserved values.
4890         * cygwin.din: Export new function.
4891         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Combine
4892         this into minor 236.
4893
4894 2011-02-09  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
4895
4896         * cygwin.din (pthread_yield): Export as alias to sched_yield.
4897         * include/pthread.h (pthread_yield): Declare.
4898         * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
4899         * posix.sgml (std-deprec): Add pthread_yield.
4900
4901 2011-02-09  Christopher Faylor  <me+cygwin@cgf.cx>
4902
4903         * cygheap.cc: Add some __stdcall decoration where appropriate.
4904         * lib/cygwin_crt0.c: __attribute -> __attribute__.
4905
4906 2011-02-09  Christopher Faylor  <me+cygwin@cgf.cx>
4907
4908         * hookapi.cc (hook_or_detect_cygwin): Prevent i from being considered
4909         uninitialized by gcc.
4910
4911 2011-02-09  Christopher Faylor  <me+cygwin@cgf.cx>
4912
4913         * exception.h: Remove DEBUG_EXCEPTION left over debugging ifdef.
4914
4915 2011-02-08  Christopher Faylor  <me+cygwin@cgf.cx>
4916
4917         * dll_init.cc: Fix typo in comment.
4918
4919 2011-02-07  Corinna Vinschen  <corinna@vinschen.de>
4920
4921         * configure.in: Remove AC_ALLOCA test and test for __builtin_memset.
4922         * configure: Regenerate.
4923
4924 2011-02-07  Corinna Vinschen  <corinna@vinschen.de>
4925
4926         * fhandler_console.cc (fhandler_console::write_normal): Remove
4927         erroneous premature return after collecting truncated multibyte
4928         sequence in trunc_buf.  Rather fall through to printing routine.
4929         Fix return value to take trunc_buf content into account.  Improve
4930         comments.
4931
4932 2011-02-05  Christopher Faylor  <me+cygwin@cgf.cx>
4933
4934         * autoload.cc (wsock_init): Properly define WSAStartup function pointer
4935         to avoid stack damage.
4936
4937 2011-02-02  Corinna Vinschen  <corinna@vinschen.de>
4938
4939         * libc/bsdlib.cc: Include err.h.
4940
4941 2011-02-02  Eric Blake  <eblake@redhat.com>
4942
4943         * include/err.h: Fix loss of semicolons in previous patch.
4944
4945 2011-02-02  Corinna Vinschen  <corinna@vinschen.de>
4946
4947         * include/err.h (err): Add noreturn attribute.
4948         (errx): Ditto.
4949         (verr): Ditto.
4950         (verrx): Ditto.
4951
4952 2011-02-02  Corinna Vinschen  <corinna@vinschen.de>
4953
4954         * path.cc (conv_path_list): Remove enclosing quotes and trailing
4955         backslashes from Win32 environment path lists.
4956
4957 2011-02-01  Christian Franke  <franke@computer.org>
4958
4959         * fhandler.cc (fhandler_base::fsync): Ignore ERROR_INVALID_FUNCTION
4960         error from FlushFileBuffers().
4961
4962 2011-01-31  Corinna Vinschen  <corinna@vinschen.de>
4963
4964         * syscalls.cc (utmp_data): Fix potential buffer overflow.
4965
4966 2011-01-31  Corinna Vinschen  <corinna@vinschen.de>
4967
4968         * fhandler_socket.cc (address_in_use): Improve comment readability.
4969
4970 2011-01-30  Corinna Vinschen  <corinna@vinschen.de>
4971
4972         * fhandler_socket.cc (address_in_use): Disable.  Add comment.
4973         (fhandler_socket::bind): Change comment to explain setting the
4974         SO_EXCLUSIVEADDRUSE socket option.  Remove code which checks for
4975         address in use.
4976         * net.cc (cygwin_setsockopt): Never set SO_REUSEADDR option.  Improve
4977         comment to compensate for the deleted comment in fhandler_socket::bind.
4978         * wincap.cc: Throughout, drop has_enhanced_socket_security from wincaps.
4979         * wincap.h (struct wincaps): Drop has_enhanced_socket_security flags
4980         and method.
4981
4982 2011-01-28 Peter Foley <jpfoley2@verizon.net>
4983
4984         * configure.in: Define LIBSERVER regardless of cross_host.
4985         * configure: Regenerate.
4986
4987 2011-01-28  Corinna Vinschen  <corinna@vinschen.de>
4988
4989         * fhandler_socket.cc (fhandler_socket::wait_for_events): Call
4990         pthread_testcancel in case of timeout to enable pthread_cancel
4991         on waiting thread.
4992
4993 2011-01-27  Corinna Vinschen  <corinna@vinschen.de>
4994
4995         * include/features.h (__STDC_ISO_10646__): Move to newlib's
4996         sys/features.h.
4997
4998 2011-01-26  Corinna Vinschen  <corinna@vinschen.de>
4999
5000         * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Fix
5001         computation of st_blocks.
5002         (fhandler_base::fstat_helper): Fix formatting.
5003
5004 2011-01-24  Corinna Vinschen  <corinna@vinschen.de>
5005
5006         * include/features.h (__STDC_ISO_10646__): Define.  Add comment.
5007
5008 2011-01-21  Corinna Vinschen  <corinna@vinschen.de>
5009
5010         * syscalls.cc (rename): Fix permission problem with symlinks on NFS.
5011         Rework how NtOpenFile gets called to make it more readable.  Change
5012         comment.
5013
5014 2011-01-20  Corinna Vinschen  <corinna@vinschen.de>
5015
5016         * exec.cc: Include pinfo.h.
5017         * winf.h: Move definitions of _P_PATH_TYPE_EXEC and _P_MODE from here...
5018         * pinfo.h: ...to here.
5019         (_P_PATH_TYPE_EXEC): Redefine to be bigger than _P_SYSTEM.
5020         (_P_MODE): Redefine so as not to mask out _P_SYSTEM.
5021         * spawn.cc (spawnlp): Add _P_PATH_TYPE_EXEC flag in call to spawnve.
5022         (spawnlpe): Ditto.
5023         (spawnvp): Ditto.
5024
5025 2011-01-19  Corinna Vinschen  <corinna@vinschen.de>
5026
5027         * spawn.cc (av::fixup): Reenable #! handling for all exec functions.
5028         Return ENOEXEC in !p_type_exec case only for unrecognized files.
5029         Fix comment formatting.
5030
5031 2011-01-19  Corinna Vinschen  <corinna@vinschen.de>
5032
5033         * exec.cc (execlp): Add missing _P_PATH_TYPE_EXEC flag in call to
5034         spawnve.
5035
5036 2011-01-19  Corinna Vinschen  <corinna@vinschen.de>
5037
5038         * exec.cc: Rearrange functions in alphabetical order.
5039         (_execve): Drop temporary define and drop export alias.
5040         (execl): Call spawnve.
5041         (execle): New function.
5042         (execlp): New function.
5043         (execv): Call spawnve.
5044         (execve): Drop converting NULL envp to emtpy envp.
5045         (execvp): Call spawnve.
5046         (execvpe): Drop converting NULL envp to emtpy envp.  Call spawnve.
5047         (fexecve): Call spawnve.
5048         * spawn.cc (spawnve): Convert NULL envp to emtpy envp.  Remove outdated
5049         comment.
5050         (spawnlp): Call spawnve.
5051         (spawnlpe): Ditto.
5052         (spawnvp): Ditto.
5053         (spawnvpe): Fix formatting.
5054
5055 2011-01-19  Corinna Vinschen  <corinna@vinschen.de>
5056
5057         * exec.cc (strccpy): Move function from here...
5058         * strfuncs.cc (strccpy): ...to here.
5059         * string.h (strccpy): Declare.
5060         * winsup.h (strccpy): Drop declaration.
5061
5062 2011-01-19  Corinna Vinschen  <corinna@vinschen.de>
5063
5064         * errno.cc (errmap): Add error codes for invalid binaries.
5065         * exec.cc (execvp): Call spawnve with _P_PATH_TYPE_EXEC flag
5066         from here.
5067         (execvpe): Ditto.
5068         * spawn.cc (spawn_guts): Filter _P_PATH_TYPE_EXEC from mode and
5069         store in p_type_exec.  Call av::fixup with addtional p_type_exec
5070         argument.
5071         (spawnve): Check for filtered mode.
5072         (spawnvpe): Add _P_PATH_TYPE_EXEC flag when calling spawnve.
5073         (av::fixup): Accept additional bool parameter p_type_exec.  Only check
5074         for script if p_type_exec is true.
5075         * winf.h (_P_PATH_TYPE_EXEC): Define.
5076         (_P_MODE): Define.
5077         (av::fixup): Declare with additional bool parameter.
5078
5079 2011-01-17  Corinna Vinschen  <corinna@vinschen.de>
5080
5081         * fhandler_proc.cc (format_proc_partitions): Fix compiler warning.
5082
5083 2011-01-17  Corinna Vinschen  <corinna@vinschen.de>
5084
5085         * path.cc (path_conv::check): Don't follow reparse point symlinks if
5086         PC_SYM_NOFOLLOW_REP flag is set.
5087         (cygwin_conv_path): Set PC_SYM_NOFOLLOW_REP flag when converting from
5088         POSIX to Win32.
5089         * path.h (enum pathconv_arg): Define PC_SYM_NOFOLLOW_REP flag.
5090
5091 2011-01-17  Corinna Vinschen  <corinna@vinschen.de>
5092
5093         * fhandler_proc.cc (proc_tab_cmp): Fix typo in comment.
5094         (fhandler_proc::fill_filebuf): Handle return value of 0 from format
5095         function as error.
5096         (format_proc_stat): Set errno when returning 0 size.
5097         (format_proc_partitions): Rewrite method to fetch partition info.
5098
5099 2011-01-13  Corinna Vinschen  <corinna@vinschen.de>
5100
5101         * fhandler_disk_file.cc (fhandler_base::fstat_helper): Always set
5102         st_size of directories to 0.  Explain why.
5103
5104 2011-01-12  Corinna Vinschen  <corinna@vinschen.de>
5105
5106         * posix.sgml: Add madvise to BSD list.
5107
5108 2011-01-12  Corinna Vinschen  <corinna@vinschen.de>
5109
5110         * cygwin.din (madvise): Export posix_madvise as madvise.
5111         * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR.
5112         * include/sys/mman.h: Define madvise constants, keep Linux-specific
5113         constants undefined.
5114         (madvise): Declare.
5115
5116 2011-01-12  Corinna Vinschen  <corinna@vinschen.de>
5117
5118         * fhandler.h (struct part_t): New type.
5119         (class fhandler_dev_floppy): Convert partitions to part_t pointer.
5120         Add lock_partition method.
5121         * fhandler_floppy.cc (fhandler_dev_floppy::lock_partition): New method
5122         to implement ondemand partition locking.
5123         (fhandler_dev_floppy::write_file): Call lock_partition from here if
5124         writing failed due to a potential write restriction on a disk
5125         partition.
5126         (fhandler_dev_floppy::open): Don't lock partitions here.
5127         (fhandler_dev_floppy::close): Keep track of partition handle reference
5128         count.  Close handles and remove partitions pointer ony if count is 0.
5129         (fhandler_dev_floppy::dup): Just copy partitions pointer and increment
5130         reference count.
5131
5132 2011-01-11  Corinna Vinschen  <corinna@vinschen.de>
5133
5134         * fhandler.h (MAX_PARTITIONS): New definition.
5135         (class fhandler_dev_floppy): Add partitions array member.  Add close
5136         method.
5137         * fhandler_floppy.cc (fhandler_dev_floppy::fhandler_dev_floppy): Zero
5138         out partitions array.
5139         (fhandler_dev_floppy::open): Fix "entire disk" condition for call to
5140         DeviceIoControl (FSCTL_ALLOW_EXTENDED_DASD_IO).
5141         When opening disks for writing, call DeviceIoControl (FSCTL_LOCK_VOLUME)
5142         on all affected disk partitions starting with Vista.
5143         (fhandler_dev_floppy::close): New method.
5144         (fhandler_dev_floppy::dup): Duplicate handles in partitions, if any.
5145         * wincap.h (wincaps::has_restricted_raw_disk_access): New element.
5146         * wincap.cc: Implement above element throughout.
5147
5148 2011-01-11  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
5149
5150         * termios.cc (cfgetospeed, cfgetispeed): Constify argument per POSIX.
5151         * include/sys/termios.h (cfgetospeed, cfgetispeed): Declare functions.
5152         Move macros after declarations and make conditional on !__cplusplus.
5153
5154 2011-01-11  Corinna Vinschen  <corinna@vinschen.de>
5155
5156         * cygtls.cc (_cygtls::init_thread): Call _REENT_INIT_PTR.  Drop setting
5157         current locale and calling srand48.
5158
5159 2011-01-02  Christopher Faylor  <me+cygwin@cgf.cx>
5160
5161         * ChangeLog-2010: Create from ChangeLog.
5162         * ChangeLog: Start fresh.