Skip to content

Commit 463e929

Browse files
committed
Add platfrom specific error converter implementations
1 parent 756cb37 commit 463e929

27 files changed

+219
-46
lines changed

libc/include/llvm-libc-macros/generic-error-number-macros.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define EPIPE 32
4444
#define EDOM 33
4545
#define ERANGE 34
46-
#define EOVERFLOW 75
4746
#define EILSEQ 84
4847

4948
#endif // LLVM_LIBC_MACROS_GENERIC_ERROR_NUMBER_MACROS_H

libc/src/stdio/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ add_entrypoint_object(
126126
libc.src.stdio.printf_core.printf_main
127127
libc.src.stdio.printf_core.writer
128128
libc.src.stdio.printf_core.core_structs
129+
libc.src.stdio.printf_core.error_converter
129130
libc.src.__support.libc_errno
130131
libc.hdr.errno_macros
131132
)
@@ -140,6 +141,7 @@ add_entrypoint_object(
140141
libc.src.stdio.printf_core.printf_main
141142
libc.src.stdio.printf_core.writer
142143
libc.src.stdio.printf_core.core_structs
144+
libc.src.stdio.printf_core.error_converter
143145
libc.src.__support.libc_errno
144146
libc.hdr.errno_macros
145147
)
@@ -153,6 +155,7 @@ add_entrypoint_object(
153155
DEPENDS
154156
libc.src.stdio.printf_core.vasprintf_internal
155157
libc.src.stdio.printf_core.core_structs
158+
libc.src.stdio.printf_core.error_converter
156159
libc.src.__support.libc_errno
157160
libc.hdr.errno_macros
158161
)
@@ -167,6 +170,7 @@ add_entrypoint_object(
167170
libc.src.stdio.printf_core.printf_main
168171
libc.src.stdio.printf_core.writer
169172
libc.src.stdio.printf_core.core_structs
173+
libc.src.stdio.printf_core.error_converter
170174
)
171175

172176
add_entrypoint_object(
@@ -179,6 +183,7 @@ add_entrypoint_object(
179183
libc.src.stdio.printf_core.printf_main
180184
libc.src.stdio.printf_core.writer
181185
libc.src.stdio.printf_core.core_structs
186+
libc.src.stdio.printf_core.error_converter
182187
libc.src.__support.libc_errno
183188
libc.hdr.errno_macros
184189
)
@@ -192,6 +197,7 @@ add_entrypoint_object(
192197
DEPENDS
193198
libc.src.stdio.printf_core.vasprintf_internal
194199
libc.src.stdio.printf_core.core_structs
200+
libc.src.stdio.printf_core.error_converter
195201
libc.src.__support.libc_errno
196202
libc.hdr.errno_macros
197203
)

libc/src/stdio/asprintf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "src/__support/arg_list.h"
1212
#include "src/__support/libc_errno.h"
1313
#include "src/__support/macros/config.h"
14+
#include "src/stdio/printf_core/error_converter.h"
1415
#include "src/stdio/printf_core/vasprintf_internal.h"
1516

1617
namespace LIBC_NAMESPACE_DECL {
@@ -30,7 +31,8 @@ LLVM_LIBC_FUNCTION(int, asprintf,
3031
return -1;
3132
}
3233
if (ret_val.value() > cpp::numeric_limits<int>::max()) {
33-
libc_errno = EOVERFLOW;
34+
libc_errno =
35+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
3436
return -1;
3537
}
3638

libc/src/stdio/baremetal/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ add_entrypoint_object(
2929
DEPENDS
3030
libc.src.stdio.printf_core.printf_main
3131
libc.src.stdio.printf_core.writer
32+
libc.src.stdio.printf_core.error_converter
3233
libc.src.__support.arg_list
3334
libc.src.__support.OSUtil.osutil
3435
libc.src.__support.libc_errno
@@ -88,6 +89,7 @@ add_entrypoint_object(
8889
DEPENDS
8990
libc.src.stdio.printf_core.printf_main
9091
libc.src.stdio.printf_core.writer
92+
libc.src.stdio.printf_core.error_converter
9193
libc.src.__support.arg_list
9294
libc.src.__support.OSUtil.osutil
9395
libc.src.__support.libc_errno

libc/src/stdio/baremetal/printf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/libc_errno.h"
1313
#include "src/__support/macros/config.h"
1414
#include "src/stdio/printf_core/core_structs.h"
15+
#include "src/stdio/printf_core/error_converter.h"
1516
#include "src/stdio/printf_core/printf_main.h"
1617
#include "src/stdio/printf_core/writer.h"
1718

@@ -56,7 +57,8 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict format, ...)) {
5657
}
5758

5859
if (retval.value() > cpp::numeric_limits<int>::max()) {
59-
libc_errno = EOVERFLOW;
60+
libc_errno =
61+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
6062
return -1;
6163
}
6264

libc/src/stdio/baremetal/vprintf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/__support/libc_errno.h"
1414
#include "src/__support/macros/config.h"
1515
#include "src/stdio/printf_core/core_structs.h"
16+
#include "src/stdio/printf_core/error_converter.h"
1617
#include "src/stdio/printf_core/printf_main.h"
1718
#include "src/stdio/printf_core/writer.h"
1819

@@ -55,7 +56,8 @@ LLVM_LIBC_FUNCTION(int, vprintf,
5556
}
5657

5758
if (retval.value() > cpp::numeric_limits<int>::max()) {
58-
libc_errno = EOVERFLOW;
59+
libc_errno =
60+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
5961
return -1;
6062
}
6163

libc/src/stdio/generic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ list(APPEND fprintf_deps
395395
libc.src.__support.arg_list
396396
libc.src.stdio.printf_core.vfprintf_internal
397397
libc.src.stdio.printf_core.core_structs
398+
libc.src.stdio.printf_core.error_converter
398399
)
399400

400401
if(LLVM_LIBC_FULL_BUILD)

libc/src/stdio/generic/fprintf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "src/__support/File/file.h"
1212
#include "src/__support/arg_list.h"
1313
#include "src/__support/macros/config.h"
14+
#include "src/stdio/printf_core/error_converter.h"
1415
#include "src/stdio/printf_core/vfprintf_internal.h"
1516

1617
#include "hdr/types/FILE.h"
@@ -33,7 +34,8 @@ LLVM_LIBC_FUNCTION(int, fprintf,
3334
return -1;
3435
}
3536
if (ret_val.value() > cpp::numeric_limits<int>::max()) {
36-
libc_errno = EOVERFLOW;
37+
libc_errno =
38+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
3739
return -1;
3840
}
3941

libc/src/stdio/generic/printf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/arg_list.h"
1313
#include "src/__support/macros/config.h"
1414
#include "src/stdio/printf_core/core_structs.h"
15+
#include "src/stdio/printf_core/error_converter.h"
1516
#include "src/stdio/printf_core/vfprintf_internal.h"
1617

1718
#include "hdr/types/FILE.h"
@@ -39,7 +40,8 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict format, ...)) {
3940
return -1;
4041
}
4142
if (ret_val.value() > cpp::numeric_limits<int>::max()) {
42-
libc_errno = EOVERFLOW;
43+
libc_errno =
44+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
4345
return -1;
4446
}
4547

libc/src/stdio/generic/vfprintf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/arg_list.h"
1313
#include "src/__support/macros/config.h"
1414
#include "src/stdio/printf_core/core_structs.h"
15+
#include "src/stdio/printf_core/error_converter.h"
1516
#include "src/stdio/printf_core/vfprintf_internal.h"
1617

1718
#include "hdr/types/FILE.h"
@@ -31,7 +32,8 @@ LLVM_LIBC_FUNCTION(int, vfprintf,
3132
return -1;
3233
}
3334
if (ret_val.value() > cpp::numeric_limits<int>::max()) {
34-
libc_errno = EOVERFLOW;
35+
libc_errno =
36+
printf_core::internal_error_to_errno(-printf_core::OVERFLOW_ERROR);
3537
return -1;
3638
}
3739

0 commit comments

Comments
 (0)