Skip to content

Commit

Permalink
MACOSX/i386: Fix incomplete C++11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
lephilousophe committed Feb 7, 2021
1 parent 541dc13 commit 6f25aae
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 2 deletions.
8 changes: 6 additions & 2 deletions toolchains/macosx-i386/Dockerfile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ m4_define(`MACOSX_PORTS_ARCH_ARG',`--i386')m4_dnl
m4_include(`macosx.m4')m4_dnl

# Our compiler is c++11 compliant but our libstdc++ is too old for that
# So far it kind of works but glew needs cstdint
# Please it by providing it
# So far it worked but several fixes are now needed
# glew needs cstdint
COPY cstdint ${TARGET_DIR}/SDK/MacOSX`'MACOSX_SDK_VERSION`'.sdk/usr/include/c++/4.2.1/cstdint
# ScummVM needs initializer_list
COPY initializer_list ${TARGET_DIR}/SDK/MacOSX`'MACOSX_SDK_VERSION`'.sdk/usr/include/c++/4.2.1/initializer_list
# nullptr_t is needed in libstdc++
RUN sed -i -e '/_GLIBCXX_BEGIN_NAMESPACE(std)/a typedef decltype(nullptr) nullptr_t;' ${TARGET_DIR}/SDK/MacOSX`'MACOSX_SDK_VERSION`'.sdk/usr/include/c++/4.2.1/cstddef
103 changes: 103 additions & 0 deletions toolchains/macosx-i386/initializer_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// std::initializer_list support -*- C++ -*-

// Copyright (C) 2008-2021 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.

/** @file initializer_list
* This is a Standard C++ Library header.
*/

#ifndef _INITIALIZER_LIST
#define _INITIALIZER_LIST

#pragma GCC system_header

#pragma GCC visibility push(default)

#include <bits/c++config.h>

namespace std
{
/// initializer_list
template<class _E>
class initializer_list
{
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;

private:
iterator _M_array;
size_type _M_len;

// The compiler can call a private constructor.
constexpr initializer_list(const_iterator __a, size_type __l)
: _M_array(__a), _M_len(__l) { }

public:
constexpr initializer_list() noexcept
: _M_array(0), _M_len(0) { }

// Number of elements.
constexpr size_type
size() const noexcept { return _M_len; }

// First element.
constexpr const_iterator
begin() const noexcept { return _M_array; }

// One past the last element.
constexpr const_iterator
end() const noexcept { return begin() + size(); }
};

/**
* @brief Return an iterator pointing to the first element of
* the initializer_list.
* @param __ils Initializer list.
* @relates initializer_list
*/
template<class _Tp>
constexpr const _Tp*
begin(initializer_list<_Tp> __ils) noexcept
{ return __ils.begin(); }

/**
* @brief Return an iterator pointing to one past the last element
* of the initializer_list.
* @param __ils Initializer list.
* @relates initializer_list
*/
template<class _Tp>
constexpr const _Tp*
end(initializer_list<_Tp> __ils) noexcept
{ return __ils.end(); }
}

#pragma GCC visibility pop

#endif // _INITIALIZER_LIST

0 comments on commit 6f25aae

Please sign in to comment.