diff options
author | Khem Raj <raj.khem@gmail.com> | 2023-09-22 14:05:06 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-26 10:35:28 +0100 |
commit | c7fdb5aca58f1a9d37905588c61cafaf585e9ff9 (patch) | |
tree | 9008a47f78932f829fec6c6fed5fc21871bed9db /meta/recipes-core/musl | |
parent | 0ccd6425db2cc91406fae14e4e5a7e4fe354ff77 (diff) | |
download | poky-c7fdb5aca58f1a9d37905588c61cafaf585e9ff9.tar.gz |
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>
Diffstat (limited to 'meta/recipes-core/musl')
-rw-r--r-- | meta/recipes-core/musl/musl-legacy-error.bb | 26 | ||||
-rw-r--r-- | meta/recipes-core/musl/musl-legacy-error/error.h | 60 |
2 files changed, 86 insertions, 0 deletions
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 0000000000..5ce5a233ab --- /dev/null +++ b/meta/recipes-core/musl/musl-legacy-error.bb | |||
@@ -0,0 +1,26 @@ | |||
1 | # Copyright (C) 2023 Khem Raj <raj.khem@gmail.com> | ||
2 | # Released under the MIT license (see COPYING.MIT for the terms) | ||
3 | |||
4 | SUMMARY = "error API GNU extention implementation" | ||
5 | LICENSE = "BSD-2-Clause" | ||
6 | LIC_FILES_CHKSUM = "file://error.h;beginline=1;md5=2ee396b23e8507fbf8f98af0471a77c6" | ||
7 | SECTION = "devel" | ||
8 | |||
9 | SRC_URI = "file://error.h" | ||
10 | |||
11 | do_configure[noexec] = "1" | ||
12 | do_compile[noexec] = "1" | ||
13 | |||
14 | INHIBIT_DEFAULT_DEPS = "1" | ||
15 | |||
16 | S = "${WORKDIR}" | ||
17 | |||
18 | do_install() { | ||
19 | install -Dm 0644 ${S}/error.h -t ${D}${includedir} | ||
20 | } | ||
21 | # | ||
22 | # We will skip parsing for non-musl systems | ||
23 | # | ||
24 | COMPATIBLE_HOST = ".*-musl.*" | ||
25 | DEV_PKG_DEPENDENCY = "" | ||
26 | 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 0000000000..9a4e1f8d00 --- /dev/null +++ b/meta/recipes-core/musl/musl-legacy-error/error.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef _ERROR_H_ | ||
2 | #define _ERROR_H_ | ||
3 | |||
4 | #include <stdarg.h> | ||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <string.h> | ||
8 | #include <errno.h> | ||
9 | |||
10 | #warning usage of non-standard #include <error.h> is deprecated | ||
11 | |||
12 | static unsigned int error_message_count = 0; | ||
13 | |||
14 | static inline void error(int status, int errnum, const char* format, ...) | ||
15 | { | ||
16 | /* should be fflush(stdout), but that's unspecified if stdout has been closed; | ||
17 | * stick with fflush(NULL) for simplicity (glibc checks if the fd is still valid) */ | ||
18 | fflush(NULL); | ||
19 | |||
20 | va_list ap; | ||
21 | fprintf(stderr, "%s: ", program_invocation_name); | ||
22 | va_start(ap, format); | ||
23 | vfprintf(stderr, format, ap); | ||
24 | va_end(ap); | ||
25 | if (errnum) | ||
26 | fprintf(stderr, ": %s", strerror(errnum)); | ||
27 | fprintf(stderr, "\n"); | ||
28 | error_message_count++; | ||
29 | if (status) | ||
30 | exit(status); | ||
31 | } | ||
32 | |||
33 | static int error_one_per_line = 0; | ||
34 | |||
35 | static inline void error_at_line(int status, int errnum, const char *filename, | ||
36 | unsigned int linenum, const char *format, ...) | ||
37 | { | ||
38 | va_list ap; | ||
39 | if (error_one_per_line) { | ||
40 | static const char *old_filename; | ||
41 | static int old_linenum; | ||
42 | if (linenum == old_linenum && filename == old_filename) | ||
43 | return; | ||
44 | old_filename = filename; | ||
45 | old_linenum = linenum; | ||
46 | } | ||
47 | fprintf(stderr, "%s: %s:%u: ", program_invocation_name, filename, linenum); | ||
48 | va_start(ap, format); | ||
49 | vfprintf(stderr, format, ap); | ||
50 | va_end(ap); | ||
51 | if (errnum) | ||
52 | fprintf(stderr, ": %s", strerror(errnum)); | ||
53 | fprintf(stderr, "\n"); | ||
54 | error_message_count++; | ||
55 | if (status) | ||
56 | exit(status); | ||
57 | } | ||
58 | |||
59 | |||
60 | #endif /* _ERROR_H_ */ | ||