Bug 723296

Summary: be64toh usage needs autoconf
Product: [Fedora] Fedora Reporter: Frank Ch. Eigler <fche>
Component: elfutilsAssignee: Roland McGrath <roland>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fche, mjw, mjw, pmachata, roland
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-20 17:28:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Frank Ch. Eigler 2011-07-19 16:25:06 UTC
For the next version of elfutils, commit 725aad5d2f8b7 added a call
to be64toh(3), but neglects to autoconf-detect/assert its presence,
leading to build failures on older libc's.

Comment 1 Mark Wielaard 2011-07-20 12:44:15 UTC
Even very old glibc have bswap_64, so maybe the simplest (untested) fix would be something like:

#ifndef be64toh
#include <byteswap.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define be64toh(x) bswap_64 (x)
#else
#define be64toh(x) (x)
#endif
#endif

Comment 2 Roland McGrath 2011-07-20 16:41:40 UTC
You can do that on the portability branch.
Just observe style with space after # for nested directives.

Comment 3 Mark Wielaard 2011-07-20 17:28:35 UTC
Tested and committed to the portable branch:

commit 878fd6e6184d791ff81cbd6d18fe8d968d3d843e
Author: Mark Wielaard <mjw>
Date:   Wed Jul 20 14:59:02 2011 +0200

    Add fallback for be64toh if not defined.