Skip to content

Commit

Permalink
fix(unittest): remove dependency with enum buffer_slot in inst_helpers.h
Browse files Browse the repository at this point in the history
inst_helpers.h has a dependency with enum buffer_slot as this is needed
by host_harness and the former includes the latter.

This patch breaks that dependency by removing a forward declaration
to `enum slot_buffer` inside host_harness.h, as C++ requires a
different syntax for forward declarations than the one used in C.

Instead, it replaces the enum with an unsigned int for functions
in host_harness.h.

Signed-off-by: Javier Almansa Sobrino <[email protected]>
Change-Id: Ia26f771f5056047e9a61b2e02fb2294928c325d6
  • Loading branch information
javieralso-arm committed Mar 22, 2023
1 parent 7582b2b commit f450817
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/common/include/fake_host/host_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#include <stdint.h>
#include <types.h>

/* Forward declaration of buffer_slot */
enum buffer_slot;

/* Fake host wrapper to read and write sysregs */
u_register_t host_read_sysreg(char *reg_name);
void host_write_sysreg(char *reg_name, u_register_t v);
Expand Down Expand Up @@ -82,7 +79,7 @@ void host_monitor_call_with_res(unsigned long id, unsigned long arg0,
*
* It returns the VA to which the buffer is mapped.
*/
void *host_buffer_arch_map(enum buffer_slot slot, unsigned long addr);
void *host_buffer_arch_map(unsigned int slot, unsigned long addr);

/*
* Fake host wrapper to unmap a buffer slot correspondig to the VA passed
Expand Down
2 changes: 1 addition & 1 deletion plat/host/host_build/src/host_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <buffer.h>
#include <host_harness.h>

void *host_buffer_arch_map(enum buffer_slot slot, unsigned long addr)
void *host_buffer_arch_map(unsigned int slot, unsigned long addr)
{
(void)slot;

Expand Down
4 changes: 2 additions & 2 deletions plat/host/host_test/src/host_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* This harness searches for a valid pointer to CB_BUFFER_MAP and calls it.
* If there is no valid pointer, the default behavior is to return addr
*/
void *host_buffer_arch_map(enum buffer_slot slot, unsigned long addr)
void *host_buffer_arch_map(unsigned int slot, unsigned long addr)
{
cb_buffer_map cb = (cb_buffer_map)get_cb(CB_BUFFER_MAP);

return (cb == NULL) ? (void *)addr : cb(slot, addr);
return (cb == NULL) ? (void *)addr : cb((enum buffer_slot)slot, addr);
}

/*
Expand Down

0 comments on commit f450817

Please sign in to comment.