util: remove safe_container_of() macro
This commit is contained in:
parent
6f6c32628a
commit
2e4627ba4a
11
src/util.c
11
src/util.c
@ -1,11 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
void* util_safe_container_of_helper(void* ptr, size_t offset) {
|
|
||||||
if (ptr == NULL)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return (char*) ptr - offset;
|
|
||||||
}
|
|
||||||
@ -15,9 +15,6 @@ typedef intptr_t ssize_t;
|
|||||||
#define container_of(ptr, type, member) \
|
#define container_of(ptr, type, member) \
|
||||||
((type*) ((char*) (ptr) -offsetof(type, member)))
|
((type*) ((char*) (ptr) -offsetof(type, member)))
|
||||||
|
|
||||||
#define safe_container_of(ptr, type, member) \
|
|
||||||
((type*) util_safe_container_of_helper((ptr), offsetof(type, member)))
|
|
||||||
|
|
||||||
#define unused_var(v) ((void) (v))
|
#define unused_var(v) ((void) (v))
|
||||||
|
|
||||||
#if defined(__clang__) || defined(__GNUC__)
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
@ -37,6 +34,4 @@ typedef intptr_t ssize_t;
|
|||||||
(__unused__)) int __static_assert_##__LINE__[(condition) ? 1 : -1];
|
(__unused__)) int __static_assert_##__LINE__[(condition) ? 1 : -1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WEPOLL_INTERNAL void* util_safe_container_of_helper(void* ptr, size_t offset);
|
|
||||||
|
|
||||||
#endif /* WEPOLL_UTIL_H_ */
|
#endif /* WEPOLL_UTIL_H_ */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user