diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2023-01-14 18:20:59 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-01-15 11:06:27 +0000 |
commit | 800bc000a08b37e22d2b36d32fd448624712a881 (patch) | |
tree | 87149cae9acb83db4a98a873b81515a99200d790 /firmware/include/buflib_malloc.h | |
parent | 92565e9246f3a47b90fea4a436ecfd8e7a1198b8 (diff) | |
download | rockbox-800bc000a08b37e22d2b36d32fd448624712a881.tar.gz rockbox-800bc000a08b37e22d2b36d32fd448624712a881.zip |
buflib: Add pinned get/put data functions
These are more efficient than separate pin/unpin calls because
pin count increment and decrement can be done cheaply when the
data pointer is known.
Secondly, pinned access can be made safe against preemption by
hardware interrupts or other CPU cores; buflib_get_data() can't.
This makes it more useful under different threading models and
for SMP targets; both of which are not particularly relevant to
Rockbox now, but might be in the future.
Change-Id: I09284251b83bbbc59ef88a494c8fda26a7f7ef26
Diffstat (limited to 'firmware/include/buflib_malloc.h')
-rw-r--r-- | firmware/include/buflib_malloc.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/firmware/include/buflib_malloc.h b/firmware/include/buflib_malloc.h index 32c837e7b7..a17c75c29a 100644 --- a/firmware/include/buflib_malloc.h +++ b/firmware/include/buflib_malloc.h | |||
@@ -50,4 +50,16 @@ static inline void *buflib_get_data(struct buflib_context *ctx, int handle) | |||
50 | } | 50 | } |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | static inline void *buflib_get_data_pinned(struct buflib_context *ctx, int handle) | ||
54 | { | ||
55 | buflib_pin(ctx, handle); | ||
56 | return buflib_get_data(ctx, handle); | ||
57 | } | ||
58 | |||
59 | void _buflib_malloc_put_data_pinned(struct buflib_context *ctx, void *data); | ||
60 | static inline void buflib_put_data_pinned(struct buflib_context *ctx, void *data) | ||
61 | { | ||
62 | _buflib_malloc_put_data_pinned(ctx, data); | ||
63 | } | ||
64 | |||
53 | #endif /* _BUFLIB_MALLOC_H_ */ | 65 | #endif /* _BUFLIB_MALLOC_H_ */ |