diff options
author | Christopher Faylor <me@cgf.cx> | 2000-09-25 16:36:12 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-09-25 16:36:12 +0000 |
commit | fb5956da13ac60a3408632efd62e685458899924 (patch) | |
tree | 99cdd3b9367da6786298104991ee5750fc08b5e1 | |
parent | eb69b80812d1b8e7d95b9e5abc95a0a839df13ed (diff) | |
download | newlib-fb5956da13ac60a3408632efd62e685458899924.zip newlib-fb5956da13ac60a3408632efd62e685458899924.tar.gz newlib-fb5956da13ac60a3408632efd62e685458899924.tar.bz2 |
* spawn.cc (av::dup_maybe): Make function void rather than void *.
* environ.cc (environ_init): Remember to reparse CYGWIN if envp is
supplied.
* heap.cc (_sbrk): Remember frame for signal handling.
* syscalls.cc (read_handler): Eliminate.
(_read): Move read_handler code here. Reorganize for one path through
'ready_for_read'.
-rw-r--r-- | winsup/cygwin/ChangeLog | 16 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 12 | ||||
-rw-r--r-- | winsup/cygwin/heap.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 59 | ||||
-rw-r--r-- | winsup/cygwin/thread.h | 6 |
6 files changed, 50 insertions, 46 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index da7c80a..f051c2c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2000-09-25 Christopher Faylor <cgf@cygnus.com> + + * spawn.cc (av::dup_maybe): Make function void rather than void *. + * environ.cc (environ_init): Remember to reparse CYGWIN if envp is + supplied. + * heap.cc (_sbrk): Remember frame for signal handling. + * syscalls.cc (read_handler): Eliminate. + (_read): Move read_handler code here. Reorganize for one path through + 'ready_for_read'. + Tue Sep 19 09:46:36 2000 Christopher Faylor <cgf@cygnus.com> * spawn.cc (spawn_guts): Use actual program argument passed in for @@ -639,7 +649,7 @@ Wed Aug 2 13:20:04 2000 Christopher Faylor <cgf@cygnus.com> * localtime.c: ditto * smallprint.c: ditto * Makefile.in: don't __INSIDE_CYGWIN__ as it messes up profiling. - + Wed Aug 2 11:22:53 2000 Christopher Faylor <cgf@cygnus.com> * include/sys/strace.h: Fix strace definition. @@ -793,7 +803,7 @@ Thu Jul 27 23:33:32 2000 Christopher Faylor <cgf@cygnus.com> * testsuite/winsup.api/winsup.exp: ignore stdout by default * testsuite/winsup.api/crlf.c: non-verbose by default - + * winsup.h: prune out windows headers we don't normally need * assert.cc: add wingdi.h and winuser.h * fhandler_console.cc: ditto @@ -806,7 +816,7 @@ Thu Jul 27 23:33:32 2000 Christopher Faylor <cgf@cygnus.com> * hinfo.cc: add winsock.h * syscalls.cc: add winnls.h * uinfo.cc: ditto - + Thu Jul 27 10:24:36 2000 Egor Duda <deo@logos-m.ru> * fhandler.cc (fhandler_disk_file::fstat): Allow block calculation to diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 9c7b72c..f0a3fc7 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -524,6 +524,7 @@ environ_init (char **envp) char *p; char *newp; int sawTERM = 0; + bool envp_passed_in; static char cygterm[] = "TERM=cygwin"; regopt ("default"); @@ -536,13 +537,16 @@ environ_init (char **envp) allow_ntsec = TRUE; #endif - if (envp) + if (!envp) + envp_passed_in = 0; + else { sz = envsize (envp, 1); char **newenv = (char **) malloc (sz); memcpy (newenv, envp, sz); cfree (envp); envp = newenv; + envp_passed_in = 1; goto out; } @@ -585,6 +589,12 @@ environ_init (char **envp) out: __cygwin_environ = envp; update_envptrs (); + if (envp_passed_in) + { + p = getenv ("CYGWIN"); + if (p) + parse_options (p); + } parse_options (NULL); MALLOC_CHECK; } diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index dc2e6e9..f31848a 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -86,6 +86,7 @@ heap_init () extern "C" void * _sbrk(int n) { + sigframe thisframe (mainthread); char *newtop, *newbrk; unsigned commitbytes, newbrksize; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 3b46f67..032082c 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -273,7 +273,7 @@ public: calloced = 1; } } - void *dup_maybe (int i) + void dup_maybe (int i) { if (i >= calloced) argv[i] = cstrdup (argv[i]); diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 40dd694..cb8683d 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -194,24 +194,34 @@ setsid (void) return -1; } -static int -read_handler (int fd, void *ptr, size_t len) +extern "C" int +_read (int fd, void *ptr, size_t len) { - int res; sigframe thisframe (mainthread); - fhandler_base *fh = fdtab[fd]; - if (fdtab.not_open (fd)) { set_errno (EBADF); return -1; } - if ((fh->get_flags() & (O_NONBLOCK | O_NDELAY)) && !fh->ready_for_read (fd, 0, 0)) + set_sig_errno (0); + fhandler_base *fh = fdtab[fd]; + DWORD wait = fh->get_flags () & (O_NONBLOCK | O_NDELAY) ? 0 : INFINITE; + + /* Could block, so let user know we at least got here. */ + syscall_printf ("read (%d, %p, %d)", fd, ptr, len); + + int res; + if (wait && (!fh->is_slow () || fh->get_r_no_interrupt ())) + debug_printf ("non-interruptible read\n"); + else if (!fh->ready_for_read (fd, wait, 0)) { - syscall_printf ("nothing to read"); - set_errno (EAGAIN); - return -1; + if (!wait) + set_sig_errno (EAGAIN); + else + set_sig_errno (EINTR); + res = -1; + goto out; } /* Check to see if this is a background read from a "tty", @@ -223,40 +233,13 @@ read_handler (int fd, void *ptr, size_t len) res = fh->read (ptr, len); myself->process_state &= ~PID_TTYIN; } - syscall_printf ("%d = read (%d<%s>, %p, %d)", res, fd, fh->get_name (), ptr, len); - return res; -} - -extern "C" int -_read (int fd, void *ptr, size_t len) -{ - if (fdtab.not_open (fd)) - { - set_errno (EBADF); - return -1; - } - - set_sig_errno (0); - fhandler_base *fh = fdtab[fd]; - - /* Could block, so let user know we at least got here. */ - syscall_printf ("read (%d, %p, %d)", fd, ptr, len); - - if (!fh->is_slow () || (fh->get_flags () & (O_NONBLOCK | O_NDELAY)) || - fh->get_r_no_interrupt ()) - { - debug_printf ("non-interruptible read\n"); - return read_handler (fd, ptr, len); - } - if (fh->ready_for_read (fd, INFINITE, 0)) - return read_handler (fd, ptr, len); - set_sig_errno (EINTR); +out: syscall_printf ("%d = read (%d<%s>, %p, %d), errno %d", -1, fd, fh->get_name (), ptr, len, get_errno ()); MALLOC_CHECK; - return -1; + return res; } extern "C" diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 4b265fb..b285faa 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -151,9 +151,9 @@ HANDLE win32_obj_id; UINT return_value; bool used; char joinable; // for thread only -bool HandleOke () {return win32_obj_id;}; +bool HandleOke () {return win32_obj_id;} virtual void Destroy (); -virtual int Id () {return (int) win32_obj_id;}; +virtual int Id () {return (int) win32_obj_id;} }; class ThreadItem:public MTitem @@ -165,7 +165,7 @@ void *arg; void *return_ptr; bool suspended; DWORD thread_id; -DWORD GetThreadId () {return thread_id;}; +DWORD GetThreadId () {return thread_id;} /* signal handling */ struct sigaction *sigs; |