mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
The current custom implementation of offsetof() fails UBSAN: runtime error: member access within null pointer of type 'struct ...' This means that all its users, including container_of(), free() and realloc(), fail. Use __builtin_offsetof() instead which does not have this issue and has been available since GCC 4 and clang 3. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260401-nolibc-asprintf-v1-1-46292313439f@weissschuh.net
25 lines
477 B
C
25 lines
477 B
C
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
|
|
/*
|
|
* Stddef definitions for NOLIBC
|
|
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
|
|
*/
|
|
|
|
/* make sure to include all global symbols */
|
|
#include "nolibc.h"
|
|
|
|
#ifndef _NOLIBC_STDDEF_H
|
|
#define _NOLIBC_STDDEF_H
|
|
|
|
#include "stdint.h"
|
|
|
|
/* note: may already be defined */
|
|
#ifndef NULL
|
|
#define NULL ((void *)0)
|
|
#endif
|
|
|
|
#ifndef offsetof
|
|
#define offsetof(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
|
|
#endif
|
|
|
|
#endif /* _NOLIBC_STDDEF_H */
|