-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS PowerPC: all tests pass, but in terminal no output upon launching the app #65
Comments
Hi, Sergey! Since you mention PowerPC, the most likely reason is that PowerPC is a big-endian architecture, but the Turbo Vision library has some code assuming a little-endian system. I'll look into it. |
@magiblot Yes, this sounds like a very plausible cause. |
The largest deterrents to big endian compatibility were: - In the public API, the unions meant for aliasing and the bit fields: - In the case of KeyDownEvent, detecting key presses would become broken. The solution is as simple as reversing the field order in CharScanType. - In the case of MessageEvent, reading from 'infoChar', 'infoInt', etc. would not work as expected when the value had been initialized through 'infoPtr', such as when using the 'message' function. It is required to add padding before the non-pointer fields. A concise way of achieving this is by using bit fields. This comes at the expense of not being able to take the address of these fields anymore, but I have found no examples of such usage. - In the case of TColorBIOS and TColorRGB, the red and blue components would become swapped. A simple solution is to reorder the bit fields. - In the internal classes: - In TCellChar, the 'moveInt' method does bit-casting, which is fine as long as the parameter itself is the result of bit-casting from a byte array. However, 'moveChar' was implemented with an invocation to 'moveInt', breaking this rule. As a result, none of the single-byte characters that went through 'moveChar' would be displayed. - The TermColor and colorconv_r structs, which had manual bit-casting optimizations. This would result in colors not being displayed at all. Rather than changing the struct's layout, in this case it seems more convenient to simply add code to to reverse the casted bytes when necessary. Some other issues that I found were: - The internal method 'utf32To8' does bit-casting from an integer to a byte array, so bytes have to be reversed. - In tvdemo, reversing the mouse buttons would not work because the address of 'TEventQueue::mouseReverse' was being treated as an address to a int32_t, even though it is a Boolean. - In the far2l terminal extensions, integer values should always be in little-endian format, so bytes have to be reversed. - The 'AsciiChar' member of 'KEY_EVENT_RECORD' is meant to alias the least significant byte of 'UnicodeChar', so padding has to be added. - In the internal method 'fast_btoa', a little-endian-dependent optimization has been replaced by an endian-safe one. The code related to streaming and resource files has not been modified, so files generated in a little endian system may be unreadable in a big endian system and viceversa. This is not so important, though, since it is highly discouraged to use these features. I also took the oportunity to add tests for several of these points and even a GitHub Actions job to run these tests automatically in a big endian system. See magiblot/turbo#65. Fixes #134. Closes #136. Co-authored-by: MookThompson <58513526+MookThompson@users.noreply.github.com>
@magiblot Thank you! I will test it today. |
@magiblot Ok, I rebuilt it from the master. Here are the results:
|
Hi Sergey! Could you also run the tvision tests with the |
@magiblot How to do it? If I just pass
|
Mhm, you are right 😅. Then, can you please |
Where does this flag come from?
It is perhaps Clang-specific, we should get rid of it. |
I have no idea, that's certainly not something that I added manually. |
No issues, I will find what added it. Will update on the matter tomorrow though, work on |
@magiblot Test results for
|
@magiblot And what adds A bug in CMake or where this comes from? |
Okay. I wasn't expecting the Then, given that no other tests failed, I wonder if "the TUI not reacting to anything" isn't just an issue with the terminal's keyboard settings. See magiblot/tvision#100 (comment).
In your case, |
@magiblot I will try your suggestions, thank you. For alignments: it is not an untypical issue, I think. Darwin ppc has 4-byte bools and spinlocks, it has some specifics with structs packing. For the flags, looks like a CMake bug, from a quick search. See, for instance: https://android.googlesource.com/platform/external/deqp-deps/glslang/+/refs/heads/main/CMakeLists.txt#99 |
Turned out locale was already set to Unicode (via Terminal app):
I have activated the setting for Option key now, but apparently |
Okay, then this is something I hadn't seen before. Could you please check:
|
I will be back to the PowerMac in a couple of hours, but I have built |
Hi, thanks for the information. It is not so unlikely that this is related to the OS version. Turbo Vision uses the |
@magiblot I tried now to |
Okay, thanks. Do you know if there is any way for me to run this pre-release macOS version you are using in a VM? |
Technically yes, but that may not be very trivial. If you could get 10.5.8 i386 (or 10.6.8 Rosetta) running, that will probably serve a functional substitute, since a) this particular issue seems not be specific to @catap has a set-up to bootstrap Macports on various macOS versions, including 10.5.8 and 10.6.8 Rosetta, with support for Parallels: https://github.com/catap/macos-ansible-playbooks Will this be helpful? P. S. If you will actually want to install 10.6 pre-release in VM, here is what I personally followed: https://ivanexpert.com/2020/06/snow-leopard-in-parallels-desktop It is also possible to install 10A190 on an old-enough Intel Mac. It gonna support building and running Finally, it might be possible to install PowerPC macOS via Qemu or UTM, but I could not make it work from the get-go, and had no time to dig into fixing that. However I mention all this just in a context of replying to your question. While I do think there is worth in using 10A190 on PowerPC natively, it may be unnecessary pain to use it in VM. Especially when the use case is to debug one specific app. |
Hi Sergey, I appreciate the effort you put into explaining all this to me. Unfortunately, even though I had already managed to get other macOS versions to run on my Linux system in VirtualBox, I was unable to do the same with this one. I do not own Apple hardware, so there's not much more I can try to reproduce the issue locally. However, if you are still interested in helping investigate this further, I suggest you try to compile and run the following program in the system where Turbo is unresponsive, and report on the result. I am suspicious about #include <stdio.h>
#include <errno.h>
#include <string.h>
#include <poll.h>
int main()
{
int fd = 0;
FILE *file = stdin;
struct pollfd pollfds[1];
pollfds[0].fd = fd;
pollfds[0].events = POLLIN;
while (true) {
if (poll(pollfds, 1, 50) < 0) {
fprintf(stderr, "'poll' error: %s\n", strerror(errno));
break;
}
if (pollfds[0].revents & POLLERR) {
fprintf(stderr, "fd %d error: POLLERR\n", fd);
break;
}
if (pollfds[0].revents & POLLHUP) {
fprintf(stderr, "fd %d error: POLLHUP\n", fd);
break;
}
if (pollfds[0].revents & POLLIN) {
fprintf(stderr, "fd %d success: POLLIN\n", fd);
char s[256];
fgets(s, sizeof(s), file);
}
}
} For example, the expected output of the program if you press Enter three times is:
If on your system the program prints something else, then the problem is actually related to Cheers. |
Just for the record, if the standard 10.6.8 installs in your setup, then choosing to install Rosetta along (it is in optional installs or something pretty obvious during installation) will enable building and running (I do not expect anyone installing specifically pre-release build of 10.6, it hardly makes sense and is considerably more problematic both to install and maintain.)
Let me try. |
@magiblot Apparently it does not work :) After adding |
Oh well: So yes, poll is known to be broken. Could we have a fallback? |
@magiblot If you could help with the fallback code that does not rely on |
Hi Sergey! Sorry for the delay. Could you please try with the following changes in the In --- a/source/platform/stdioctl.cpp
+++ b/source/platform/stdioctl.cpp
@@ -40,16 +40,7 @@ namespace tvision
StdioCtl::StdioCtl() noexcept
{
if (getEnv<TStringView>("TVISION_USE_STDIO").empty())
- {
- for (int fd : {0, 1, 2})
- if (auto *name = ::ttyname(fd))
- if ((ttyfd = ::open(name, O_RDWR)) != -1)
- break;
- // Last resort, although this may lead to 100% CPU usage because
- // /dev/tty is not supported by macOS's poll(),
- if (ttyfd == -1)
- ttyfd = ::open("/dev/tty", O_RDWR);
- }
+ ttyfd = ::open("/dev/tty", O_RDWR);
if (ttyfd != -1)
{ In --- a/source/platform/events.cpp
+++ b/source/platform/events.cpp
@@ -10,6 +10,7 @@ using std::chrono::steady_clock;
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#include <sys/select.h>
#endif
namespace tvision
@@ -135,17 +136,35 @@ static void pollHandles(PollData &pd, int ms) noexcept
{
auto &fds = pd.items;
auto &states = pd.states;
- if (poll(fds.data(), fds.size(), ms) > 0)
- for (size_t i = 0; i < fds.size(); ++i)
+ fd_set readFds;
+ FD_ZERO(&readFds);
+ int maxFd = -1;
+ for (size_t i = 0; i < fds.size(); ++i)
+ if (fds[i].fd < FD_SETSIZE)
{
- if ( (fds[i].revents & POLLHUP) ||
- ((fds[i].revents & POLLIN) && fdEmpty(fds[i].fd)) )
- // Broken pipe or EOF will cause poll to return immediately,
- // so remove it from the list.
- states[i] = psDisconnect;
- else if (fds[i].revents & POLLIN)
- states[i] = psReady;
+ FD_SET(fds[i].fd, &readFds);
+ if (fds[i].fd > maxFd)
+ maxFd = fds[i].fd;
}
+ if (maxFd >= 0)
+ {
+ struct timeval timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = ms*1000;
+
+ if ( select( maxFd + 1, &readFds, nullptr, nullptr,
+ (ms < 0 ? nullptr : &timeout) ) >= 0 )
+ {
+ for (size_t i = 0; i < fds.size(); ++i)
+ if (fds[i].fd < FD_SETSIZE && FD_ISSET(fds[i].fd, &readFds))
+ {
+ if (fdEmpty(fds[i].fd))
+ states[i] = psDisconnect;
+ else
+ states[i] = psReady;
+ }
+ }
+ }
}
#else Cheers. |
@magiblot I rebuilt |
ne 4. 2. 2024 v 9:49 odesílatel Sergey Fedorov ***@***.***>
napsal:
@magiblot <https://github.com/magiblot> I rebuilt turbo with the patch,
and now graphics is gone, but those sliders on the right are clickable, I
can create subsections of empty screen :)
0F99AC79-2D35-4CE2-B664-C99D28CC68AF.jpeg (view on web)
<https://github.com/magiblot/turbo/assets/92015510/3fbf9f95-3ca0-497f-b02f-f48839e24854>
465AF797-B33A-4BAC-B87C-982924C44983.jpeg (view on web)
<https://github.com/magiblot/turbo/assets/92015510/7620d07a-8a0e-438c-8e68-a0146300626d>
The reason can be missing switch to alternate screen, or usual escape codes
doesn't work
… —
Reply to this email directly, view it on GitHub
<#65 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEFO422JU34FGKUCTVXGQ3YR5DSVAVCNFSM6AAAAABBZ3YU46VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGY2DCMBTGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Does the same happen if you undo the patch in |
@magiblot It works now! Using source from 782df70 and applying the patch above #65 (comment) |
Great. Some of the block-drawing characters are not displayed properly, but that's most likely the fault of the terminal emulator or the font it's using. You may try using a different font or copying the font from a more recent of macOS. So I think the only thing that remains broken is:
But I have no knowledge on whether that script can be made to work in the macOS version you are using. I do not wish to spend time on it, so I do not mind if it stays broken. It's not that important. |
So that we can support older macOS versions. See magiblot/turbo#65.
@magiblot Thank you very much for helping to fix this! For icon thing, I will take a look, if it is an easy fix, I will make a PR, otherwise indeed it is not something important. |
I have built, ran tests and tried to launch the binary on macOS 14.2.1 (arm64) and 10.6 (ppc). In both cases build and tests are fine. However, when I run the binary on 10.6, there is no graphical output, the terminal window is just blank. No error or crash happens, it just shows nothing.
ncurses
seems to work with other apps (I have no idea if it works perfectly, but I certainly do get graphical output in terminal with other apps using it.)@magiblot Any idea what may be the cause?
The text was updated successfully, but these errors were encountered: