diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2017-06-21 16:42:38 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-06-29 11:56:08 +0100 |
commit | cb6c52b42559a0730cf6d7ae7ed841e31399496f (patch) | |
tree | 7bda0bf6445062f85d2f511dd28336a261067137 /risu.h | |
parent | 471b24f6d36610a143ecdcb851b752d62e7572b0 (diff) |
risu: parameterise send/receive functions
This is a precursor to record/playback support. Instead of passing the
socket fd we now pass helper functions for reading/writing and
responding. This will allow us to do the rest of the record/playback
cleanly outside of the main worker function.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20170621154244.28309-5-alex.bennee@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: fixed checkpatch nits]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'risu.h')
-rw-r--r-- | risu.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -57,17 +57,28 @@ struct reginfo; /* Functions operating on reginfo */ +/* Function prototypes for read/write helper functions. + * + * We pass the helper function to send_register_info and + * recv_and_compare_register_info which can either be backed by the + * traditional network socket or a trace file. + */ +typedef int (*write_fn) (void *ptr, size_t bytes); +typedef int (*read_fn) (void *ptr, size_t bytes); +typedef void (*respond_fn) (int response); + /* Send the register information from the struct ucontext down the socket. * Return the response code from the master. * NB: called from a signal handler. */ -int send_register_info(int sock, void *uc); +int send_register_info(write_fn write_fn, void *uc); /* Read register info from the socket and compare it with that from the * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch. * NB: called from a signal handler. */ -int recv_and_compare_register_info(int sock, void *uc); +int recv_and_compare_register_info(read_fn read_fn, + respond_fn respond, void *uc); /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on |