Skip to contentSkip to conversation

char: Enable build of pty on macOS

PATCH In review Roman Bolshakov 4 participants 4 messages Aug 21, 2018 – Aug 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char: Enable build of pty on macOS

For some reason __APPLE__ was not checked in pty code. pty chardev should be available on macOS, according to man page.

---
 chardev/char-pty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-pty.c +1 -1
index 68fd4e20c3..cb00257ebe 100644
@@ -33,7 +33,7 @@
 
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)      \
     || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
-    || defined(__GLIBC__)
+    || defined(__GLIBC__) || defined(__APPLE__)
 
 typedef struct {
     Chardev parent;
Signature · 1 line
2.15.2 (Apple Git-101.1)
#1 lore raw
Quoted 13 lines · Roman Bolshakov

For some reason __APPLE__ was not checked in pty code. pty chardev should be available on macOS, according to man page.

---
  chardev/char-pty.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-pty.c +0 -0
index 68fd4e20c3..cb00257ebe 100644

chardev/char-pty.c line 37

Quoted 6 lines
chardev/char-pty.c +1 -1
@@ -33,7 +33,7 @@
 
  #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)      \
      || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
-    || defined(__GLIBC__)
+    || defined(__GLIBC__) || defined(__APPLE__)
 

Rather than maintaining an ever-growing fragile list of platforms, could we instead replace this whole mess with a single define determined at configure time based on a feature test?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
In reply to Roman Bolshakov
Quoted 13 lines · Roman Bolshakov

For some reason __APPLE__ was not checked in pty code. pty chardev should be available on macOS, according to man page.

---
 chardev/char-pty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-pty.c +0 -0
index 68fd4e20c3..cb00257ebe 100644

chardev/char-pty.c line 36

Quoted 5 lines
chardev/char-pty.c +1 -1
@@ -33,7 +33,7 @@
 
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)      \
     || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
-    || defined(__GLIBC__)
+    || defined(__GLIBC__) || defined(__APPLE__)

We should fix this by figuring out what the code is actually looking for (ie what OS functions), having a configure test for those functions, and dropping the big long list of OS ifdefs. Otherwise we've just got exactly the same problem for the next unix-ish OS that comes along...

thanks
-- PMM

#3 lore raw
Quoted 10 lines · Peter Maydell

chardev/char-pty.c line 36

Quoted 5 lines
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)      \
     || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
chardev/char-pty.c +1 -1
-    || defined(__GLIBC__)
+    || defined(__GLIBC__) || defined(__APPLE__)

We should fix this by figuring out what the code is actually looking for (ie what OS functions), having a configure test for those functions, and dropping the big long list of OS ifdefs. Otherwise we've just got exactly the same problem for the next unix-ish OS that comes along...

It's really looking only for qemu_openpty_raw, which in turn is compiled for all CONFIG_POSIX systems. Because the file is already compiled for CONFIG_POSIX only, the #ifdef is a legacy of the time before chardev/char-pty.c was split out of qemu-char.c. It can be removed.

Paolo