Skip to content

Commit

Permalink
Add basic C++ library support.
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantinschwarz committed Jan 17, 2019
1 parent 550c750 commit 344c7a1
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Expand Up @@ -168,6 +168,7 @@ if(LIBCXX_INSTALL_SUPPORT_HEADERS)
${files}
support/android/locale_bionic.h
support/fuchsia/xlocale.h
support/hightec/locale_htc.h
support/ibm/limits.h
support/ibm/locale_mgmt_aix.h
support/ibm/support.h
Expand Down
6 changes: 6 additions & 0 deletions libcxx/include/__config
Expand Up @@ -307,6 +307,8 @@
# define _LIBCPP_USING_NACL_RANDOM
#elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_USING_WIN32_RANDOM
#elif defined(__HIGHTEC__)
// Do not define anything here for HighTec
#else
# define _LIBCPP_USING_DEV_RANDOM
#endif
Expand Down Expand Up @@ -979,6 +981,10 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#endif

#if defined(__HIGHTEC__)
#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#endif

#if defined(__APPLE__)
# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__locale
Expand Up @@ -37,6 +37,8 @@
# include <support/fuchsia/xlocale.h>
#elif defined(_LIBCPP_HAS_MUSL_LIBC)
# include <support/musl/xlocale.h>
#elif defined(__HIGHTEC__)
# include <support/hightec/locale_htc.h>
#endif

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
4 changes: 3 additions & 1 deletion libcxx/include/math.h
Expand Up @@ -298,6 +298,8 @@ long double truncl(long double x);
#pragma GCC system_header
#endif

#include <type_traits>

#include_next <math.h>

#ifdef __cplusplus
Expand All @@ -306,7 +308,7 @@ long double truncl(long double x);
// back to C++ linkage before including these C++ headers.
extern "C++" {

#include <type_traits>

#include <limits>

// signbit
Expand Down
56 changes: 56 additions & 0 deletions libcxx/include/support/hightec/locale_htc.h
@@ -0,0 +1,56 @@
// -*- C++ -*-
//===------------ support/hightec/locale_htc.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_HIGHTEC_LOCALE_HTC_H
#define _LIBCPP_SUPPORT_HIGHTEC_LOCALE_HTC_H

#include <clocale>

// Add definition for isascii function, which is not part of ISO C
static inline int isascii(int c) {
return c == (c & 0x7f);
}

// Patch over lack of extended locale support
typedef void *locale_t;

static inline locale_t duplocale(locale_t) {
return NULL;
}

static inline void freelocale(locale_t) {
}

static inline locale_t newlocale(int, const char *, locale_t) {
return NULL;
}

static inline locale_t uselocale(locale_t) {
return NULL;
}

#define LC_COLLATE_MASK (LC_COLLATE)
#define LC_CTYPE_MASK (LC_CTYPE)
#define LC_MESSAGES_MASK (LC_MESSAGES)
#define LC_MONETARY_MASK (LC_MONETARY)
#define LC_NUMERIC_MASK (LC_NUMERIC)
#define LC_TIME_MASK (LC_TIME)
#define LC_ALL_MASK (LC_COLLATE_MASK|\
LC_CTYPE_MASK|\
LC_MONETARY_MASK|\
LC_NUMERIC_MASK|\
LC_TIME_MASK|\
LC_MESSAGES_MASK)

#include <support/xlocale/__posix_l_fallback.h>
#include <support/xlocale/__strtonum_fallback.h>


#endif // _LIBCPP_SUPPORT_HIGHTEC_LOCALE_HTC_H
2 changes: 2 additions & 0 deletions libcxx/src/locale.cpp
Expand Up @@ -31,6 +31,8 @@
#include "__sso_allocator"
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
#include "support/win32/locale_win32.h"
#elif defined(__HIGHTEC__)

#elif !defined(__BIONIC__)
#include <langinfo.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/random.cpp
Expand Up @@ -166,6 +166,8 @@ random_device::operator()()
return r;
}

#elif defined(__HIGHTEC__)
#warning TODO: implement random device for this architecture
#else
#error "Random device not implemented for this architecture"
#endif
Expand Down

0 comments on commit 344c7a1

Please sign in to comment.