aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-12-01 19:52:00 -0800
committerZachary T Welch <zw@superlucidity.net>2009-12-02 13:26:26 -0800
commiteaf10f69de969652d03742809b9c970158b90719 (patch)
treebb382e74018d2352a0ee05912d53c34b28ad6113 /src
parent34654359a918edae10ca7dd7ebc0a487fdf609a4 (diff)
downloadriscv-openocd-eaf10f69de969652d03742809b9c970158b90719.zip
riscv-openocd-eaf10f69de969652d03742809b9c970158b90719.tar.gz
riscv-openocd-eaf10f69de969652d03742809b9c970158b90719.tar.bz2
remove BUILD_IOUTIL symbol
Add ioutil_stubs.c to provide an empty ioutil_init() routine. Add ioutil.h to prevent applications from needing to declare it. Allows unconditionally calling that function during startup, and the resulting libocdhelper library API is now more stable. Prints a DEBUG message when the stub implementation is included.
Diffstat (limited to 'src')
-rw-r--r--src/ecosboard.c8
-rw-r--r--src/helper/Makefile.am3
-rw-r--r--src/helper/ioutil.h27
-rw-r--r--src/helper/ioutil_stubs.c29
-rw-r--r--src/openocd.c7
5 files changed, 61 insertions, 13 deletions
diff --git a/src/ecosboard.c b/src/ecosboard.c
index dcd497c..cfb5765 100644
--- a/src/ecosboard.c
+++ b/src/ecosboard.c
@@ -23,6 +23,7 @@
#include "types.h"
#include "jtag.h"
+#include "ioutil.h"
#include "configuration.h"
#include "xsvf.h"
#include "svf.h"
@@ -942,8 +943,6 @@ static int add_default_dirs(void)
return ERROR_OK;
}
-int ioutil_init(struct command_context *cmd_ctx);
-
int main(int argc, char *argv[])
{
/* ramblockdevice will be the same address every time. The deflate app uses a buffer 16mBytes out, so we
@@ -1080,13 +1079,8 @@ int main(int argc, char *argv[])
command_set_output_handler(cmd_ctx, configuration_output_handler, NULL);
command_context_mode(cmd_ctx, COMMAND_CONFIG);
-#if BUILD_IOUTIL
if (ioutil_init(cmd_ctx) != ERROR_OK)
- {
return EXIT_FAILURE;
- }
-#endif
-
#ifdef CYGPKG_PROFILE_GPROF
COMMAND_REGISTER(cmd_ctx, NULL, "ecosboard_profile", eCosBoard_handle_eCosBoard_profile_command,
diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am
index 22b3c33..01e805e 100644
--- a/src/helper/Makefile.am
+++ b/src/helper/Makefile.am
@@ -27,6 +27,8 @@ libhelper_la_SOURCES = \
if IOUTIL
libhelper_la_SOURCES += ioutil.c
+else
+libhelper_la_SOURCES += ioutil_stubs.c
endif
libhelper_la_CFLAGS =
@@ -38,6 +40,7 @@ endif
noinst_HEADERS = \
binarybuffer.h \
configuration.h \
+ ioutil.h \
types.h \
log.h \
command.h \
diff --git a/src/helper/ioutil.h b/src/helper/ioutil.h
new file mode 100644
index 0000000..855ae55
--- /dev/null
+++ b/src/helper/ioutil.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * *
+ * 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 2 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef HELPER_IOUTILS_H
+#define HELPER_IOUTILS_H
+
+struct command_context;
+
+int ioutil_init(struct command_context *cmd_ctx);
+
+#endif // HELPER_IOUTILS_H
diff --git a/src/helper/ioutil_stubs.c b/src/helper/ioutil_stubs.c
new file mode 100644
index 0000000..1171a6f
--- /dev/null
+++ b/src/helper/ioutil_stubs.c
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * *
+ * 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 2 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "ioutil.h"
+
+int ioutil_init(struct command_context *cmd_ctx)
+{
+ LOG_DEBUG("libocdhelper was built without I/O utility support");
+ return ERROR_OK;
+}
diff --git a/src/openocd.c b/src/openocd.c
index 2043a92..1f45837 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -30,6 +30,7 @@
#include "openocd.h"
#include "jtag.h"
+#include "ioutil.h"
#include "configuration.h"
#include "xsvf.h"
#include "svf.h"
@@ -85,8 +86,6 @@ static int log_target_callback_event_handler(struct target *target, enum target_
return ERROR_OK;
}
-int ioutil_init(struct command_context *cmd_ctx);
-
static bool init_at_startup = true;
COMMAND_HANDLER(handle_noinit_command)
@@ -227,12 +226,8 @@ int openocd_main(int argc, char *argv[])
cmd_ctx = setup_command_handler(NULL);
-#if BUILD_IOUTIL
if (ioutil_init(cmd_ctx) != ERROR_OK)
- {
return EXIT_FAILURE;
- }
-#endif
LOG_OUTPUT("For bug reports, read\n\t"
"http://openocd.berlios.de/doc/doxygen/bugs.html"