1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

Hopefully good fix for va_listval build fails (re: 41ed8047, etc.)

The last commit still failed to build on macOS M1. That va_listval
macro keeps causing trouble. It's an AST thing that is defined in
src/lib/libast/features/common. That looks like some incredibly
opaque attempt to make it compatible with everything, and clearly
it no longer works properly on all systems. I don't dare touch it,
though. That code looks like any minimal change will probably break
the build on some system or other.

src/lib/libast/features/hack:
- Add feature test to check if that macro needs (0) no workaround,
  or (1) the workaround from the 93v- beta, or (2) the FreeBSD one.
  Whichever version compiles first, it will use. If none does, this
  test will not output a value, which will be treated as 0.

src/lib/libast/hash/hashalloc.c,
src/lib/libast/string/tokscan.c:
- Update to use the result of the hack feature test.

src/lib/libast/Mamfile:
- Update for new #include dependencies.
This commit is contained in:
Martijn Dekker 2021-05-16 04:27:57 +02:00
parent 41ed8047d2
commit 153c4b56e8
4 changed files with 71 additions and 10 deletions

View file

@ -523,6 +523,13 @@ make install
done fastfind.o generated
make hashalloc.o
make hash/hashalloc.c
make FEATURE/hack implicit
meta FEATURE/hack features/%>FEATURE/% features/hack hack
make features/hack
prev FEATURE/common implicit
done features/hack
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" run features/hack
done FEATURE/hack generated
make hash/hashlib.h implicit
make include/hash.h implicit
make include/hashpart.h implicit
@ -909,6 +916,7 @@ make install
done tokline.o generated
make tokscan.o
make string/tokscan.c
prev FEATURE/hack implicit
prev include/tok.h implicit
prev include/ast.h implicit
done string/tokscan.c
@ -3118,12 +3126,7 @@ make install
make locale_attr.h implicit
done locale_attr.h dontcare virtual
done comp/gross_sgi.h dontcare
make FEATURE/hack implicit
meta FEATURE/hack features/%>FEATURE/% features/hack hack
make features/hack
done features/hack
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" run features/hack
done FEATURE/hack generated
prev FEATURE/hack implicit
prev include/ls.h implicit
prev include/ast.h implicit
done comp/gross.c

View file

@ -1 +1,51 @@
hdr locale_attr
tst - -DVAL=0 - -DVAL=1 - -DVAL=2 note{ probing need for va_listval() workaround }end output{
/*
* This workaround test is needed until libast's va_listval macro from
* features/common can be made to work properly on all systems (if ever).
* It is used in hash/hashalloc.c and string/tokscan.c.
*/
#include "FEATURE/common"
#if _STD_ && _hdr_stdarg
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void foo(int bar, ...)
{
va_list ap;
va_start(ap, bar);
if (bar==1)
{
#if VAL == 0
/*
* Normal version. On some systems, it won't compile.
*/
va_copy(ap, va_listval(va_arg(ap, va_listarg)));
#elif VAL == 1
/*
* This is the workaround from the ksh 93v- beta distribution.
*/
va_list np;
np = va_listval(va_arg(ap, va_listarg));
va_copy(ap, np);
#elif VAL == 2
/*
* This is the workaround from the FreeBSD port.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255308
*/
va_listarg np;
np = va_listval(va_arg(ap, va_listarg));
va_copy(ap, np);
#endif
}
va_end(ap);
}
int main()
{
foo(0,"one",2);
printf("#define _need_va_listval_workaround %d\n",VAL);
return 0;
}
}end

View file

@ -31,6 +31,7 @@
static const char id_hash[] = "\n@(#)$Id: hash (AT&T Research) 1996-08-11 $\0\n";
#include "hashlib.h"
#include "FEATURE/hack"
Hash_info_t hash_info = { 0 };
@ -152,10 +153,13 @@ hashalloc(Hash_table_t* ref, ...)
va_copy(*vp, ap);
vp++;
}
#if __clang__ && __SIZEOF_POINTER__ == 4 && !__APPLE__
#if _need_va_listval_workaround
{
# if _need_va_listval_workaround == 2
va_listarg np;
# else
va_list np;
# endif
np = va_listval(va_arg(ap, va_listarg));
va_copy(ap, np);
}

View file

@ -64,6 +64,7 @@
#include <ast.h>
#include <tok.h>
#include "FEATURE/hack"
static char empty[1];
@ -234,10 +235,13 @@ tokscan(register char* s, char** nxt, const char* fmt, ...)
prv_f = f;
f = va_arg(ap, char*);
va_copy(prv_ap, ap);
#if __clang__ && __SIZEOF_POINTER__ == 4 && !__APPLE__
#if _need_va_listval_workaround
{
# if _need_va_listval_workaround == 2
va_listarg np;
# else
va_list np;
# endif
np = va_listval(va_arg(ap, va_listarg));
va_copy(ap, np);
}