From 872cf03f26c2801ae6c3008ce5fa0d7856f5f85d Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 14 Dec 2025 18:10:13 +0100 Subject: libc: implement err/warn functions --- include/arch/x86_64/drm/drm.h | 2 +- include/arch/x86_64/drm/i915_drm.h | 8 ++++---- include/arch/x86_64/linux/can/isotp.h | 2 +- include/arch/x86_64/linux/hdlcdrv.h | 2 +- include/arch/x86_64/linux/scc.h | 2 +- include/complex.h | 1 - include/err.h | 11 +++++------ include/execinfo.h | 14 ++++++++++++++ include/sys/cdefs.h | 5 +++++ include/sys/reboot.h | 14 ++++++++++++++ 10 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 include/execinfo.h create mode 100644 include/sys/reboot.h (limited to 'include') diff --git a/include/arch/x86_64/drm/drm.h b/include/arch/x86_64/drm/drm.h index a928f61f..ebd6ebb5 100644 --- a/include/arch/x86_64/drm/drm.h +++ b/include/arch/x86_64/drm/drm.h @@ -253,7 +253,7 @@ enum drm_stat_type { _DRM_STAT_DMA, /**< DMA */ _DRM_STAT_SPECIAL, /**< Special DMA (e.g., priority or polled) */ _DRM_STAT_MISSED /**< Missed DMA opportunity */ - /* Add to the *END* of the list */ + /* Add to the *END* of the list */ }; /* diff --git a/include/arch/x86_64/drm/i915_drm.h b/include/arch/x86_64/drm/i915_drm.h index e0403cb6..68f08e16 100644 --- a/include/arch/x86_64/drm/i915_drm.h +++ b/include/arch/x86_64/drm/i915_drm.h @@ -2115,10 +2115,10 @@ struct drm_i915_gem_context_param { #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */ #define I915_CONTEXT_DEFAULT_PRIORITY 0 #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */ - /* - * When using the following param, value should be a pointer to - * drm_i915_gem_context_param_sseu. - */ + /* + * When using the following param, value should be a pointer to + * drm_i915_gem_context_param_sseu. + */ #define I915_CONTEXT_PARAM_SSEU 0x7 /* diff --git a/include/arch/x86_64/linux/can/isotp.h b/include/arch/x86_64/linux/can/isotp.h index d986173d..3d72f3d3 100644 --- a/include/arch/x86_64/linux/can/isotp.h +++ b/include/arch/x86_64/linux/can/isotp.h @@ -85,7 +85,7 @@ struct can_isotp_options { /* __u8 value : content on rx path */ __u8 rx_ext_address; /* set address for extended addressing */ - /* __u8 value : extended address (rx) */ + /* __u8 value : extended address (rx) */ }; struct can_isotp_fc_options { diff --git a/include/arch/x86_64/linux/hdlcdrv.h b/include/arch/x86_64/linux/hdlcdrv.h index 784d1dcf..0d3f0ba7 100644 --- a/include/arch/x86_64/linux/hdlcdrv.h +++ b/include/arch/x86_64/linux/hdlcdrv.h @@ -29,7 +29,7 @@ struct hdlcdrv_channel_params { int slottime; /* the slottime in 10ms; usually 10 = 100ms */ int ppersist; /* the p-persistence 0..255 */ int fulldup; /* some driver do not support full duplex, setting */ - /* this just makes them send even if DCD is on */ + /* this just makes them send even if DCD is on */ }; struct hdlcdrv_old_channel_state { diff --git a/include/arch/x86_64/linux/scc.h b/include/arch/x86_64/linux/scc.h index ce9c783b..ac19e3ef 100644 --- a/include/arch/x86_64/linux/scc.h +++ b/include/arch/x86_64/linux/scc.h @@ -87,7 +87,7 @@ enum CLOCK_sources { CLK_DIVIDER, /* Rx = DPLL, Tx = divider (fullduplex with */ /* modems without clock regeneration */ CLK_BRG /* experimental fullduplex mode with DPLL/BRG for */ - /* MODEMs without clock recovery */ + /* MODEMs without clock recovery */ }; /* Tx state */ diff --git a/include/complex.h b/include/complex.h index e8cec9cc..ced87a8f 100644 --- a/include/complex.h +++ b/include/complex.h @@ -1,7 +1,6 @@ #ifndef __COMPLEX_H #define __COMPLEX_H -#include #define complex _Complex #define _Complex_I (__extension__(0.0f + 1.0fi)) #define imaginary _Imaginary diff --git a/include/err.h b/include/err.h index f08005f7..3e670fb8 100644 --- a/include/err.h +++ b/include/err.h @@ -2,16 +2,15 @@ #define __ERR_H #include +#include -_Noreturn void err(int eval, const char *fmt, ...); -_Noreturn void errx(int eval, const char *fmt, ...); +__dead void err(int eval, const char *fmt, ...); +__dead void errx(int eval, const char *fmt, ...); +__dead void verr(int eval, const char *fmt, va_list args); +__dead void verrx(int eval, const char *fmt, va_list args); void warn(const char *fmt, ...); void warnx(const char *fmt, ...); - -_Noreturn void verr(int eval, const char *fmt, va_list args); -_Noreturn void verrx(int eval, const char *fmt, va_list args); - void vwarn(const char *fmt, va_list args); void vwarnx(const char *fmt, va_list args); diff --git a/include/execinfo.h b/include/execinfo.h new file mode 100644 index 00000000..08ff6557 --- /dev/null +++ b/include/execinfo.h @@ -0,0 +1,14 @@ +#ifndef __EXECINFO_H +#define __EXECINFO_H + +#include + +__BEGIN_DECLS + +int backtrace(void *, int); +char **backtrace_symbols(void *const, int size); +void backtrace_symbols_fd(void *const, int, int); + +__END_DECLS + +#endif diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index 4c86d599..70ace705 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -1,8 +1,13 @@ #ifndef __SYS_CDEFS_H #define __SYS_CDEFS_H +#ifdef __cplusplus #define __BEGIN_DECLS extern "C" { #define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif #define __dead __attribute__((__noreturn__)) #define __used __attribute__((__used__)) diff --git a/include/sys/reboot.h b/include/sys/reboot.h new file mode 100644 index 00000000..d6499d10 --- /dev/null +++ b/include/sys/reboot.h @@ -0,0 +1,14 @@ +#ifndef __SYS_REBOOT_H +#define __SYS_REBOOT_H + +#define RB_AUTOBOOT 0x01234567 +#define RB_HALT_SYSTEM 0xCDEF0123 +#define RB_ENABLE_CAD 0x89ABCDEF +#define RB_DISABLE_CAD 0x00000000 +#define RB_POWRT_OFF 0x4321FEDC +#define RB_SW_SUSPEND 0xD000FCE2 +#define RB_KEXEC 0x45584543 + +int reboot(int); + +#endif -- cgit v1.2.3