From a010e6abed2c84e302823c4403ef3782b34bb6f1 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 30 Jul 2008 04:58:24 +0000 Subject: [PATCH] * cygwin.din (_getutline): Remove. * lib/bsdlib.cc (login): Make argument const as per linux. (logout): Ditto. * syscalls.cc (getutid): Ditto. (getutline): Ditto. (pututline): Ditto. (getutxent): Add comment mentioning non-thread-safety. (getutxid): Ditto. (getutxline): Ditto. (pututxline): Ditto. * sys/utmp.h: Declare arguments to various functions as const as per linux. Remove bogus _getutline definition. --- winsup/cygwin/ChangeLog | 15 +++++++++++++++ winsup/cygwin/cygwin.din | 1 - winsup/cygwin/include/sys/utmp.h | 13 ++++++------- winsup/cygwin/libc/bsdlib.cc | 4 ++-- winsup/cygwin/select.cc | 4 ++-- winsup/cygwin/syscalls.cc | 15 +++++++++++---- 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 25f1601a5..cde34cf6d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,18 @@ +2008-07-30 Christopher Faylor + + * cygwin.din (_getutline): Remove. + * lib/bsdlib.cc (login): Make argument const as per linux. + (logout): Ditto. + * syscalls.cc (getutid): Ditto. + (getutline): Ditto. + (pututline): Ditto. + (getutxent): Add comment mentioning non-thread-safety. + (getutxid): Ditto. + (getutxline): Ditto. + (pututxline): Ditto. + * sys/utmp.h: Declare arguments to various functions as const as per + linux. Remove bogus _getutline definition. + 2008-07-29 Christopher Faylor * include/cygwin/version.h: Add comment indicating that current API number diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 1dac2268d..1b5ac9f4e 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -701,7 +701,6 @@ _getutent = getutent SIGFE getutid SIGFE _getutid = getutid SIGFE getutline SIGFE -_getutline = getutline SIGFE getutxent SIGFE getutxid SIGFE getutxline SIGFE diff --git a/winsup/cygwin/include/sys/utmp.h b/winsup/cygwin/include/sys/utmp.h index 8828d0f88..8a63b348b 100644 --- a/winsup/cygwin/include/sys/utmp.h +++ b/winsup/cygwin/include/sys/utmp.h @@ -1,6 +1,6 @@ /* sys/utmp.h - Copyright 2001, 2004 Red Hat, Inc. + Copyright 2001, 2003, 2004, 2005, 2008 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for @@ -34,17 +34,16 @@ struct utmp long ut_addr; }; -extern struct utmp *_getutline (struct utmp *); extern struct utmp *getutent (void); -extern struct utmp *getutid (struct utmp *); -extern struct utmp *getutline (struct utmp *); -extern struct utmp *pututline (struct utmp *); +extern struct utmp *getutid (const struct utmp *); +extern struct utmp *getutline (const struct utmp *); +extern struct utmp *pututline (const struct utmp *); extern void endutent (void); extern void setutent (void); extern void utmpname (const char *); -void login (struct utmp *); -int logout (char *); +void login (const struct utmp *); +int logout (const char *); int login_tty (int); void updwtmp (const char *, const struct utmp *); void logwtmp (const char *, const char *, const char *); diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index b61c7aaaf..9d488c35a 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -271,7 +271,7 @@ logwtmp (const char *line, const char *user, const char *host) } extern "C" void -login (struct utmp *ut) +login (const struct utmp *ut) { pututline (ut); endutent (); @@ -279,7 +279,7 @@ login (struct utmp *ut) } extern "C" int -logout (char *line) +logout (const char *line) { struct utmp ut_buf, *ut; diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 874c14469..6be10ec27 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -506,7 +506,7 @@ out: fh->get_name ()); else { -#if 0 +#if 1 /* FIXME: This code is not quite correct. There's no better solution so far but to make simple assumptions based on WriteQuotaAvailable. */ @@ -531,7 +531,7 @@ out: that. This means that a pipe could still block since you could be trying to write more to the pipe than is available in the buffer but that is the hazard of select(). */ - else if (fpli.WriteQuotaAvailable) + else if (fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable)) { select_printf ("%s, ready for write: size %lu, avail %lu", fh->get_name (), diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a8a66ecbf..92446bcc0 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3098,7 +3098,7 @@ getutent () } extern "C" struct utmp * -getutid (struct utmp *id) +getutid (const struct utmp *id) { myfault efault; if (efault.faulted (EFAULT)) @@ -3137,7 +3137,7 @@ getutid (struct utmp *id) } extern "C" struct utmp * -getutline (struct utmp *line) +getutline (const struct utmp *line) { myfault efault; if (efault.faulted (EFAULT)) @@ -3160,7 +3160,7 @@ getutline (struct utmp *line) } extern "C" struct utmp * -pututline (struct utmp *ut) +pututline (const struct utmp *ut) { myfault efault; if (efault.faulted (EFAULT)) @@ -3184,7 +3184,10 @@ pututline (struct utmp *ut) } else locked_append (utmp_fd, ut, sizeof *ut); - return ut; + /* The documentation says to return a pointer to this which implies that + this has to be cast from a const. That doesn't seem right but the + documentation seems pretty clear on this. */ + return (struct utmp *) ut; } extern "C" void @@ -3202,6 +3205,7 @@ endutxent () extern "C" struct utmpx * getutxent () { + /* UGH. Not thread safe. */ static struct utmpx utx; return copy_ut_to_utx (getutent (), &utx); } @@ -3209,6 +3213,7 @@ getutxent () extern "C" struct utmpx * getutxid (const struct utmpx *id) { + /* UGH. Not thread safe. */ static struct utmpx utx; myfault efault; @@ -3221,6 +3226,7 @@ getutxid (const struct utmpx *id) extern "C" struct utmpx * getutxline (const struct utmpx *line) { + /* UGH. Not thread safe. */ static struct utmpx utx; myfault efault; @@ -3233,6 +3239,7 @@ getutxline (const struct utmpx *line) extern "C" struct utmpx * pututxline (const struct utmpx *utmpx) { + /* UGH. Not thread safe. */ static struct utmpx utx; myfault efault;