mirror of
https://gitee.com/apaki/cmake_demo.git
synced 2025-05-18 04:11:37 +08:00
25 lines
685 B
C
25 lines
685 B
C
|
|
#ifndef _COMMON_H_
|
|
#define _COMMON_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <stdarg.h>
|
|
|
|
// [warring] offsetof is redefined in stddef.h
|
|
//
|
|
// #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
// #define container_of(ptr, type, member) ({ \
|
|
// const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
// (type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
#define _offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
#define container_of(ptr, type, member) ({ \
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
(type *)( (char *)__mptr - _offsetof(type,member) );})
|
|
|
|
#endif
|