mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
* cygerrno.h (set_errno): Define more informative version of this function for
debugging. (__set_errno): Declare when DEBUGGING. * cygheap.h (cygheap_fdget::cygheap_fdget): Add a flag to control when errno is set. * debug.cc (__set_errno): New function. * fcntl.cc (_fcntl): Fix so that correct fd is used for second argument to dup2. * syscalls.cc (_cygwin_istext_for_stdio): Don't set errno here when using cygheap_fdget.
This commit is contained in:
parent
df63bd490a
commit
0f4db8cbe0
@ -1,3 +1,16 @@
|
||||
2001-10-15 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* cygerrno.h (set_errno): Define more informative version of this
|
||||
function for debugging.
|
||||
(__set_errno): Declare when DEBUGGING.
|
||||
* cygheap.h (cygheap_fdget::cygheap_fdget): Add a flag to control when
|
||||
errno is set.
|
||||
* debug.cc (__set_errno): New function.
|
||||
* fcntl.cc (_fcntl): Fix so that correct fd is used for second argument
|
||||
to dup2.
|
||||
* syscalls.cc (_cygwin_istext_for_stdio): Don't set errno here when
|
||||
using cygheap_fdget.
|
||||
|
||||
2001-10-15 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* fhandler.cc (fhandler_base::fork_fixup): Don't protect handle.
|
||||
|
@ -15,7 +15,12 @@ int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ (
|
||||
#define __seterrno() seterrno (__FILE__, __LINE__)
|
||||
#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val)
|
||||
|
||||
#ifndef DEBUGGING
|
||||
#define set_errno(val) (_impure_ptr->_errno = (val))
|
||||
#else
|
||||
void __stdcall __set_errno (const char *ln, int ln, int val) __attribute ((regparm(3)));
|
||||
#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val))
|
||||
#endif
|
||||
#define get_errno() (_impure_ptr->_errno)
|
||||
extern "C" void __stdcall set_sig_errno (int e);
|
||||
|
||||
|
@ -228,7 +228,7 @@ class cygheap_fdnew : public cygheap_fdmanip
|
||||
class cygheap_fdget : public cygheap_fdmanip
|
||||
{
|
||||
public:
|
||||
cygheap_fdget (int fd, bool lockit = false)
|
||||
cygheap_fdget (int fd, bool lockit = false, bool do_set_errno = true)
|
||||
{
|
||||
if (lockit)
|
||||
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
|
||||
@ -241,7 +241,8 @@ class cygheap_fdget : public cygheap_fdmanip
|
||||
else
|
||||
{
|
||||
this->fd = -1;
|
||||
set_errno (EBADF);
|
||||
if (do_set_errno)
|
||||
set_errno (EBADF + 1);
|
||||
if (lockit)
|
||||
ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
|
||||
locked = false;
|
||||
|
@ -14,6 +14,7 @@ details. */
|
||||
#include "perthread.h"
|
||||
#include "perprocess.h"
|
||||
#include "security.h"
|
||||
#include "cygerrno.h"
|
||||
|
||||
#undef CloseHandle
|
||||
|
||||
@ -348,4 +349,12 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Add a handle to the linked list of known handles. */
|
||||
void __stdcall
|
||||
__set_errno (const char *func, int ln, int val)
|
||||
{
|
||||
debug_printf ("%s:%d val %d", func, ln, val);
|
||||
_impure_ptr->_errno = val;
|
||||
}
|
||||
#endif /*DEBUGGING*/
|
||||
|
@ -41,13 +41,7 @@ _fcntl (int fd, int cmd,...)
|
||||
if (cmd != F_DUPFD)
|
||||
res = cfd->fcntl(cmd, arg);
|
||||
else
|
||||
{
|
||||
cygheap_fdnew newfd;
|
||||
if (newfd >= 0)
|
||||
res = dup2 (fd, newfd);
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
res = dup2 (fd, cygheap_fdnew (((int) arg) - 1));
|
||||
va_end (args);
|
||||
|
||||
done:
|
||||
|
@ -1461,7 +1461,7 @@ _cygwin_istext_for_stdio (int fd)
|
||||
return 0; /* we do it for old apps, due to getc/putc macros */
|
||||
}
|
||||
|
||||
cygheap_fdget cfd (fd);
|
||||
cygheap_fdget cfd (fd, false, false);
|
||||
if (cfd < 0)
|
||||
{
|
||||
syscall_printf (" _cifs: fd not open\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user