-
Notifications
You must be signed in to change notification settings - Fork 6
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
import macOS fixes from blaztinn/macos #33
Conversation
Instead of `pthread_spinlock_t` use `os_unfair_lock_t` because macos is missing the pthread spinlock. `sem_init` is deprecated on macos and always returns `-1`. Use `sem_open` together with `sem_unlink` to open an exclusive sempahore in global namespace. Use `sem_wait` because `sem_timedWait` is missing on macos.
The commit `4bb735f7966eedf414aa8e24533967cffd5bbcdb` only fixed the threading limit on the decoder part. Use the limit also in the encoder.
Avoids errors on macOS like: In file included from crunch/crnlib/crn_threading.h:7: crunch/crnlib/crn_threading_pthreads.h:177:40: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions] virtual ~executable_task( void ) = default; ^ crunch/crnlib/crn_threading_pthreads.h:253:11: error: exception specification of overriding function is more lax than base version virtual ~object_task( void ) = default; ^ crunch/crnlib/crn_threading_pthreads.h:177:13: note: overridden virtual function is here virtual ~executable_task( void ) = default; ^ crunch/crnlib/crn_threading_pthreads.h:253:34: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions] virtual ~object_task( void ) = default; ^
…r will override anyway Avoids errors on macOS like: duplicate symbol __ZN6crnlib5utils10write_le64EPvy in: crn_arealist.o crn_assert.o Setting static instead of extern would also workaround the error but it's wrong and would raise warnings on other systems like FreeBSD: In file included from crunch/crnlib/crn_core.h:174: crunch/crnlib/crn_utils.h:235:8: warning: 'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10 [-Wgnu-inline-cpp-without-extern] static CRNLIB_FORCE_INLINE void write_be64(void* p, uint64 x) { ^ crunch/crnlib/crn_core.h:85:70: note: expanded from macro 'CRNLIB_FORCE_INLINE' #define CRNLIB_FORCE_INLINE inline __attribute__((__always_inline__, __gnu_inline__)) ^ Setting extern fixes the duplicate symbols error on macOS without introducing warnings on FreeBSD.
Ok, it now builds. There is one bug, though. The
|
f605370
to
d1189c5
Compare
d1189c5
to
6bcfe8e
Compare
Maybe the bug about reading file on NFS on macOS is not a macOS specific bug but a generic crunch bug about the way it does file access and specificity of network file system, I would have to test NFS on other platforms to know more. I don't see that issue as a blocking issue for this merge, as the tool can actually be built and converts properly images to and from crn on macOS. It is known crunch for Windows is able to read and write files on Windows native CIFS network share, but this is not NFS. After the macOS patches are applied the tool still builds and run on Linux (tested with GCC) and Windows (tested with MSYS2/Mingw). I consider this PR ready. |
I tested on amd64 macOS Mojave. A test on arm64 Apple with newer macOS would also be nice. |
As an alternative way to the #ifdef __APPLE__
#define CRNLIB_FORCE_INLINE inline __attribute__((__always_inline__))
#else
#define CRNLIB_FORCE_INLINE inline __attribute__((__always_inline__, __gnu_inline__))
#endif I haven't tested though. But before I replaced existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't test but seems ok
6bcfe8e
to
ec8eb7a
Compare
I noticed this implementation, like this other one or this other one is implementing the second fix discussed in #14 in addition to the first one we already do. I guess it's harmless, and this other macOS patch for macOS is know to already do both fixes. That people especially applied the second fix above our own fix, so maybe that was intentional. The two macOS ports we know both do that second fix, above or not above our first fix. So doing that second fix as well reduces diff noise between trees. |
Import macOS fixes from
blaztinn/macos
, see:The
crnlib
was already buildable on macOS when integrated in another software (like the Dæmon engine or the Netradiant editor), but not thecrunch
command line tool.The branch also features some other minor fixes around that are probably not bad.
The macOS crunch tool builds and runs, tested on amd64 macOS Mojave.
Part of original message:
This PR still builds on Linux and Windows.
This PR doesn't build on macOS yet because cd8353d introduced this:
If I temporarily revert cd8353d the build continues but then the linkage fails:
So,
We need to fix the
exception specification of overriding function is more lax than base version
error. @bmorel can you look at it? You're the one having introduced the commit triggering it so maybe you know what those errors are about… 🙂️We need to fix the linkage error.