This adds glibc error() API implementation which is needed by few packages still.
Signed-off-by: Khem Raj <raj.k...@gmail.com> --- v3: Added new meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-core/musl/musl-legacy-error.bb | 26 ++++++++ .../musl/musl-legacy-error/error.h | 60 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 meta/recipes-core/musl/musl-legacy-error.bb create mode 100644 meta/recipes-core/musl/musl-legacy-error/error.h diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc index e977c84fc82..f69f229fc85 100644 --- a/meta/conf/distro/include/maintainers.inc +++ b/meta/conf/distro/include/maintainers.inc @@ -531,6 +531,7 @@ RECIPE_MAINTAINER:pn-mtd-utils = "Denys Dmytriyenko <de...@denix.org>" RECIPE_MAINTAINER:pn-mtdev = "Anuj Mittal <anuj.mit...@intel.com>" RECIPE_MAINTAINER:pn-mtools = "Anuj Mittal <anuj.mit...@intel.com>" RECIPE_MAINTAINER:pn-musl = "Khem Raj <raj.k...@gmail.com>" +RECIPE_MAINTAINER:pn-musl-legacy-error = "Khem Raj <raj.k...@gmail.com>" RECIPE_MAINTAINER:pn-musl-locales = "Khem Raj <raj.k...@gmail.com>" RECIPE_MAINTAINER:pn-musl-obstack = "Khem Raj <raj.k...@gmail.com>" RECIPE_MAINTAINER:pn-musl-utils = "Khem Raj <raj.k...@gmail.com>" diff --git a/meta/recipes-core/musl/musl-legacy-error.bb b/meta/recipes-core/musl/musl-legacy-error.bb new file mode 100644 index 00000000000..5ce5a233ab1 --- /dev/null +++ b/meta/recipes-core/musl/musl-legacy-error.bb @@ -0,0 +1,26 @@ +# Copyright (C) 2023 Khem Raj <raj.k...@gmail.com> +# Released under the MIT license (see COPYING.MIT for the terms) + +SUMMARY = "error API GNU extention implementation" +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://error.h;beginline=1;md5=2ee396b23e8507fbf8f98af0471a77c6" +SECTION = "devel" + +SRC_URI = "file://error.h" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +INHIBIT_DEFAULT_DEPS = "1" + +S = "${WORKDIR}" + +do_install() { + install -Dm 0644 ${S}/error.h -t ${D}${includedir} +} +# +# We will skip parsing for non-musl systems +# +COMPATIBLE_HOST = ".*-musl.*" +DEV_PKG_DEPENDENCY = "" +RRECOMMENDS:${PN}-dbg = "${PN}-dev (= ${EXTENDPKGV})" diff --git a/meta/recipes-core/musl/musl-legacy-error/error.h b/meta/recipes-core/musl/musl-legacy-error/error.h new file mode 100644 index 00000000000..9a4e1f8d006 --- /dev/null +++ b/meta/recipes-core/musl/musl-legacy-error/error.h @@ -0,0 +1,60 @@ +#ifndef _ERROR_H_ +#define _ERROR_H_ + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#warning usage of non-standard #include <error.h> is deprecated + +static unsigned int error_message_count = 0; + +static inline void error(int status, int errnum, const char* format, ...) +{ + /* should be fflush(stdout), but that's unspecified if stdout has been closed; + * stick with fflush(NULL) for simplicity (glibc checks if the fd is still valid) */ + fflush(NULL); + + va_list ap; + fprintf(stderr, "%s: ", program_invocation_name); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + if (errnum) + fprintf(stderr, ": %s", strerror(errnum)); + fprintf(stderr, "\n"); + error_message_count++; + if (status) + exit(status); +} + +static int error_one_per_line = 0; + +static inline void error_at_line(int status, int errnum, const char *filename, + unsigned int linenum, const char *format, ...) +{ + va_list ap; + if (error_one_per_line) { + static const char *old_filename; + static int old_linenum; + if (linenum == old_linenum && filename == old_filename) + return; + old_filename = filename; + old_linenum = linenum; + } + fprintf(stderr, "%s: %s:%u: ", program_invocation_name, filename, linenum); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + if (errnum) + fprintf(stderr, ": %s", strerror(errnum)); + fprintf(stderr, "\n"); + error_message_count++; + if (status) + exit(status); +} + + +#endif /* _ERROR_H_ */ -- 2.42.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#188135): https://lists.openembedded.org/g/openembedded-core/message/188135 Mute This Topic: https://lists.openembedded.org/mt/101529917/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-