summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKO Myung-Hun <komh78@gmail.com>2023-02-18 13:43:16 -0500
committerPaul Smith <psmith@gnu.org>2023-02-19 01:02:16 -0500
commit62194015fa250e62b5534783cdcc2337c3ce6834 (patch)
tree11614fdc94fb51e4403bd9285cc97a565f7e6548
parentc85f68c4e952294304e5938acb601e66f5df71a0 (diff)
downloadmake-git-62194015fa250e62b5534783cdcc2337c3ce6834.tar.gz
* src/misc.c (ttyname) [OS/2]: Add an implementation for OS/2 kLIBC
-rw-r--r--src/misc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index 0d7a44e5..eb14f405 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -28,6 +28,11 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
# include <io.h>
#endif
+#ifdef __EMX__
+# define INCL_DOS
+# include <os2.h>
+#endif
+
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#else
@@ -781,6 +786,40 @@ get_tmpfile (char **name)
}
+#if HAVE_TTYNAME && defined(__EMX__)
+/* OS/2 kLIBC has a declaration for ttyname(), so configure finds it.
+ But, it is not implemented! Roll our own. */
+char *ttyname (int fd)
+{
+ ULONG type;
+ ULONG attr;
+ ULONG rc;
+
+ rc = DosQueryHType (fd, &type, &attr);
+ if (rc)
+ {
+ errno = EBADF;
+ return NULL;
+ }
+
+ if (type == HANDTYPE_DEVICE)
+ {
+ if (attr & 3) /* 1 = KBD$, 2 = SCREEN$ */
+ return (char *) "/dev/con";
+
+ if (attr & 4) /* 4 = NUL */
+ return (char *) "/dev/nul";
+
+ if (attr & 8) /* 8 = CLOCK$ */
+ return (char *) "/dev/clock$";
+ }
+
+ errno = ENOTTY;
+ return NULL;
+}
+#endif
+
+
#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
for it, define our own version. */