* cygheap.h (cygheap_fdmanip): Delete fh and use fd index into cygheap->fdtab
throughout. (cygheap_fdnew): Replace fh by using fd index into cygheap->fdtab throughout. (cygheap_fdget): Ditto. (cygheap_fdenum): Ditto.
This commit is contained in:
parent
6d27f82985
commit
514fdad34d
@ -1,3 +1,10 @@
|
|||||||
|
2010-08-09 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* cygheap.h (cygheap_fdmanip): Delete fh and use fd index into
|
||||||
|
cygheap->fdtab throughout.
|
||||||
|
(cygheap_fdnew): Replace fh by using fd index into cygheap->fdtab
|
||||||
|
throughout. (cygheap_fdget): Ditto. (cygheap_fdenum): Ditto.
|
||||||
|
|
||||||
2010-08-09 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
2010-08-09 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
||||||
|
|
||||||
Implement POSIX.1-2004 Monotonic Clock.
|
Implement POSIX.1-2004 Monotonic Clock.
|
||||||
|
@ -314,10 +314,9 @@ class cygheap_fdmanip
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int fd;
|
int fd;
|
||||||
fhandler_base **fh;
|
|
||||||
bool locked;
|
bool locked;
|
||||||
public:
|
public:
|
||||||
cygheap_fdmanip (): fh (NULL) {}
|
cygheap_fdmanip (): fd (-1), locked (false) {}
|
||||||
virtual ~cygheap_fdmanip ()
|
virtual ~cygheap_fdmanip ()
|
||||||
{
|
{
|
||||||
if (locked)
|
if (locked)
|
||||||
@ -328,14 +327,14 @@ class cygheap_fdmanip
|
|||||||
cygheap->fdtab.release (fd);
|
cygheap->fdtab.release (fd);
|
||||||
}
|
}
|
||||||
operator int &() {return fd;}
|
operator int &() {return fd;}
|
||||||
operator fhandler_base* &() {return *fh;}
|
operator fhandler_base* &() {return cygheap->fdtab[fd];}
|
||||||
operator fhandler_socket* () const {return reinterpret_cast<fhandler_socket *> (*fh);}
|
operator fhandler_socket* () const {return reinterpret_cast<fhandler_socket *> (cygheap->fdtab[fd]);}
|
||||||
operator fhandler_pipe* () const {return reinterpret_cast<fhandler_pipe *> (*fh);}
|
operator fhandler_pipe* () const {return reinterpret_cast<fhandler_pipe *> (cygheap->fdtab[fd]);}
|
||||||
void operator = (fhandler_base *fh) {*this->fh = fh;}
|
void operator = (fhandler_base *fh) {cygheap->fdtab[fd] = fh;}
|
||||||
fhandler_base *operator -> () const {return *fh;}
|
fhandler_base *operator -> () const {return cygheap->fdtab[fd];}
|
||||||
bool isopen () const
|
bool isopen () const
|
||||||
{
|
{
|
||||||
if (*fh)
|
if (cygheap->fdtab[fd])
|
||||||
return true;
|
return true;
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return false;
|
return false;
|
||||||
@ -354,10 +353,7 @@ class cygheap_fdnew : public cygheap_fdmanip
|
|||||||
else
|
else
|
||||||
fd = cygheap->fdtab.find_unused_handle (seed_fd + 1);
|
fd = cygheap->fdtab.find_unused_handle (seed_fd + 1);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
locked = lockit;
|
||||||
locked = lockit;
|
|
||||||
fh = cygheap->fdtab + fd;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
@ -366,7 +362,7 @@ class cygheap_fdnew : public cygheap_fdmanip
|
|||||||
locked = false;
|
locked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator = (fhandler_base *fh) {*this->fh = fh;}
|
void operator = (fhandler_base *fh) {cygheap->fdtab[fd] = fh;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class cygheap_fdget : public cygheap_fdmanip
|
class cygheap_fdget : public cygheap_fdmanip
|
||||||
@ -376,8 +372,7 @@ class cygheap_fdget : public cygheap_fdmanip
|
|||||||
{
|
{
|
||||||
if (lockit)
|
if (lockit)
|
||||||
cygheap->fdtab.lock ();
|
cygheap->fdtab.lock ();
|
||||||
if (fd >= 0 && fd < (int) cygheap->fdtab.size
|
if (fd >= 0 && fd < (int) cygheap->fdtab.size && cygheap->fdtab[fd] != NULL)
|
||||||
&& *(fh = cygheap->fdtab + fd) != NULL)
|
|
||||||
{
|
{
|
||||||
this->fd = fd;
|
this->fd = fd;
|
||||||
locked = lockit;
|
locked = lockit;
|
||||||
@ -407,7 +402,7 @@ class cygheap_fdenum : public cygheap_fdmanip
|
|||||||
int next ()
|
int next ()
|
||||||
{
|
{
|
||||||
while (++fd < (int) cygheap->fdtab.size)
|
while (++fd < (int) cygheap->fdtab.size)
|
||||||
if (*(fh = cygheap->fdtab + fd) != NULL)
|
if (cygheap->fdtab[fd] != NULL)
|
||||||
return fd;
|
return fd;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user