lib: Add memcat_p(): paste 2 pointer arrays together
This adds a helper to paste 2 pointer arrays together, useful for merging various types of attribute arrays. There are a few places in the kernel tree where this is open coded, and I just added one more in the STM class. The naming is inspired by memset_p() and memcat(), and partial credit for it goes to Andy Shevchenko. This patch adds the function wrapped in a type-enforcing macro and a test module. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
6c7e4b6882
commit
ce76d938dd
@@ -131,6 +131,13 @@ static inline void *memset_p(void **p, void *v, __kernel_size_t n)
|
||||
return memset64((uint64_t *)p, (uintptr_t)v, n);
|
||||
}
|
||||
|
||||
extern void **__memcat_p(void **a, void **b);
|
||||
#define memcat_p(a, b) ({ \
|
||||
BUILD_BUG_ON_MSG(!__same_type(*(a), *(b)), \
|
||||
"type mismatch in memcat_p()"); \
|
||||
(typeof(*a) *)__memcat_p((void **)(a), (void **)(b)); \
|
||||
})
|
||||
|
||||
#ifndef __HAVE_ARCH_MEMCPY
|
||||
extern void * memcpy(void *,const void *,__kernel_size_t);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user