Path: blob/main/contrib/llvm-project/libc/include/llvm-libc-macros/containerof-macro.h
213766 views
//===-- Definition of the containerof macro -------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIBC_MACROS_CONTAINEROF_MACRO_H9#define LLVM_LIBC_MACROS_CONTAINEROF_MACRO_H1011#include "offsetof-macro.h"1213#define __containerof(ptr, type, member) \14({ \15const __typeof(((type *)0)->member) *__ptr = (ptr); \16(type *)(void *)((const char *)__ptr - offsetof(type, member)); \17})1819#endif // LLVM_LIBC_MACROS_CONTAINEROF_MACRO_H202122