mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
As reported in PR libsframe/33168, the libsframe tests don't build on
Solaris. The failure is
In file included from libsframe/testsuite/libsframe.decode/be-flipping.c:28:
/usr/include/dejagnu.h:48:1: error: conflicting types for ‘wait’; have ‘void(void)’
48 | wait (void)
| ^~~~
In file included from /usr/include/stdlib.h:16,
from libsframe/testsuite/libsframe.decode/be-flipping.c:21:
/usr/include/sys/wait.h:85:14: note: previous declaration of ‘wait’ with type ‘pid_t(int *)’ {aka ‘long int(int *)’}
85 | extern pid_t wait(int *);
| ^~~~
We have a combination of two factors here:
* Solaris <stdlib.h> has
and configure.ac predefines __EXTENSIONS__ due to the use of
AC_USE_SYSTEM_EXTENSIONS.
* This conflicts with <dejagnu.h>'s definition
void
wait (void)
{
...
}
While this version of wait was removed in upstream DejaGnu, the removal
only happened after the latest release, 1.6.3.
To avoid this, I've moved all testsuite includes into a new
sframe-test.h, adding a workaround for the wait conflict.
-Wall and -I$(srcdir) have been removed from AM_CPPFLAGS since they
don't seem to be needed. To fix the Makefile fragment duplication, the
local.mk files now use $(testsuite_LDADD) and $(testsuite_CPPFLAGS)
throughout.
Tested on {i386,amd64}-pc-solaris2.11, {sparc,sparcv9}-sun-solaris2.11,
{x86_64,i686}-pc-linux-gnu, and amd64-pc-freebsd14.0.
Coauthored-By: Alan Modra <amodra@gmail.com>
2025-08-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Alan Modra <amodra@gmail.com>
libsframe:
PR libsframe/33168
* testsuite/sframe-test.h: New file.
* testsuite/libsframe.decode/be-flipping.c: Replace includes by
sframe-test.h.
* testsuite/libsframe.decode/frecnt-1.c: Likewise.
* testsuite/libsframe.decode/frecnt-2.c: Likewise.
* testsuite/libsframe.encode/encode-1.c: Likewise.
* testsuite/libsframe.find/findfre-1.c: Likewise.
* testsuite/libsframe.find/findfunc-1.c: Likewise.
* testsuite/libsframe.find/plt-findfre-1.c: Likewise.
* testsuite/libsframe.find/plt-findfre-2.c: Likewise.
* Makefile.am (AM_CPPFLAGS): Remove -I$(srcdir).
* Makefile.in: Regenerate.
* testsuite/local.mk (testsuite_LDADD): New variable.
(testsuite_CPPFLAGS): Likewise.
* testsuite/libsframe.decode/local.mk: Use $(testsuite_LDADD),
$(testsuite_CPPFLAGS).
* testsuite/libsframe.encode/local.mk: Likewise.
* testsuite/libsframe.find/local.mk: Likewise.
99 lines
2.8 KiB
C
99 lines
2.8 KiB
C
/* frecnt-2.c -- Test for decoder in libsframe.
|
|
|
|
Copyright (C) 2022-2025 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "sframe-test.h"
|
|
|
|
/*
|
|
* SFrame info from the following source (2 fde 8 fres):
|
|
* static int cnt;
|
|
* int foo() { return ++cnt; }
|
|
* int main() { return foo(); }
|
|
*/
|
|
#define DATA "DATA2"
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
sframe_decoder_ctx *dctx = NULL;
|
|
uint32_t nfres, fsize;
|
|
int32_t fstart;
|
|
unsigned char finfo;
|
|
unsigned int i;
|
|
int err = 0;
|
|
FILE *fp;
|
|
struct stat st;
|
|
char *sf_buf;
|
|
size_t sf_size;
|
|
uint8_t rep_block_size;
|
|
|
|
#define TEST(name, cond) \
|
|
do \
|
|
{ \
|
|
if (cond) \
|
|
pass (name); \
|
|
else \
|
|
fail (name); \
|
|
} \
|
|
while (0)
|
|
|
|
fp = fopen (DATA, "r");
|
|
if (fp == NULL)
|
|
goto setup_fail;
|
|
if (fstat (fileno (fp), &st) < 0)
|
|
{
|
|
perror ("fstat");
|
|
fclose (fp);
|
|
goto setup_fail;
|
|
}
|
|
sf_buf = malloc (st.st_size);
|
|
if (sf_buf == NULL)
|
|
{
|
|
perror ("malloc");
|
|
goto setup_fail;
|
|
}
|
|
|
|
/* Execute tests. */
|
|
sf_size = fread (sf_buf, 1, st.st_size, fp);
|
|
fclose (fp);
|
|
TEST ("frecnt-2: Read data", sf_size != 0);
|
|
|
|
dctx = sframe_decode (sf_buf, sf_size, &err);
|
|
TEST ("frecnt-2: Decode setup", dctx != NULL);
|
|
|
|
unsigned int fde_cnt = sframe_decoder_get_num_fidx (dctx);
|
|
TEST ("frecnt-2: Decode FDE count", fde_cnt == 2);
|
|
|
|
for (i = 0; i < fde_cnt; ++i)
|
|
{
|
|
err = sframe_decoder_get_funcdesc_v2 (dctx, i, &nfres, &fsize, &fstart,
|
|
&finfo, &rep_block_size);
|
|
TEST ("frecnt-2: Decode get FDE", err == 0);
|
|
TEST ("frecnt-2: Decode get FRE", nfres == 4);
|
|
}
|
|
|
|
free (sf_buf);
|
|
sf_buf = NULL;
|
|
|
|
sframe_decoder_free (&dctx);
|
|
return 0;
|
|
|
|
setup_fail:
|
|
sframe_decoder_free (&dctx);
|
|
fail ("frecnt-2: Test setup");
|
|
return 1;
|
|
}
|