tools/include/nolibc/assert.h

Source file repositories/reference/linux-study-clean/tools/include/nolibc/assert.h

File Facts

System
Linux kernel
Corpus path
tools/include/nolibc/assert.h
Extension
.h
Size
756 bytes
Lines
37
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#include "nolibc.h"

#ifndef _NOLIBC_ASSERT_H
#define _NOLIBC_ASSERT_H

#include "errno.h"
#include "stdio.h"
#include "stdlib.h"

#endif /* _NOLIBC_ASSERT_H */

/* NDEBUG needs to be evaluated on *each* inclusion */
#ifdef assert
#undef assert
#endif

#ifndef NDEBUG
#define assert(expr)									\
({											\
	if (!(expr)) {									\
		fprintf(stderr, "%s: %s:%d: %s: Assertion `%s' failed.\n",		\
			program_invocation_short_name, __FILE__, __LINE__, __func__,	\
			#expr);								\
		abort();								\
	}										\
})
#else
#define assert(expr) ((void)0)
#endif

Annotation

Implementation Notes