rpmio/set.c array initialization uses ... gcc extension
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
RPM |
New
|
Undecided
|
Unassigned |
Bug Description
Building rpm 5.4.12 on x86_64-
This issue wouldn't affect compilation with gcc but it does affect any other compiler that doesn't implement the gcc "..." array initialization extension.
gmake[2]: Entering directory `/local/
source='set.c' object='set.lo' libtool=yes \
/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 454: syntax error before or at: ...
cc: acomp failed for set.c
gmake[2]: *** [set.lo] Error 1
gmake[2]: Leaving directory `/local/
In both cases, it's an array that's using ... syntax for initialization, which gcc supports and many other compilers won't. I checked the C11 standard and designated array initialization with ... is not part of the standard.
I could generate the table by hand for the 256 elements in the first array, but the array at line 454 has 65536 elements. I'm open to any suggestions you might have for what the least onerous way to make this portable might be.
Yep the "portability" issues in set.c are well known.
I'm waiting for a usage case (I know what my usage case is) to appear
before attempting some rather straightforward fixes with one-shot
initialization for tables that are 65K in size. There is a run-time approach
(using a variable) and there is a build time approach including a
large table generated by a helper.
Meanwhile the rpmio/set.c code is largely just sketched in atm (and
tested against ALT linux while installing: no build time support has been
attempted yet, it isn't hard but is seriously different).
Ultimately I'd like to see rpmio/set.c have an API that was interchangeable
with rpmio/rpmbf.c (Bloom filters) so that either the set.c or the Bloom filter
could be switched seamlessly: there are many usage cases in RPM for algorithms
that can compute subset booleans efficiently, and set.c does not have
false positive probabilities as Bloom filters do (but set.c is likelier more costly
in both memory/cpu than Bloom filters are).
The easy fix is of course to ignore set.c and add some #ifdef that hides
all the problematic code on OpenSolaris. That is a perfectly acceptable
WORKSFORME patch considering the lack of any usage case for set.c
dependencies outside of ALT Linux.