8000 build_system/xfa: change API to fix alignment by maribu · Pull Request #20960 · RIOT-OS/RIOT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

build_system/xfa: change API to fix alignment #20960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions core/lib/include/xfa.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
*
* @internal
*/
#define _XFA(name, prio) \
#define _XFA(type, name, prio) \
NO_SANITIZE_ARRAY \
__attribute__((used, section(".xfa." #name "." #prio)))
__attribute__((used, section(".xfa." #name "." #prio))) _Alignas(type) type

/**
* @brief helper macro for other XFA_* macros
*
* @internal
*/
#define _XFA_CONST(name, prio) \
#define _XFA_CONST(type, name, prio) \
NO_SANITIZE_ARRAY \
__attribute__((used, section(".roxfa." #name "." #prio)))
__attribute__((used, section(".roxfa." #name "." #prio))) _Alignas(type) type

/**
* @brief Define a read-only cross-file array
Expand All @@ -73,8 +73,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
#define XFA_INIT_CONST(type, name) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
_XFA_CONST(name, 0_) type name [0] = {}; \
_XFA_CONST(name, 9_) type name ## _end [0] = {}; \
_XFA_CONST(type, name, 0_) name [0] = {}; \
_XFA_CONST(type, name, 9_) name ## _end [0] = {}; \
_Pragma("GCC diagnostic pop") \
extern const unsigned __xfa_dummy

Expand All @@ -95,8 +95,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
#define XFA_INIT(type, name) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
_XFA(name, 0_) type name [0] = {}; \
_XFA(name, 9_) type name ## _end [0] = {}; \
_XFA(type, name, 0_) name [0] = {}; \
_XFA(type, name, 9_) name ## _end [0] = {}; \
_Pragma("GCC diagnostic pop") \
extern const unsigned __xfa_dummy

Expand Down Expand Up @@ -136,12 +136,13 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
*
* Add this to the type in a variable definition, e.g.:
*
* XFA(driver_params, 0) driver_params_t _onboard = { .pin=42 };
* XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
*
* @param[in] type type of the xfa elements
* @param[in] xfa_name name of the xfa
* @param[in] prio priority within the xfa
*/
#define XFA(xfa_name, prio) _XFA(xfa_name, 5_ ## prio)
#define XFA(type, xfa_name, prio) _XFA(type, xfa_name, 5_ ## prio)

/**
* @brief Define variable in read-only cross-file array
Expand All @@ -150,12 +151,13 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
*
* Add this to the type in a variable definition, e.g.:
*
* XFA(driver_params, 0) driver_params_t _onboard = { .pin=42 };
* XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
*
* @param[in] type type of the xfa elements
* @param[in] xfa_name name of the xfa
* @param[in] prio priority within the xfa
*/
#define XFA_CONST(xfa_name, prio) _XFA_CONST(xfa_name, 5_ ## prio)
#define XFA_CONST(type, xfa_name, prio) _XFA_CONST(type, xfa_name, 5_ ## prio)

/**
* @brief Add a pointer to cross-file array
Expand All @@ -174,8 +176,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
* @param[in] entry pointer variable to add to xfa
*/
#define XFA_ADD_PTR(xfa_name, prio, name, entry) \
_XFA_CONST(xfa_name, 5_ ## prio) \
__typeof__(entry) xfa_name ## _ ## prio ## _ ## name = entry
_XFA_CONST(__typeof__(entry), xfa_name, 5_ ## prio) \
xfa_name ## _ ## prio ## _ ## name = entry

/**
* @brief Calculate number of entries in cross-file array
Expand Down
4 changes: 2 additions & 2 deletions cpu/esp32/periph/sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ static_assert(SDMMC_CONFIG_NUMOF == ARRAY_SIZE(_sdmmc_devs),
static_assert(SDMMC_CONFIG_NUMOF <= SOC_SDMMC_NUM_SLOTS,
"SDMMC_CONFIG_NUMOF is greater than the supported number of slots");

XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_0 = (sdmmc_dev_t * const)&_sdmmc_devs[0];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_0 = (sdmmc_dev_t * const)&_sdmmc_devs[0];
#if SDMMC_CONFIG_NUMOF > 1
XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_sdmmc_devs[1];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_1 = (sdmmc_dev_t * const)&_sdmmc_devs[1];
#endif

/* forward declaration of internal functions */
Expand Down
4 changes: 2 additions & 2 deletions cpu/stm32/periph/sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ static_assert(SDMMC_CONFIG_NUMOF < 3, "MCU supports only 2 SDIO/SD/MMC interface
static_assert(SDMMC_CONFIG_NUMOF < 2, "MCU supports only 1 SDIO/SD/MMC interface");
#endif

XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_sdmmc_devs[0];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_1 = (sdmmc_dev_t * const)&_sdmmc_devs[0];
#if SDMMC_CONFIG_NUMOF > 1
XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_2 = (sdmmc_dev_t * const)&_sdmmc_devs[1];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_2 = (sdmmc_dev_t * const)&_sdmmc_devs[1];
#endif

static inline bool _use_dma(const sdmmc_conf_t *conf)
Expand Down
2 changes: 1 addition & 1 deletion drivers/include/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* MTD devices expose a block based erase and write interface. In that, they
* are the distinct from block devices (like hard disks) on which individual
* bytes can be overwritten. The [Linux MTD FAQ](http://www.linux-mtd.infradead.org/faq/general.html)

Check warning on line 25 in drivers/include/mtd.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* has a convenient comparison (beware though of terminology differences
* outlined below). They can be erased (with some granularity, often wearing
* out the erased area a bit), and erased areas can be written to (sometimes
Expand Down Expand Up @@ -116,7 +116,7 @@
uint32_t page_size; /**< Size of the pages in the MTD */
uint32_t write_size; /**< Minimum size and alignment of writes to the device */
#if defined(MODULE_MTD_WRITE_PAGE) || DOXYGEN
void *work_area; /**< sector-sized buffer (only present when @ref mtd_write_page is enabled) */

Check warning on line 119 in drivers/include/mtd.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
#endif
} mtd_dev_t;

Expand Down Expand Up @@ -164,7 +164,7 @@
* @param idx Priority of the MTD device pointer within the XFA
*/
#define MTD_XFA_ADD(dev, idx) \
XFA_CONST(mtd_dev_xfa, idx) mtd_dev_t *mtd ## idx = (mtd_dev_t *)&(dev)
XFA_CONST(mtd_dev_t, mtd_dev_xfa, idx) *mtd ## idx = (mtd_dev_t *)&(dev)

/**
* @brief Number of MTDs defined in the MTD device array in XFA
Expand Down
2 changes: 1 addition & 1 deletion drivers/include/mtd_emulated.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
.init_done = false, \
}; \
\
XFA_CONST(mtd_dev_xfa, 99) mtd_dev_t CONCAT(*mtd_emulated, n) = (mtd_dev_t *)&mtd_emulated_dev ## n
XFA_CONST(mtd_dev_t, mtd_dev_xfa, 99) CONCAT(*mtd_emulated, n) = (mtd_dev_t *)&mtd_emulated_dev ## n

Check warning on line 66 in drivers/include/mtd_emulated.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

#if MODULE_VFS_AUTO_MOUNT || DOXYGEN
/**
Expand Down
11 changes: 6 additions & 5 deletions drivers/include/sdmmc/sdmmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1397,9 +1397,10 @@
*
* @warning To ensure to have the references to all SDIO/SD/MMC device
* descriptors in this array, the low-level SDIO/SD/MMC peripheral
* drivers must define the references to their SDIO/SD/MMC
* device descriptors as XFA members by using the macro
* `XFA_CONST(sdmmc_devs, 0)` as shown in the example below.
* drivers must define the references to their SDIO/SD/MMC device
* descriptors as XFA members by using the macro
* `XFA_CONST(sdmmc_dev_t *, sdmmc_devs, 0)` as shown in the example
* below.
*
* For example, if the low-level
* SDIO/SD/MMC peripheral driver defines an MCU-specific SDIO/SD/MMC
Expand All @@ -1422,8 +1423,8 @@
* },
* };
*
* XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[0];
* XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_2 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[1];
* XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_1 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[0];

Check warning on line 1426 in drivers/include/sdmmc/sdmmc.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_2 = (sdmmc_dev_t * const)&_mcu_sdmmc_devs[1];

Check warning on line 1427 in drivers/include/sdmmc/sdmmc.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd_sdcard/mtd_sdcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const mtd_desc_t mtd_sdcard_driver = {
.params = &sdcard_spi_params[n] \
}; \
\
XFA_CONST(mtd_dev_xfa, m) mtd_dev_t CONCAT(*mtd, m) = (mtd_dev_t *)&mtd_sdcard_dev ## n
XFA_CONST(mtd_dev_t, mtd_dev_xfa, m) CONCAT(*mtd, m) = (mtd_dev_t *)&mtd_sdcard_dev ## n

#define MTD_SDCARD_DEV_FS(n, m, filesystem) \
VFS_AUTO_MOUNT(filesystem, VFS_MTD(mtd_sdcard_dev ## n), VFS_DEFAULT_SD(n), m)
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd_sdmmc/mtd_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const mtd_desc_t mtd_sdmmc_driver = {
.sdmmc_idx = n, \
}; \
\
XFA_CONST(mtd_dev_xfa, m) mtd_dev_t CONCAT(*mtd, m) = (mtd_dev_t *)&mtd_sdmmc_dev ## n
XFA_CONST(mtd_dev_t, mtd_dev_xfa, m) CONCAT(*mtd, m) = (mtd_dev_t *)&mtd_sdmmc_dev ## n

#if IS_USED(MODULE_MTD_SDCARD_DEFAULT)
/* we use /sd1 as default mount point for coexistence with mtd_sdcard */
Expand Down
4 changes: 2 additions & 2 deletions drivers/sdmmc/sdmmc_sdhc.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ static_assert(SDHC_CONFIG_NUMOF < 3, "MCU supports only 2 SDHC peripherals");
static_assert(SDHC_CONFIG_NUMOF < 2, "MCU supports only 1 SDHC peripheral");
#endif

XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_0 = (sdmmc_dev_t * const)&_sdhc_devs[0];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_0 = (sdmmc_dev_t * const)&_sdhc_devs[0];
#if SDHC_CONFIG_NUMOF > 1
XFA_CONST(sdmmc_devs, 0) sdmmc_dev_t * const _sdmmc_1 = (sdmmc_dev_t * const)&_sdhc_devs[1];
XFA_CONST(sdmmc_dev_t * const, sdmmc_devs, 0) _sdmmc_1 = (sdmmc_dev_t * const)&_sdhc_devs[1];
#endif

static int _set_clock_rate(sdmmc_dev_t *dev, sdmmc_clock_rate_t rate);
Expand Down
4 changes: 2 additions & 2 deletions examples/suit_update/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
#if IS_USED(MODULE_SUIT_STORAGE_VFS)
XFA_USE(char*, suit_storage_files_reg);
#ifdef CPU_NATIVE
XFA(suit_storage_files_reg, 0) char* _slot0 = VFS_DEFAULT_DATA "/SLOT0.txt";
XFA(suit_storage_files_reg, 1) char* _slot1 = VFS_DEFAULT_DATA "/SLOT1.txt";
XFA(char*, suit_storage_files_reg, 0) _slot0 = VFS_DEFAULT_DATA "/SLOT0.txt";
XFA(char*, suit_storage_files_reg, 1) _slot1 = VFS_DEFAULT_DATA "/SLOT1.txt";
#endif
#endif

Expand Down
8 changes: 4 additions & 4 deletions sys/include/auto_init_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ typedef struct {
* @param priority Priority level @ref auto_init_prio_t
*/
#define AUTO_INIT(function, priority) \
XFA_CONST(auto_init_xfa, priority) \
auto_init_module_t auto_init_xfa_ ## function \
XFA_CONST(auto_init_module_t, auto_init_xfa, priority) \
auto_init_xfa_ ## function \
= { .init = (auto_init_fn_t)function, \
.prio = priority, \
.name = XTSTR(function) }
#else
#define AUTO_INIT(function, priority) \
XFA_CONST(auto_init_xfa, priority) \
auto_init_module_t auto_init_xfa_ ## function \
XFA_CONST(auto_init_module_t, auto_init_xfa, priority) \
auto_init_xfa_ ## function \
= { .init = (auto_init_fn_t)function }
#endif

Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/nanocoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
* @param name internal name of the resource entry, must be unique
*/
#define NANOCOAP_RESOURCE(name) \
XFA_CONST(coap_resources_xfa, 0) coap_resource_t CONCAT(coap_resource_, name) =
XFA_CONST(coap_resource_t, coap_resources_xfa, 0) CONCAT(coap_resource_, name) =
#else
/**
* @brief Global CoAP resource list
Expand Down Expand Up @@ -1897,7 +1897,7 @@
*
* @returns amount of bytes written to @p buf
*/
size_t coap_put_option(uint8_t *buf, uint16_t lastonum, uint16_t onum, const void *odata, size_t olen);

Check warning on line 1900 in sys/include/net/nanocoap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

/**
* @brief Insert block1 option into buffer
Expand Down Expand Up @@ -2339,4 +2339,4 @@
}
#endif
#endif /* NET_NANOCOAP_H */
/** @} */

Check warning on line 2342 in sys/include/net/nanocoap.h

View workflow job for this annotation

GitHub Actions / static-tests

source file is too long
2 changes: 1 addition & 1 deletion sys/include/stdio_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void stdio_close(void);
* @param _write write function
*/
#define STDIO_PROVIDER(_type, _open, _close, _write) \
XFA_CONST(stdio_provider_xfa, 0) stdio_provider_t stdio_ ##_type = { \
XFA_CONST(stdio_provider_t, stdio_provider_xfa, 0) stdio_ ##_type = { \
.open = _open, \
.close = _close, \
.write = _write, \
Expand Down
2 changes: 1 addition & 1 deletion sys/include/suit/storage/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* #include "xfa.h"
*
* XFA_USE(char*, suit_storage_files_reg);
* XFA(suit_storage_files_reg, 0) char* _firmware_0 = VFS_DEFAULT_DATA "/FW0.TXT";
* XFA(char*, suit_storage_files_reg, 0) _firmware_0 = VFS_DEFAULT_DATA "/FW0.TXT";
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Once registered its content may be securely updated via SUIT by specifying the
Expand Down
4 changes: 2 additions & 2 deletions sys/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* The overall design goals are:
* - Provide implementations for all newlib "file" syscalls
* - Keep it simple, do not add every possible file operation from Linux VFS.
* - Easy to map existing file system implementations for resource constrained systems onto the VFS layer API

Check warning on line 22 in sys/include/vfs.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* - Avoid keeping a central `enum` of all file system drivers that has to be kept up to date with external packages etc.

Check warning on line 23 in sys/include/vfs.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* - Use POSIX `<errno.h>` numbers as negative return codes for errors, avoid the global `errno` variable.

Check warning on line 24 in sys/include/vfs.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* - Only absolute paths to files (no per-process working directory)
* - No dynamic memory allocation
*
Expand Down Expand Up @@ -330,8 +330,8 @@
#define VFS_AUTO_MOUNT(type, mtd, path, idx) \
static type ## _desc_t fs_desc_ ## idx = mtd; \
\
XFA(vfs_mountpoints_xfa, 0) \
vfs_mount_t _mount_mtd_ ## idx = { \
XFA(vfs_mount_t, vfs_mountpoints_xfa, 0) \
_mount_mtd_ ## idx = { \
.fs = &type ## _file_system, \
.mount_point = path, \
.private_data = &fs_desc_ ## idx, \
Expand Down
2 changes: 1 addition & 1 deletion sys/suit/storage/flashwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ static suit_storage_flashwrite_t suit_storage_flashwrite = {
},
};

XFA(suit_storage_reg, 0) suit_storage_t* suit_storage_flashwrite_ptr = &suit_storage_flashwrite.storage;
XFA(suit_storage_t *, suit_storage_reg, 0) suit_storage_flashwrite_ptr = &suit_storage_flashwrite.storage;
2 changes: 1 addition & 1 deletion sys/suit/storage/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ suit_storage_ram_t suit_storage_ram = {
},
};

XFA(suit_storage_reg, 0) suit_storage_t* suit_storage_ram_ptr = &suit_storage_ram.storage;
XFA(suit_storage_t *, suit_storage_reg, 0) suit_storage_ram_ptr = &suit_storage_ram.storage;
2 changes: 1 addition & 1 deletion sys/suit/storage/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ suit_storage_vfs_t suit_storage_vfs = {
},
};

XFA(suit_storage_reg, 0) suit_storage_t *suit_storage_vfs_ptr = &suit_storage_vfs.storage;
XFA(suit_storage_t *, suit_storage_reg, 0) suit_storage_vfs_ptr = &suit_storage_vfs.storage;
7 changes: 4 additions & 3 deletions tests/build_system/xfa/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

#include <stdio.h>
#include <stdint.h>

#include "xfa.h"

Expand All @@ -35,12 +34,14 @@ int main(void)
unsigned n = XFA_LEN(xfatest_t, xfatest);
printf("xfatest[%u]:\n", n);
for (unsigned i = 0; i < n; i++) {
printf("[%u] = %u, \"%s\"\n", i, xfatest[i].val, xfatest[i].text);
printf("[%u] = %u, \"%s\", '%c'\n",
i, xfatest[i].val, xfatest[i].text, xfatest[i].letter);
}
n = XFA_LEN(xfatest_t, xfatest_const);
printf("xfatest_const[%u]:\n", n);
for (unsigned i = 0; i < n; i++) {
printf("[%u] = %u, \"%s\"\n", i, xfatest_const[i].val, xfatest_const[i].text);
printf("[%u] = %u, \"%s\", '%c'\n",
i, xfatest_const[i].val, xfatest_const[i].text, xfatest_const[i].letter);
}

return 0;
Expand Down
16 changes: 10 additions & 6 deletions tests/build_system/xfa/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

def testfunc(child):
child.expect_exact('Cross file array test')
child.expect_exact('xfatest[2]:')
child.expect_exact('[0] = 1, "xfatest1"')
child.expect_exact('[1] = 2, "xfatest2"')
child.expect_exact('xfatest_const[2]:')
child.expect_exact('[0] = 123, "xfatest_const1"')
child.expect_exact('[1] = 45, "xfatest_const2"')
child.expect_exact('xfatest[4]:')
child.expect_exact("[0] = 1, \"xfatest1\", 'a'")
child.expect_exact("[1] = 2, \"xfatest2\", 'b'")
child.expect_exact("[2] = 3, \"xfatest3\", 'c'")
child.expect_exact("[3] = 4, \"xfatest4\", 'd'")
child.expect_exact('xfatest_const[4]:')
child.expect_exact("[0] = 123, \"xfatest_const1\", 'a'")
child.expect_exact("[1] = 45, \"xfatest_const2\", 'b'")
child.expect_exact("[2] = 42, \"xfatest_const3\", 'c'")
child.expect_exact("[3] = 44, \"xfatest_const4\", 'd'")


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions tests/build_system/xfa/xfatest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
typedef struct {
unsigned val;
const char *text;
char letter;
} xfatest_t;

#endif /* DOXYGEN */
Expand Down
4 changes: 2 additions & 2 deletions tests/build_system/xfa/xfatest1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "xfa.h"
#include "xfatest.h"

XFA(xfatest, 0) xfatest_t _xfatest1 = { .val = 1, .text = "xfatest1" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const1 = { .val = 123, .text = "xfatest_const1" };
XFA(xfatest_t, xfatest, 0) _xfatest1 = { .val = 1, .text = "xfatest1", .letter = 'a' };
XFA_CONST(xfatest_t, xfatest_const, 0) _xfatest_const1 = { .val = 123, .text = "xfatest_const1", .letter = 'a' };
9 changes: 7 additions & 2 deletions tests/build_system/xfa/xfatest2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "xfa.h"
#include "xfatest.h"

XFA(xfatest, 0) xfatest_t _xfatest2 = { .val = 2, .text = "xfatest2" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const2 = { .val = 45, .text = "xfatest_const2" };
XFA(xfatest_t, xfatest, 1) _xfatest2 = { .val = 2, .text = "xfatest2", .letter = 'b' };
XFA(xfatest_t, xfatest, 3) _xfatest4 = { .val = 4, .text = "xfatest4", .letter = 'd' };
XFA(xfatest_t, xfatest, 2) _xfatest3 = { .val = 3, .text = "xfatest3", .letter = 'c' };

XFA_CONST(xfatest_t, xfatest_const, 1) _xfatest_const2 = { .val = 45, .text = "xfatest_const2", .letter = 'b' };
XFA_CONST(xfatest_t, xfatest_const, 3) _xfatest_const4 = { .val = 44, .text = "xfatest_const4", .letter = 'd' };
XFA_CONST(xfatest_t, xfatest_const, 2) _xfatest_const3 = { .val = 42, .text = "xfatest_const3", .letter = 'c' };
10 changes: 5 additions & 5 deletions tests/unittests/tests-core/tests-core-xfa-data1.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
#include "xfa.h"
#include "tests-core-xfa.h"

XFA(xfatest, 0) xfatest_t _xfatest1 = { .val = 12345, .text = "xfatest1" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const1 = { .val = 0xcafe, .text = "xfatest_const1" };
XFA(xfatest_t, xfatest, 0) _xfatest1 = { .val = 12345, .text = "xfatest1" };
XFA_CONST(xfatest_t, xfatest_const, 0) _xfatest_const1 = { .val = 0xcafe, .text = "xfatest_const1" };

XFA_INIT(xfatest_t, xfatest_use);
XFA_INIT_CONST(xfatest_t, xfatest_use_const);

XFA(xfatest_use, 0) xfatest_t _xfatest_use1 = { .val = 3333, .text = "xfatest_use1" };
XFA(xfatest_use, 0) xfatest_t _xfatest_use_again = { .val = 555, .text = "xfatest use again" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const1 =
XFA(xfatest_t, xfatest_use, 0) _xfatest_use1 = { .val = 3333, .text = "xfatest_use1" };
XFA(xfatest_t, xfatest_use, 0) _xfatest_use_again = { .val = 555, .text = "xfatest use again" };
XFA_CONST(xfatest_t, xfatest_use_const, 0) _xfatest_use_const1 =
{ .val = 4444, .text = "xfatest_use_const1" };

int hack1;
Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/tests-core/tests-core-xfa-data2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
#include "xfa.h"
#include "tests-core-xfa.h"

XFA(xfatest, 0) xfatest_t _xfatest2 = { .val = 0xbeef, .text = "another test string" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const2 =
XFA(xfatest_t, xfatest, 0) _xfatest2 = { .val = 0xbeef, .text = "another test string" };
XFA_CONST(xfatest_t, xfatest_const, 0) _xfatest_const2 =
{ .val = 32444, .text = "const string xfa 2" };
XFA(xfatest_use, 0) xfatest_t _xfatest_use2 = { .val = 11111, .text = "xfatest_use2" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const2 =
XFA(xfatest_t, xfatest_use, 0) _xfatest_use2 = { .val = 11111, .text = "xfatest_use2" };
XFA_CONST(xfatest_t, xfatest_use_const, 0) _xfatest_use_const2 =
{ .val = 22222, .text = "xfatest_use_const2" };

/** @} */
Loading
0