Commit 2217abe0 authored by Thomas Weißschuh's avatar Thomas Weißschuh
Browse files

tools/nolibc: move NULL and offsetof() to sys/stddef.h



This is the location regular userspace expects these definitions.

Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Acked-by: default avatarWilly Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-8-74f82eea3b59@weissschuh.net
parent 0f971358
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ all_files := \
		std.h \
		stdarg.h \
		stdbool.h \
		stddef.h \
		stdint.h \
		stdlib.h \
		string.h \
+1 −5
Original line number Diff line number Diff line
@@ -13,12 +13,8 @@
 * syscall-specific stuff, as this file is expected to be included very early.
 */

/* note: may already be defined */
#ifndef NULL
#define NULL ((void *)0)
#endif

#include "stdint.h"
#include "stddef.h"

/* those are commonly provided by sys/types.h */
typedef unsigned int          dev_t;
+24 −0
Original line number Diff line number Diff line
/* 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) ((size_t) &((TYPE *)0)->FIELD)
#endif

#endif /* _NOLIBC_STDDEF_H */
+0 −4
Original line number Diff line number Diff line
@@ -188,10 +188,6 @@ struct stat {
typedef __kernel_clockid_t clockid_t;
typedef int timer_t;

#ifndef offsetof
#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
#endif

#ifndef container_of
#define container_of(PTR, TYPE, FIELD) ({			\
	__typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR);	\