After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769139 - g_log_writer_journald uses non-standard 'htole64' function
g_log_writer_journald uses non-standard 'htole64' function
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
2.49.x
Other FreeBSD
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-07-25 04:12 UTC by Ting-Wei Lan
Modified: 2016-07-25 16:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ting-Wei Lan 2016-07-25 04:12:16 UTC
g_log_writer_journald is no longer guarded by HAVE_LIBSYSTEMD, so the code inside the function will be compiled on all platforms. However, it uses non-standard 'htole64' function, which is not available in POSIX.

gmessages.c:1933:18: error: implicit declaration of function 'htole64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          nstr = htole64 (length);
                 ^
1 error generated.

FreeBSD requires sys/endian.h to be included before using htole64, but I think we should not add #include to fix the problem because the code is never used on non-Linux systems.
Comment 1 Ting-Wei Lan 2016-07-25 15:40:08 UTC
Simply including endian.h doesn't work. glibc uses endian.h, but other systems may use sys/endian.h.

glib/gmessages.c:109:10: fatal error: 'endian.h' file not found

As 'htole64' is non-standard, isn't it required to check it before using?
Comment 2 Simon McVittie 2016-07-25 15:42:46 UTC
If the function needs to be compiled on non-Linux, this sounds like a job for GINT64_TO_LE().
Comment 3 Simon McVittie 2016-07-25 15:43:27 UTC
Or possibly GUINT64_TO_LE, depending on signedness.