OSDN Git Service

* cygwin.din: Export rand_r and ttyname_r.
authorcorinna <corinna>
Wed, 14 Apr 2004 09:12:03 +0000 (09:12 +0000)
committercorinna <corinna>
Wed, 14 Apr 2004 09:12:03 +0000 (09:12 +0000)
* syscalls.cc (ttyname_r): New function.
(ttyname): Move functionality to ttyname_r.  Call it from here.
* include/cygwin/version.h: Bump API minor number.

winsup/cygwin/ChangeLog
winsup/cygwin/cygwin.din
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/syscalls.cc

index 5be12c9..db6a4c7 100644 (file)
@@ -1,11 +1,18 @@
+2004-04-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.din: Export rand_r and ttyname_r.
+       * syscalls.cc (ttyname_r): New function.
+       (ttyname): Move functionality to ttyname_r.  Call it from here.
+       * include/cygwin/version.h: Bump API minor number.
+
 2004-04-14  Pierre Humblet <pierre.humblet@ieee.org>
 
-        * path.h (path_conv::set_symlink): Add argument.
-        (path_conv::get_symlink_length): New method. 
-        (path_conv::symlink_length): New member.
-        * path.cc (path_conv::check): Pass symlen to set_symlink.
-        * fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks
-        set st_size from get_symlink_length.    
+       * path.h (path_conv::set_symlink): Add argument.
+       (path_conv::get_symlink_length): New method. 
+       (path_conv::symlink_length): New member.
+       * path.cc (path_conv::check): Pass symlen to set_symlink.
+       * fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks
+       set st_size from get_symlink_length.    
 
 2004-04-13  Corinna Vinschen  <corinna@vinschen.de>
 
index bb32236..dd8cbee 100644 (file)
@@ -1067,6 +1067,7 @@ raise SIGFE
 _raise = raise SIGFE
 rand NOSIGFE
 _rand = rand NOSIGFE
+rand_r NOSIGFE
 random NOSIGFE
 read SIGFE
 _read = read SIGFE
@@ -1438,6 +1439,7 @@ truncf NOSIGFE
 tsearch SIGFE
 ttyname SIGFE
 _ttyname = ttyname SIGFE
+ttyname_r SIGFE
 ttyslot NOSIGFE
 twalk NOSIGFE
 tzset SIGFE
index 2db2e9b..b63fcc1 100644 (file)
@@ -240,12 +240,13 @@ details. */
       112: Redefine some mtget fields.
       113: Again redefine some mtget fields.  Use mt_fileno and mt_blkno as
            on Linux.
+      114: Export rand_r, ttyname_r.
      */
 
      /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 113
+#define CYGWIN_VERSION_API_MINOR 114
 
      /* There is also a compatibity version number associated with the
        shared memory regions.  It is incremented when incompatible
index ed8b902..daae8a3 100644 (file)
@@ -1511,15 +1511,38 @@ pathconf (const char *file, int v)
     }
 }
 
+extern "C" int
+ttyname_r (int fd, char *buf, size_t buflen)
+{
+  int ret = 0;
+  if (__check_null_invalid_struct (buf, buflen))
+    ret = EINVAL;
+  else
+    {
+      cygheap_fdget cfd (fd, true);
+      if (cfd < 0)
+       ret = EBADF;
+      else if (!cfd->is_tty ())
+       ret = ENOTTY;
+      else if (buflen < strlen (cfd->ttyname ()) + 1)
+       ret = ERANGE;
+      else
+        strcpy (buf, cfd->ttyname ());
+    }
+  debug_printf ("returning %d tty: %s", ret, ret ? "NULL" : buf);
+  return ret;
+}
+
 extern "C" char *
 ttyname (int fd)
 {
-  char *name;
-  cygheap_fdget cfd (fd);
-  if (cfd < 0 || !cfd->is_tty ())
-    return 0;
-  name = (char *) (cfd->ttyname ());
-  debug_printf ("returning %s", name);
+  static char name[CYG_MAX_PATH];
+  int ret = ttyname_r (fd, name, CYG_MAX_PATH);
+  if (ret)
+    {
+      set_errno (ret);
+      return NULL;
+    }
   return name;
 }