Skip to content

Commit 3af1196

Browse files
committed
Modify musl errno messages to match llvm-libc
1 parent b805400 commit 3af1196

File tree

14 files changed

+52
-34
lines changed

14 files changed

+52
-34
lines changed

system/lib/libc/musl/src/errno/__strerror.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* with these messages, and then to define a lookup table translating
44
* error codes to offsets of corresponding fields in the structure. */
55

6-
E(0, "No error information")
6+
E(0, "Success")
77

88
E(EILSEQ, "Illegal byte sequence")
99
E(EDOM, "Domain error")
@@ -16,7 +16,7 @@ E(ENOENT, "No such file or directory")
1616
E(ESRCH, "No such process")
1717
E(EEXIST, "File exists")
1818

19-
E(EOVERFLOW, "Value too large for data type")
19+
E(EOVERFLOW, "Value too large for defined data type")
2020
E(ENOSPC, "No space left on device")
2121
E(ENOMEM, "Out of memory")
2222

system/lib/llvm-libc/src/__support/StringUtil/platform_errors.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
1010
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
1111

12-
#if defined(__linux__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
12+
#if defined(__linux__) || defined(__Fuchsia__)
1313
#include "tables/linux_platform_errors.h"
14+
#elif defined(__EMSCRIPTEN__)
15+
#include "tables/emscripten_platform_errors.h"
1416
#else
1517
#include "tables/minimal_platform_errors.h"
1618
#endif
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- Map of error numbers to strings for the Emscripten platform --*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_EMSCRPITEN_PLATFORM_ERRORS_H
10+
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_EMSCRPITEN_PLATFORM_ERRORS_H
11+
12+
#include "posix_errors.h"
13+
#include "src/__support/macros/config.h"
14+
#include "stdc_errors.h"
15+
16+
namespace LIBC_NAMESPACE_DECL {
17+
18+
LIBC_INLINE_VAR constexpr auto PLATFORM_ERRORS =
19+
STDC_ERRORS + POSIX_ERRORS;
20+
21+
LIBC_INLINE_VAR constexpr auto PLATFORM_ERRNO_NAMES =
22+
STDC_ERRNO_NAMES + POSIX_ERRNO_NAMES;
23+
24+
} // namespace LIBC_NAMESPACE_DECL
25+
26+
#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_EMSCRPITEN_PLATFORM_ERRORS_H

system/lib/llvm-libc/src/__support/StringUtil/tables/posix_errors.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {
6363
MsgMapping(EPROTO, "Protocol error"),
6464
MsgMapping(EMULTIHOP, "Multihop attempted"),
6565
MsgMapping(EBADMSG, "Bad message"),
66-
#ifdef __EMSCRIPTEN__
67-
// For now, match the musl string
68-
MsgMapping(EOVERFLOW, "Value too large for data type"),
69-
#else
7066
MsgMapping(EOVERFLOW, "Value too large for defined data type"),
71-
#endif
7267
MsgMapping(ENOTSOCK, "Socket operation on non-socket"),
7368
MsgMapping(EDESTADDRREQ, "Destination address required"),
7469
MsgMapping(EMSGSIZE, "Message too long"),

system/lib/llvm-libc/src/__support/StringUtil/tables/stdc_errors.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616
namespace LIBC_NAMESPACE_DECL {
1717

1818
LIBC_INLINE_VAR constexpr const MsgTable<4> STDC_ERRORS = {
19-
#ifdef __EMSCRIPTEN__
20-
// For now, match the musl name for errno 0.
21-
MsgMapping(0, "No error information"),
22-
#else
2319
MsgMapping(0, "Success"),
24-
#endif
2520
MsgMapping(EDOM, "Numerical argument out of domain"),
2621
MsgMapping(ERANGE, "Numerical result out of range"),
2722
MsgMapping(EILSEQ, "Invalid or incomplete multibyte or wide character"),

test/fcntl/test_fcntl_misc.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ st_size: 10
88

99
posix_fallocate 3: Invalid argument
1010
posix_fallocate 4: Invalid argument
11-
posix_fallocate 5: Value too large for data type
12-
posix_fallocate 6: Value too large for data type
11+
posix_fallocate 5: Value too large for defined data type
12+
posix_fallocate 6: Value too large for defined data type

test/unistd/curdir.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
getcwd: /
2-
errno: No error information
2+
errno: Success
33

44
chdir(file): -1
55
errno: Not a directory
@@ -11,16 +11,16 @@ chdir(device): -1
1111
errno: Not a directory
1212

1313
chdir(folder): 0
14-
errno: No error information
14+
errno: Success
1515
getcwd: /folder
1616

1717
chdir(nonexistent): -1
1818
errno: No such file or directory
1919

2020
chdir(link): 0
21-
errno: No error information
21+
errno: Success
2222
getcwd: /folder
2323

2424
fchdir(/): 0
25-
errno: No error information
25+
errno: Success
2626
getcwd: /

test/unistd/dup.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
DUP
2-
errno: No error information
2+
errno: Success
33
f: 1
44
f2,f3: 1
55
close(f1): 0
66
close(f2): 0
77
close(f3): 0
88

99
DUP2
10-
errno: No error information
10+
errno: Success
1111
f: 1
1212
f2,f3: 1
1313
close(f1): 0

test/unistd/links.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
readlink: 'link'
2-
errno: No error information
2+
errno: Success
33

44
readlink: 'file'
55
errno: Invalid argument
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
link result: 0
2-
source_fd: 3, errno: 0 No error information
3-
target_fd: 3, errno: 0 No error information
2+
source_fd: 3, errno: 0 Success
3+
target_fd: 3, errno: 0 Success
44
buf: 'abc'
5-
target_fd: 3, errno: 0 No error information
5+
target_fd: 3, errno: 0 Success
66
buf: 'abc'

0 commit comments

Comments
 (0)