From ee964e2f97ca0ca9033b6daf975cada710a46737 Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me@cgf.cx>
Date: Thu, 6 Jun 2002 00:09:55 +0000
Subject: [PATCH] * cygwin.din: Eliminate some newlib wrappers. * path.cc
 (get_devn): Only consider first 99 potential com devices.
 (get_device_number): Ditto. * times.cc (_times): Eliminate. (_times): Renamed
 from times().

---
 winsup/cygwin/ChangeLog  |  8 ++++++++
 winsup/cygwin/cygwin.din | 36 ++++++++++++++++++------------------
 winsup/cygwin/path.cc    |  4 ++--
 winsup/cygwin/times.cc   |  8 +-------
 4 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 958c5d3d1..45de9f84c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2002-06-05  Christopher Faylor  <cgf@redhat.com>
+
+	* cygwin.din: Eliminate some newlib wrappers.
+	* path.cc (get_devn): Only consider first 99 potential com devices.
+	(get_device_number): Ditto.
+	* times.cc (_times): Eliminate.
+	(_times): Renamed from times().
+
 2002-06-05  Christopher Faylor  <cgf@redhat.com>
 
 	* dir.cc (rmdir): Streamline.  Detect attempts to remove directories
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 709b311e0..9bbfa5f4e 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -106,8 +106,8 @@ clearerr
 _clearerr = clearerr
 clock
 _clock = clock
-close
-_close = close
+_close
+close = _close
 closedir
 _closedir = closedir
 copysign
@@ -209,8 +209,8 @@ _fchown = fchown
 fchown32
 fclose
 _fclose = fclose
-fcntl
-_fcntl = fcntl
+_fcntl
+fcntl = _fcntl
 fcvt
 _fcvt = fcvt
 fcvtbuf
@@ -304,8 +304,8 @@ fseek
 _fseek = fseek
 fsetpos
 _fsetpos = fsetpos
-fstat
-_fstat = fstat
+_fstat
+fstat = _fstat
 fstat64
 fstatfs
 _fstatfs = fstatfs
@@ -472,8 +472,8 @@ jn
 _jn = jn
 jnf
 _jnf = jnf
-kill
-_kill = kill
+_kill
+kill = _kill
 labs
 _labs = labs
 lchown
@@ -521,8 +521,8 @@ login
 logout
 longjmp
 _longjmp = longjmp
-lseek
-_lseek = lseek
+_lseek
+lseek = _lseek
 lseek64
 lstat = cygwin_lstat
 _lstat = cygwin_lstat
@@ -630,8 +630,8 @@ remainderf
 _remainderf = remainderf
 remove
 _remove = remove
-rename
-_rename = rename
+_rename
+rename = _rename
 rewind
 _rewind = rewind
 rewinddir
@@ -764,8 +764,8 @@ sscanf
 _sscanf = sscanf
 _sscanf_r
 sscanf_r = _sscanf_r
-stat
-_stat = stat
+_stat
+stat = _stat
 stat64
 statfs
 _statfs = statfs
@@ -868,8 +868,8 @@ tempnam
 _tempnam = tempnam
 time
 _time = time
-times
-_times = times
+_times
+times = _times
 timezone
 tmpfile
 _tmpfile = tmpfile
@@ -930,8 +930,8 @@ vsscanf
 _vsscanf = vsscanf
 _vsscanf_r
 vsscanf_r = _vsscanf_r
-wait
-_wait = wait
+_wait
+wait = _wait
 waitpid
 _waitpid = waitpid
 wait3
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 25412b261..336df5e4e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -916,7 +916,7 @@ get_devn (const char *name, int &unit)
       devn = FH_MEM;
       unit = 4;
     }
-  else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0)
+  else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0 && unit < 100)
     devn = FH_SERIAL;
   else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0)
     {
@@ -1070,7 +1070,7 @@ get_device_number (const char *unix_path, const char *w32_path, int &unit)
       if (p)
 	unix_path = p + 1;
       if (udeveqn ("com", 3)
-	 && (unit = digits (unix_path + 3)) >= 0)
+	 && (unit = digits (unix_path + 3)) >= 0 && unit < 100)
 	devn = FH_SERIAL;
     }
 
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 6769b4e74..e8a886b71 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -46,7 +46,7 @@ __to_clock_t (FILETIME * src, int flag)
 
 /* times: POSIX 4.5.2.1 */
 extern "C" clock_t
-times (struct tms * buf)
+_times (struct tms * buf)
 {
   FILETIME creation_time, exit_time, kernel_time, user_time;
 
@@ -86,12 +86,6 @@ times (struct tms * buf)
    return tc;
 }
 
-extern "C" clock_t
-_times (struct tms * buf)
-{
-  return times (buf);
-}
-
 /* settimeofday: BSD */
 extern "C" int
 settimeofday (const struct timeval *tv, const struct timezone *tz)