Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
174 stars 17 forks source link

build of adlmidi2 util fails with musl libc #241

Closed rofl0r closed 3 years ago

rofl0r commented 3 years ago

due to usage of the non-posix struct termio instead of struct termios

diff --git a/utils/adlmidi-2/input.cc b/utils/adlmidi-2/input.cc
index bb276cb..28aa96a 100644
--- a/utils/adlmidi-2/input.cc
+++ b/utils/adlmidi-2/input.cc
@@ -7,7 +7,7 @@ xInput::xInput()
 #endif
 #if (!defined(_WIN32) || defined(__CYGWIN__)) && !defined(__DJGPP__) && !defined(__APPLE__)
     ioctl(0, TCGETA, &back);
-    struct termio term = back;
+    struct termios term = back;
     term.c_lflag &= ~(ICANON | ECHO);
     term.c_cc[VMIN] = 0; // 0=no block, 1=do block
     if(ioctl(0, TCSETA, &term) < 0)
diff --git a/utils/adlmidi-2/input.hpp b/utils/adlmidi-2/input.hpp
index 0cafd51..4a34263 100644
--- a/utils/adlmidi-2/input.hpp
+++ b/utils/adlmidi-2/input.hpp
@@ -35,7 +35,7 @@ class xInput
     void *inhandle;
     #endif
     #if (!defined(_WIN32) || defined(__CYGWIN__)) && !defined(__DJGPP__) && !defined(__APPLE__)
-    struct termio back;
+    struct termios back;
     #endif
 public:
     xInput();

this patch fixes it, and i think you should get rid of all the ifdef junk and instead write a configure style check whether struct termios or termio is provided by termios.h, even though any platform claiming posix compatibility should expose the former.

Wohlstand commented 3 years ago

The adlmidi2 is one of most messy parts which does replication of the original adlmidi tool by Joel Yliluoma. Yeah, in my mind here should be a typedef and the macro that defines what of them should been used. Thanks for the suggestion, I'll try to add the small configure test into the CMake side, that shouldn't be hard to make.

Wohlstand commented 3 years ago

Just now I added the compile test into the CMake build that recognizes what termio or termios should be used during the build. I made the typedef for each of them. Please check :fox_face:

rofl0r commented 3 years ago

[100%] Linking CXX executable ../../adlmidi2 [100%] Built target adlmidi2

i don't recall the exact config i used, but adl2midi build succeeded, so i guess this works, thanks!

Wohlstand commented 3 years ago

i don't recall the exact config i used, but adl2midi build succeeded, so i guess this works, thanks!

It should work with any config, and, since you have updated files, the CMake should automatically re-generate all makefiles to be sure all up to date :fox_face: Thanks for the confirmation, closing.