Ticket #49449: pymol_no_cxx11.patch

File pymol_no_cxx11.patch, 8.5 KB (added by howarth.at.macports@…, 9 years ago)

Upstream fix to properly address lack of c++11 support in legacy libstdc++ of earlier OS X

  • layer2/AtomInfo.cpp

     
    11631163    for (int i = 0; ok && i < 6; ++i)
    11641164      ok = CPythonVal_PConvPyFloatToFloat_From_List(G, list, 41 + i, u + i);
    11651165    if(ok && (u[0] || u[1] || u[2] || u[3] || u[4] || u[5]))
    1166       std::copy_n(u, 6, I->get_anisou());
     1166      memcpy(I->get_anisou(), u, 6 * sizeof(float));
    11671167  }
    11681168  if(ok && (ll > 47)) {
    11691169    OrthoLineType temp;
     
    11961196#endif
    11971197  if (src->anisou) {
    11981198    dst->anisou = NULL;
    1199     std::copy_n(src->anisou, 6, dst->get_anisou());
     1199    memcpy(dst->get_anisou(), src->anisou, 6 * sizeof(float));
    12001200  }
    12011201}
    12021202
  • layer2/CifBondDict.h

     
    2525// Working with this limitation is currently reasonable in PyMOL,
    2626// since cResnLen=5 and cAtomNameLen=4 (see AtomInfo.h).
    2727
    28 #include <cstdint>
     28#ifdef _PYMOL_NO_CXX11
     29#define unordered_map map
     30#else
    2931#include <unordered_map>
     32#endif
     33
     34#include <stdint.h>
    3035#include <string.h>
    3136
    3237// mapped type of bond_dict_t
    33 class res_bond_dict_t : std::unordered_map<std::int_fast64_t, signed char> {
     38class res_bond_dict_t : std::unordered_map<int64_t, signed char> {
    3439  static key_type make_key(const char * name1, const char * name2) {
    35     union { char s[4]; std::int32_t i; } u1, u2;
     40    union { char s[4]; int32_t i; } u1, u2;
    3641
    3742    strncpy(u1.s, name1, 4);
    3843    strncpy(u2.s, name2, 4);
     
    5762};
    5863
    5964// type for mapping: resn -> ((name1, name2) -> bond order)
    60 class bond_dict_t : public std::map<std::int_fast64_t, res_bond_dict_t> {
     65class bond_dict_t : public std::map<int64_t, res_bond_dict_t> {
    6166  static key_type make_key(const char * s_) {
    6267    union { key_type i; char s[sizeof(key_type)]; };
    6368    strncpy(s, s_, sizeof(s));
  • layer2/CifMoleculeReader.cpp

     
    195195      I->Bond = bond;
    196196    } else {
    197197      VLASize(I->Bond, BondType, I->NBond + nbond);
    198       std::copy(bond, bond + nbond, I->Bond + I->NBond);
     198      memcpy(I->Bond + I->NBond, bond, nbond * sizeof(*bond));
    199199      VLAFreeP(bond);
    200200    }
    201201
     
    21062106  }
    21072107
    21082108  const char * filename = NULL;
     2109#ifndef _PYMOL_NO_CXX11
    21092110  auto cif = std::make_shared<cif_file>(filename, st);
     2111#else
     2112  cif_file _cif_stack(filename, st);
     2113  auto cif = &_cif_stack;
     2114#endif
    21102115
    21112116  for (auto it = cif->datablocks.begin(); it != cif->datablocks.end(); ++it) {
    21122117    ObjectMolecule * obj = ObjectMoleculeReadCifData(G, it->second, discrete);
     
    21172122      continue;
    21182123    }
    21192124
    2120 #ifndef _PYMOL_NOPY
     2125#if !defined(_PYMOL_NOPY) && !defined(_PYMOL_NO_CXX11)
    21212126    // we only provide access from the Python API so far
    21222127    if (SettingGetGlobal_b(G, cSetting_cif_keepinmemory)) {
    21232128      obj->m_cifdata = it->second;
  • layer2/CoordSet.cpp

     
    978978      char *atomline = (*charVLA) + (*c);
    979979      char *anisoline = atomline + linelen;
    980980      float anisou[6];
    981       std::copy_n(ai->anisou, 6, anisou);
     981      memcpy(anisou, ai->anisou, 6 * sizeof(float));
    982982
    983983      if(matrix && !RotateU(matrix, anisou)) {
    984984        PRINTFB(G, FB_CoordSet, FB_Errors) "RotateU failed\n" ENDFB(G);
     
    10591059    float tmp_array[6] = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f };
    10601060
    10611061    if (ai->anisou) {
    1062       std::copy_n(ai->anisou, 6, tmp_array);
     1062      memcpy(tmp_array, ai->anisou, 6 * sizeof(float));
    10631063      if (matrix)
    10641064      RotateU(matrix, tmp_array);
    10651065    }
  • layer2/ObjectMolecule.cpp

     
    2222#include <algorithm>
    2323#include <set>
    2424
     25#ifdef _PYMOL_NO_CXX11
     26#define STD_MOVE(x) (x)
     27#else
     28#define STD_MOVE(x) std::move(x)
     29#endif
     30
    2531#include"Base.h"
    2632#include"Debug.h"
    2733#include"Parse.h"
     
    77307736          if(PConvPyListToFloatArrayInPlace(tmp, u, 6)) {
    77317737            // only allocate if not all zero
    77327738            if(u[0] || u[1] || u[2] || u[3] || u[4] || u[5])
    7733               std::copy_n(u, 6, ai->get_anisou());
     7739              memcpy(ai->get_anisou(), u, 6 * sizeof(float));
    77347740          }
    77357741          Py_DECREF(tmp);
    77367742        }
     
    96009606  CHECKOK(ok, ai2);
    96019607  if (ok){
    96029608    for(a = 0; a < cs->NIndex; a++)
    9603       ai2[a] = std::move(ai[index[a]]);      /* creates a sorted list of atom info records */
     9609      ai2[a] = STD_MOVE(ai[index[a]]);      /* creates a sorted list of atom info records */
    96049610  }
    96059611  VLAFreeP(ai);
    96069612  ai = ai2;
     
    97229728      if(a2 < oldNAtom)
    97239729        AtomInfoCombine(G, I->AtomInfo + a2, ai + a1, aic_mask);
    97249730      else
    9725         *(I->AtomInfo + a2) = std::move(*(ai + a1));
     9731        *(I->AtomInfo + a2) = STD_MOVE(*(ai + a1));
    97269732    }
    97279733  }
    97289734
     
    98619867    dest = I->AtomInfo + I->NAtom;
    98629868    src = atInfo;
    98639869    for(a = 0; a < cs->NIndex; a++)
    9864       *(dest++) = std::move(*(src++));
     9870      *(dest++) = STD_MOVE(*(src++));
    98659871    I->NAtom = nAtom;
    98669872    VLAFreeP(atInfo);
    98679873  } else {
     
    1256112567  VLAFreeP(I->DiscreteAtmToIdx);
    1256212568  VLAFreeP(I->DiscreteCSet);
    1256312569  VLAFreeP(I->CSet);
     12570#ifndef _PYMOL_NO_CXX11
    1256412571  I->m_ciffile.reset(); // free data
     12572#endif
    1256512573
    1256612574  {
    1256712575    int nAtom = I->NAtom;
  • layer2/ObjectMolecule.h

     
    8686  int RepVisCache;     /* for transient storage during updates */
    8787
    8888  // for reporting available assembly ids after mmCIF loading - SUBJECT TO CHANGE
     89#ifndef _PYMOL_NO_CXX11
    8990  std::shared_ptr<cif_file> m_ciffile;
     91#endif
    9092  const cif_data * m_cifdata;
    9193
    9294  // methods
  • layer2/ObjectMolecule2.cpp

     
    4848#include <iostream>
    4949#include <map>
    5050
     51#ifdef _PYMOL_NO_CXX11
     52#define STD_MOVE(x) (x)
     53#else
     54#define STD_MOVE(x) std::move(x)
     55#endif
     56
    5157#define ntrim ParseNTrim
    5258#define nextline ParseNextLine
    5359#define ncopy ParseNCopy
     
    44814487      if (ok){
    44824488        /* autozero here is important */
    44834489        for(a = 0; a < i_NAtom; a++)
    4484           atInfo[a] = std::move(I->AtomInfo[index[a]]);
     4490          atInfo[a] = STD_MOVE(I->AtomInfo[index[a]]);
    44854491      }
    44864492      VLAFreeP(I->AtomInfo);
    44874493      I->AtomInfo = atInfo;
  • monkeypatch_distutils.py

     
    1313# threaded parallel map (optional)
    1414pmap = map
    1515
    16 if sys.platform == 'darwin':
     16try:
    1717    import _osx_support
    1818    _osx_support._UNIVERSAL_CONFIG_VARS += ('CXXFLAGS', 'LDCXXSHARED',)
    1919    _osx_support._COMPILER_CONFIG_VARS += ('LDCXXSHARED',)
     20except ImportError:
     21    _osx_support = None
    2022
    2123distutils.unixccompiler.UnixCCompiler.executables.update({
    2224    'compiler_cxx'      : ["c++"],
     
    8688    compiler_so = self.compiler_so
    8789    compiler_so_cxx = self.compiler_so_cxx
    8890
    89     if sys.platform == 'darwin':
     91    if sys.platform == 'darwin' and _osx_support is not None:
    9092        compiler_so = _osx_support.compiler_fixup(compiler_so, cc_args + extra_postargs)
    9193        compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx, cc_args + extra_postargs)
    9294
  • setup.py

     
    149149pyogl_libs = []
    150150lib_dirs = []
    151151ext_comp_args = [
    152     "-Wno-narrowing",
    153152    # warnings as errors
    154153    "-Werror=implicit-function-declaration",
    155154    "-Werror=declaration-after-statement",
     
    213212            ("NO_MMLIBS",None),
    214213            ]
    215214
     215    if sys.platform == 'darwin':
     216        import platform
     217        if int(platform.mac_ver()[0].split('.')[1]) < 9:
     218            # OS X <= 10.8, will still use some C++11 features
     219            # like the "auto" keyword, but excludes features which
     220            # depend on the C++11 std library.
     221            def_macros += [
     222                ('_PYMOL_NO_CXX11', None),
     223            ]
     224
    216225    try:
    217226        import numpy
    218227        inc_dirs += [