DEPENDS
.ctype_utils
.str_to_num_result
- libc.include.errno
libc.src.errno.errno
libc.src.__support.CPP.limits
libc.src.__support.common
HDRS
file.h
DEPENDS
- libc.include.errno
+
libc.src.__support.CPP.new
libc.src.__support.CPP.span
libc.src.__support.threads.mutex
${LIBC_TARGET_OS}_file.cpp
DEPENDS
.file
- libc.include.errno
+
libc.include.fcntl
libc.include.stdio
libc.include.sys_syscall
${LIBC_TARGET_OS}_dir.cpp
DEPENDS
.dir
- libc.include.errno
libc.include.fcntl
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
libc.src.__support.error_or
+ libc.src.errno.errno
)
endif()
#include "src/__support/CPP/new.h"
#include "src/__support/error_or.h"
+#include "src/errno/libc_errno.h" // For error macros
-#include <errno.h>
#include <stdlib.h>
namespace __llvm_libc {
#include "src/__support/CPP/new.h"
#include "src/__support/CPP/span.h"
+#include "src/errno/libc_errno.h" // For error macros
-#include <errno.h> // For error macros
#include <stdio.h>
#include <stdlib.h>
#include "src/__support/CPP/new.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/errno/libc_errno.h" // For error macros
-#include <errno.h> // For error macros
#include <fcntl.h> // For mode_t and other flags to the open syscall
#include <stdio.h>
#include <sys/syscall.h> // For syscall numbers
error_to_string.cpp
DEPENDS
.message_mapper
- libc.include.errno
+ libc.src.errno.errno
libc.src.__support.CPP.span
libc.src.__support.CPP.string_view
libc.src.__support.CPP.stringstream
#include "src/__support/CPP/stringstream.h"
#include "src/__support/StringUtil/message_mapper.h"
#include "src/__support/integer_to_string.h"
+#include "src/errno/libc_errno.h" // For error macros
-#include <errno.h>
#include <stddef.h>
namespace __llvm_libc {
#include "src/__support/high_precision_decimal.h"
#include "src/__support/str_to_integer.h"
#include "src/__support/str_to_num_result.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h" // For ERANGE
namespace __llvm_libc {
namespace internal {
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/str_to_num_result.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h" // For ERANGE
#include <limits.h>
namespace __llvm_libc {
.futex_word_type
libc.config.linux.app_h
libc.include.sys_syscall
+ libc.src.errno.errno
libc.src.__support.CPP.atomic
libc.src.__support.CPP.stringstream
libc.src.__support.CPP.string_view
#include "src/__support/common.h"
#include "src/__support/error_or.h"
#include "src/__support/threads/linux/futex_word.h" // For FutexWordType
+#include "src/errno/libc_errno.h" // For error macros
#ifdef LIBC_TARGET_ARCH_IS_AARCH64
#include <arm_acle.h>
#endif
-#include <errno.h>
#include <fcntl.h>
#include <linux/futex.h>
#include <linux/prctl.h> // For PR_SET_NAME
fclose.h
DEPENDS
libc.include.stdio
- libc.include.errno
+ libc.src.errno.errno
libc.src.__support.File.file
libc.src.__support.File.platform_file
)
HDRS
fgetc.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fgetc_unlocked.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
getc.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
getc_unlocked.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fgets.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fflush.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fread_unlocked.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fread.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fwrite_unlocked.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fwrite.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fputc.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
putc.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
putchar.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fputs.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
puts.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
fseek.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
setbuf.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
setvbuf.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
HDRS
ftell.h
DEPENDS
- libc.include.errno
+ libc.src.errno.errno
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.File.platform_file
#include "src/stdio/fclose.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto *file = reinterpret_cast<__llvm_libc::File *>(stream);
int result = File::cleanup(file);
if (result != 0) {
- errno = result;
+ libc_errno = result;
return EOF;
}
return 0;
#include "src/stdio/fflush.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(int, fflush, (::FILE * stream)) {
int result = reinterpret_cast<__llvm_libc::File *>(stream)->flush();
if (result != 0) {
- errno = result;
+ libc_errno = result;
return EOF;
}
return 0;
#include "src/stdio/fgetc.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read(&c, 1);
size_t r = result.value;
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (r != 1)
return EOF;
#include "src/stdio/fgetc_unlocked.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked(&c, 1);
size_t r = result.value;
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (r != 1)
return EOF;
return c;
#include "src/stdio/fgets.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stddef.h>
#include <stdio.h>
auto result = stream->read_unlocked(&c, 1);
size_t r = result.value;
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (r != 1)
break;
#include "src/stdio/fopen.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
(const char *__restrict name, const char *__restrict mode)) {
auto result = __llvm_libc::openfile(name, mode);
if (!result.has_value()) {
- errno = result.error();
+ libc_errno = result.error();
return nullptr;
}
return reinterpret_cast<::FILE *>(result.value());
#include "src/__support/CPP/new.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
#include <stdlib.h>
#include "src/stdio/fputc.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(&uc, 1);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
size_t written = result.value;
if (1 != written) {
#include "src/__support/CPP/string_view.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(
str, str_view.size());
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
size_t written = result.value;
if (str_view.size() != written) {
#include "src/stdio/fread.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result =
reinterpret_cast<__llvm_libc::File *>(stream)->read(buffer, size * nmemb);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result.value / size;
}
#include "src/stdio/fread_unlocked.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked(
buffer, size * nmemb);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result.value / size;
}
#include "src/stdio/fseek.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result =
reinterpret_cast<__llvm_libc::File *>(stream)->seek(offset, whence);
if (!result.has_value()) {
- errno = result.error();
+ libc_errno = result.error();
return -1;
}
return 0;
#include "src/stdio/ftell.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(long, ftell, (::FILE * stream)) {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->tell();
if (!result.has_value()) {
- errno = result.error();
+ libc_errno = result.error();
return -1;
}
return result.value();
#include "src/stdio/fwrite.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(
buffer, size * nmemb);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result.value / size;
}
#include "src/stdio/fwrite_unlocked.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write_unlocked(
buffer, size * nmemb);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result.value / size;
}
#include "src/stdio/getc.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read(&c, 1);
size_t r = result.value;
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (r != 1)
return EOF;
#include "src/stdio/getc_unlocked.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked(&c, 1);
size_t r = result.value;
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (r != 1)
return EOF;
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <fcntl.h> // For AT_* macros.
#include <sys/syscall.h> // For syscall numbers.
ret = __llvm_libc::syscall_impl(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
if (ret >= 0)
return 0;
- errno = -ret;
+ libc_errno = -ret;
return -1;
}
#include "src/stdio/putc.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(&uc, 1);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
size_t written = result.value;
if (1 != written) {
#include "src/stdio/putchar.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
auto result = __llvm_libc::stdout->write(&uc, 1);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
size_t written = result.value;
if (1 != written) {
#include "src/__support/CPP/string_view.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
cpp::string_view str_view(str);
auto result = __llvm_libc::stdout->write(str, str_view.size());
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
size_t written = result.value;
if (str_view.size() != written) {
// The stream should be in an error state in this case.
}
result = __llvm_libc::stdout->write("\n", 1);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
written = result.value;
if (1 != written) {
// The stream should be in an error state in this case.
#include "src/stdio/setbuf.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
int err = reinterpret_cast<__llvm_libc::File *>(stream)->set_buffer(
buf, BUFSIZ, mode);
if (err != 0)
- errno = err;
+ libc_errno = err;
}
} // namespace __llvm_libc
#include "src/stdio/setvbuf.h"
#include "src/__support/File/file.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
namespace __llvm_libc {
int err = reinterpret_cast<__llvm_libc::File *>(stream)->set_buffer(buf, size,
type);
if (err != 0)
- errno = err;
+ libc_errno = err;
return err;
}
HDRS
atoi.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
atof.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_float
)
HDRS
atol.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
atoll.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
strtof.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_float
)
HDRS
strtod.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_float
)
HDRS
strtold.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_float
)
HDRS
strtol.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
strtoll.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
strtoul.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
HDRS
strtoull.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.str_to_integer
)
#include "src/stdlib/atof.h"
#include "src/__support/common.h"
#include "src/__support/str_to_float.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(double, atof, (const char *str)) {
auto result = internal::strtofloatingpoint<double>(str);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result.value;
}
#include "src/stdlib/atoi.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
// (int)(strtol).
auto result = internal::strtointeger<long>(str, 10);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return static_cast<int>(result);
}
#include "src/stdlib/atol.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(long, atol, (const char *str)) {
auto result = internal::strtointeger<long>(str, 10);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result;
}
#include "src/stdlib/atoll.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(long long, atoll, (const char *str)) {
auto result = internal::strtointeger<long long>(str, 10);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
return result;
}
#include "src/stdlib/strtod.h"
#include "src/__support/common.h"
#include "src/__support/str_to_float.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
(const char *__restrict str, char **__restrict str_end)) {
auto result = internal::strtofloatingpoint<double>(str);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != NULL)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtof.h"
#include "src/__support/common.h"
#include "src/__support/str_to_float.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
(const char *__restrict str, char **__restrict str_end)) {
auto result = internal::strtofloatingpoint<float>(str);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != NULL)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtol.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
int base)) {
auto result = internal::strtointeger<long>(str, base);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != nullptr)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtold.h"
#include "src/__support/common.h"
#include "src/__support/str_to_float.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
(const char *__restrict str, char **__restrict str_end)) {
auto result = internal::strtofloatingpoint<long double>(str);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != NULL)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtoll.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
int base)) {
auto result = internal::strtointeger<long long>(str, base);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != nullptr)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtoul.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
int base)) {
auto result = internal::strtointeger<unsigned long>(str, base);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != nullptr)
*str_end = const_cast<char *>(str + result.parsed_len);
#include "src/stdlib/strtoull.h"
#include "src/__support/common.h"
#include "src/__support/str_to_integer.h"
+#include "src/errno/libc_errno.h"
namespace __llvm_libc {
int base)) {
auto result = internal::strtointeger<unsigned long long>(str, base);
if (result.has_error())
- errno = result.error;
+ libc_errno = result.error;
if (str_end != nullptr)
*str_end = const_cast<char *>(str + result.parsed_len);
SRCS
fileop_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.clearerr
libc.src.stdio.fclose
libc.src.stdio.feof
SRCS
setvbuf_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.fopen
libc.src.stdio.fread
SRCS
unlocked_fileop_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.clearerr_unlocked
libc.src.stdio.fclose
libc.src.stdio.feof_unlocked
SRCS
fopencookie_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
libc.include.stdlib
+ libc.src.errno.errno
libc.src.stdio.clearerr
libc.src.stdio.fclose
libc.src.stdio.feof
SRCS
remove_test.cpp
DEPENDS
- libc.include.errno
libc.include.unistd
+ libc.src.errno.errno
libc.src.fcntl.open
libc.src.stdio.remove
libc.src.sys.stat.mkdirat
SRCS
fgetc_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
SRCS
fgetc_unlocked_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.ferror
libc.src.stdio.ferror_unlocked
SRCS
fgets_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
+ libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
SRCS
ftell_test.cpp
DEPENDS
- libc.include.errno
libc.include.stdio
libc.src.stdio.fclose
libc.src.stdio.fflush
#include "src/stdio/getc.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
class LlvmLibcGetcTest : public __llvm_libc::testing::Test {
// This is an error and not a real EOF.
ASSERT_EQ(__llvm_libc::feof(file), 0);
ASSERT_NE(__llvm_libc::ferror(file), 0);
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(0, __llvm_libc::fclose(file));
#include "src/stdio/getc_unlocked.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
class LlvmLibcGetcTest : public __llvm_libc::testing::Test {
// This is an error and not a real EOF.
ASSERT_EQ(__llvm_libc::feof(file), 0);
ASSERT_NE(__llvm_libc::ferror(file), 0);
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(0, __llvm_libc::fclose(file));
#include "src/stdio/fwrite.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
// This is an error and not a real EOF.
ASSERT_EQ(__llvm_libc::feof(file), 0);
ASSERT_NE(__llvm_libc::ferror(file), 0);
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(0, __llvm_libc::fclose(file));
output = __llvm_libc::fgets(buff, 1, file);
ASSERT_TRUE(output == buff);
ASSERT_EQ(buff[0], '\0');
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
// If we request less than 1 byte, it should do nothing and return nullptr.
// This is also implementation defined.
// fails to read anything.
ASSERT_NE(__llvm_libc::feof(file), 0);
ASSERT_EQ(__llvm_libc::ferror(file), 0);
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
// Reading more should be an EOF, but not an error.
output = __llvm_libc::fgets(buff, 8, file);
ASSERT_TRUE(output == nullptr);
ASSERT_NE(__llvm_libc::feof(file), 0);
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
ASSERT_EQ(0, __llvm_libc::fclose(file));
}
#include "src/stdio/fwrite.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
TEST(LlvmLibcFILETest, SimpleFileOperations) {
char read_data[sizeof(CONTENT)];
ASSERT_EQ(__llvm_libc::fread(read_data, 1, sizeof(CONTENT), file), size_t(0));
ASSERT_NE(__llvm_libc::ferror(file), 0);
- EXPECT_NE(errno, 0);
- errno = 0;
+ EXPECT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr(file);
ASSERT_EQ(__llvm_libc::ferror(file), 0);
// Should be an error to write.
ASSERT_EQ(size_t(0), __llvm_libc::fwrite(CONTENT, 1, sizeof(CONTENT), file));
ASSERT_NE(__llvm_libc::ferror(file), 0);
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr(file);
// Should be an error to puts.
ASSERT_EQ(EOF, __llvm_libc::fputs(CONTENT, file));
ASSERT_NE(__llvm_libc::ferror(file), 0);
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr(file);
ASSERT_EQ(__llvm_libc::ferror(file), 0);
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(__llvm_libc::fwrite("nothing", 1, 1, file), size_t(0));
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
ASSERT_EQ(__llvm_libc::fclose(file), 0);
ASSERT_EQ(__llvm_libc::ferror(file), 0);
// This is not a readable file.
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(__llvm_libc::fread(data, 1, 1, file), size_t(0));
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
ASSERT_EQ(0, __llvm_libc::fclose(file));
ASSERT_STREQ(read_data, CONTENT);
ASSERT_EQ(__llvm_libc::fclose(file), 0);
- // Check that the other functions correctly set errno.
+ // Check that the other functions correctly set libc_errno.
- // errno = 0;
+ // libc_errno = 0;
// ASSERT_NE(__llvm_libc::fseek(file, 0, SEEK_SET), 0);
- // EXPECT_NE(errno, 0);
+ // EXPECT_NE(libc_errno, 0);
- // errno = 0;
+ // libc_errno = 0;
// ASSERT_NE(__llvm_libc::fclose(file), 0);
- // EXPECT_NE(errno, 0);
+ // EXPECT_NE(libc_errno, 0);
- // errno = 0;
+ // libc_errno = 0;
// ASSERT_EQ(__llvm_libc::fopen("INVALID FILE NAME", "r"),
// static_cast<FILE *>(nullptr));
- // EXPECT_NE(errno, 0);
+ // EXPECT_NE(libc_errno, 0);
}
TEST(LlvmLibcFILETest, FFlush) {
constexpr size_t WRITE_NMEMB = sizeof(WRITE_DATA) / sizeof(MyStruct);
constexpr char FILENAME[] = "testdata/fread_fwrite.test";
- errno = 0;
+ libc_errno = 0;
FILE *file = __llvm_libc::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
ASSERT_EQ(size_t(0), __llvm_libc::fwrite(WRITE_DATA, 0, 1, file));
ASSERT_EQ(WRITE_NMEMB, __llvm_libc::fwrite(WRITE_DATA, sizeof(MyStruct),
WRITE_NMEMB, file));
- EXPECT_EQ(errno, 0);
+ EXPECT_EQ(libc_errno, 0);
ASSERT_EQ(__llvm_libc::fclose(file), 0);
file = __llvm_libc::fopen(FILENAME, "r");
ASSERT_EQ(size_t(0), __llvm_libc::fread(read_data, 0, 1, file));
ASSERT_EQ(WRITE_NMEMB,
__llvm_libc::fread(read_data, sizeof(MyStruct), WRITE_NMEMB, file));
- EXPECT_EQ(errno, 0);
+ EXPECT_EQ(libc_errno, 0);
// Trying to read more should fetch nothing.
ASSERT_EQ(size_t(0),
__llvm_libc::fread(read_data, sizeof(MyStruct), WRITE_NMEMB, file));
- EXPECT_EQ(errno, 0);
+ EXPECT_EQ(libc_errno, 0);
EXPECT_NE(__llvm_libc::feof(file), 0);
EXPECT_EQ(__llvm_libc::ferror(file), 0);
ASSERT_EQ(__llvm_libc::fclose(file), 0);
#include "test/UnitTest/MemoryMatcher.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
#include <stdlib.h>
} else if (whence == SEEK_END) {
new_offset = *offset + ss->endpos;
} else {
- errno = EINVAL;
+ libc_errno = EINVAL;
return -1;
}
if (new_offset < 0 || size_t(new_offset) > ss->bufsize)
// Should be an error to write.
ASSERT_EQ(size_t(0), __llvm_libc::fwrite(CONTENT, 1, sizeof(CONTENT), f));
ASSERT_NE(__llvm_libc::ferror(f), 0);
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr(f);
ASSERT_EQ(__llvm_libc::ferror(f), 0);
// Should be an error to read.
ASSERT_EQ(size_t(0), __llvm_libc::fread(read_data, 1, sizeof(WRITE_DATA), f));
ASSERT_NE(__llvm_libc::ferror(f), 0);
- ASSERT_EQ(errno, EBADF);
- errno = 0;
+ ASSERT_EQ(libc_errno, EBADF);
+ libc_errno = 0;
__llvm_libc::clearerr(f);
ASSERT_EQ(__llvm_libc::ferror(f), 0);
// This is not a readable file.
ASSERT_EQ(__llvm_libc::fread(read_data, 1, READ_SIZE, f), size_t(0));
ASSERT_NE(__llvm_libc::ferror(f), 0);
- EXPECT_NE(errno, 0);
- errno = 0;
+ EXPECT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr(f);
ASSERT_EQ(__llvm_libc::ferror(f), 0);
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <stdio.h>
TEST(LlvmLibcFPrintfTest, WriteToFile) {
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <stdio.h>
TEST(LlvmLibcFScanfTest, WriteToFile) {
#include "src/stdio/setvbuf.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <stdio.h>
class LlvmLibcFTellTest : public __llvm_libc::testing::Test {
ASSERT_EQ(size_t(__llvm_libc::ftell(file)), READ_SIZE);
ASSERT_EQ(0, __llvm_libc::fclose(file));
-
- // errno = 0;
- // ASSERT_EQ(__llvm_libc::ftell(file), long(-1));
- // ASSERT_NE(errno, 0);
}
};
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <stdio.h>
TEST(LlvmLibcPutcTest, WriteToFile) {
#include "test/UnitTest/Test.h"
#include "utils/testutils/FDReader.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <unistd.h>
TEST(LlvmLibcRemoveTest, CreateAndRemoveFile) {
// The test strategy is to create a file and remove it, and also verify that
// it was removed.
- errno = 0;
+ libc_errno = 0;
using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/remove.test.file";
int fd = __llvm_libc::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
ASSERT_GT(fd, 0);
ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0));
TEST(LlvmLibcRemoveTest, CreateAndRemoveDir) {
// The test strategy is to create a dir and remove it, and also verify that
// it was removed.
- errno = 0;
+ libc_errno = 0;
using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_DIR = "testdata/remove.test.dir";
#include "src/stdio/setvbuf.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
TEST(LlvmLibcSetvbufTest, SetNBFBuffer) {
ASSERT_FALSE(f == nullptr);
char buf[BUFSIZ];
ASSERT_NE(__llvm_libc::setvbuf(f, buf, _IOFBF + _IOLBF + _IONBF, BUFSIZ), 0);
- ASSERT_EQ(errno, EINVAL);
+ ASSERT_EQ(libc_errno, EINVAL);
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(0, __llvm_libc::fclose(f));
}
#include "src/stdio/fwrite_unlocked.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
+#include "src/errno/libc_errno.h"
#include <stdio.h>
TEST(LlvmLibcFILETest, UnlockedReadAndWrite) {
ASSERT_EQ(size_t(0),
__llvm_libc::fread_unlocked(data, 1, sizeof(READ_SIZE), f));
ASSERT_NE(__llvm_libc::ferror_unlocked(f), 0);
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr_unlocked(f);
ASSERT_EQ(__llvm_libc::ferror_unlocked(f), 0);
ASSERT_EQ(size_t(0),
__llvm_libc::fwrite_unlocked(CONTENT, 1, sizeof(CONTENT), f));
ASSERT_NE(__llvm_libc::ferror_unlocked(f), 0);
- ASSERT_NE(errno, 0);
- errno = 0;
+ ASSERT_NE(libc_errno, 0);
+ libc_errno = 0;
__llvm_libc::clearerr_unlocked(f);
ASSERT_EQ(__llvm_libc::ferror_unlocked(f), 0);
SRCS
atof_test.cpp
DEPENDS
+ libc.src.errno.errno
libc.src.stdlib.atof
)
HDRS
AtoiTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.__support.CPP.type_traits
)
SRCS
strtod_test.cpp
DEPENDS
+ libc.src.errno.errno
libc.src.stdlib.strtod
)
SRCS
strtof_test.cpp
DEPENDS
+ libc.src.errno.errno
libc.src.stdlib.strtof
)
DEPENDS
libc.src.__support.CPP.limits
libc.src.__support.CPP.type_traits
- libc.include.errno
libc.src.errno.errno
)
SRCS
strtold_test.cpp
DEPENDS
+ libc.src.errno.errno
libc.src.__support.uint128
libc.src.stdlib.strtold
)
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
+#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <limits.h>
#include <stddef.h>
void InvalidBase(FunctionT func) {
const char *ten = "10";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(ten, nullptr, -1), ReturnT(0));
- ASSERT_EQ(errno, EINVAL);
+ ASSERT_EQ(libc_errno, EINVAL);
}
void CleanBaseTenDecode(FunctionT func) {
// TODO: Look into collapsing these repeated segments.
const char *ten = "10";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(ten, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - ten, ptrdiff_t(2));
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(ten, nullptr, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
const char *hundred = "100";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(hundred, &str_end, 10), ReturnT(100));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - hundred, ptrdiff_t(3));
const char *big_number = "1234567890";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(big_number, &str_end, 10), ReturnT(1234567890));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - big_number, ptrdiff_t(10));
// This number is larger than 2^32, meaning that if long is only 32 bits
// wide, strtol will return LONG_MAX.
const char *bigger_number = "12345678900";
- errno = 0;
+ libc_errno = 0;
if constexpr (sizeof(ReturnT) < 8) {
ASSERT_EQ(func(bigger_number, &str_end, 10), T_MAX);
- ASSERT_EQ(errno, ERANGE);
+ ASSERT_EQ(libc_errno, ERANGE);
} else {
ASSERT_EQ(func(bigger_number, &str_end, 10), ReturnT(12345678900));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
EXPECT_EQ(str_end - bigger_number, ptrdiff_t(11));
const char *too_big_number = "123456789012345678901";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(too_big_number, &str_end, 10), T_MAX);
- ASSERT_EQ(errno, ERANGE);
+ ASSERT_EQ(libc_errno, ERANGE);
EXPECT_EQ(str_end - too_big_number, ptrdiff_t(21));
const char *long_number_range_test =
"10000000000000000000000000000000000000000000000000";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(long_number_range_test, &str_end, 10), T_MAX);
- ASSERT_EQ(errno, ERANGE);
+ ASSERT_EQ(libc_errno, ERANGE);
EXPECT_EQ(str_end - long_number_range_test, ptrdiff_t(50));
// For most negative numbers, the unsigned functions treat it the same as
// casting a negative variable to an unsigned type.
const char *negative = "-100";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(negative, &str_end, 10), ReturnT(-100));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - negative, ptrdiff_t(4));
const char *big_negative_number = "-1234567890";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(big_negative_number, &str_end, 10), ReturnT(-1234567890));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - big_negative_number, ptrdiff_t(11));
const char *too_big_negative_number = "-123456789012345678901";
- errno = 0;
+ libc_errno = 0;
// If the number is signed, it should return the smallest negative number
// for the current type, but if it's unsigned it should max out and return
// the largest positive number for the current type. From the standard:
// Note that 0 is not on that list.
ASSERT_EQ(func(too_big_negative_number, &str_end, 10),
(is_signed_v<ReturnT> ? T_MIN : T_MAX));
- ASSERT_EQ(errno, ERANGE);
+ ASSERT_EQ(libc_errno, ERANGE);
EXPECT_EQ(str_end - too_big_negative_number, ptrdiff_t(22));
}
char *str_end = nullptr;
const char *spaces_before = " 10";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(spaces_before, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - spaces_before, ptrdiff_t(7));
const char *spaces_after = "10 ";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(spaces_after, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - spaces_after, ptrdiff_t(2));
const char *word_before = "word10";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(word_before, &str_end, 10), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - word_before, ptrdiff_t(0));
const char *word_after = "10word";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(word_after, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - word_after, ptrdiff_t(2));
const char *two_numbers = "10 999";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(two_numbers, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - two_numbers, ptrdiff_t(2));
const char *two_signs = "--10 999";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(two_signs, &str_end, 10), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - two_signs, ptrdiff_t(0));
const char *sign_before = "+2=4";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(sign_before, &str_end, 10), ReturnT(2));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - sign_before, ptrdiff_t(2));
const char *sign_after = "2+2=4";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(sign_after, &str_end, 10), ReturnT(2));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - sign_after, ptrdiff_t(1));
const char *tab_before = "\t10";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(tab_before, &str_end, 10), ReturnT(10));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - tab_before, ptrdiff_t(3));
const char *all_together = "\t -12345and+67890";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(all_together, &str_end, 10), ReturnT(-12345));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - all_together, ptrdiff_t(9));
const char *just_spaces = " ";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_spaces, &str_end, 10), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_spaces, ptrdiff_t(0));
const char *just_space_and_sign = " +";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_space_and_sign, &str_end, 10), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_space_and_sign, ptrdiff_t(0));
}
for (int first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit);
if (first_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
}
}
for (int second_digit = 0; second_digit <= 36; ++second_digit) {
small_string[1] = int_to_b36_char(second_digit);
if (first_digit < base && second_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(
func(small_string, nullptr, base),
static_cast<ReturnT>(second_digit + (first_digit * base)));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else if (first_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
}
}
if (first_digit < base && second_digit < base &&
third_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(third_digit +
(second_digit * base) +
(first_digit * base * base)));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else if (first_digit < base && second_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(
func(small_string, nullptr, base),
static_cast<ReturnT>(second_digit + (first_digit * base)));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else if (first_digit < base) {
// if the base is 16 there is a special case for the prefix 0X.
// The number is treated as a one digit hexadecimal.
if (base == 16 && first_digit == 0 && second_digit == 33) {
if (third_digit < base) {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(third_digit));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
} else {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
} else {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
} else {
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
}
}
}
char *str_end = nullptr;
const char *no_prefix = "123abc";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(no_prefix, &str_end, 16), ReturnT(0x123abc));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - no_prefix, ptrdiff_t(6));
const char *yes_prefix = "0x456def";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(yes_prefix, &str_end, 16), ReturnT(0x456def));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - yes_prefix, ptrdiff_t(8));
const char *letter_after_prefix = "0xabc123";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(letter_after_prefix, &str_end, 16), ReturnT(0xabc123));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - letter_after_prefix, ptrdiff_t(8));
}
char *str_end = nullptr;
const char *just_prefix = "0x";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_prefix, &str_end, 16), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_prefix, ptrdiff_t(1));
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_prefix, &str_end, 0), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_prefix, ptrdiff_t(1));
const char *prefix_with_x_after = "0xx";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(prefix_with_x_after, &str_end, 16), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - prefix_with_x_after, ptrdiff_t(1));
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(prefix_with_x_after, &str_end, 0), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - prefix_with_x_after, ptrdiff_t(1));
}
char *str_end = nullptr;
const char *base_ten = "12345";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(base_ten, &str_end, 0), ReturnT(12345));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - base_ten, ptrdiff_t(5));
const char *base_sixteen_no_prefix = "123abc";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(base_sixteen_no_prefix, &str_end, 0), ReturnT(123));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - base_sixteen_no_prefix, ptrdiff_t(3));
const char *base_sixteen_with_prefix = "0x456def";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(base_sixteen_with_prefix, &str_end, 0), ReturnT(0x456def));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - base_sixteen_with_prefix, ptrdiff_t(8));
const char *base_eight_with_prefix = "012345";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(base_eight_with_prefix, &str_end, 0), ReturnT(012345));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - base_eight_with_prefix, ptrdiff_t(6));
const char *just_zero = "0";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_zero, &str_end, 0), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_zero, ptrdiff_t(1));
const char *just_zero_x = "0x";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_zero_x, &str_end, 0), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_zero_x, ptrdiff_t(1));
const char *just_zero_eight = "08";
- errno = 0;
+ libc_errno = 0;
ASSERT_EQ(func(just_zero_eight, &str_end, 0), ReturnT(0));
- ASSERT_EQ(errno, 0);
+ ASSERT_EQ(libc_errno, 0);
EXPECT_EQ(str_end - just_zero_eight, ptrdiff_t(1));
}
};
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/stdlib/atof.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <limits.h>
#include <stddef.h>
__llvm_libc::fputil::FPBits<double> expected_fp =
__llvm_libc::fputil::FPBits<double>(uint64_t(0x405ec00000000000));
- errno = 0;
+ libc_errno = 0;
double result = __llvm_libc::atof("123");
__llvm_libc::fputil::FPBits<double> actual_fp =
EXPECT_EQ(actual_fp.get_sign(), expected_fp.get_sign());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(errno, 0);
+ EXPECT_EQ(libc_errno, 0);
}
TEST(LlvmLibcAToFTest, FailedParsingTest) {
__llvm_libc::fputil::FPBits<double> expected_fp =
__llvm_libc::fputil::FPBits<double>(uint64_t(0));
- errno = 0;
+ libc_errno = 0;
double result = __llvm_libc::atof("???");
__llvm_libc::fputil::FPBits<double> actual_fp =
EXPECT_EQ(actual_fp.get_sign(), expected_fp.get_sign());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(errno, 0);
+ EXPECT_EQ(libc_errno, 0);
}
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/stdlib/strtod.h"
#include "test/UnitTest/Test.h"
#include "utils/testutils/RoundingModeUtils.h"
-#include <errno.h>
#include <limits.h>
#include <stddef.h>
__llvm_libc::fputil::FPBits<double> expected_fp =
__llvm_libc::fputil::FPBits<double>(expectedRawData);
- errno = 0;
+ libc_errno = 0;
double result = __llvm_libc::strtod(inputString, &str_end);
__llvm_libc::fputil::FPBits<double> actual_fp =
EXPECT_EQ(actual_fp.get_sign(), expected_fp.get_sign());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(errno, expectedErrno);
+ EXPECT_EQ(libc_errno, expectedErrno);
}
};
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/stdlib/strtof.h"
#include "test/UnitTest/Test.h"
#include "utils/testutils/RoundingModeUtils.h"
-#include <errno.h>
#include <limits.h>
#include <stddef.h>
__llvm_libc::fputil::FPBits<float> expected_fp =
__llvm_libc::fputil::FPBits<float>(expectedRawData);
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::strtof(inputString, &str_end);
__llvm_libc::fputil::FPBits<float> actual_fp =
EXPECT_EQ(actual_fp.get_sign(), expected_fp.get_sign());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(errno, expectedErrno);
+ EXPECT_EQ(libc_errno, expectedErrno);
}
};
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/UInt128.h"
+#include "src/errno/libc_errno.h"
#include "src/stdlib/strtold.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <limits.h>
#include <stddef.h>
__llvm_libc::fputil::FPBits<long double>(expectedRawData);
const int expected_errno = expectedErrno;
- errno = 0;
+ libc_errno = 0;
long double result = __llvm_libc::strtold(inputString, &str_end);
__llvm_libc::fputil::FPBits<long double> actual_fp =
EXPECT_EQ(actual_fp.get_sign(), expected_fp.get_sign());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(errno, expected_errno);
+ EXPECT_EQ(libc_errno, expected_errno);
}
};
":__support_cpp_limits",
":__support_ctype_utils",
":__support_str_to_num_result",
+ ":errno",
],
)
":__support_str_to_integer",
":__support_str_to_num_result",
":__support_uint128",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_float",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_integer",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_float",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_float",
+ ":errno",
],
)
deps = [
":__support_common",
":__support_str_to_float",
+ ":errno",
],
)