mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
musl-legacy-error: Add recipe
This adds glibc error() API implementation which is needed by few packages still. (From OE-Core rev: c3f0f00a8dcc76ece298cf4debf1ca71f930ec57) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -531,6 +531,7 @@ RECIPE_MAINTAINER:pn-mtd-utils = "Denys Dmytriyenko <denis@denix.org>"
|
||||
RECIPE_MAINTAINER:pn-mtdev = "Anuj Mittal <anuj.mittal@intel.com>"
|
||||
RECIPE_MAINTAINER:pn-mtools = "Anuj Mittal <anuj.mittal@intel.com>"
|
||||
RECIPE_MAINTAINER:pn-musl = "Khem Raj <raj.khem@gmail.com>"
|
||||
RECIPE_MAINTAINER:pn-musl-legacy-error = "Khem Raj <raj.khem@gmail.com>"
|
||||
RECIPE_MAINTAINER:pn-musl-locales = "Khem Raj <raj.khem@gmail.com>"
|
||||
RECIPE_MAINTAINER:pn-musl-obstack = "Khem Raj <raj.khem@gmail.com>"
|
||||
RECIPE_MAINTAINER:pn-musl-utils = "Khem Raj <raj.khem@gmail.com>"
|
||||
|
||||
26
meta/recipes-core/musl/musl-legacy-error.bb
Normal file
26
meta/recipes-core/musl/musl-legacy-error.bb
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright (C) 2023 Khem Raj <raj.khem@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})"
|
||||
60
meta/recipes-core/musl/musl-legacy-error/error.h
Normal file
60
meta/recipes-core/musl/musl-legacy-error/error.h
Normal file
@@ -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_ */
|
||||
Reference in New Issue
Block a user