diff -ruN libcxx.orig/CREDITS.TXT libcxx/CREDITS.TXT --- libcxx.orig/CREDITS.TXT 2013-08-13 15:51:00.560040835 -0400 +++ libcxx/CREDITS.TXT 2013-08-13 15:54:25.790251822 -0400 @@ -109,6 +109,10 @@ E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. +N: Xing Xue +E: xingxue@ca.ibm.com +D: AIX port + N: Zhihao Yuan E: lichray@gmail.com D: Standard compatibility fixes. diff -ruN libcxx.orig/include/__bit_reference libcxx/include/__bit_reference --- libcxx.orig/include/__bit_reference 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/__bit_reference 2013-08-13 13:39:00.420312046 -0400 @@ -40,7 +40,7 @@ __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -130,7 +130,7 @@ __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -1222,7 +1222,7 @@ __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT : __seg_(__s), __ctz_(__ctz) {} -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) friend typename _Cp::__self; #else friend class _Cp::__self; diff -ruN libcxx.orig/include/__config libcxx/include/__config --- libcxx.orig/include/__config 2013-08-13 15:51:00.532544378 -0400 +++ libcxx/include/__config 2013-08-13 13:15:37.930242877 -0400 @@ -434,7 +434,39 @@ namespace std { } -#endif // __clang__ || __GNUC__ || _LIBCPP_MSVC +#elif defined(__IBMCPP__) + +#define _ALIGNAS(x) __attribute__((__aligned__(x))) +#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) +#define _ATTRIBUTE(x) __attribute__((x)) +#define _LIBCPP_NORETURN __attribute__((noreturn)) + +#define _NOEXCEPT throw() +#define _NOEXCEPT_(x) + +#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#define _LIBCPP_HAS_NO_NULLPTR +#define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_STRONG_ENUMS +#define _LIBCPP_HAS_IS_BASE_OF + +#if defined(_AIX) +#define __MULTILOCALE_API +#endif + +#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { +#define _LIBCPP_END_NAMESPACE_STD } } +#define _VSTD std::_LIBCPP_NAMESPACE + +namespace std { + inline namespace _LIBCPP_NAMESPACE { + } +} + +#endif // __clang__ || __GNUC___ || _MSC_VER || __IBMCPP__ #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; diff -ruN libcxx.orig/include/__locale libcxx/include/__locale --- libcxx.orig/include/__locale 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/__locale 2013-08-13 15:12:40.790274605 -0400 @@ -21,9 +21,11 @@ #include #ifdef _LIBCPP_MSVCRT # include -#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(EMSCRIPTEN) +#elif _AIX +# include +#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(EMSCRIPTEN) || defined(__IBMCPP__) # include -#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || EMSCRIPTEN +#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || EMSCRIPTEN || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff -ruN libcxx.orig/include/algorithm libcxx/include/algorithm --- libcxx.orig/include/algorithm 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/algorithm 2013-08-13 14:33:31.530243878 -0400 @@ -628,6 +628,10 @@ #include #include +#if defined(__IBMCPP__) +#include "support/ibm/support.h" +#endif + #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff -ruN libcxx.orig/include/cmath libcxx/include/cmath --- libcxx.orig/include/cmath 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/cmath 2013-08-13 14:11:56.020036217 -0400 @@ -654,6 +654,7 @@ // abs +#if !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY float abs(float __x) _NOEXCEPT {return fabsf(__x);} @@ -665,6 +666,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double abs(long double __x) _NOEXCEPT {return fabsl(__x);} +#endif // !defined(_AIX) #ifndef __sun__ @@ -673,7 +675,7 @@ using ::acos; using ::acosf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) _NOEXCEPT {return acosf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);} #endif @@ -688,7 +690,7 @@ using ::asin; using ::asinf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) _NOEXCEPT {return asinf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);} #endif @@ -703,7 +705,7 @@ using ::atan; using ::atanf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) _NOEXCEPT {return atanf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);} #endif @@ -718,7 +720,7 @@ using ::atan2; using ::atan2f; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) _NOEXCEPT {return atan2f(__y, __x);} inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __x);} #endif @@ -744,7 +746,7 @@ using ::ceil; using ::ceilf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) _NOEXCEPT {return ceilf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);} #endif @@ -759,7 +761,7 @@ using ::cos; using ::cosf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) _NOEXCEPT {return cosf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);} #endif @@ -774,7 +776,7 @@ using ::cosh; using ::coshf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) _NOEXCEPT {return coshf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);} #endif @@ -792,7 +794,7 @@ #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) _NOEXCEPT {return expf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);} #endif @@ -808,7 +810,7 @@ using ::fabs; using ::fabsf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) _NOEXCEPT {return fabsf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);} #endif @@ -823,7 +825,7 @@ using ::floor; using ::floorf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) _NOEXCEPT {return floorf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);} #endif @@ -840,7 +842,7 @@ using ::fmodf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) _NOEXCEPT {return fmodf(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __y);} #endif @@ -867,7 +869,7 @@ using ::frexp; using ::frexpf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) _NOEXCEPT {return frexpf(__x, __e);} inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);} #endif @@ -882,7 +884,7 @@ using ::ldexp; using ::ldexpf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) _NOEXCEPT {return ldexpf(__x, __e);} inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);} #endif @@ -899,7 +901,7 @@ using ::logf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float log(float __x) _NOEXCEPT {return logf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);} #endif @@ -915,7 +917,7 @@ using ::log10; using ::log10f; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) _NOEXCEPT {return log10f(__x);} inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);} #endif @@ -930,7 +932,7 @@ using ::modf; using ::modff; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) _NOEXCEPT {return modff(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);} #endif @@ -943,7 +945,7 @@ #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) _NOEXCEPT {return powf(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __y);} #endif @@ -970,7 +972,7 @@ using ::sin; using ::sinf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) _NOEXCEPT {return sinf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);} #endif @@ -985,7 +987,7 @@ using ::sinh; using ::sinhf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) _NOEXCEPT {return sinhf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);} #endif @@ -1002,7 +1004,7 @@ using ::sqrtf; -#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__)) +#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) _NOEXCEPT {return sqrtf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);} #endif @@ -1018,7 +1020,7 @@ using ::tanf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) _NOEXCEPT {return tanf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);} #endif @@ -1033,7 +1035,7 @@ using ::tanh; using ::tanhf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) _NOEXCEPT {return tanhf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);} #endif diff -ruN libcxx.orig/include/cstdlib libcxx/include/cstdlib --- libcxx.orig/include/cstdlib 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/cstdlib 2013-08-13 13:45:06.190241413 -0400 @@ -155,7 +155,7 @@ #endif // MSVCRT already has the correct prototype in #ifdef __cplusplus -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);} #ifndef _LIBCPP_HAS_NO_LONG_LONG inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);} diff -ruN libcxx.orig/include/limits libcxx/include/limits --- libcxx.orig/include/limits 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/limits 2013-08-13 13:32:21.170252340 -0400 @@ -115,6 +115,10 @@ #include "support/win32/limits_win32.h" #endif // _LIBCPP_MSVCRT +#if defined(__IBMCPP__) +#include "support/ibm/limits.h" +#endif // __IBMCPP__ + _LIBCPP_BEGIN_NAMESPACE_STD enum float_round_style diff -ruN libcxx.orig/include/locale libcxx/include/locale --- libcxx.orig/include/locale 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/locale 2013-08-13 14:36:27.160250025 -0400 @@ -224,7 +224,7 @@ // OSX has nice foo_l() functions that let you turn off use of the global // locale. Linux, not so much. The following functions avoid the locale when // that's possible and otherwise do the wrong thing. FIXME. -#if defined(__linux__) || defined(EMSCRIPTEN) +#if defined(__linux__) || defined(EMSCRIPTEN) || defined(_AIX) #ifdef _LIBCPP_LOCALE__L_EXTENSIONS decltype(MB_CUR_MAX_L(_VSTD::declval())) diff -ruN libcxx.orig/include/random libcxx/include/random --- libcxx.orig/include/random 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/random 2013-08-13 14:29:30.190249274 -0400 @@ -5901,8 +5901,8 @@ discrete_distribution(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} - explicit discrete_distribution(const param_type& __p) _LIBCPP_INLINE_VISIBILITY + explicit discrete_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} diff -ruN libcxx.orig/include/string libcxx/include/string --- libcxx.orig/include/string 2013-08-13 15:51:00.522546759 -0400 +++ libcxx/include/string 2013-08-13 13:25:37.800243674 -0400 @@ -1615,13 +1615,13 @@ template static _LIBCPP_INLINE_VISIBILITY - size_type __align(size_type __s) _NOEXCEPT + size_type __align_it(size_type __s) _NOEXCEPT {return __s + (__a-1) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT {return (__s < __min_cap ? __min_cap : - __align (__s+1)) - 1;} void __init(const value_type* __s, size_type __sz, size_type __reserve); diff -ruN libcxx.orig/include/support/ibm/limits.h libcxx/include/support/ibm/limits.h --- libcxx.orig/include/support/ibm/limits.h 1969-12-31 19:00:00.000000000 -0500 +++ libcxx/include/support/ibm/limits.h 2013-08-13 13:29:02.000243284 -0400 @@ -0,0 +1,99 @@ +// -*- C++ -*- +//===--------------------- support/ibm/limits.h -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H +#define _LIBCPP_SUPPORT_IBM_LIMITS_H + +#if !defined(_AIX) // Linux +#include // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN + +static const unsigned int _QNAN_F = 0x7fc00000; +#define NANF (*((float *)(&_QNAN_F))) +static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0}; +#define NANL (*((long double *)(&_QNAN_LDBL128))) +static const unsigned int _SNAN_F= 0x7f855555; +#define NANSF (*((float *)(&_SNAN_F))) +static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555}; +#define NANS (*((double *)(&_SNAN_D))) +static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0}; +#define NANSL (*((long double *)(&_SNAN_LDBL128))) + +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() HUGE_VALF +#define __builtin_huge_vall() HUGE_VALL +#define __builtin_nan(__dummy) NAN +#define __builtin_nanf(__dummy) NANF +#define __builtin_nanl(__dummy) NANL +#define __builtin_nans(__dummy) NANS +#define __builtin_nansf(__dummy) NANSF +#define __builtin_nansl(__dummy) NANSL + +#else + +#include +#include // limit constants + +#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000 +#define __builtin_huge_valf() HUGE_VALF //0x7f800000 +#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000 +#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000 +#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000 +#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000 +#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555 +#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555 +#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555 + +#define __FLT_MANT_DIG__ FLT_MANT_DIG +#define __FLT_DIG__ FLT_DIG +#define __FLT_RADIX__ FLT_RADIX +#define __FLT_MIN_EXP__ FLT_MIN_EXP +#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP +#define __FLT_MAX_EXP__ FLT_MAX_EXP +#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP +#define __FLT_MIN__ FLT_MIN +#define __FLT_MAX__ FLT_MAX +#define __FLT_EPSILON__ FLT_EPSILON +// predefined by XLC on LoP +#define __FLT_DENORM_MIN__ 1.40129846e-45F + +#define __DBL_MANT_DIG__ DBL_MANT_DIG +#define __DBL_DIG__ DBL_DIG +#define __DBL_MIN_EXP__ DBL_MIN_EXP +#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP +#define __DBL_MAX_EXP__ DBL_MAX_EXP +#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP +#define __DBL_MIN__ DBL_MIN +#define __DBL_MAX__ DBL_MAX +#define __DBL_EPSILON__ DBL_EPSILON +// predefined by XLC on LoP +#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 + +#define __LDBL_MANT_DIG__ LDBL_MANT_DIG +#define __LDBL_DIG__ LDBL_DIG +#define __LDBL_MIN_EXP__ LDBL_MIN_EXP +#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP +#define __LDBL_MAX_EXP__ LDBL_MAX_EXP +#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP +#define __LDBL_MIN__ LDBL_MIN +#define __LDBL_MAX__ LDBL_MAX +#define __LDBL_EPSILON__ LDBL_EPSILON +// predefined by XLC on LoP +#if __LONGDOUBLE128 +#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L +#else +#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L +#endif + +// predefined by XLC on LoP +#define __CHAR_BIT__ 8 + +#endif // _AIX + +#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H diff -ruN libcxx.orig/include/support/ibm/support.h libcxx/include/support/ibm/support.h --- libcxx.orig/include/support/ibm/support.h 1969-12-31 19:00:00.000000000 -0500 +++ libcxx/include/support/ibm/support.h 2013-08-13 13:29:02.000243284 -0400 @@ -0,0 +1,54 @@ +// -*- C++ -*- +//===----------------------- support/ibm/support.h ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H +#define _LIBCPP_SUPPORT_IBM_SUPPORT_H + +extern "builtin" int __popcnt4(unsigned int); +extern "builtin" int __popcnt8(unsigned long long); +extern "builtin" unsigned int __cnttz4(unsigned int); +extern "builtin" unsigned int __cnttz8(unsigned long long); +extern "builtin" unsigned int __cntlz4(unsigned long long); +extern "builtin" unsigned int __cntlz8(unsigned long long); + +// Builtin functions for counting population +#define __builtin_popcount(x) __popcnt4(x) +#define __builtin_popcountll(x) __popcnt8(x) +#if defined(__64BIT__) +#define __builtin_popcountl(x) __builtin_popcountll(x) +#else +#define __builtin_popcountl(x) __builtin_popcount(x) +#endif + +// Builtin functions for counting trailing zeros +#define __builtin_ctz(x) __cnttz4(x) +#define __builtin_ctzll(x) __cnttz8(x) +#if defined(__64BIT__) +#define __builtin_ctzl(x) __builtin_ctzll(x) +#else +#define __builtin_ctzl(x) __builtin_ctz(x) +#endif + +// Builtin functions for counting leading zeros +#define __builtin_clz(x) __cntlz4(x) +#define __builtin_clzll(x) __cntlz8(x) +#if defined(__64BIT__) +#define __builtin_clzl(x) __builtin_clzll(x) +#else +#define __builtin_clzl(x) __builtin_clz(x) +#endif + +#if defined(__64BIT__) +#define __SIZE_WIDTH__ 64 +#else +#define __SIZE_WIDTH__ 32 +#endif + +#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H diff -ruN libcxx.orig/include/support/ibm/xlocale.h libcxx/include/support/ibm/xlocale.h --- libcxx.orig/include/support/ibm/xlocale.h 1969-12-31 19:00:00.000000000 -0500 +++ libcxx/include/support/ibm/xlocale.h 2013-08-13 13:29:02.000243284 -0400 @@ -0,0 +1,328 @@ +// -*- C++ -*- +//===--------------------- support/ibm/xlocale.h -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H +#define _LIBCPP_SUPPORT_IBM_XLOCALE_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK 4 +#define LC_MONETARY_MASK 8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK 32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { + errno = EINVAL; + return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { + errno = ENOMEM; + return (locale_t)0; + } + if (!base) + base = (_LC_locale_t *)__xopen_locale("C"); + memcpy(newloc, base, sizeof (_LC_locale_t)); + if (category_mask & LC_COLLATE_MASK) + newloc->lc_collate = loc->lc_collate; + if (category_mask & LC_CTYPE_MASK) + newloc->lc_ctype = loc->lc_ctype; + //if (category_mask & LC_MESSAGES_MASK) + // newloc->lc_messages = loc->lc_messages; + if (category_mask & LC_MONETARY_MASK) + newloc->lc_monetary = loc->lc_monetary; + if (category_mask & LC_TIME_MASK) + newloc->lc_time = loc->lc_time; + if (category_mask & LC_NUMERIC_MASK) + newloc->lc_numeric = loc->lc_numeric; + return (locale_t)newloc; +} +static inline +void freelocale(locale_t locobj) +{ + free(locobj); +} +static inline +locale_t uselocale(locale_t newloc) +{ + return (locale_t)0; +} + +static inline +int isalnum_l(int c, locale_t locale) +{ + return __xisalnum(locale, c); +} +static inline +int isalpha_l(int c, locale_t locale) +{ + return __xisalpha(locale, c); +} +static inline +int isblank_l(int c, locale_t locale) +{ + return __xisblank(locale, c); +} +static inline +int iscntrl_l(int c, locale_t locale) +{ + return __xiscntrl(locale, c); +} +static inline +int isdigit_l(int c, locale_t locale) +{ + return __xisdigit(locale, c); +} +static inline +int isgraph_l(int c, locale_t locale) +{ + return __xisgraph(locale, c); +} +static inline +int islower_l(int c, locale_t locale) +{ + return __xislower(locale, c); +} +static inline +int isprint_l(int c, locale_t locale) +{ + return __xisprint(locale, c); +} + +static inline +int ispunct_l(int c, locale_t locale) +{ + return __xispunct(locale, c); +} +static inline +int isspace_l(int c, locale_t locale) +{ + return __xisspace(locale, c); +} +static inline +int isupper_l(int c, locale_t locale) +{ + return __xisupper(locale, c); +} + +static inline +int isxdigit_l(int c, locale_t locale) +{ + return __xisxdigit(locale, c); +} + +static inline +int iswalnum_l(wchar_t wc, locale_t locale) +{ + return __xiswalnum(locale, wc); +} + +static inline +int iswalpha_l(wchar_t wc, locale_t locale) +{ + return __xiswalpha(locale, wc); +} + +static inline +int iswblank_l(wchar_t wc, locale_t locale) +{ + return __xiswblank(locale, wc); +} + +static inline +int iswcntrl_l(wchar_t wc, locale_t locale) +{ + return __xiswcntrl(locale, wc); +} + +static inline +int iswdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswdigit(locale, wc); +} + +static inline +int iswgraph_l(wchar_t wc, locale_t locale) +{ + return __xiswgraph(locale, wc); +} + +static inline +int iswlower_l(wchar_t wc, locale_t locale) +{ + return __xiswlower(locale, wc); +} + +static inline +int iswprint_l(wchar_t wc, locale_t locale) +{ + return __xiswprint(locale, wc); +} + +static inline +int iswpunct_l(wchar_t wc, locale_t locale) +{ + return __xiswpunct(locale, wc); +} + +static inline +int iswspace_l(wchar_t wc, locale_t locale) +{ + return __xiswspace(locale, wc); +} + +static inline +int iswupper_l(wchar_t wc, locale_t locale) +{ + return __xiswupper(locale, wc); +} + +static inline +int iswxdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswxdigit(locale, wc); +} + +static inline +int iswctype_l(wint_t wc, wctype_t desc, locale_t locale) +{ + return __xiswctype(locale, wc, desc); +} + +static inline +int toupper_l(int c, locale_t locale) +{ + return __xtoupper(locale, c); +} +static inline +int tolower_l(int c, locale_t locale) +{ + return __xtolower(locale, c); +} +static inline +wint_t towupper_l(wint_t wc, locale_t locale) +{ + return __xtowupper(locale, wc); +} +static inline +wint_t towlower_l(wint_t wc, locale_t locale) +{ + return __xtowlower(locale, wc); +} + +static inline +int strcoll_l(const char *__s1, const char *__s2, locale_t locale) +{ + return __xstrcoll(locale, __s1, __s2); +} +static inline +int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale) +{ + return __xwcscoll(locale, __s1, __s2); +} +static inline +size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale) +{ + return __xstrxfrm(locale, __s1, __s2, __n); +} + +static inline +size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n, + locale_t locale) +{ + return __xwcsxfrm(locale, __ws1, __ws2, __n); +} +#endif // !defined(_AIX71) + +locale_t cloc(void); + +// strftime_l() is defined by POSIX. However, AIX 7.1 does not have it +// implemented yet. +static inline +size_t strftime_l(char *__s, size_t __size, const char *__fmt, + const struct tm *__tm, locale_t locale) { + return __xstrftime(locale, __s, __size, __fmt, __tm); +} + +// The following are not POSIX routines. These are quick-and-dirty hacks +// to make things pretend to work +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoll(__nptr, __endptr, __base); +} +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtol(__nptr, __endptr, __base); +} +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t locale) { + return strtold(__nptr, __endptr); +} +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoull(__nptr, __endptr, __base); +} +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoul(__nptr, __endptr, __base); +} + +static inline +int vasprintf(char **strp, const char *fmt, va_list ap) +{ + const size_t buff_size = 256; + int str_size; + if ((*strp = (char *)malloc(buff_size)) == NULL) + { + return -1; + } + if ((str_size = vsnprintf(*strp, buff_size, fmt, ap)) >= buff_size) + { + if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) + { + return -1; + } + str_size = vsnprintf(*strp, str_size + 1, fmt, ap); + } + return str_size; +} + +#ifdef __cplusplus +} +#endif +#endif // defined(_AIX) +#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H diff -ruN libcxx.orig/include/vector libcxx/include/vector --- libcxx.orig/include/vector 2013-08-13 15:51:00.542542850 -0400 +++ libcxx/include/vector 2013-08-13 13:28:09.770247775 -0400 @@ -2267,7 +2267,7 @@ void allocate(size_type __n); void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - static size_type __align(size_type __new_size) _NOEXCEPT + static size_type __align_it(size_type __new_size) _NOEXCEPT {return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);}; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); @@ -2440,7 +2440,7 @@ const size_type __cap = capacity(); if (__cap >= __ms / 2) return __ms; - return _VSTD::max(2*__cap, __align(__new_size)); + return _VSTD::max(2*__cap, __align_it(__new_size)); } // Default constructs __n objects starting at __end_ diff -ruN libcxx.orig/lib/buildit libcxx/lib/buildit --- libcxx.orig/lib/buildit 2013-08-13 15:51:00.510247093 -0400 +++ libcxx/lib/buildit 2013-08-12 17:45:00.180244845 -0400 @@ -22,20 +22,20 @@ CC=clang fi -if [ -z $MACOSX_DEPLOYMENT_TARGET ] +if [ -z "$MACOSX_DEPLOYMENT_TARGET" ] then - if [ -z $IPHONEOS_DEPLOYMENT_TARGET ] + if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ] then MACOSX_DEPLOYMENT_TARGET=10.7 fi fi -if [ -z $RC_ProjectSourceVersion ] +if [ -z "$RC_ProjectSourceVersion" ] then RC_ProjectSourceVersion=1 fi -EXTRA_FLAGS="-std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ +EXTRA_FLAGS="-nostdinc++ -std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 \ -Wstrict-overflow=4 " @@ -48,7 +48,7 @@ SOEXT=dylib if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ] then - EXTRA_FLAGS="-std=c++11 -U__STRICT_ANSI__" + EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__" LDSHARED_FLAGS="-o libc++.1.dylib \ -dynamiclib -nodefaultlibs -current_version 1 \ -compatibility_version 1 \ @@ -59,7 +59,7 @@ else if [ -n "$SDKROOT" ] then - EXTRA_FLAGS+="-isysroot ${SDKROOT}" + EXTRA_FLAGS+="-nostdinc++ -isysroot ${SDKROOT}" if echo "${RC_ARCHS}" | grep -q "armv7" then RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp" @@ -97,6 +97,23 @@ -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \ -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" ;; + *-ibm-*) + hostOS=`uname` + hostOS=`echo $hostOS | sed -e "s/\s+$//"` + hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'` + + if [ $hostOS == "linux" ] + then + LDSHARED_FLAGS="-o libc++.so.1.0 \ + -qmkshrobj -Wl,-soname,libc++.so.1 \ + -lpthread -lrt -lc -lstdc++" + EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1" + else + LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet" + EXTRA_FLAGS="-qlanglvl=extended0x" + fi + RC_CFLAGS="-qpic=large" + ;; *) RC_CFLAGS="-fPIC" SOEXT=so @@ -106,7 +123,7 @@ ;; esac -if [ -z $RC_XBS ] +if [ -z "$RC_XBS" ] then rm -f libc++.1.$SOEXT* fi @@ -114,12 +131,12 @@ set -x for FILE in ../src/*.cpp; do - $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE + $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE done case $TRIPLE in *-*-mingw*) for FILE in ../src/support/win32/*.cpp; do - $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE + $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE done ;; esac @@ -136,13 +153,23 @@ ;; *-*-mingw*) ;; + *-ibm-*) + if [ $hostOS == "linux" ] + then + rm -f libc++.so + ln -s libc++.so.1.0 libc++.so + else #AIX + rm -f libc++.a + ar r libc++.a shr.o + fi + ;; *) rm -f libc++.so - ln -s libc++.so.1 libc++.so + ln -s libc++.so.1.0 libc++.so ;; esac -if [ -z $RC_XBS ] +if [ -z "$RC_XBS" ] then rm *.o fi diff -ruN libcxx.orig/src/locale.cpp libcxx/src/locale.cpp --- libcxx.orig/src/locale.cpp 2013-08-13 15:51:00.552544052 -0400 +++ libcxx/src/locale.cpp 2013-08-13 14:46:42.860242635 -0400 @@ -1015,6 +1015,8 @@ // going to end up dereferencing it later... #elif defined(EMSCRIPTEN) return *__ctype_b_loc(); +#elif defined(_AIX) + return (const unsigned long *)__lc_ctype_ptr->obj->mask; #else // Platform not supported: abort so the person doing the port knows what to // fix diff -ruN libcxx.orig/src/thread.cpp libcxx/src/thread.cpp --- libcxx.orig/src/thread.cpp 2013-08-13 15:51:00.552544052 -0400 +++ libcxx/src/thread.cpp 2013-08-13 14:30:32.630243574 -0400 @@ -14,9 +14,9 @@ #include "limits" #include #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) +#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) #include -#endif // !__sun__ && !__linux__ +#endif // !__sun__ && !__linux__ && !_AIX #include #endif // !_WIN32