rpmio/set.c BYTE_ORDER patch for Solaris
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
RPM |
Fix Released
|
Medium
|
Jeff Johnson |
Bug Description
Building rpm-5.4.12 on x86_64-
rpmio/set.c fails to compile because it's expecting BYTE_ORDER to be defined, as it would be on Linux with endian.h included:
/bin/sh ../libtool --tag=CC --mode=compile cc -m64 -DHAVE_CONFIG_H -I. -I.. -I. -I.. -I../build -I../lib -I../lib -I../rpmdb -I../rpmio -I../misc -I../beecrypt/
libtool: compile: cc -m64 -DHAVE_CONFIG_H -I. -I.. -I. -I.. -I../build -I../lib -I../lib -I../rpmdb -I../rpmio -I../misc -I../beecrypt/
"set.c", line 128: syntax error before or at: ...
"set.c", line 448: #error: "unknown byte order"
cc: acomp failed for set.c
gmake[4]: *** [set.lo] Error 1
gmake[4]: Leaving directory `/local/
Note there are two syntax errors there -- I'll tackle the more difficult issue from line 128 (and elsewhere) in a separate report.
Solaris doesn't have endian.h. It has sys/byteorder.h (which actually includes sys/isa_defs.h for the important stuff). Including sys/byteorder.h gets you either _LITTLE_ENDIAN or _BIG_ENDIAN defined (to nothing). From there, it's trivial to make a set of defines that are Linux-compatible. I've had to use essentially the same patch for ruby and a few other programs that expect the BSD and Linux BYTEORDER and LITTLE_ENDIAN symbols to be defined.
The attached patch adds a configure check for sys/byteorder.h and code in system.h to rig up BYTE_ORDER, LITTLE_ENDIAN,
etc. in system.h.
NOTE: I notice that configure.ac is checking for sys/endian.h but it's not checking for just "endian.h". None of the Linux systems I have access to have a sys/endian.h, but they do have endian.h and bits/endian.h. It seems to me like the only reason the current byte order dependent code is working even for Linux is because sys/types.h eventually includes endian.h.
Ideally the ifdef guards I added in system.h would check for !defined(
If you would prefer the BYTE_ORDER defines be directly in set.c, I can provide a new patch. Alternately, it looks like set.c is derived from elsewhere. If you can provide me with where upstream is, I would be happy to report the issue to upstream.
Changed in rpm: | |
importance: | Undecided → Medium |
assignee: | nobody → Jeff Johnson (n3npq) |
milestone: | none → 5.4.13 |
status: | New → Confirmed |
Changed in rpm: | |
milestone: | 5.4.13 → 5.4.14 |
status: | Confirmed → Fix Released |
Thanks for the portable endian.h retrofit: there are likely lots
of additional issues just fixed in the NIST SHA3 digests that just got
fixed as well.
There's a number of tricky non-portable GNUisms in set.c, including " … "
initialization as well as the remaining nested static function in need of fixing.
See the -DSELF_TEST which absolutely MUST pass for any serious refactoring
of the rpmio/set.c code: the algorithm is quite complex, debugging any serious
breakage would take a week or more to figure out.