sim/common: Fix warnings: "warning: implicit declaration of function..."
authorStafford Horne <shorne@gmail.com>
Wed, 27 Mar 2019 21:40:30 +0000 (06:40 +0900)
committerStafford Horne <shorne@gmail.com>
Wed, 27 Mar 2019 21:40:30 +0000 (06:40 +0900)
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>.

sim/common/ChangeLog
sim/common/hw-device.c
sim/common/hw-events.c
sim/common/hw-handles.c
sim/common/sim-fpu.c
sim/common/sim-options.c
sim/common/sim-watch.c

index 653a2fb639d01197e85b4bf48e19d1af4650a405..53dde497681c4f0f9972618d9a56150f145101fa 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-28  Stafford Horne  <shorne@gmail.com>
+
+       * 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>.
+
 2019-03-28  Stafford Horne  <shorne@gmail.com>
 
        * Make-common.in (sim-arange_h): Remove sim-arange.c
index ee1bfad893aa184ba8283b1805de8a351f2db68e..458ee22caab34055a660836a4bdab3034a2cac38 100644 (file)
 #include <stdlib.h>
 #endif
 
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
 /* Address methods */
 
 const hw_unit *
index e6523365bdbdeaf281f069e2f9f348482abb88fd..f78be2aa46439356745a6f72d32c41c40171c7c3 100644 (file)
@@ -23,6 +23,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-events.h"
 
+#if HAVE_STRING_H
+#include <string.h>
+#endif
 
 /* The hw-events object is implemented using sim-events */
 
index 2848b9bcb5541df7a16fbf6171409aa65641fc6c..d05656235db6abff229f87a65f7180653d2fef90 100644 (file)
@@ -23,6 +23,9 @@
 #include "hw-main.h"
 #include "hw-base.h"
 
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
 
 struct hw_handle_mapping
 {
index 81cdbf5061517aa73113e33897f7528e2a9e2f91..74f5fd488c3409c5546faffe28b2d94bac4aa460 100644 (file)
@@ -41,6 +41,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-io.h"
 #include "sim-assert.h"
 
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
 
 /* Debugging support.
    If digits is -1, then print all digits.  */
index 69aebfe3d0a9ff8cf7d6f4b70dd07729d42174e1..dc4a71203a06afbc4b65c62dcfd84994b5edfe15 100644 (file)
@@ -17,6 +17,7 @@ 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 "config.h"
 #include "sim-main.h"
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -29,6 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdlib.h>
 #endif
 #include <ctype.h>
+#include <stdio.h>
 #include "libiberty.h"
 #include "sim-options.h"
 #include "sim-io.h"
index 6c357f8267a43ba97fc7c4c8d64e4a26b4b2190b..174336b3773821b205ed04adeeffd07fbacec3c4 100644 (file)
@@ -17,12 +17,14 @@ 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 "config.h"
 #include "sim-main.h"
 #include "sim-options.h"
 
 #include "sim-assert.h"
 
 #include <ctype.h>
+#include <stdio.h>
 
 #ifdef HAVE_STRING_H
 #include <string.h>