diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-09 02:47:00 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-09 09:44:33 -0800 |
commit | 1712d7835e0fbba60d578b52b21b95b046805757 (patch) | |
tree | b5a7413720202e0ac52b3bd07c5f481e86c7ddb5 /src | |
parent | 4882647f3ee7fc0680c49fbd27a484359fd7e86a (diff) | |
download | riscv-openocd-1712d7835e0fbba60d578b52b21b95b046805757.zip riscv-openocd-1712d7835e0fbba60d578b52b21b95b046805757.tar.gz riscv-openocd-1712d7835e0fbba60d578b52b21b95b046805757.tar.bz2 |
src/helper: wrap and clean headers.
Remove all useless 'extern' keywords from function prototypes.
Wraps long lines for readability.
Diffstat (limited to 'src')
-rw-r--r-- | src/helper/binarybuffer.h | 42 | ||||
-rw-r--r-- | src/helper/command.h | 41 | ||||
-rw-r--r-- | src/helper/configuration.h | 21 | ||||
-rw-r--r-- | src/helper/fileio.h | 22 | ||||
-rw-r--r-- | src/helper/log.h | 25 | ||||
-rw-r--r-- | src/helper/replacements.h | 7 |
6 files changed, 95 insertions, 63 deletions
diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index eef4057..5017a35 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -30,7 +30,8 @@ */ /* inlining this will help show what fn that is taking time during profiling. */ -static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int num, uint32_t value) +static inline void buf_set_u32(uint8_t* buffer, + unsigned int first, unsigned int num, uint32_t value) { if ((num == 32) && (first == 0)) { @@ -51,13 +52,16 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int } } } -static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, unsigned int num) +static inline uint32_t buf_get_u32(const uint8_t* buffer, + unsigned int first, unsigned int num) { if ((num == 32) && (first == 0)) { - return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[1]) << 8) | (((uint32_t)buffer[0]) << 0); - } else - { + return (((uint32_t)buffer[3]) << 24) | + (((uint32_t)buffer[2]) << 16) | + (((uint32_t)buffer[1]) << 8) | + (((uint32_t)buffer[0]) << 0); + } else { uint32_t result = 0; unsigned int i; @@ -71,30 +75,30 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, un } } -extern uint32_t flip_u32(uint32_t value, unsigned int num); +uint32_t flip_u32(uint32_t value, unsigned int num); -extern int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size); -extern int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, const uint8_t *mask, int size); -extern uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size); +int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size); +int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, + const uint8_t *mask, int size); +uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size); -extern uint8_t* buf_set_ones(uint8_t *buf, int count); -extern uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len); +uint8_t* buf_set_ones(uint8_t *buf, int count); +uint8_t* buf_set_buf(const uint8_t *src, int src_start, + uint8_t *dst, int dst_start, int len); -extern int str_to_buf(const char *str, int len, uint8_t *bin_buf, int buf_size, int radix); -extern char* buf_to_str(const uint8_t *buf, int size, int radix); +int str_to_buf(const char *str, int len, + uint8_t *bin_buf, int buf_size, int radix); +char* buf_to_str(const uint8_t *buf, int size, int radix); struct scan_field_s; -extern int buf_to_u32_handler(uint8_t *in_buf, void *priv, struct scan_field_s *field); +int buf_to_u32_handler(uint8_t *in_buf, void *priv, struct scan_field_s *field); #define CEIL(m, n) (((m) + (n) - 1) / (n)) /* read a uint32_t from a buffer in target memory endianness */ -static inline uint32_t fast_target_buffer_get_u32(const uint8_t *buffer, int little) +static inline uint32_t fast_target_buffer_get_u32(const uint8_t *p, int le) { - if (little) - return le_to_h_u32(buffer); - else - return be_to_h_u32(buffer); + return le ? le_to_h_u32(p) : be_to_h_u32(p); } #endif /* BINARYBUFFER_H */ diff --git a/src/helper/command.h b/src/helper/command.h index 2d0142f..70b00c3 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -84,25 +84,36 @@ typedef struct command_s struct command_s *next; } command_t; -extern command_t* register_command(command_context_t *context, command_t *parent, char *name, int (*handler)(struct command_context_s *context, char* name, char** args, int argc), enum command_mode mode, char *help); -extern int unregister_command(command_context_t *context, char *name); -extern int unregister_all_commands(command_context_t *context); -extern void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv); -extern command_context_t* copy_command_context(command_context_t* context); -extern int command_context_mode(command_context_t *context, enum command_mode mode); -extern command_context_t* command_init(void); -extern int command_done(command_context_t *context); - -extern void command_print(command_context_t *context, const char *format, ...) +command_t* register_command(command_context_t *context, + command_t *parent, char *name, + int (*handler)(struct command_context_s *context, + char* name, char** args, int argc), + enum command_mode mode, char *help); + +int unregister_command(command_context_t *context, char *name); +int unregister_all_commands(command_context_t *context); + +void command_set_output_handler(command_context_t* context, + int (*output_handler)(struct command_context_s *context, + const char* line), void *priv); + +command_context_t* copy_command_context(command_context_t* context); + +int command_context_mode(command_context_t *context, enum command_mode mode); + +command_context_t* command_init(void); +int command_done(command_context_t *context); + +void command_print(command_context_t *context, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3))); -extern void command_print_sameline(command_context_t *context, const char *format, ...) +void command_print_sameline(command_context_t *context, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3))); -extern int command_run_line(command_context_t *context, char *line); -extern int command_run_linef(command_context_t *context, const char *format, ...) +int command_run_line(command_context_t *context, char *line); +int command_run_linef(command_context_t *context, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3))); -extern void command_output_text(command_context_t *context, const char *data); +void command_output_text(command_context_t *context, const char *data); -extern void process_jim_events(void); +void process_jim_events(void); #define ERROR_COMMAND_CLOSE_CONNECTION (-600) #define ERROR_COMMAND_SYNTAX_ERROR (-601) diff --git a/src/helper/configuration.h b/src/helper/configuration.h index 16bd8d8..5d60148 100644 --- a/src/helper/configuration.h +++ b/src/helper/configuration.h @@ -25,12 +25,19 @@ #include "command.h" -extern int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]); -extern int parse_config_file(struct command_context_s *cmd_ctx); -extern void add_config_command (const char *cfg); -extern void add_script_search_dir (const char *dir); -extern int configuration_output_handler(struct command_context_s *context, const char* line); -extern FILE *open_file_from_path (char *file, char *mode); -extern char *find_file(const char *name); +int parse_cmdline_args(struct command_context_s *cmd_ctx, + int argc, char *argv[]); + +int parse_config_file(struct command_context_s *cmd_ctx); +void add_config_command(const char *cfg); + +void add_script_search_dir(const char *dir); + +int configuration_output_handler(struct command_context_s *cmd_ctx, + const char *line); + +FILE *open_file_from_path(char *file, char *mode); + +char *find_file(const char *name); #endif /* CONFIGURATION_H */ diff --git a/src/helper/fileio.h b/src/helper/fileio.h index d1e227c..3f47cb9 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -54,14 +54,20 @@ typedef struct fileio_s FILE *file; } fileio_t; -extern int fileio_write(fileio_t *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written); -extern int fileio_read(fileio_t *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read); -extern int fileio_fgets(fileio_t *fileio, uint32_t size, char *buffer); -extern int fileio_seek(fileio_t *fileio, uint32_t position); -extern int fileio_close(fileio_t *fileio); -extern int fileio_open(fileio_t *fileio, const char *url, enum fileio_access access, enum fileio_type type); -extern int fileio_read_u32(fileio_t *fileio, uint32_t *data); -extern int fileio_write_u32(fileio_t *fileio, uint32_t data); +int fileio_open(fileio_t *fileio, + const char *url, enum fileio_access access, enum fileio_type type); +int fileio_close(fileio_t *fileio); + +int fileio_seek(fileio_t *fileio, uint32_t position); +int fileio_fgets(fileio_t *fileio, uint32_t size, char *buffer); + +int fileio_read(fileio_t *fileio, + uint32_t size, uint8_t *buffer, uint32_t *size_read); +int fileio_write(fileio_t *fileio, + uint32_t size, const uint8_t *buffer, uint32_t *size_written); + +int fileio_read_u32(fileio_t *fileio, uint32_t *data); +int fileio_write_u32(fileio_t *fileio, uint32_t data); #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200) #define ERROR_FILEIO_NOT_FOUND (-1201) diff --git a/src/helper/log.h b/src/helper/log.h index f43e1e6..15bd3c8 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -59,20 +59,23 @@ enum log_levels LOG_LVL_DEBUG = 3 }; -extern void log_printf(enum log_levels level, const char *file, int line, +void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); -extern void log_printf_lf(enum log_levels level, const char *file, int line, +void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); -extern int log_register_commands(struct command_context_s *cmd_ctx); -extern int log_init(struct command_context_s *cmd_ctx); -extern int set_log_output(struct command_context_s *cmd_ctx, FILE *output); -extern void keep_alive(void); -extern void kept_alive(void); -extern void alive_sleep(int ms); -extern void busy_sleep(int ms); +int log_init(struct command_context_s *cmd_ctx); +int set_log_output(struct command_context_s *cmd_ctx, FILE *output); + +int log_register_commands(struct command_context_s *cmd_ctx); + +void keep_alive(void); +void kept_alive(void); + +void alive_sleep(int ms); +void busy_sleep(int ms); /* log entries can be paused and replayed roughly according to the try/catch/rethrow * concepts in C++ @@ -92,8 +95,8 @@ typedef struct log_callback_s struct log_callback_s *next; } log_callback_t; -extern int log_add_callback(log_callback_fn fn, void *priv); -extern int log_remove_callback(log_callback_fn fn, void *priv); +int log_add_callback(log_callback_fn fn, void *priv); +int log_remove_callback(log_callback_fn fn, void *priv); char *alloc_vprintf(const char *fmt, va_list ap); char *alloc_printf(const char *fmt, ...); diff --git a/src/helper/replacements.h b/src/helper/replacements.h index f2c6e94..a029674 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -65,7 +65,8 @@ struct timezone { #endif struct timezone; -extern int gettimeofday(struct timeval *tv, struct timezone *tz); +int gettimeofday(struct timeval *tv, struct timezone *tz); + #endif #ifndef IN_REPLACEMENTS_C @@ -105,11 +106,11 @@ void *fill_malloc(size_t size); /* GNU extensions to the C library that may be missing on some systems */ #ifndef HAVE_STRNDUP -extern char* strndup(const char *s, size_t n); +char* strndup(const char *s, size_t n); #endif /* HAVE_STRNDUP */ #ifndef HAVE_STRNLEN -extern size_t strnlen(const char *s, size_t maxlen); +size_t strnlen(const char *s, size_t maxlen); #endif /* HAVE_STRNLEN */ #ifndef HAVE_USLEEP |