Skip to content

Commit aa1b487

Browse files
committed
Use C++ headers and reserved naming for vasprintf and fix CI
1 parent 26e4eac commit aa1b487

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

libcxx/include/__locale_dir/support/zos.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct __locale_guard {
3232
_LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(std::uselocale(__loc)) {}
3333

3434
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
35-
// if (__old_loc_)
3635
if (__old_loc_ != (locale_t)0)
3736
std::uselocale(__old_loc_);
3837
}
@@ -299,7 +298,7 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __as
299298
va_list __va;
300299
va_start(__va, __format);
301300
__locale_guard __current(__loc);
302-
int __res = std::__ibm::vasprintf(__s, __format, __va); // non-standard
301+
int __res = std::__ibm::__vasprintf(__s, __format, __va); // non-standard
303302
va_end(__va);
304303
return __res;
305304
}

libcxx/include/__support/ibm/vasprintf.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@
1010
#define _LIBCPP___SUPPORT_IBMVASPRINTF_H
1111

1212
#include <cstdlib> // malloc, realloc
13-
#include <stdarg.h> // va_copy, va_end
14-
#include <stdio.h> // vsnprintf
13+
#include <cstdarg> // va_copy, va_end
14+
#include <cstdio> // vsnprintf
1515

1616
_LIBCPP_BEGIN_NAMESPACE_STD
1717
namespace __ibm {
1818

1919
inline _LIBCPP_HIDE_FROM_ABI
20-
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
20+
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int __vasprintf(char** __strp, const char* __fmt, va_list __ap) {
2121
const size_t buff_size = 256;
22-
if ((*strp = (char*)malloc(buff_size)) == nullptr) {
22+
if ((*__strp = (char*)std::malloc(buff_size)) == nullptr) {
2323
return -1;
2424
}
2525

2626
va_list ap_copy;
2727
// va_copy may not be provided by the C library in C++03 mode.
2828
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
2929
# if defined(__MVS__) && !defined(_VARARG_EXT_)
30-
__builtin_zos_va_copy(ap_copy, ap);
30+
__builtin_zos_va_copy(ap_copy, __ap);
3131
# else
32-
__builtin_va_copy(ap_copy, ap);
32+
__builtin_va_copy(ap_copy, __ap);
3333
# endif
3434
#else
35-
va_copy(ap_copy, ap);
35+
va_copy(ap_copy, __ap);
3636
#endif
37-
int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
37+
int str_size = vsnprintf(*__strp, buff_size, __fmt, ap_copy);
3838
va_end(ap_copy);
3939

4040
if ((size_t)str_size >= buff_size) {
41-
if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
41+
if ((*__strp = (char*)std::realloc(*__strp, str_size + 1)) == nullptr) {
4242
return -1;
4343
}
44-
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
44+
str_size = vsnprintf(*__strp, str_size + 1, __fmt, __ap);
4545
}
4646
return str_size;
4747
}

libcxx/test/libcxx/internal.zos.locale.funcs.compile.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// REQUIRES: target={{.+}}-zos{{.*}}
10+
911
// Test that version of the POSIX functions provided outside of libc++ don't
1012
// cause compilation errors.
1113

libcxx/test/libcxx/internal.zos.mbsnrtowcs.compile.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// REQUIRES: target={{.+}}-zos{{.*}}
10+
911
// Validating the following declaration of mbsnrtowcs resides in std::__locale::__ibm namespace.
1012
// size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
1113

libcxx/test/libcxx/internal.zos.wcsnrtombs.compile.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// REQUIRES: target={{.+}}-zos{{.*}}
10+
911
// Validating the following declaration of wcsnrtombs resides in std::__locale::__ibm namespace.
1012
// size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*);
1113

libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/ctype.cxx.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(int, char**) {
2424
char lower = 'a';
2525
char digit = '1';
2626
char xdigit = 'b';
27-
auto& CF = std::use_facet<std::ctype_byname<char>>(loc);
27+
auto& CF = std::use_facet<std::ctype_byname<char> >(loc);
2828
assert(CF.is(std::ctype_base::lower, lower));
2929
assert(CF.is(std::ctype_base::upper, upper));
3030
assert(CF.is(std::ctype_base::digit, digit));
@@ -60,7 +60,7 @@ int main(int, char**) {
6060
assert(std::iswpunct(wpunct));
6161
assert(std::iswxdigit(wxdigit));
6262

63-
auto& WF = std::use_facet<std::ctype_byname<wchar_t>>(loc);
63+
auto& WF = std::use_facet<std::ctype_byname<wchar_t> >(loc);
6464
assert(wlower == WF.tolower(wupper));
6565
assert(wupper == WF.toupper(wlower));
6666
}

0 commit comments

Comments
 (0)