mirror of
https://github.com/NGSolve/netgen.git
synced 2025-02-14 22:33:08 +05:00
fix 32-bit usage of size_t
On 32-bit systems size_t is identical unsigned in, causing
redefinition errors in tables (Array_I_S).
This patch guards against the 32-bit redefinition and defines
Array_I_S = Array_I_U for the python interface if not already defined.
Applies debian patch size_t_int32.patch
d7ca1c564d/debian/patches/size_t_int32.patch
Fixes #168
This commit is contained in:
parent
63cb566b8d
commit
84fc680e72
@ -2,6 +2,7 @@
|
|||||||
#define NETGEN_CORE_PYTHON_NGCORE_HPP
|
#define NETGEN_CORE_PYTHON_NGCORE_HPP
|
||||||
|
|
||||||
#include "ngcore_api.hpp" // for operator new
|
#include "ngcore_api.hpp" // for operator new
|
||||||
|
#include <cstdint>
|
||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/operators.h>
|
#include <pybind11/operators.h>
|
||||||
#include <pybind11/numpy.h>
|
#include <pybind11/numpy.h>
|
||||||
@ -182,10 +183,12 @@ namespace ngcore
|
|||||||
static std::string GetName() { return "D"; }
|
static std::string GetName() { return "D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if INTPTR_MAX != INT32_MAX
|
||||||
template<>
|
template<>
|
||||||
struct PyNameTraits<size_t> {
|
struct PyNameTraits<size_t> {
|
||||||
static std::string GetName() { return "S"; }
|
static std::string GetName() { return "S"; }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PyNameTraits<std::shared_ptr<T>> {
|
struct PyNameTraits<std::shared_ptr<T>> {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "python_ngcore.hpp"
|
#include "python_ngcore.hpp"
|
||||||
#include "bitarray.hpp"
|
#include "bitarray.hpp"
|
||||||
#include "taskmanager.hpp"
|
#include "taskmanager.hpp"
|
||||||
@ -23,7 +25,9 @@ PYBIND11_MODULE(pyngcore, m) // NOLINT
|
|||||||
catch(...) {}
|
catch(...) {}
|
||||||
ExportArray<int>(m);
|
ExportArray<int>(m);
|
||||||
ExportArray<unsigned>(m);
|
ExportArray<unsigned>(m);
|
||||||
|
#if INTPTR_MAX != INT32_MAX
|
||||||
ExportArray<size_t>(m);
|
ExportArray<size_t>(m);
|
||||||
|
#endif
|
||||||
ExportArray<double>(m);
|
ExportArray<double>(m);
|
||||||
ExportArray<float>(m);
|
ExportArray<float>(m);
|
||||||
ExportArray<signed short>(m);
|
ExportArray<signed short>(m);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
@ -104,8 +105,10 @@ namespace ngcore
|
|||||||
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(int*)(entrysize.Addr(0)))); }
|
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(int*)(entrysize.Addr(0)))); }
|
||||||
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<std::atomic<int>> entrysize)
|
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<std::atomic<int>> entrysize)
|
||||||
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(std::atomic<int>*)entrysize.Addr(0))); }
|
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(std::atomic<int>*)entrysize.Addr(0))); }
|
||||||
|
#if INTPTR_MAX != INT32_MAX
|
||||||
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<size_t> entrysize)
|
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<size_t> entrysize)
|
||||||
{ return TablePrefixSum64 (entrysize); }
|
{ return TablePrefixSum64 (entrysize); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1 +1,7 @@
|
|||||||
from .pyngcore import *
|
from .pyngcore import *
|
||||||
|
|
||||||
|
# <size_t> is the same as <unsigned int> on 32 bit arches
|
||||||
|
# in which case Array_I_S is not defined by python_ngcore_export.cpp.
|
||||||
|
# In this case identify it with Array_I_U.
|
||||||
|
try: Array_I_S
|
||||||
|
except NameError: Array_I_S=Array_I_U
|
||||||
|
Loading…
Reference in New Issue
Block a user