Skip to content

Commit b6061d4

Browse files
committed
sim/common: Fix warnings: "warning: implicit declaration of function..."
During building of several cgen simulator's I notices the below warnings. Adding includes fixes these. Including config.h allows stdio.h to properly configure itself to expose asprintf(). The other warnings for abort, free, memset, strlen are trivial. Warnings: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c: In function ‘sim_watchpoint_install’: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c:415:10: warning: implicit declaration of function ‘asprintf’; did you mean ‘vasprintf’? [-Wimplicit-function-declaration] if (asprintf (&name, "watch-%s-%s", ^~~~~~~~ vasprintf ../../../binutils-gdb/sim/lm32/../common/hw-device.c: In function ‘hw_strdup’: ../../../binutils-gdb/sim/lm32/../common/hw-device.c:59:34: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration] char *dup = hw_zalloc (me, strlen (str) + 1); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-events.c: In function ‘hw_event_queue_schedule’: ../../../binutils-gdb/sim/lm32/../common/hw-events.c:92:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] memset (&dummy, 0, sizeof dummy); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-handles.c: In function ‘hw_handle_remove_ihandle’: ../../../binutils-gdb/sim/lm32/../common/hw-handles.c:211:4: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration] free (delete); ^~~~ ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c: In function ‘pack_fpu’: ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c:292:7: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration] abort (); ^~~~~ sim/common/ChangeLog: * sim-options.c: Include "config.h". Include <stdio.h>. * sim-watch.c: Include "config.h". Include <stdio.h>. * hw-device.c: Include <string.h>. * hw-events.c: Include <string.h>. * hw-handles.c: Include <stdlib.h>. * sim-fpu.c: Include <stdlib.h>.
1 parent ef98669 commit b6061d4

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

sim/common/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2019-03-28 Stafford Horne <[email protected]>
2+
3+
* sim-options.c: Include "config.h".
4+
Include <stdio.h>.
5+
* sim-watch.c: Include "config.h".
6+
Include <stdio.h>.
7+
* hw-device.c: Include <string.h>.
8+
* hw-events.c: Include <string.h>.
9+
* hw-handles.c: Include <stdlib.h>.
10+
* sim-fpu.c: Include <stdlib.h>.
11+
112
2019-03-28 Stafford Horne <[email protected]>
213

314
* Make-common.in (sim-arange_h): Remove sim-arange.c

sim/common/hw-device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include <stdlib.h>
2828
#endif
2929

30+
#if HAVE_STRING_H
31+
#include <string.h>
32+
#endif
33+
3034
/* Address methods */
3135

3236
const hw_unit *

sim/common/hw-events.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2323

2424
#include "sim-events.h"
2525

26+
#if HAVE_STRING_H
27+
#include <string.h>
28+
#endif
2629

2730
/* The hw-events object is implemented using sim-events */
2831

sim/common/hw-handles.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "hw-main.h"
2424
#include "hw-base.h"
2525

26+
#if HAVE_STDLIB_H
27+
#include <stdlib.h>
28+
#endif
2629

2730
struct hw_handle_mapping
2831
{

sim/common/sim-fpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
4141
#include "sim-io.h"
4242
#include "sim-assert.h"
4343

44+
#ifdef HAVE_STDLIB_H
45+
#include <stdlib.h>
46+
#endif
4447

4548
/* Debugging support.
4649
If digits is -1, then print all digits. */

sim/common/sim-options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ GNU General Public License for more details.
1717
You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1919

20+
#include "config.h"
2021
#include "sim-main.h"
2122
#ifdef HAVE_STRING_H
2223
#include <string.h>
@@ -29,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2930
#include <stdlib.h>
3031
#endif
3132
#include <ctype.h>
33+
#include <stdio.h>
3234
#include "libiberty.h"
3335
#include "sim-options.h"
3436
#include "sim-io.h"

sim/common/sim-watch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ GNU General Public License for more details.
1717
You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1919

20+
#include "config.h"
2021
#include "sim-main.h"
2122
#include "sim-options.h"
2223

2324
#include "sim-assert.h"
2425

2526
#include <ctype.h>
27+
#include <stdio.h>
2628

2729
#ifdef HAVE_STRING_H
2830
#include <string.h>

0 commit comments

Comments
 (0)