misc: Switched to using C11
This commit is contained in:
parent
52e5357e99
commit
c530bd077b
|
@ -1 +1 @@
|
|||
Subproject commit 8435287300e5ca9af9f889c529e7b1fa019c42fb
|
||||
Subproject commit 44e142d4f97863e669737707a1a22bf40ed49bbc
|
|
@ -9,7 +9,7 @@ Q := @
|
|||
endif
|
||||
|
||||
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts \
|
||||
-std=gnu99 -g3 -MD -I./target \
|
||||
-std=c11 -g3 -MD -I./target \
|
||||
-I. -Iinclude -I$(PLATFORM_DIR)
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
# include "traceswo.h"
|
||||
#endif
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
static bool cmd_version(target *t, int argc, char **argv);
|
||||
static bool cmd_help(target *t, int argc, char **argv);
|
||||
|
||||
|
@ -117,6 +119,9 @@ int command_process(target *t, char *cmd)
|
|||
for(char *s = cmd; *s; s++)
|
||||
if((*s == ' ') || (*s == '\t')) argc++;
|
||||
|
||||
/* This needs replacing with something more sensible.
|
||||
* It should be pinging -Wvla among other things, and it failing is straight-up UB
|
||||
*/
|
||||
argv = alloca(sizeof(const char *) * argc);
|
||||
|
||||
/* Tokenize cmd to find argv */
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "rtt.h"
|
||||
#endif
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
enum gdb_signal {
|
||||
GDB_SIGINT = 2,
|
||||
GDB_SIGTRAP = 5,
|
||||
|
@ -361,6 +363,8 @@ static void exec_q_rcmd(const char *packet,int len)
|
|||
|
||||
/* calculate size and allocate buffer for command */
|
||||
datalen = len / 2;
|
||||
// This needs replacing with something more sensible.
|
||||
// It should be pinging -Wvla among other things, and it failing is straight-up UB
|
||||
data = alloca(datalen + 1);
|
||||
/* dehexify command */
|
||||
unhexify(data, packet, datalen);
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
#ifndef __GENERAL_H
|
||||
#define __GENERAL_H
|
||||
|
||||
#if !defined(_GNU_SOURCE)
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#define _GNU_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#if !defined(__USE_MINGW_ANSI_STDIO)
|
||||
# define __USE_MINGW_ANSI_STDIO 1
|
||||
#endif
|
||||
|
|
|
@ -59,7 +59,7 @@ static void jtagtap_reset(void)
|
|||
if (platform_hwversion() == 0) {
|
||||
gpio_clear(TRST_PORT, TRST_PIN);
|
||||
for (volatile size_t i = 0; i < 10000; i++)
|
||||
asm("nop");
|
||||
__asm__("nop");
|
||||
gpio_set(TRST_PORT, TRST_PIN);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -92,7 +92,7 @@ void platform_nrst_set_val(bool assert)
|
|||
volatile int i;
|
||||
if (assert) {
|
||||
gpio_clear(NRST_PORT, NRST_PIN);
|
||||
for(i = 0; i < 10000; i++) asm("nop");
|
||||
for(i = 0; i < 10000; i++) __asm__("nop");
|
||||
} else {
|
||||
gpio_set(NRST_PORT, NRST_PIN);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ int platform_hwversion(void)
|
|||
gpio_set(GPIOB, hwversion_pins);
|
||||
|
||||
/* Wait a little to make sure the pull up is in effect... */
|
||||
for(int i = 0; i < 100; i++) asm("nop");
|
||||
for(int i = 0; i < 100; i++) __asm__("nop");
|
||||
|
||||
/* Get all pins that are pulled low in hardware.
|
||||
* This also sets all the "unused" pins to 1.
|
||||
|
@ -119,7 +119,7 @@ int platform_hwversion(void)
|
|||
gpio_clear(GPIOB, hwversion_pins);
|
||||
|
||||
/* Wait a little to make sure the pull down is in effect... */
|
||||
for(int i = 0; i < 100; i++) asm("nop");
|
||||
for(int i = 0; i < 100; i++) __asm__("nop");
|
||||
|
||||
/* Get all the pins that are pulled high in hardware. */
|
||||
uint16_t pins_positive = gpio_get(GPIOB, hwversion_pins);
|
||||
|
@ -243,7 +243,7 @@ void platform_nrst_set_val(bool assert)
|
|||
gpio_set_val(NRST_PORT, NRST_PIN, !assert);
|
||||
}
|
||||
if (assert) {
|
||||
for(int i = 0; i < 10000; i++) asm("nop");
|
||||
for(int i = 0; i < 10000; i++) __asm__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,9 @@ void dfu_jump_app_if_valid(void)
|
|||
/* Set vector table base address */
|
||||
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
||||
/* Initialise master stack pointer */
|
||||
asm volatile ("msr msp, %0"::"g"
|
||||
__asm__ volatile("msr msp, %0"::"g"
|
||||
(*(volatile uint32_t*)app_address));
|
||||
/* Jump to application */
|
||||
(*(void(**)())(app_address + 4))();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,10 +101,9 @@ void dfu_jump_app_if_valid(void)
|
|||
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
||||
#endif
|
||||
/* Initialise master stack pointer */
|
||||
asm volatile ("msr msp, %0"::"g"
|
||||
__asm__ volatile("msr msp, %0"::"g"
|
||||
(*(volatile uint32_t*)app_address));
|
||||
/* Jump to application */
|
||||
(*(void(**)())(app_address + 4))();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static void gdb_if_update_buf(void)
|
|||
{
|
||||
while (cdcacm_get_config() != 1);
|
||||
#ifdef STM32F4
|
||||
asm volatile ("cpsid i; isb");
|
||||
__asm__ volatile("cpsid i; isb");
|
||||
if (count_new) {
|
||||
memcpy(buffer_out, double_buffer_out, count_new);
|
||||
count_out = count_new;
|
||||
|
@ -89,7 +89,7 @@ static void gdb_if_update_buf(void)
|
|||
out_ptr = 0;
|
||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
asm volatile ("cpsie i; isb");
|
||||
__asm__ volatile("cpsie i; isb");
|
||||
#else
|
||||
count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
|
||||
buffer_out, CDCACM_PACKET_SIZE);
|
||||
|
@ -129,4 +129,3 @@ unsigned char gdb_if_getchar_to(int timeout)
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -629,7 +629,7 @@ void debug_monitor_handler_c(struct ex_frame *sp)
|
|||
|
||||
}
|
||||
|
||||
asm(".globl debug_monitor_handler\n"
|
||||
__asm__(".globl debug_monitor_handler\n"
|
||||
".thumb_func\n"
|
||||
"debug_monitor_handler: \n"
|
||||
" mov r0, sp\n"
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
static inline void __attribute__((always_inline))
|
||||
stub_exit(const int code)
|
||||
{
|
||||
asm("bkpt %0"::"i"(code));
|
||||
__asm__("bkpt %0"::"i"(code));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -466,10 +466,10 @@ static bool rp_attach(target *t)
|
|||
if (!cortexm_attach(t))
|
||||
return false;
|
||||
|
||||
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
|
||||
uint16_t *table = alloca(RP_MAX_TABLE_SIZE);
|
||||
uint16_t table_offset = target_mem_read32(t, BOOTROM_MAGIC_ADDR + 4);
|
||||
if (!table || target_mem_read(t, table, table_offset, RP_MAX_TABLE_SIZE))
|
||||
struct rp_priv_s *ps = (struct rp_priv_s*)t->target_storage;
|
||||
uint16_t table[RP_MAX_TABLE_SIZE];
|
||||
uint16_t table_offset = target_mem_read32( t, BOOTROM_MAGIC_ADDR + 4);
|
||||
if (target_mem_read(t, table, table_offset, RP_MAX_TABLE_SIZE))
|
||||
return false;
|
||||
if (rp2040_fill_table(ps, table, RP_MAX_TABLE_SIZE))
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue