Skip to content

Add support for Haiku, a POSIX platform without thread naming and vasprintf #188

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kcgen
Copy link
Contributor

@kcgen kcgen commented Dec 4, 2021

Loguru doesn't compile on Haiku, which is a "generally" complete Posix platform - but with some addons missing, like thread naming.

Most of the thread naming is protected with #if MACOS and #elif BSD and LINUX platform branches, however some of these blocks are missing the trailing #else to cover unsupported systems (like Haiku).

This PR also simplifies vtextprintf with standard vsnprintf calls, so avoids needing the WIN32 and POSIX branches. The previous vtextprintf implementation failed on Haiku because it's missing vasprintf.

-h2a

kcgen added 2 commits December 3, 2021 19:29
Fixes an invalid conversion error on 32-bit platforms that don't
support assigning pointers directly to integers.
@kcgen kcgen force-pushed the upstream/support-haiku-1 branch from b4d2245 to 8a27e50 Compare December 4, 2021 03:29
@kcgen kcgen marked this pull request as draft December 4, 2021 03:33
Add a simple solution to a compilation warning that doesn't require any special changes to be made to already existing enums, types or logic.

loguru/loguru.cpp: In function ‘void loguru::print_preamble(char*, size_t, loguru::Verbosity, const char*, unsigned int)’:
loguru/loguru.cpp:1208:50: warning: ‘% 4d’ directive output may be truncated writing between 4 and 11 bytes into a region of size 5 [-Wformat-truncation=]
 1208 |    snprintf(level_buff, sizeof(level_buff) - 1, "% 4d", verbosity);
      |                                                  ^~~~
loguru/loguru.cpp:1208:49: note: directive argument in the range [1, 2147483647]
 1208 |    snprintf(level_buff, sizeof(level_buff) - 1, "% 4d", verbosity);
      |                                                 ^~~~~~
In file included from /usr/include/stdio.h:867,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/c++/9/ext/string_conversions.h:43,
                 from /usr/include/c++/9/bits/basic_string.h:6493,
                 from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/stdexcept:39,
                 from /usr/include/c++/9/array:39,
                 from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/functional:54,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from loguru/loguru.cpp:36:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 5 and 12 bytes into a destination of size 5
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@kcgen
Copy link
Contributor Author

kcgen commented Dec 4, 2021

Hmm.. it looks like the current master branch is actually failing CI with this:

2021-12-03_19-43

Fortunately @zivke's already submitted a one-line fix for this (#187), which is also sitting in the PR queue.

I merged @zivke's fix to this PR, just to get passing the AppVeyor tests.

@kcgen kcgen marked this pull request as ready for review April 14, 2022 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants