From 8d8d509d59334ba6d031f0b8544bf7aa89ac546e Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 2 Sep 2010 11:59:07 +0100 Subject: [PATCH] misc: Made (most) of the headers c++ friendly No functional changes Signed-off-by: Michel Pollet --- include/avr_mcu_section.h | 7 +++++++ simavr/sim/sim_avr.h | 8 ++++++++ simavr/sim/sim_core.h | 8 ++++++++ simavr/sim/sim_cycle_timers.h | 8 ++++++++ simavr/sim/sim_elf.h | 8 ++++++++ simavr/sim/sim_gdb.h | 8 ++++++++ simavr/sim/sim_hex.h | 8 ++++++++ simavr/sim/sim_interrupts.h | 8 ++++++++ simavr/sim/sim_io.h | 8 ++++++++ simavr/sim/sim_irq.h | 8 ++++++++ simavr/sim/sim_regbit.h | 7 +++++++ simavr/sim/sim_twi.h | 8 ++++++++ simavr/sim/sim_vcd_file.h | 8 ++++++++ 13 files changed, 102 insertions(+) diff --git a/include/avr_mcu_section.h b/include/avr_mcu_section.h index bce65e8..8991ac5 100644 --- a/include/avr_mcu_section.h +++ b/include/avr_mcu_section.h @@ -40,6 +40,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + enum { AVR_MMCU_TAG = 0, AVR_MMCU_TAG_NAME, @@ -150,5 +154,8 @@ const uint8_t _##_tag _MMCU_ = { _tag, 1, _val } #endif /* __AVR__ */ +#ifdef __cplusplus +}; +#endif #endif diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index 8904dfd..5b20178 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -24,6 +24,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef uint64_t avr_cycle_count_t; typedef uint16_t avr_io_addr_t; @@ -253,6 +257,10 @@ uint8_t avr_core_watch_read(avr_t *avr, uint16_t addr); // this might activate gdb server void avr_sadly_crashed(avr_t *avr, uint8_t signal); +#ifdef __cplusplus +}; +#endif + #include "sim_io.h" #include "sim_regbit.h" #include "sim_interrupts.h" diff --git a/simavr/sim/sim_core.h b/simavr/sim/sim_core.h index fb818a0..dc9e12f 100644 --- a/simavr/sim/sim_core.h +++ b/simavr/sim/sim_core.h @@ -22,6 +22,10 @@ #ifndef SIM_CORE_H_ #define SIM_CORE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * Instruction decoder, run ONE instruction */ @@ -91,4 +95,8 @@ void avr_dump_state(avr_t * avr); #endif +#ifdef __cplusplus +}; +#endif + #endif /* SIM_CORE_H_ */ diff --git a/simavr/sim/sim_cycle_timers.h b/simavr/sim/sim_cycle_timers.h index 8496b6c..49a9851 100644 --- a/simavr/sim/sim_cycle_timers.h +++ b/simavr/sim/sim_cycle_timers.h @@ -25,6 +25,10 @@ #include "sim_avr.h" +#ifdef __cplusplus +extern "C" { +#endif + // converts a number of usec to a number of machine cycles, at current speed static inline avr_cycle_count_t avr_usec_to_cycles(avr_t * avr, uint32_t usec) { @@ -56,4 +60,8 @@ void avr_cycle_timer_cancel(avr_t * avr, avr_cycle_timer_t timer, void * param); // avr_cycle_count_t avr_cycle_timer_process(avr_t * avr); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_CYCLE_TIMERS_H___ */ diff --git a/simavr/sim/sim_elf.h b/simavr/sim/sim_elf.h index 53edaeb..cd70f4d 100644 --- a/simavr/sim/sim_elf.h +++ b/simavr/sim/sim_elf.h @@ -24,6 +24,10 @@ #include "avr_mcu_section.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef ELF_SYMBOLS #define ELF_SYMBOLS 1 #endif @@ -72,4 +76,8 @@ int elf_read_firmware(const char * file, elf_firmware_t * firmware); void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware); +#ifdef __cplusplus +}; +#endif + #endif /* ELF_H_ */ diff --git a/simavr/sim/sim_gdb.h b/simavr/sim/sim_gdb.h index 49a5645..497dabf 100644 --- a/simavr/sim/sim_gdb.h +++ b/simavr/sim/sim_gdb.h @@ -22,9 +22,17 @@ #ifndef __SIM_GDB_H__ #define __SIM_GDB_H__ +#ifdef __cplusplus +extern "C" { +#endif + int avr_gdb_init(avr_t * avr); // call from the main AVR decoder thread int avr_gdb_processor(avr_t * avr, uint32_t sleep); +#ifdef __cplusplus +}; +#endif + #endif diff --git a/simavr/sim/sim_hex.h b/simavr/sim/sim_hex.h index 83f50db..f187c38 100644 --- a/simavr/sim/sim_hex.h +++ b/simavr/sim/sim_hex.h @@ -25,6 +25,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + // parses a hex text string 'src' of at max 'maxlen' characters, decodes it into 'buffer' int read_hex_string(const char * src, uint8_t * buffer, int maxlen); @@ -49,4 +53,8 @@ uint8_t * read_ihex_file(const char * fname, uint32_t * dsize, uint32_t * start) // hex dump from pointer 'b' for 'l' bytes with string prefix 'w' void hdump(const char *w, uint8_t *b, size_t l); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_HEX_H___ */ diff --git a/simavr/sim/sim_interrupts.h b/simavr/sim/sim_interrupts.h index b03cfbb..659a497 100644 --- a/simavr/sim/sim_interrupts.h +++ b/simavr/sim/sim_interrupts.h @@ -25,6 +25,10 @@ #include "sim_avr.h" #include "sim_irq.h" +#ifdef __cplusplus +extern "C" { +#endif + // interrupt vector for the IO modules typedef struct avr_int_vector_t { uint8_t vector; // vector number, zero (reset) is reserved @@ -60,4 +64,8 @@ int avr_clear_interupt_if(avr_t * avr, avr_int_vector_t * vector, uint8_t old); // this allows tracing of pending interupts avr_irq_t * avr_get_interupt_irq(avr_t * avr, uint8_t v); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_INTERUPTS_H__ */ diff --git a/simavr/sim/sim_io.h b/simavr/sim/sim_io.h index eeb2f48..8fa338d 100644 --- a/simavr/sim/sim_io.h +++ b/simavr/sim/sim_io.h @@ -24,6 +24,10 @@ #include "sim_avr.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * used by the ioports to implement their own features * see avr_eeprom.* for an example, and avr_ioctl(). @@ -78,4 +82,8 @@ struct avr_irq_t * avr_io_getirq(avr_t * avr, uint32_t ctl, int index); #define AVR_IOMEM_IRQ_ALL 8 struct avr_irq_t * avr_iomem_getirq(avr_t * avr, avr_io_addr_t addr, int index); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_IO_H__ */ diff --git a/simavr/sim/sim_irq.h b/simavr/sim/sim_irq.h index b09137b..d7a9db0 100644 --- a/simavr/sim/sim_irq.h +++ b/simavr/sim/sim_irq.h @@ -24,6 +24,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* * Internal IRQ system * @@ -73,4 +77,8 @@ void avr_connect_irq(avr_irq_t * src, avr_irq_t * dst); // register a notification 'hook' for 'irq' -- 'param' is anything that your want passed back as argument void avr_irq_register_notify(avr_irq_t * irq, avr_irq_notify_t notify, void * param); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_IRQ_H__ */ diff --git a/simavr/sim/sim_regbit.h b/simavr/sim/sim_regbit.h index 1f74197..8325d63 100644 --- a/simavr/sim/sim_regbit.h +++ b/simavr/sim/sim_regbit.h @@ -24,6 +24,10 @@ #include "sim_avr.h" +#ifdef __cplusplus +extern "C" { +#endif + #define ARRAY_SIZE(_aa) (sizeof(_aa) / sizeof((_aa)[0])) /* @@ -104,5 +108,8 @@ static inline uint8_t avr_regbit_get_array(avr_t * avr, avr_regbit_t *rb, int co #define AVR_IO_REGBIT(_io, _bit) { . reg = (_io), .bit = (_bit), .mask = 1 } #define AVR_IO_REGBITS(_io, _bit, _mask) { . reg = (_io), .bit = (_bit), .mask = (_mask) } +#ifdef __cplusplus +}; +#endif #endif /* __SIM_REGBIT_H__ */ diff --git a/simavr/sim/sim_twi.h b/simavr/sim/sim_twi.h index 195098a..dbb6b96 100644 --- a/simavr/sim/sim_twi.h +++ b/simavr/sim/sim_twi.h @@ -29,6 +29,10 @@ #include #include "sim_irq.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * The TWI system is designed to be representing the same state as * a TWI/i2c bus itself. So each "state" of the bus is an IRQ sent @@ -93,4 +97,8 @@ void twi_bus_stop(twi_bus_t * bus); void twi_slave_init(twi_slave_t * slave, uint8_t address, void * param); void twi_slave_detach(twi_slave_t * slave); +#ifdef __cplusplus +}; +#endif + #endif /* SIM_TWI_H_ */ diff --git a/simavr/sim/sim_vcd_file.h b/simavr/sim/sim_vcd_file.h index a94c256..7f55be8 100644 --- a/simavr/sim/sim_vcd_file.h +++ b/simavr/sim/sim_vcd_file.h @@ -28,6 +28,10 @@ #include #include "sim_irq.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Value Change dump module for simavr. * @@ -85,4 +89,8 @@ int avr_vcd_start(avr_vcd_t * vcd); // stops recording signal values into the file int avr_vcd_stop(avr_vcd_t * vcd); +#ifdef __cplusplus +}; +#endif + #endif /* __SIM_VCD_FILE_H__ */ -- 2.20.1