diff --git a/.github/workflows/everything.yml b/.github/workflows/everything.yml index be966def07..4bd22408f5 100644 --- a/.github/workflows/everything.yml +++ b/.github/workflows/everything.yml @@ -339,7 +339,7 @@ jobs: runs-on: ${{ matrix.image }} env: - GH_YML_JOBNAME: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }} + GH_YML_JOBNAME: ${{ matrix.os }}-${{ matrix.compiler }}${{ matrix.shared == 'static' && '-static' || ''}}-${{ matrix.parallel }} GH_YML_BASE_OS: Windows GH_YML_MATRIX_OS: ${{ matrix.os }} GH_YML_MATRIX_COMPILER: ${{ matrix.compiler }} @@ -349,6 +349,7 @@ jobs: fail-fast: false matrix: os: [win2019, win2022] + shared: [shared] parallel: [serial, ompi] include: - os: win2019 @@ -357,6 +358,11 @@ jobs: - os: win2022 image: windows-2022 compiler: vs2022 + - os: win2022 + image: windows-2022 + shared: static + compiler: vs2022 + parallel: serial defaults: run: diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a3b2a8534..8511e152bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,6 +187,9 @@ adios_option(Campaign "Enable support for Campaigns (requires SQLite3 and ZLIB adios_option(AWSSDK "Enable support for S3 compatible storage using AWS SDK's S3 module" OFF) adios_option(Derived_Variable "Enable support for derived variables" OFF) adios_option(PIP "Enable support for pip packaging" OFF) + +option(ADIOS2_Blosc2_PREFER_SHARED "Prefer shared Blosc2 libraries" ON) +mark_as_advanced(ADIOS2_Blosc2_PREFER_SHARED) mark_as_advanced(ADIOS2_USE_PIP) include(${PROJECT_SOURCE_DIR}/cmake/DetectOptions.cmake) @@ -217,9 +220,6 @@ if(ADIOS2_HAVE_MPI) add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) endif() -cmake_dependent_option(ADIOS2_Blosc2_PREFER_SHARED "Prefer shared Blosc2 libraries" - ON "Blosc2_shlib_available" OFF) - #------------------------------------------------------------------------------# # POSIX O_DIRECT is only working for Unix in adios for now #------------------------------------------------------------------------------# diff --git a/bindings/Python/py11Engine.cpp b/bindings/Python/py11Engine.cpp index f4bdafef27..8787bd1419 100644 --- a/bindings/Python/py11Engine.cpp +++ b/bindings/Python/py11Engine.cpp @@ -70,12 +70,44 @@ void Engine::Put(Variable variable, const pybind11::array &array, const Mode lau else { throw std::invalid_argument("ERROR: for variable " + variable.Name() + - " numpy array type is not supported or " + " numpy array type " + variable.Type() + + " is not supported (found type " + ToString(type) + + ") or " "is not memory contiguous " ", in call to Put\n"); } } +void Engine::Put(Variable variable, const std::vector &ints, const Mode launch) +{ + helper::CheckForNullptr(m_Engine, "in call to Engine::Put list of ints"); + helper::CheckForNullptr(variable.m_VariableBase, + "for variable, in call to Engine::Put list of ints"); + + m_Engine->Put(*dynamic_cast *>(variable.m_VariableBase), + reinterpret_cast(ints.data()), launch); +} + +void Engine::Put(Variable variable, const std::vector &floats, const Mode launch) +{ + helper::CheckForNullptr(m_Engine, "in call to Engine::Put list of floats"); + helper::CheckForNullptr(variable.m_VariableBase, + "for variable, in call to Engine::Put list of floats"); + + m_Engine->Put(*dynamic_cast *>(variable.m_VariableBase), + reinterpret_cast(floats.data()), launch); +} + +void Engine::Put(Variable variable, const std::vector> &complexes, + const Mode launch) +{ + helper::CheckForNullptr(m_Engine, "in call to Engine::Put list of complexes"); + helper::CheckForNullptr(variable.m_VariableBase, + "for variable, in call to Engine::Put list of complexes"); + m_Engine->Put(*dynamic_cast> *>(variable.m_VariableBase), + reinterpret_cast *>(complexes.data()), launch); +} + void Engine::Put(Variable variable, const std::string &string) { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Put string"); @@ -235,12 +267,18 @@ std::vector> Engine::BlocksInfo(std::string & const size_t step) const { std::vector> rv; + auto &varMap = m_Engine->m_IO.GetVariables(); + auto itVariable = varMap.find(var_name); + if (itVariable == varMap.end()) + { + return rv; + } // Grab the specified variable object and get its type string adios2::DataType var_type = m_Engine->GetIO().InquireVariableType(var_name); MinVarInfo *minBlocksInfo = nullptr; - auto itVariable = m_Engine->m_IO.GetVariables().find(var_name); + auto Variable = itVariable->second.get(); minBlocksInfo = m_Engine->MinBlocksInfo(*Variable, 0); if (minBlocksInfo) @@ -261,7 +299,8 @@ std::vector> Engine::BlocksInfo(std::string & { start_ss << ","; } - start_ss << info.Start[i]; + start_ss << (minBlocksInfo->WasLocalValue ? reinterpret_cast(info.Start) + : info.Start[i]); } } info_map["Start"] = start_ss.str(); @@ -278,7 +317,8 @@ std::vector> Engine::BlocksInfo(std::string & { count_ss << ","; } - count_ss << info.Count[i]; + count_ss << (minBlocksInfo->WasLocalValue ? reinterpret_cast(info.Count) + : info.Count[i]); } } info_map["Count"] = count_ss.str(); diff --git a/bindings/Python/py11Engine.h b/bindings/Python/py11Engine.h index 3fb286f2de..617efd1d55 100644 --- a/bindings/Python/py11Engine.h +++ b/bindings/Python/py11Engine.h @@ -49,6 +49,12 @@ class Engine StepStatus BeginStep(); void Put(Variable variable, const pybind11::array &array, const Mode launch = Mode::Deferred); + void Put(Variable variable, const std::vector &ints, + const Mode launch = Mode::Deferred); + void Put(Variable variable, const std::vector &doubles, + const Mode launch = Mode::Deferred); + void Put(Variable variable, const std::vector> &complexes, + const Mode launch = Mode::Deferred); void Put(Variable variable, const std::string &string); void PerformPuts(); void PerformDataWrite(); diff --git a/bindings/Python/py11IO.cpp b/bindings/Python/py11IO.cpp index b5931219d5..f44e260dd9 100644 --- a/bindings/Python/py11IO.cpp +++ b/bindings/Python/py11IO.cpp @@ -101,6 +101,51 @@ Variable IO::DefineVariable(const std::string &name, const pybind11::array &arra return Variable(variable); } +Variable IO::DefineVariable(const std::string &name, const pybind11::object &value, + const Dims &shape, const Dims &start, const Dims &count, + const bool isConstantDims) +{ + helper::CheckForNullptr(m_IO, "for variable " + name + ", in call to IO::DefineVariable"); + core::VariableBase *variable = nullptr; + const auto t = value.get_type(); + const auto ts = pybind11::str(t); + const auto tss = pybind11::cast(ts); + if (pybind11::isinstance(value)) + { + variable = &m_IO->DefineVariable(name); + } + else if (pybind11::isinstance(value)) + { + variable = &m_IO->DefineVariable(name, shape, start, count, isConstantDims); + } + else if (pybind11::isinstance(value)) + { + variable = &m_IO->DefineVariable(name, shape, start, count, isConstantDims); + } + else if (tss == "") + { + variable = + &m_IO->DefineVariable>(name, shape, start, count, isConstantDims); + } + else if (tss == "") + { + variable = + &m_IO->DefineVariable>(name, shape, start, count, isConstantDims); + } + else if (tss == "") + { + variable = + &m_IO->DefineVariable>(name, shape, start, count, isConstantDims); + } + else + { + throw std::invalid_argument("ERROR: variable " + name + + " can't be defined with an object with type " + tss + + ", in call to DefineVariable\n"); + } + return Variable(variable); +} + Variable IO::InquireVariable(const std::string &name) { helper::CheckForNullptr(m_IO, "for variable " + name + ", in call to IO::InquireVariable"); @@ -126,7 +171,6 @@ Attribute IO::DefineAttribute(const std::string &name, const pybind11::array &ar const std::string &variableName, const std::string separator) { helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); - core::AttributeBase *attribute = nullptr; if (false) @@ -156,7 +200,6 @@ Attribute IO::DefineAttribute(const std::string &name, const std::string &string const std::string &variableName, const std::string separator) { helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); - return Attribute( &m_IO->DefineAttribute(name, stringValue, variableName, separator)); } @@ -165,11 +208,78 @@ Attribute IO::DefineAttribute(const std::string &name, const std::vectorDefineAttribute(name, strings.data(), strings.size(), variableName, separator)); } +Attribute IO::DefineAttribute(const std::string &name, const std::vector &ints, + const std::string &variableName, const std::string separator) +{ + helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); + return Attribute( + &m_IO->DefineAttribute(name, ints.data(), ints.size(), variableName, separator)); +} + +Attribute IO::DefineAttribute(const std::string &name, const std::vector &doubles, + const std::string &variableName, const std::string separator) +{ + helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); + return Attribute(&m_IO->DefineAttribute(name, doubles.data(), doubles.size(), + variableName, separator)); +} + +Attribute IO::DefineAttribute(const std::string &name, + const std::vector> &complexdoubles, + const std::string &variableName, const std::string separator) +{ + helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); + return Attribute(&m_IO->DefineAttribute>( + name, complexdoubles.data(), complexdoubles.size(), variableName, separator)); +} + +Attribute IO::DefineAttribute(const std::string &name, const pybind11::object &value, + const std::string &variableName, const std::string separator) +{ + helper::CheckForNullptr(m_IO, "for attribute " + name + ", in call to IO::DefineAttribute"); + + core::AttributeBase *attribute = nullptr; + const auto t = value.get_type(); + const auto ts = pybind11::str(t); + const auto tss = pybind11::cast(ts); + if (pybind11::isinstance(value)) + { + auto v = pybind11::cast(value); + attribute = &m_IO->DefineAttribute(name, v, variableName, separator); + } + else if (pybind11::isinstance(value)) + { + auto v = pybind11::cast(value); + attribute = &m_IO->DefineAttribute(name, v, variableName, separator); + } + else if (tss == "") + { + auto v = pybind11::cast>(value); + attribute = &m_IO->DefineAttribute(name, v, variableName, separator); + } + else if (tss == "") + { + auto v = pybind11::cast>(value); + attribute = &m_IO->DefineAttribute(name, v, variableName, separator); + } + else if (tss == "") + { + auto v = pybind11::cast>(value); + attribute = &m_IO->DefineAttribute(name, v, variableName, separator); + } + else + { + throw std::invalid_argument("ERROR: attribute " + name + + " can't be defined with an object with type " + tss + + ", in call to DefineAttribute\n"); + } + return Attribute(attribute); +} + Attribute IO::InquireAttribute(const std::string &name, const std::string &variableName, const std::string separator) { @@ -234,10 +344,11 @@ std::map IO::AvailableVariables() return m_IO->GetAvailableVariables(); } -std::map IO::AvailableAttributes() +std::map IO::AvailableAttributes(const std::string &varname, + const std::string &separator) { helper::CheckForNullptr(m_IO, "in call to IO::AvailableAttributes"); - return m_IO->GetAvailableAttributes(); + return m_IO->GetAvailableAttributes(varname, separator); } std::string IO::VariableType(const std::string &name) const diff --git a/bindings/Python/py11IO.h b/bindings/Python/py11IO.h index 9308af270d..80c7c7599b 100644 --- a/bindings/Python/py11IO.h +++ b/bindings/Python/py11IO.h @@ -13,6 +13,7 @@ #include +#include #include #include "py11Attribute.h" @@ -57,6 +58,10 @@ class IO const Dims &shape, const Dims &start, const Dims &count, const bool isConstantDims); + Variable DefineVariable(const std::string &name, const pybind11::object &value, + const Dims &shape, const Dims &start, const Dims &count, + const bool isConstantDims); + Variable InquireVariable(const std::string &name); Attribute DefineAttribute(const std::string &name, const pybind11::array &array, @@ -71,6 +76,22 @@ class IO const std::string &variableName = "", const std::string separator = "/"); + Attribute DefineAttribute(const std::string &name, const std::vector &ints, + const std::string &variableName = "", + const std::string separator = "/"); + + Attribute DefineAttribute(const std::string &name, const std::vector &doubles, + const std::string &variableName = "", + const std::string separator = "/"); + + Attribute DefineAttribute(const std::string &name, + const std::vector> &complexdoubles, + const std::string &variableName = "", + const std::string separator = "/"); + + Attribute DefineAttribute(const std::string &name, const pybind11::object &value, + const std::string &variableName, const std::string separator); + Attribute InquireAttribute(const std::string &name, const std::string &variableName = "", const std::string separator = "/"); @@ -92,7 +113,8 @@ class IO std::map AvailableVariables(); - std::map AvailableAttributes(); + std::map AvailableAttributes(const std::string &varname = "", + const std::string &separator = "/"); std::string VariableType(const std::string &name) const; diff --git a/bindings/Python/py11glue.cpp b/bindings/Python/py11glue.cpp index 90b12ba1e9..13ca876517 100644 --- a/bindings/Python/py11glue.cpp +++ b/bindings/Python/py11glue.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -203,6 +204,15 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) pybind11::arg("shape") = adios2::Dims(), pybind11::arg("start") = adios2::Dims(), pybind11::arg("count") = adios2::Dims(), pybind11::arg("isConstantDims") = false) + .def("DefineVariable", + (adios2::py11::Variable(adios2::py11::IO::*)( + const std::string &, const pybind11::object &, const adios2::Dims &, + const adios2::Dims &, const adios2::Dims &, const bool)) & + adios2::py11::IO::DefineVariable, + pybind11::return_value_policy::move, pybind11::arg("name"), pybind11::arg("value"), + pybind11::arg("shape") = adios2::Dims(), pybind11::arg("start") = adios2::Dims(), + pybind11::arg("count") = adios2::Dims(), pybind11::arg("isConstantDims") = false) + .def("DefineVariable", (adios2::py11::Variable(adios2::py11::IO::*)(const std::string &)) & adios2::py11::IO::DefineVariable, @@ -243,6 +253,38 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) pybind11::arg("name"), pybind11::arg("strings"), pybind11::arg("variable_name") = "", pybind11::arg("separator") = "/", pybind11::return_value_policy::move) + .def("DefineAttribute", + (adios2::py11::Attribute(adios2::py11::IO::*)( + const std::string &, const std::vector &, const std::string &, + const std::string)) & + adios2::py11::IO::DefineAttribute, + pybind11::arg("name"), pybind11::arg("ints"), pybind11::arg("variable_name") = "", + pybind11::arg("separator") = "/", pybind11::return_value_policy::move) + + .def("DefineAttribute", + (adios2::py11::Attribute(adios2::py11::IO::*)( + const std::string &, const std::vector &, const std::string &, + const std::string)) & + adios2::py11::IO::DefineAttribute, + pybind11::arg("name"), pybind11::arg("doubles"), pybind11::arg("variable_name") = "", + pybind11::arg("separator") = "/", pybind11::return_value_policy::move) + + .def("DefineAttribute", + (adios2::py11::Attribute(adios2::py11::IO::*)( + const std::string &, const std::vector> &, + const std::string &, const std::string)) & + adios2::py11::IO::DefineAttribute, + pybind11::arg("name"), pybind11::arg("complexes"), pybind11::arg("variable_name") = "", + pybind11::arg("separator") = "/", pybind11::return_value_policy::move) + + .def("DefineAttribute", + (adios2::py11::Attribute(adios2::py11::IO::*)( + const std::string &, const pybind11::object &, const std::string &, + const std::string)) & + adios2::py11::IO::DefineAttribute, + pybind11::arg("name"), pybind11::arg("value"), pybind11::arg("variable_name") = "", + pybind11::arg("separator") = "/", pybind11::return_value_policy::move) + .def("Open", (adios2::py11::Engine(adios2::py11::IO::*)(const std::string &, const int)) & adios2::py11::IO::Open) #if ADIOS2_USE_MPI @@ -250,8 +292,11 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) adios2::py11::MPI4PY_Comm comm)) & adios2::py11::IO::Open) #endif + .def("AvailableAttributes", &adios2::py11::IO::AvailableAttributes, + pybind11::arg("varname") = "", pybind11::arg("separator") = "/", + pybind11::return_value_policy::move) + .def("AvailableVariables", &adios2::py11::IO::AvailableVariables) - .def("AvailableAttributes", &adios2::py11::IO::AvailableAttributes) .def("FlushAll", &adios2::py11::IO::FlushAll) .def("EngineType", &adios2::py11::IO::EngineType) .def("RemoveVariable", &adios2::py11::IO::RemoveVariable) @@ -385,6 +430,28 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) .def("Put", (void(adios2::py11::Engine::*)(adios2::py11::Variable, const std::string &)) & adios2::py11::Engine::Put) + .def("Put", + (void(adios2::py11::Engine::*)(adios2::py11::Variable, const std::vector &, + const adios2::Mode launch)) & + adios2::py11::Engine::Put, + pybind11::arg("variable"), pybind11::arg("ints"), + pybind11::arg("launch") = adios2::Mode::Sync) + + .def("Put", + (void(adios2::py11::Engine::*)(adios2::py11::Variable, const std::vector &, + const adios2::Mode launch)) & + adios2::py11::Engine::Put, + pybind11::arg("variable"), pybind11::arg("floats"), + pybind11::arg("launch") = adios2::Mode::Sync) + + .def("Put", + (void(adios2::py11::Engine::*)(adios2::py11::Variable, + const std::vector> &, + const adios2::Mode launch)) & + adios2::py11::Engine::Put, + pybind11::arg("variable"), pybind11::arg("complexes"), + pybind11::arg("launch") = adios2::Mode::Sync) + .def("PerformPuts", &adios2::py11::Engine::PerformPuts) .def("PerformDataWrite", &adios2::py11::Engine::PerformDataWrite) diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index 2b3b8cbe3d..13c98e4f5c 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -92,15 +92,14 @@ if(Blosc2_FOUND) set(adios2_blosc2_tgt Blosc2::Blosc2) if (Blosc2_VERSION VERSION_GREATER_EQUAL 2.10.1) - if (Blosc2_shlib_available) - set(adios2_blosc2_tgt Blosc2::blosc2_$,shared,static>) + if (Blosc2_shlib_available AND ADIOS2_Blosc2_PREFER_SHARED) + set(adios2_blosc2_tgt Blosc2::blosc2_shared) else() set(adios2_blosc2_tgt Blosc2::blosc2_static) endif() endif() - add_library(adios2_blosc2 INTERFACE) - target_link_libraries(adios2_blosc2 INTERFACE ${adios2_blosc2_tgt}) + add_library(adios2_blosc2 ALIAS ${adios2_blosc2_tgt}) endif() # BZip2 diff --git a/cmake/adios2-config-common.cmake.in b/cmake/adios2-config-common.cmake.in index 04a41531f1..4be4ff7ff0 100644 --- a/cmake/adios2-config-common.cmake.in +++ b/cmake/adios2-config-common.cmake.in @@ -81,11 +81,6 @@ else() endif() if(NOT @BUILD_SHARED_LIBS@) - set(ADIOS2_HAVE_Blosc2 @ADIOS2_HAVE_Blosc2@) - if(ADIOS2_HAVE_Blosc2) - find_dependency(Blosc2) - endif() - set(ADIOS2_HAVE_BZip2 @ADIOS2_HAVE_BZip2@) if(ADIOS2_HAVE_BZip2) find_dependency(BZip2) diff --git a/cmake/install/pre/CMakeLists.txt b/cmake/install/pre/CMakeLists.txt index a9dd447228..6f0fd32be6 100644 --- a/cmake/install/pre/CMakeLists.txt +++ b/cmake/install/pre/CMakeLists.txt @@ -4,7 +4,7 @@ install(CODE " " COMPONENT adios2_core-development ) -file(GLOB ADIOS2_MODULE_FILES +file(GLOB ADIOS2_MODULE_FILES "${ADIOS2_SOURCE_DIR}/cmake/Find*.cmake" "${ADIOS2_SOURCE_DIR}/cmake/CMake*.cmake" ) diff --git a/examples/hello/bpReader/bpReaderHeatMap2D.py b/examples/hello/bpReader/bpReaderHeatMap2D.py index 3208af23b1..0f7dfe70ea 100644 --- a/examples/hello/bpReader/bpReaderHeatMap2D.py +++ b/examples/hello/bpReader/bpReaderHeatMap2D.py @@ -12,7 +12,7 @@ from mpi4py import MPI import numpy -from adios2 import Stream +from adios2 import Stream, FileReader # MPI comm = MPI.COMM_WORLD @@ -39,15 +39,23 @@ with Stream("HeatMap2D_py.bp", "w", comm) as obpStream: obpStream.write("temperature2D", temperatures, shape, start, count) - -if rank == 0: - with Stream("HeatMap2D_py.bp", "r", MPI.COMM_SELF) as ibpStream: - for _ in ibpStream.steps(): - var_inTemperature = ibpStream.inquire_variable("temperature2D") - if var_inTemperature is not None: - var_inTemperature.set_selection([[2, 2], [4, 4]]) - inTemperatures = ibpStream.read(var_inTemperature) - - print("Incoming temperature map") - for i in range(0, inTemperatures.shape[1]): - print(str(inTemperatures[i]) + " ") + if not rank: + obpStream.write("N", [size, Nx, Ny]) # will be an array in output + obpStream.write("Nx", numpy.array(Nx)) # will be a scalar in output + obpStream.write("Ny", Ny) # will be a scalar in output + obpStream.write_attribute("dimensions", [size * Nx, Ny], "temperature2D") + +if not rank: + with FileReader("HeatMap2D_py.bp", MPI.COMM_SELF) as ibpFile: + var_inTemperature = ibpFile.inquire_variable("temperature2D") + if var_inTemperature is not None: + var_inTemperature.set_selection([[2, 2], [4, 4]]) + inTemperatures = ibpFile.read(var_inTemperature) + + in_nx = ibpFile.read("Nx") # scalar is read as a numpy array with 1 element + in_ny = ibpFile.read("Ny") # scalar is read as a numpy array with 1 element + print(f"Incoming nx, ny = {in_nx}, {in_ny}") + + print("Incoming temperature map") + for i in range(0, inTemperatures.shape[1]): + print(str(inTemperatures[i])) diff --git a/examples/hello/bpWriter/bpWriter-bindings.py b/examples/hello/bpWriter/bpWriter-bindings.py index 118b2fe04e..4c98371e79 100644 --- a/examples/hello/bpWriter/bpWriter-bindings.py +++ b/examples/hello/bpWriter/bpWriter-bindings.py @@ -46,10 +46,15 @@ "bpArray", myArray, [size * Nx], [rank * Nx], [Nx], adios2.ConstantDims ) +varNx = bpIO.DefineVariable("Nx", numpy.array(Nx)) # type is derived from numpy array type +bpIO.DefineAttribute("size", Nx, "bpArray") +bpIO.DefineAttribute("dimensions", ["Nx"], "bpArray") + # ADIOS Engine bpFileWriter = bpIO.Open("bpWriter-py-bindings.bp", adios2.Mode.Write) bpFileWriter.BeginStep() bpFileWriter.Put(ioArray, myArray, adios2.Mode.Sync) +bpFileWriter.Put(varNx, numpy.array(Nx), adios2.Mode.Sync) bpFileWriter.EndStep() bpFileWriter.Close() diff --git a/examples/hello/bpWriter/bpWriter.py b/examples/hello/bpWriter/bpWriter.py index dbfacc9dc7..96daec8ece 100644 --- a/examples/hello/bpWriter/bpWriter.py +++ b/examples/hello/bpWriter/bpWriter.py @@ -43,6 +43,9 @@ # ADIOS output stream with adios2.Stream(bpIO, "bpWriter-py.bp", "w", comm) as fh: fh.write("bpArray", myArray, [size * Nx], [rank * Nx], [Nx]) + fh.write("Nx", Nx) + fh.write_attribute("size", Nx, "bpArray") + fh.write_attribute("dimensions", ["Nx"], "bpArray") # Read content: # bpls -la bpWriter-py.bp diff --git a/examples/useCases/CMakeLists.txt b/examples/useCases/CMakeLists.txt index e53d930f80..d49e897634 100644 --- a/examples/useCases/CMakeLists.txt +++ b/examples/useCases/CMakeLists.txt @@ -1,7 +1,7 @@ -#------------------------------------------------------------------------------# +# ------------------------------------------------------------------------------# # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# +# ------------------------------------------------------------------------------# add_subdirectory(fidesOneCell) add_subdirectory(insituGlobalArrays) diff --git a/python/adios2/engine.py b/python/adios2/engine.py index eb091cae50..9954392807 100644 --- a/python/adios2/engine.py +++ b/python/adios2/engine.py @@ -102,8 +102,15 @@ def put(self, variable, content, mode=bindings.Mode.Deferred): """ if isinstance(content, np.ndarray): self.impl.Put(variable.impl, content, mode) - else: + elif isinstance(content, str): + self.impl.Put(variable.impl, content) + elif isinstance(content, list): self.impl.Put(variable.impl, content) + elif not hasattr(content, "__len__"): + content = np.array([content]) + self.impl.Put(variable.impl, content) + else: + raise ValueError def perform_puts(self): """Perform the puts calls""" diff --git a/python/adios2/file_reader.py b/python/adios2/file_reader.py index ac40791a6f..74f0f640fe 100644 --- a/python/adios2/file_reader.py +++ b/python/adios2/file_reader.py @@ -2,9 +2,11 @@ Distributed under the OSI-approved Apache License, Version 2.0. See accompanying file Copyright.txt for details. """ + from functools import singledispatchmethod from adios2 import Stream, IO + # pylint: disable=W0221 class FileReader(Stream): """High level implementation of the FileReader class for read Random access mode""" diff --git a/python/adios2/io.py b/python/adios2/io.py index b493de72bc..ae0318d0cf 100644 --- a/python/adios2/io.py +++ b/python/adios2/io.py @@ -67,13 +67,13 @@ def define_attribute( Not used if variable_name is empty """ - # string or list of strings passed on as is - if isinstance(content, list) and len(content) > 0 and isinstance(content[0], str): + if isinstance(content, (np.ndarray, str, list)): return Attribute(self.impl, name, content, variable_name, separator) - if isinstance(content, str): + + if not hasattr(content, "__len__") and isinstance(content, (int, float, complex)): return Attribute(self.impl, name, content, variable_name, separator) - # python values (single or list) needs to be passed as a numpy array + # Anything else, try to pass as a numpy array (and get an error here if that fails) return Attribute(self.impl, name, np.asarray(content), variable_name, separator) def inquire_attribute(self, name, variable_name="", separator="/"): @@ -99,11 +99,22 @@ def inquire_attribute(self, name, variable_name="", separator="/"): attr.impl = attrimpl return attr - def available_attributes(self): + def available_attributes(self, varname="", separator="/"): """ Returns a 2-level dictionary with attribute information. Read mode only. + Parameters + variable_name + If varname is set, attributes assigned to that variable are returned. + The keys returned are attribute names with the prefix of varname + separator + removed. + + separator + concatenation string between variable_name and attribute + e.g. varname + separator + name ("var/attr") + Not used if varname is empty + Returns attributes dictionary key @@ -111,7 +122,7 @@ def available_attributes(self): value attribute information dictionary """ - return self.impl.AvailableAttributes() + return self.impl.AvailableAttributes(varname, separator) def remove_attribute(self, name): """ @@ -161,13 +172,18 @@ def define_variable( Whether dimensions are constant """ var_impl = None - if isinstance(content, np.ndarray): + if isinstance(content, list) and len(content) > 0: var_impl = self.impl.DefineVariable( - name, content, shape, start, count, is_constant_dims + name, content[0], shape, start, count, is_constant_dims ) + elif content is None: + var_impl = self.impl.DefineVariable(name, "", shape, start, count, is_constant_dims) + else: - var_impl = self.impl.DefineVariable(name) + var_impl = self.impl.DefineVariable( + name, content, shape, start, count, is_constant_dims + ) return Variable(var_impl) diff --git a/python/adios2/stream.py b/python/adios2/stream.py index d737864290..eb632f19fb 100644 --- a/python/adios2/stream.py +++ b/python/adios2/stream.py @@ -2,6 +2,7 @@ Distributed under the OSI-approved Apache License, Version 2.0. See accompanying file Copyright.txt for details. """ + from functools import singledispatchmethod from sys import maxsize import numpy as np @@ -22,6 +23,8 @@ def type_adios_to_numpy(name): "uint64_t": np.uint64, "float": np.float32, "double": np.float64, + "complex": np.complex64, + "double complex": np.complex128, }[name] @@ -47,6 +50,9 @@ def string_to_mode(mode: str) -> [bindings.Mode, bool]: class Stream: """High level implementation of the Stream class from the core API""" + # Default timeout for stream.begin_step() + DEFAULT_TIMEOUT_SEC = -1.0 + @singledispatchmethod def __init__(self, path, mode, comm=None): # pylint: disable=R0912 # Too many branches @@ -68,6 +74,7 @@ def __init__(self, path, mode, comm=None): self.index = -1 self.max_steps = maxsize self._step_status = bindings.StepStatus.EndOfStream + self._step_timeout_sec = self.DEFAULT_TIMEOUT_SEC # e.g. Stream(io: adios2.IO, path, mode) @__init__.register(IO) @@ -79,6 +86,7 @@ def _(self, io: IO, path, mode, comm=None): self.index = -1 self.max_steps = maxsize self._step_status = bindings.StepStatus.EndOfStream + self._step_timeout_sec = self.DEFAULT_TIMEOUT_SEC @property def mode(self): @@ -120,10 +128,17 @@ def __next__(self): raise StopIteration self.index += 1 - self._step_status = self.begin_step() + self._step_status = self.begin_step(timeout=self._step_timeout_sec) if self._step_status == bindings.StepStatus.EndOfStream: raise StopIteration + if self._step_status == bindings.StepStatus.NotReady: + print( + "ERROR: Stream returned no new step within the time limit of" + f" {self._step_timeout_sec} seconds. Ending the loop" + ) + raise StopIteration + if self._step_status == bindings.StepStatus.OtherError: print("ERROR: Stream returned an error. Ending the loop") raise StopIteration @@ -170,11 +185,22 @@ def available_variables(self): """ return self._io.available_variables() - def available_attributes(self): + def available_attributes(self, varname="", separator="/"): """ Returns a 2-level dictionary with attribute information. Read mode only. + Parameters + variable_name + If varname is set, attributes assigned to that variable are returned. + The keys returned are attribute names with the prefix of varname + separator + removed. + + separator + concatenation string between variable_name and attribute + e.g. varname + separator + name ("var/attr") + Not used if varname is empty + Returns attributes dictionary key @@ -182,11 +208,12 @@ def available_attributes(self): value attribute information dictionary """ - return self._io.available_attributes() + return self._io.available_attributes(varname, separator) def define_variable(self, name): """ Define new variable without specifying its type and content. + This only works for string output variables """ return self._io.define_variable(name) @@ -226,7 +253,9 @@ def inquire_attribute(self, name, variable_name="", separator="/"): @singledispatchmethod def write(self, variable: Variable, content): """ - writes a variable + Writes a variable. + Note that the content will be available for consumption only at + the end of the for loop or in the end_step() call. Parameters variable @@ -237,16 +266,12 @@ def write(self, variable: Variable, content): content variable data values """ - if isinstance(content, list): - content_np = np.array(content) - self._engine.put(variable, content_np, bindings.Mode.Sync) - else: - self._engine.put(variable, content, bindings.Mode.Sync) + self._engine.put(variable, content, bindings.Mode.Sync) @write.register(str) def _(self, name, content, shape=[], start=[], count=[], operations=None): """ - writes a variable + Writes a variable Parameters name @@ -270,15 +295,20 @@ def _(self, name, content, shape=[], start=[], count=[], operations=None): variable = self._io.inquire_variable(name) if not variable: - # Sequences variables + # Sequence variables if isinstance(content, np.ndarray): variable = self._io.define_variable(name, content, shape, start, count) elif isinstance(content, list): - content_np = np.array(content) - variable = self._io.define_variable(name, content_np, shape, start, count) - # Scalars variables - elif isinstance(content, str) or not hasattr(content, "__len__"): - variable = self.define_variable(name) + if shape == [] and count == []: + shape = [len(content)] + count = shape + start = [0] + variable = self._io.define_variable(name, content, shape, start, count) + # Scalar variables + elif isinstance(content, str): + variable = self._io.define_variable(name, content) + elif not hasattr(content, "__len__"): + variable = self._io.define_variable(name, content, [], [], []) else: raise ValueError @@ -334,7 +364,11 @@ def read(self, variable: Variable): output_shape[0] *= steps else: # scalar - output_shape = (variable.selection_size(),) + size_all_steps = variable.selection_size() + if size_all_steps > 1: + output_shape = [size_all_steps] + else: + output_shape = [] output = np.zeros(output_shape, dtype=dtype) self._engine.get(variable, output) @@ -370,14 +404,13 @@ def _(self, name: str, start=[], count=[], block_id=None, step_selection=None): if not variable: raise ValueError() - if step_selection and not self._mode == bindings.Mode.ReadRandomAccess: + if step_selection is not None and not self._mode == bindings.Mode.ReadRandomAccess: raise RuntimeError("step_selection parameter requires 'rra' mode") - if step_selection: - print(f"Stream.read step selection = {step_selection}") + if step_selection is not None: variable.set_step_selection(step_selection) - if block_id: + if block_id is not None: variable.set_block_selection(block_id) if variable.type() == "string" and variable.single_value() is True: @@ -466,25 +499,29 @@ def read_attribute_string(self, name, variable_name="", separator="/"): return attribute.data_string() - def begin_step(self): + def begin_step(self, *, timeout=DEFAULT_TIMEOUT_SEC): """ - Write mode: advances to the next step. Convenient when declaring - variable attributes as advancing to the next step is not attached - to any variable. + Write mode: declare the starting of an output step. Pass data in + stream.write() and stream.write_attribute(). All data will be published + in end_step(). Read mode: in streaming mode releases the current step (no effect in file based engines) """ + if self._read_mode: + mode = bindings.StepMode.Read + else: + mode = bindings.StepMode.Append if not self._engine.between_step_pairs(): - return self._engine.begin_step() + return self._engine.begin_step(mode=mode, timeoutSeconds=timeout) return bindings.StepStatus.OtherError def end_step(self): """ - Write mode: advances to the next step. Convenient when declaring - variable attributes as advancing to the next step is not attached - to any variable. + Write mode: declaring the end of an output step. All data passed in + stream.write() and all attributes passed in stream.write_attribute() + will be published for consumers. Read mode: in streaming mode releases the current step (no effect in file based engines) @@ -530,7 +567,7 @@ def loop_index(self): """ return self.index - def steps(self, num_steps=0): + def steps(self, num_steps=0, *, timeout=DEFAULT_TIMEOUT_SEC): """ Returns an interator that can be use to itererate throught the steps. In each iteration begin_step() and end_step() will be internally called. @@ -561,6 +598,8 @@ def steps(self, num_steps=0): else: self.max_steps = maxsize # engine steps will limit the loop + self._step_timeout_sec = timeout + # in write mode we can run yet another loop self.index = -1 diff --git a/scripts/ci/cmake/ci-win2022-vs2022-static-serial.cmake b/scripts/ci/cmake/ci-win2022-vs2022-static-serial.cmake new file mode 100644 index 0000000000..605be8e69b --- /dev/null +++ b/scripts/ci/cmake/ci-win2022-vs2022-static-serial.cmake @@ -0,0 +1,28 @@ +set(ENV{CC} cl) +set(ENV{CXX} cl) +set(ENV{CFLAGS} /WX) +set(ENV{CXXFLAGS} /WX) + +# Tests need to find hdf5.dll +# set(ENV{PATH} "$ENV{PATH};C:/hdf5/HDF5-1.14.2.1-win64/bin") + +set(dashboard_cache " +CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug +BUILD_SHARED_LIBS=OFF +gtest_force_shared_crt=ON +ADIOS2_USE_EXTERNAL_GTEST=OFF +BUILD_TESTING:BOOL=ON +ADIOS2_BUILD_EXAMPLES:BOOL=ON + +ADIOS2_USE_Fortran:BOOL=OFF +ADIOS2_USE_MPI:BOOL=OFF +ADIOS2_USE_HDF5:STRING=OFF +ADIOS2_USE_Python:BOOL=OFF +ADIOS2_USE_HDF5_VOL:STRING=OFF +# HDF5_ROOT:PATH=C:/hdf5/HDF5-1.14.2.1-win64 +") + +set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") +set(CTEST_CMAKE_GENERATOR_PLATFORM "x64") +list(APPEND CTEST_UPDATE_NOTES_FILES "${CMAKE_CURRENT_LIST_FILE}") +include(${CMAKE_CURRENT_LIST_DIR}/ci-common.cmake) diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index ff96f8e2c1..c4f8d893d2 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -480,7 +480,7 @@ install(DIRECTORY toolkit/ ) # Library installation -install(TARGETS adios2_core ${maybe_adios2_core_mpi} ${maybe_adios2_core_cuda} ${maybe_adios2_core_kokkos} ${maybe_adios2_blosc2} ${maybe_adios2_core_derived} EXPORT adios2Exports +install(TARGETS adios2_core ${maybe_adios2_core_mpi} ${maybe_adios2_core_cuda} ${maybe_adios2_core_kokkos} ${maybe_adios2_core_derived} EXPORT adios2Exports RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_core-runtime LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT adios2_core-libraries NAMELINK_COMPONENT adios2_core-development ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT adios2_core-development diff --git a/testing/adios2/bindings/python/TestBPBlocksInfo.py b/testing/adios2/bindings/python/TestBPBlocksInfo.py index 6968ae2ba8..fd9eee5c35 100644 --- a/testing/adios2/bindings/python/TestBPBlocksInfo.py +++ b/testing/adios2/bindings/python/TestBPBlocksInfo.py @@ -38,22 +38,22 @@ adios = adios2.ADIOS(comm) ioWrite = adios.DeclareIO("ioWriter") -varTemperature = ioWrite.DefineVariable("temperature2D", temperatures, shape, - start, count, adios2.ConstantDims) +varTemperature = ioWrite.DefineVariable( + "temperature2D", temperatures, shape, start, count, adios2.ConstantDims +) -obpStream = ioWrite.Open('HeatMap2D_py.bp', adios2.Mode.Write) +obpStream = ioWrite.Open("HeatMap2D_py.bp", adios2.Mode.Write) obpStream.Put(varTemperature, temperatures) obpStream.Close() if rank == 0: ioRead = adios.DeclareIO("ioReader") - ibpStream = ioRead.Open('HeatMap2D_py.bp', adios2.Mode.ReadRandomAccess, - MPI.COMM_SELF) + ibpStream = ioRead.Open("HeatMap2D_py.bp", adios2.Mode.ReadRandomAccess, MPI.COMM_SELF) var_inTemperature = ioRead.InquireVariable("temperature2D") info = ibpStream.BlocksInfo("temperature2D", 0) assert info is not None - assert info[0]['Start'] == '0,0' - assert info[0]['Count'] == '10,10' - assert info[0]['WriterID'] == '0' + assert info[0]["Start"] == "0,0" + assert info[0]["Count"] == "10,10" + assert info[0]["WriterID"] == "0" diff --git a/testing/adios2/bindings/python/TestBPReadMultisteps.py b/testing/adios2/bindings/python/TestBPReadMultisteps.py index 0b0b1133cf..c165ab8b84 100644 --- a/testing/adios2/bindings/python/TestBPReadMultisteps.py +++ b/testing/adios2/bindings/python/TestBPReadMultisteps.py @@ -17,12 +17,12 @@ def check_object(adios2_object, name): if adios2_object is None: - raise ValueError(str(name) + ' not found') + raise ValueError(str(name) + " not found") def check_name(name, name_list): if name not in name_list: - raise ValueError(str(name) + ' not found in list') + raise ValueError(str(name) + " not found in list") # MPI @@ -43,29 +43,19 @@ def check_name(name, name_list): # ADIOS Variable name, shape, start, offset, constant dims # All local variables -varI8 = ioWriter.DefineVariable( - "varI8", data.I8, shape, start, count, adios2.ConstantDims) -varI16 = ioWriter.DefineVariable( - "varI16", data.I16, shape, start, count, adios2.ConstantDims) -varI32 = ioWriter.DefineVariable( - "varI32", data.I32, shape, start, count, adios2.ConstantDims) -varI64 = ioWriter.DefineVariable( - "varI64", data.I64, shape, start, count, adios2.ConstantDims) - -varU8 = ioWriter.DefineVariable( - "varU8", data.U8, shape, start, count, adios2.ConstantDims) -varU16 = ioWriter.DefineVariable( - "varU16", data.U16, shape, start, count, adios2.ConstantDims) -varU32 = ioWriter.DefineVariable( - "varU32", data.U32, shape, start, count, adios2.ConstantDims) -varU64 = ioWriter.DefineVariable( - "varU64", data.U64, shape, start, count, adios2.ConstantDims) - -varR32 = ioWriter.DefineVariable( - "varR32", data.R32, shape, start, count, adios2.ConstantDims) - -varR64 = ioWriter.DefineVariable( - "varR64", data.R64, shape, start, count, adios2.ConstantDims) +varI8 = ioWriter.DefineVariable("varI8", data.I8, shape, start, count, adios2.ConstantDims) +varI16 = ioWriter.DefineVariable("varI16", data.I16, shape, start, count, adios2.ConstantDims) +varI32 = ioWriter.DefineVariable("varI32", data.I32, shape, start, count, adios2.ConstantDims) +varI64 = ioWriter.DefineVariable("varI64", data.I64, shape, start, count, adios2.ConstantDims) + +varU8 = ioWriter.DefineVariable("varU8", data.U8, shape, start, count, adios2.ConstantDims) +varU16 = ioWriter.DefineVariable("varU16", data.U16, shape, start, count, adios2.ConstantDims) +varU32 = ioWriter.DefineVariable("varU32", data.U32, shape, start, count, adios2.ConstantDims) +varU64 = ioWriter.DefineVariable("varU64", data.U64, shape, start, count, adios2.ConstantDims) + +varR32 = ioWriter.DefineVariable("varR32", data.R32, shape, start, count, adios2.ConstantDims) + +varR64 = ioWriter.DefineVariable("varR64", data.R64, shape, start, count, adios2.ConstantDims) attString = ioWriter.DefineAttribute("attrString", ["hello attribute"]) attI8 = ioWriter.DefineAttribute("attrI8", data.I8) @@ -74,7 +64,6 @@ def check_name(name, name_list): writer = ioWriter.Open("npTypes.bp", adios2.Mode.Write) for i in range(0, 3): - npi8 = np.full((Nx), i, dtype=np.int8) npi16 = np.full((Nx), i, dtype=np.int16) npi32 = np.full((Nx), i, dtype=np.int32) @@ -138,9 +127,19 @@ def check_name(name, name_list): attr_names = ["attrString", "attrI8"] -var_names = ["varStr", "varI8", "varI16", "varI32", "varI64", - "varU8", "varU16", "varU32", "varU64", - "varR32", "varR64"] +var_names = [ + "varStr", + "varI8", + "varI16", + "varI32", + "varI64", + "varU8", + "varU16", + "varU32", + "varU64", + "varR32", + "varR64", +] attributesInfo = ioReader.AvailableAttributes() for name, info in attributesInfo.items(): @@ -226,34 +225,34 @@ def check_name(name, name_list): for i in range(0, 3): for j in range(0, Nx): if inI8[i][j] != i: - raise ValueError('failed reading I8') + raise ValueError("failed reading I8") if inI16[i][j] != i: - raise ValueError('failed reading I16') + raise ValueError("failed reading I16") if inI32[i][j] != i: - raise ValueError('failed reading I32') + raise ValueError("failed reading I32") if inI64[i][j] != i: - raise ValueError('failed reading I64') + raise ValueError("failed reading I64") if inU8[i][j] != i: - raise ValueError('failed reading U8') + raise ValueError("failed reading U8") if inU16[i][j] != i: - raise ValueError('failed reading U16') + raise ValueError("failed reading U16") if inU32[i][j] != i: - raise ValueError('failed reading U32') + raise ValueError("failed reading U32") if inU64[i][j] != i: - raise ValueError('failed reading U64') + raise ValueError("failed reading U64") if inR32[i][j] != i: - raise ValueError('failed reading R32') + raise ValueError("failed reading R32") if inR64[i][j] != i: - raise ValueError('failed reading R64') + raise ValueError("failed reading R64") # here tests reader data diff --git a/testing/adios2/bindings/python/TestBPSelectSteps.py b/testing/adios2/bindings/python/TestBPSelectSteps.py index 803ee45ccd..a0d209001d 100644 --- a/testing/adios2/bindings/python/TestBPSelectSteps.py +++ b/testing/adios2/bindings/python/TestBPSelectSteps.py @@ -25,13 +25,11 @@ class TestAdiosSelectSteps(unittest.TestCase): - def setUp(self): total_steps = 10 with adios2.open(TESTDATA_FILENAME, "w", comm) as fh: for i in range(total_steps): - fh.write("step", np.full((Nx), i, dtype=np.int32), - shape, start, count) + fh.write("step", np.full((Nx), i, dtype=np.int32), shape, start, count) fh.end_step() def test_select_steps_reading_fullAPI(self): @@ -40,18 +38,22 @@ def test_select_steps_reading_fullAPI(self): adios = adios2.ADIOS() ioReadBP = adios.DeclareIO("hellopy") ioReadBP.SetParameter(TESTDATA_FILENAME, param_string) - fh = ioReadBP.Open(TESTDATA_FILENAME, - adios2.Mode.ReadRandomAccess, comm) + fh = ioReadBP.Open(TESTDATA_FILENAME, adios2.Mode.ReadRandomAccess, comm) var = ioReadBP.InquireVariable("step") var.SetSelection([[0], [size * Nx]]) var.SetStepSelection([0, len(selected_steps)]) data = np.zeros((len(selected_steps), size * Nx), dtype=np.int32) fh.Get(var, data) fh.PerformGets() - self.assertTrue(all( - [list(data[i]) == [selected_steps[i] for x in range(len(data[i]))] - for i in range(len(selected_steps))])) + self.assertTrue( + all( + [ + list(data[i]) == [selected_steps[i] for x in range(len(data[i]))] + for i in range(len(selected_steps)) + ] + ) + ) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/testing/adios2/bindings/python/TestBPWriteRead2D.py b/testing/adios2/bindings/python/TestBPWriteRead2D.py index 17a04a2c8e..f8be1a4758 100644 --- a/testing/adios2/bindings/python/TestBPWriteRead2D.py +++ b/testing/adios2/bindings/python/TestBPWriteRead2D.py @@ -38,10 +38,11 @@ adios = adios2.ADIOS(comm) ioWrite = adios.DeclareIO("ioWriter") -varTemperature = ioWrite.DefineVariable("temperature2D", temperatures, shape, - start, count, adios2.ConstantDims) +varTemperature = ioWrite.DefineVariable( + "temperature2D", temperatures, shape, start, count, adios2.ConstantDims +) -obpStream = ioWrite.Open('HeatMap2D_py.bp', adios2.Mode.Write) +obpStream = ioWrite.Open("HeatMap2D_py.bp", adios2.Mode.Write) obpStream.Put(varTemperature, temperatures) obpStream.Close() @@ -49,12 +50,11 @@ if rank == 0: # ADIOS2 read ioRead = adios.DeclareIO("ioReader") - ibpStream = ioRead.Open('HeatMap2D_py.bp', adios2.Mode.ReadRandomAccess, - MPI.COMM_SELF) + ibpStream = ioRead.Open("HeatMap2D_py.bp", adios2.Mode.ReadRandomAccess, MPI.COMM_SELF) var_inTemperature = ioRead.InquireVariable("temperature2D") if var_inTemperature is False: - raise ValueError('var_inTemperature is False') + raise ValueError("var_inTemperature is False") assert var_inTemperature is not None readOffset = [2, 2] @@ -66,8 +66,7 @@ ibpStream.Close() # print('Incoming temperature map\n', inTemperatures) - expected = np.array([[22, 23, 24, 25], - [32, 33, 34, 35], - [42, 43, 44, 45], - [52, 53, 54, 55]], np.int32) + expected = np.array( + [[22, 23, 24, 25], [32, 33, 34, 35], [42, 43, 44, 45], [52, 53, 54, 55]], np.int32 + ) assert np.array_equal(inTemperatures, expected) diff --git a/testing/adios2/bindings/python/TestBPWriteReadString.py b/testing/adios2/bindings/python/TestBPWriteReadString.py index 355347c7a4..5b1d104545 100644 --- a/testing/adios2/bindings/python/TestBPWriteReadString.py +++ b/testing/adios2/bindings/python/TestBPWriteReadString.py @@ -15,14 +15,13 @@ class TestAdiosWriteReadStringfullAPI(unittest.TestCase): - def test_write_read_string_fullAPI(self): comm = MPI.COMM_WORLD - theString = 'hello adios' - bpFilename = 'string_test_fullAPI.bp' - varname = 'mystringvar' + theString = "hello adios" + bpFilename = "string_test_fullAPI.bp" + varname = "mystringvar" adios = adios2.ADIOS(comm) - ioWrite = adios.DeclareIO('ioWriter') + ioWrite = adios.DeclareIO("ioWriter") adEngine = ioWrite.Open(bpFilename, adios2.Mode.Write) varMyString = ioWrite.DefineVariable(varname) for step in range(N_STEPS): @@ -31,7 +30,7 @@ def test_write_read_string_fullAPI(self): adEngine.EndStep() adEngine.Close() - ioRead = adios.DeclareIO('ioReader') + ioRead = adios.DeclareIO("ioReader") adEngine = ioRead.Open(bpFilename, adios2.Mode.Read) for step in range(N_STEPS): adEngine.BeginStep() @@ -42,5 +41,5 @@ def test_write_read_string_fullAPI(self): adEngine.Close() -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/testing/adios2/bindings/python/TestBPWriteReadTypes.py b/testing/adios2/bindings/python/TestBPWriteReadTypes.py index 399758bdb1..c2eda114db 100644 --- a/testing/adios2/bindings/python/TestBPWriteReadTypes.py +++ b/testing/adios2/bindings/python/TestBPWriteReadTypes.py @@ -16,19 +16,19 @@ def check_object(adios2_object, name): if adios2_object is False: - raise ValueError(str(name) + ' not found') + raise ValueError(str(name) + " not found") def check_name(name, name_list): if name not in name_list: - raise ValueError(str(name) + ' not found in list') + raise ValueError(str(name) + " not found in list") def check_array(np1, np2, hint): if (np1 == np2).all() is False: print("InData: " + str(np1)) print("Data: " + str(np2)) - raise ValueError('Array read failed ' + str(hint)) + raise ValueError("Array read failed " + str(hint)) # MPI @@ -38,11 +38,33 @@ def check_array(np1, np2, hint): Nx = 8 # list of tested attributes and variables -attr_names = ["attrString", "attrStringArray", "attrI8", "attrI16", "attrI32", "attrI64", - "attrU8", "attrU16", "attrU32", "attrU64", "attrR32", "attrR64"] -var_names = ["varStr", "varI8", "varI16", "varI32", "varI64", - "varU8", "varU16", "varU32", "varU64", - "varR32", "varR64"] +attr_names = [ + "attrString", + "attrStringArray", + "attrI8", + "attrI16", + "attrI32", + "attrI64", + "attrU8", + "attrU16", + "attrU32", + "attrU64", + "varR32/attrR32", + "varR64::attrR64", +] +var_names = [ + "varStr", + "varI8", + "varI16", + "varI32", + "varI64", + "varU8", + "varU16", + "varU32", + "varU64", + "varR32", + "varR64", +] # Start ADIOS adios = adios2.ADIOS(comm) @@ -58,29 +80,19 @@ def check_array(np1, np2, hint): # All local variables varStr = ioWriter.DefineVariable("varStr") -varI8 = ioWriter.DefineVariable( - "varI8", data.I8, shape, start, count, adios2.ConstantDims) -varI16 = ioWriter.DefineVariable( - "varI16", data.I16, shape, start, count, adios2.ConstantDims) -varI32 = ioWriter.DefineVariable( - "varI32", data.I32, shape, start, count, adios2.ConstantDims) -varI64 = ioWriter.DefineVariable( - "varI64", data.I64, shape, start, count, adios2.ConstantDims) - -varU8 = ioWriter.DefineVariable( - "varU8", data.U8, shape, start, count, adios2.ConstantDims) -varU16 = ioWriter.DefineVariable( - "varU16", data.U16, shape, start, count, adios2.ConstantDims) -varU32 = ioWriter.DefineVariable( - "varU32", data.U32, shape, start, count, adios2.ConstantDims) -varU64 = ioWriter.DefineVariable( - "varU64", data.U64, shape, start, count, adios2.ConstantDims) - -varR32 = ioWriter.DefineVariable( - "varR32", data.R32, shape, start, count, adios2.ConstantDims) - -varR64 = ioWriter.DefineVariable( - "varR64", data.R64, shape, start, count, adios2.ConstantDims) +varI8 = ioWriter.DefineVariable("varI8", data.I8, shape, start, count, adios2.ConstantDims) +varI16 = ioWriter.DefineVariable("varI16", data.I16, shape, start, count, adios2.ConstantDims) +varI32 = ioWriter.DefineVariable("varI32", data.I32, shape, start, count, adios2.ConstantDims) +varI64 = ioWriter.DefineVariable("varI64", data.I64, shape, start, count, adios2.ConstantDims) + +varU8 = ioWriter.DefineVariable("varU8", data.U8, shape, start, count, adios2.ConstantDims) +varU16 = ioWriter.DefineVariable("varU16", data.U16, shape, start, count, adios2.ConstantDims) +varU32 = ioWriter.DefineVariable("varU32", data.U32, shape, start, count, adios2.ConstantDims) +varU64 = ioWriter.DefineVariable("varU64", data.U64, shape, start, count, adios2.ConstantDims) + +varR32 = ioWriter.DefineVariable("varR32", data.R32, shape, start, count, adios2.ConstantDims) + +varR64 = ioWriter.DefineVariable("varR64", data.R64, shape, start, count, adios2.ConstantDims) attString = ioWriter.DefineAttribute("attrString", "one") attStringArray = ioWriter.DefineAttribute("attrStringArray", ["one", "two", "three"]) @@ -92,17 +104,17 @@ def check_array(np1, np2, hint): attU16 = ioWriter.DefineAttribute("attrU16", data.U16) attU32 = ioWriter.DefineAttribute("attrU32", data.U32) attU64 = ioWriter.DefineAttribute("attrU64", data.U64) -attR32 = ioWriter.DefineAttribute("attrR32", data.R32) -attR64 = ioWriter.DefineAttribute("attrR64", data.R64) +# add an attribute to a variable +attR32 = ioWriter.DefineAttribute("attrR32", data.R32, "varR32") +attR64 = ioWriter.DefineAttribute("attrR64", data.R64, "varR64", "::") ioWriter.SetEngine("BPFile") -ioParams = {'Threads': '1', 'InitialBufferSize': '17Kb'} +ioParams = {"Threads": "1", "InitialBufferSize": "17Kb"} ioWriter.SetParameters(ioParams) engineType = ioWriter.EngineType() if engineType != "BPFile": - raise ValueError(str(engineType) + - ' incorrect engine type, should be BPFile') + raise ValueError(str(engineType) + " incorrect engine type, should be BPFile") ioWriter.SetParameter("profileunits", "microseconds") ioWriter.AddTransport("file") @@ -120,7 +132,6 @@ def check_array(np1, np2, hint): writer.LockWriterDefinitions() for i in range(0, nsteps): - data.update(rank, i, size) writer.BeginStep() @@ -156,8 +167,8 @@ def check_array(np1, np2, hint): attrU16 = ioReader.InquireAttribute("attrU16") attrU32 = ioReader.InquireAttribute("attrU32") attrU64 = ioReader.InquireAttribute("attrU64") -attrR32 = ioReader.InquireAttribute("attrR32") -attrR64 = ioReader.InquireAttribute("attrR64") +attrR32 = ioReader.InquireAttribute("attrR32", "varR32") +attrR64 = ioReader.InquireAttribute("attrR64", "varR64", "::") check_object(attrString, "attrString") check_object(attrStringArray, "attrStringArray") @@ -169,22 +180,28 @@ def check_array(np1, np2, hint): check_object(attrU16, "attrU16") check_object(attrU32, "attrU32") check_object(attrU64, "attrU64") -check_object(attrR32, "attrR32") -check_object(attrR64, "attrR64") +check_object(attrR32, "varR32/attrR32") +check_object(attrR64, "varR64::attrR64") + +# alternative inquire format +attrR32 = ioReader.InquireAttribute("varR32/attrR32") +attrR64 = ioReader.InquireAttribute("varR64::attrR64") +check_object(attrR32, "varR32/attrR32") +check_object(attrR64, "varR64::attrR64") attrStringData = attrString.DataString() print(f"attrString = {attrStringData}", flush=True) if attrStringData[0] != "one": - raise ValueError('attrString failed') + raise ValueError("attrString failed") attrStringData = attrStringArray.DataString() print(f"attrStringArray = {attrStringData}", flush=True) if attrStringData[0] != "one": - raise ValueError('attrStringData[0] failed') + raise ValueError("attrStringData[0] failed") if attrStringData[1] != "two": - raise ValueError('attrStringData[1] failed') + raise ValueError("attrStringData[1] failed") if attrStringData[2] != "three": - raise ValueError('attrStringData[2] failed') + raise ValueError("attrStringData[2] failed") attrI8Data = attrI8.Data() attrI16Data = attrI16.Data() @@ -197,17 +214,18 @@ def check_array(np1, np2, hint): attrR32Data = attrR32.Data() attrR64Data = attrR64.Data() -check_array(attrI8Data, data.I8, 'I8') -check_array(attrI16Data, data.I16, 'I16') -check_array(attrI32Data, data.I32, 'I32') -check_array(attrI64Data, data.I64, 'I64') -check_array(attrU8Data, data.U8, 'U8') -check_array(attrU16Data, data.U16, 'U16') -check_array(attrU32Data, data.U32, 'U32') -check_array(attrU64Data, data.U64, 'U64') -check_array(attrR32Data, data.R32, 'R32') -check_array(attrR64Data, data.R64, 'R64') - +check_array(attrI8Data, data.I8, "I8") +check_array(attrI16Data, data.I16, "I16") +check_array(attrI32Data, data.I32, "I32") +check_array(attrI64Data, data.I64, "I64") +check_array(attrU8Data, data.U8, "U8") +check_array(attrU16Data, data.U16, "U16") +check_array(attrU32Data, data.U32, "U32") +check_array(attrU64Data, data.U64, "U64") +check_array(attrR32Data, data.R32, "R32") +check_array(attrR64Data, data.R64, "R64") + +print("=========== Attributes ===========") attributesInfo = ioReader.AvailableAttributes() for name, info in attributesInfo.items(): check_name(name, attr_names) @@ -217,6 +235,27 @@ def check_array(np1, np2, hint): print("\t" + key + ": " + value) print("\n") +print("=========== Available attributes of varR32 ===========") +attributesInfoR32 = ioReader.AvailableAttributes("varR32") +for name, info in attributesInfoR32.items(): + check_name(name, ["attrR32"]) + if rank == 0: + print("attribute_name: " + name) + for key, value in info.items(): + print("\t" + key + ": " + value) + print("\n") + +print("=========== Available attributes of varR64 ===========") +attributesInfoR32 = ioReader.AvailableAttributes("varR64", "::") +for name, info in attributesInfoR32.items(): + check_name(name, ["attrR64"]) + if rank == 0: + print("attribute_name: " + name) + for key, value in info.items(): + print("\t" + key + ": " + value) + print("\n") + +print("=========== Variables ===========") varStr = ioReader.InquireVariable("varStr") varI8 = ioReader.InquireVariable("varI8") varI16 = ioReader.InquireVariable("varI16") @@ -251,11 +290,11 @@ def check_array(np1, np2, hint): print("\n") -result = adios.RemoveIO('writer') +result = adios.RemoveIO("writer") if result is False: - raise ValueError('Could not remove IO writer') + raise ValueError("Could not remove IO writer") -assert (reader.Steps() == nsteps) +assert reader.Steps() == nsteps reader.Close() @@ -263,10 +302,10 @@ def check_array(np1, np2, hint): ioReader.RemoveAllVariables() varStr = ioReader.InquireVariable("varStr") if varStr is True: - raise ValueError('Could remove reader variables') + raise ValueError("Could remove reader variables") adios.RemoveAllIOs() try: - ioWriter = adios.DeclareIO('reader') + ioWriter = adios.DeclareIO("reader") except ValueError: - raise ValueError('Could not re-Declare IO reader') + raise ValueError("Could not re-Declare IO reader") diff --git a/testing/adios2/bindings/python/TestBPWriteReadTypes_nompi.py b/testing/adios2/bindings/python/TestBPWriteReadTypes_nompi.py index edee61f1c1..1df907a4d5 100644 --- a/testing/adios2/bindings/python/TestBPWriteReadTypes_nompi.py +++ b/testing/adios2/bindings/python/TestBPWriteReadTypes_nompi.py @@ -22,29 +22,19 @@ # ADIOS Variable name, shape, start, offset, constant dims # All local variables -varI8 = bpIO.DefineVariable( - "varI8", data.I8, [], [], [data.I8.size], adios2.ConstantDims) -varI16 = bpIO.DefineVariable( - "varI16", data.I16, [], [], [data.I16.size], adios2.ConstantDims) -varI32 = bpIO.DefineVariable( - "varI32", data.I32, [], [], [data.I32.size], adios2.ConstantDims) -varI64 = bpIO.DefineVariable( - "varI64", data.I64, [], [], [data.I64.size], adios2.ConstantDims) - -varU8 = bpIO.DefineVariable( - "varUI8", data.U8, [], [], [data.U8.size], adios2.ConstantDims) -varU16 = bpIO.DefineVariable( - "varUI16", data.U16, [], [], [data.U16.size], adios2.ConstantDims) -varU32 = bpIO.DefineVariable( - "varUI32", data.U32, [], [], [data.U32.size], adios2.ConstantDims) -varU64 = bpIO.DefineVariable( - "varUI64", data.U64, [], [], [data.U64.size], adios2.ConstantDims) - -varR32 = bpIO.DefineVariable( - "varR32", data.R32, [], [], [data.R32.size], adios2.ConstantDims) - -varR64 = bpIO.DefineVariable( - "varR64", data.R64, [], [], [data.R64.size], adios2.ConstantDims) +varI8 = bpIO.DefineVariable("varI8", data.I8, [], [], [data.I8.size], adios2.ConstantDims) +varI16 = bpIO.DefineVariable("varI16", data.I16, [], [], [data.I16.size], adios2.ConstantDims) +varI32 = bpIO.DefineVariable("varI32", data.I32, [], [], [data.I32.size], adios2.ConstantDims) +varI64 = bpIO.DefineVariable("varI64", data.I64, [], [], [data.I64.size], adios2.ConstantDims) + +varU8 = bpIO.DefineVariable("varUI8", data.U8, [], [], [data.U8.size], adios2.ConstantDims) +varU16 = bpIO.DefineVariable("varUI16", data.U16, [], [], [data.U16.size], adios2.ConstantDims) +varU32 = bpIO.DefineVariable("varUI32", data.U32, [], [], [data.U32.size], adios2.ConstantDims) +varU64 = bpIO.DefineVariable("varUI64", data.U64, [], [], [data.U64.size], adios2.ConstantDims) + +varR32 = bpIO.DefineVariable("varR32", data.R32, [], [], [data.R32.size], adios2.ConstantDims) + +varR64 = bpIO.DefineVariable("varR64", data.R64, [], [], [data.R64.size], adios2.ConstantDims) # ADIOS Engine diff --git a/testing/adios2/bindings/python/TestGetException_nompi.py b/testing/adios2/bindings/python/TestGetException_nompi.py index 6e2d8a333d..86b2dd235d 100644 --- a/testing/adios2/bindings/python/TestGetException_nompi.py +++ b/testing/adios2/bindings/python/TestGetException_nompi.py @@ -1,26 +1,22 @@ - import numpy as np import logging import adios2.bindings as adios2 -if __name__ == '__main__': +if __name__ == "__main__": __spec__ = None def main(): - print("====================================") format = "%(asctime)s: %(message)s" - logging.basicConfig(format=format, level=logging.INFO, - datefmt="%H:%M:%S") + logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S") writer() reader_fail() reader_success() def writer(): - logging.info(" Writer: initiating writing") data = np.arange(3, dtype=np.float32) logging.info(f" data dtypes: {data.dtype!s}") @@ -33,8 +29,7 @@ def writer(): IO = adios_io.DeclareIO("writer") writer = IO.Open("testdatafile", adios2.Mode.Write) - writebuffer = IO.DefineVariable("np_data", data, shape, start, - count, adios2.ConstantDims) + writebuffer = IO.DefineVariable("np_data", data, shape, start, count, adios2.ConstantDims) if writebuffer: writer.BeginStep() writer.Put(writebuffer, data, adios2.Mode.Sync) @@ -48,7 +43,6 @@ def writer(): def reader_fail(): - adios_io = adios2.ADIOS() io = adios_io.DeclareIO("reader") @@ -85,11 +79,12 @@ def reader_fail(): raise StopIteration(f"next step failed to initiate {stepStatus!s}") reader.EndStep() reader.Close() - logging.info(" Reader: finished reading",) + logging.info( + " Reader: finished reading", + ) def reader_success(): - adios_io = adios2.ADIOS() io = adios_io.DeclareIO("reader") @@ -126,7 +121,9 @@ def reader_success(): raise StopIteration(f"next step failed to initiate {stepStatus!s}") reader.EndStep() reader.Close() - logging.info(" Reader: finished reading",) + logging.info( + " Reader: finished reading", + ) if __name__ == "__main__": diff --git a/testing/adios2/bindings/python/TestNullEngine.py b/testing/adios2/bindings/python/TestNullEngine.py index ac5fb1796a..9b88b01afc 100644 --- a/testing/adios2/bindings/python/TestNullEngine.py +++ b/testing/adios2/bindings/python/TestNullEngine.py @@ -36,16 +36,17 @@ adios = adios2.ADIOS(comm) ioWrite = adios.DeclareIO("ioWriter") -varTemperature = ioWrite.DefineVariable("temperature2D", temperatures, shape, - start, count, adios2.ConstantDims) +varTemperature = ioWrite.DefineVariable( + "temperature2D", temperatures, shape, start, count, adios2.ConstantDims +) ioWrite.SetEngine("NULL") -nullWriter = ioWrite.Open('NULL_py.bp', adios2.Mode.Write) +nullWriter = ioWrite.Open("NULL_py.bp", adios2.Mode.Write) -assert (nullWriter.Type() == "NullWriter") +assert nullWriter.Type() == "NullWriter" status = nullWriter.BeginStep() -assert (status == adios2.StepStatus.OK) +assert status == adios2.StepStatus.OK nullWriter.Put(varTemperature, temperatures) nullWriter.EndStep() @@ -54,19 +55,19 @@ # ADIOS2 read ioRead = adios.DeclareIO("ioReader") ioRead.SetEngine("null") -nullReader = ioRead.Open('NULL_py.bp', adios2.Mode.Read, MPI.COMM_SELF) +nullReader = ioRead.Open("NULL_py.bp", adios2.Mode.Read, MPI.COMM_SELF) -assert (nullReader.Type() == "NullReader") +assert nullReader.Type() == "NullReader" inTemperatures = np.zeros(1, dtype=np.int32) status = nullReader.BeginStep() -assert (status == adios2.StepStatus.EndOfStream) +assert status == adios2.StepStatus.EndOfStream var_inTemperature = ioRead.InquireVariable("temperature2D") -if (var_inTemperature is True): - raise ValueError('var_inTemperature is not False') +if var_inTemperature is True: + raise ValueError("var_inTemperature is not False") # nullReader.Get(var_inTemperature, inTemperatures) diff --git a/testing/adios2/bindings/python/TestQuery.py b/testing/adios2/bindings/python/TestQuery.py index d0ee554d0f..a1b1cd59e3 100644 --- a/testing/adios2/bindings/python/TestQuery.py +++ b/testing/adios2/bindings/python/TestQuery.py @@ -13,29 +13,29 @@ # # usage: [bp4 | bp5=default] ## # ####################################### numSteps = 5 -queryFile = 'query.xml' -targetVarName = 'var0' +queryFile = "query.xml" +targetVarName = "var0" # User data -myArray = np.array([0, 1., 2., 3., 4., 5., 6., 7., 8., 9.]) +myArray = np.array([0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) Nx = myArray.size # ADIOS MPI Communicator adios = adios2.ADIOS(comm) -supportedEngines = ['bp5', 'bp4'] -engineType = 'bp5' -if (len(sys.argv) > 1): +supportedEngines = ["bp5", "bp4"] +engineType = "bp5" +if len(sys.argv) > 1: engineType = sys.argv[1].lower() -if (engineType in supportedEngines): - if (rank == 0): - print('Using engine type:', engineType) +if engineType in supportedEngines: + if rank == 0: + print("Using engine type:", engineType) else: - sys.exit('specified engine does not exist') + sys.exit("specified engine does not exist") -dataFileName = 'test_' + engineType + '.bp' +dataFileName = "test_" + engineType + ".bp" def writeDataFile(): @@ -43,8 +43,8 @@ def writeDataFile(): bpIO.SetEngine(engineType) ioArray = bpIO.DefineVariable( - targetVarName, myArray, [size * Nx], [rank * Nx], - [Nx], adios2.ConstantDims) + targetVarName, myArray, [size * Nx], [rank * Nx], [Nx], adios2.ConstantDims + ) bpFileWriter = bpIO.Open(dataFileName, adios2.Mode.Write) @@ -59,29 +59,31 @@ def writeDataFile(): def createQueryFile(): print(".. Writing query file to: ", queryFile) - file1 = open(queryFile, 'w') + file1 = open(queryFile, "w") queryContent = [ - "\n", "\n", - " \n" - " \n", - " \n", - " \n", - " \n", " \n", - " \n", " \n", "\n" + '\n', + "\n", + ' \n' ' \n', + ' \n', + ' \n', + ' \n', + " \n", + " \n", + " \n", + "\n", ] file1.writelines(queryContent) file1.close() def doAnalysis(reader, touched_blocks, varList): - print(" Step: ", reader.CurrentStep(), - " num touched blocks: ", len(touched_blocks)) - if (0 == reader.CurrentStep()): - assert (len(touched_blocks) == min(size, 2)) - if (1 == reader.CurrentStep()): - assert (len(touched_blocks) == size) - if (1 < reader.CurrentStep()): - assert (len(touched_blocks) == 0) + print(" Step: ", reader.CurrentStep(), " num touched blocks: ", len(touched_blocks)) + if 0 == reader.CurrentStep(): + assert len(touched_blocks) == min(size, 2) + if 1 == reader.CurrentStep(): + assert len(touched_blocks) == size + if 1 < reader.CurrentStep(): + assert len(touched_blocks) == 0 values = [] data = {} @@ -89,7 +91,7 @@ def doAnalysis(reader, touched_blocks, varList): for var in varList: data[var] = [] - if (len(touched_blocks) > 0): + if len(touched_blocks) > 0: for n in touched_blocks: for var in varList: values = np.zeros(n[1], dtype=np.double) @@ -109,14 +111,14 @@ def queryDataFile(): print("Num steps: ", reader.Steps()) - while (reader.BeginStep() == adios2.StepStatus.OK): + while reader.BeginStep() == adios2.StepStatus.OK: # bp5 loads metadata after beginstep(), # therefore query has to be called per step w = adios2.Query(queryFile, reader) # assume only rank 0 wants to process result var = [queryIO.InquireVariable(targetVarName)] - if (rank == 0): + if rank == 0: touched_blocks = w.GetResult() doAnalysis(reader, touched_blocks, var) @@ -127,10 +129,12 @@ def queryDataFile(): def cleanUp(): import os import shutil + os.remove(queryFile) shutil.rmtree(dataFileName) print(" Cleanup generated files: ", queryFile, dataFileName) + # # actual setup: # @@ -138,7 +142,7 @@ def cleanUp(): writeDataFile() -if (0 == rank): +if 0 == rank: createQueryFile() queryDataFile() cleanUp() diff --git a/testing/adios2/bindings/python/TestQueryLocalArray.py b/testing/adios2/bindings/python/TestQueryLocalArray.py index 4eab11acde..b78dd7a2e3 100644 --- a/testing/adios2/bindings/python/TestQueryLocalArray.py +++ b/testing/adios2/bindings/python/TestQueryLocalArray.py @@ -13,29 +13,29 @@ # # usage: [bp4 | bp5=default] ## # ####################################### numSteps = 5 -queryFile = 'query.xml' -targetVarName = 'var0' +queryFile = "query.xml" +targetVarName = "var0" # User data -myArray = np.array([0, 1., 2., 3., 4., 5., 6., 7., 8., 9.]) +myArray = np.array([0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) Nx = myArray.size # ADIOS MPI Communicator adios = adios2.ADIOS(comm) -supportedEngines = ['bp5', 'bp4'] -engineType = 'bp5' -if (len(sys.argv) > 1): +supportedEngines = ["bp5", "bp4"] +engineType = "bp5" +if len(sys.argv) > 1: engineType = sys.argv[1].lower() -if (engineType in supportedEngines): - if (rank == 0): - print('Using engine type:', engineType) +if engineType in supportedEngines: + if rank == 0: + print("Using engine type:", engineType) else: - sys.exit('specified engine does not exist') + sys.exit("specified engine does not exist") -dataFileName = 'test_' + engineType + '.bp' +dataFileName = "test_" + engineType + ".bp" def writeDataFile(): @@ -50,8 +50,7 @@ def writeDataFile(): for i in range(numSteps): bpFileWriter.BeginStep() - bpFileWriter.Put(ioArray, i * 10.0 + myArray / (rank + 1), - adios2.Mode.Sync) + bpFileWriter.Put(ioArray, i * 10.0 + myArray / (rank + 1), adios2.Mode.Sync) bpFileWriter.EndStep() bpFileWriter.Close() @@ -60,23 +59,25 @@ def writeDataFile(): def createQueryFile(): print(".. Writing query file to: ", queryFile) - file1 = open(queryFile, 'w') + file1 = open(queryFile, "w") queryContent = [ - "\n", "\n", - " \n" - " \n", - " \n", - " \n", - " \n", " \n", - " \n", " \n", "\n" + '\n', + "\n", + ' \n' ' \n', + ' \n', + ' \n', + ' \n', + " \n", + " \n", + " \n", + "\n", ] file1.writelines(queryContent) file1.close() def doAnalysis(reader, touched_blocks, varList): - print(" Step: ", reader.CurrentStep(), - " num touched blocks: ", len(touched_blocks)) + print(" Step: ", reader.CurrentStep(), " num touched blocks: ", len(touched_blocks)) values = [] data = {} @@ -84,7 +85,7 @@ def doAnalysis(reader, touched_blocks, varList): for var in varList: data[var] = [] - if (len(touched_blocks) > 0): + if len(touched_blocks) > 0: for n in touched_blocks: for var in varList: values = np.zeros(10, dtype=np.double) @@ -104,14 +105,14 @@ def queryDataFile(): print("Num steps: ", reader.Steps()) - while (reader.BeginStep() == adios2.StepStatus.OK): + while reader.BeginStep() == adios2.StepStatus.OK: # bp5 loads metadata after beginstep(), # therefore query has to be called per step w = adios2.Query(queryFile, reader) # assume only rank 0 wants to process result var = [queryIO.InquireVariable(targetVarName)] - if (rank == 0): + if rank == 0: touched_blocks = w.GetBlockIDs() doAnalysis(reader, touched_blocks, var) @@ -122,10 +123,12 @@ def queryDataFile(): def cleanUp(): import os import shutil + os.remove(queryFile) shutil.rmtree(dataFileName) print(" Cleanup generated files: ", queryFile, dataFileName) + # # actual setup: # @@ -134,7 +137,7 @@ def cleanUp(): writeDataFile() -if (0 == rank): +if 0 == rank: createQueryFile() queryDataFile() cleanUp() diff --git a/testing/adios2/bindings/python/adios2NPTypes.py b/testing/adios2/bindings/python/adios2NPTypes.py index d0cc81cf6f..d35f73e644 100644 --- a/testing/adios2/bindings/python/adios2NPTypes.py +++ b/testing/adios2/bindings/python/adios2NPTypes.py @@ -10,45 +10,70 @@ class SmallTestData: - def __init__(self): self.Nx = 10 self.Str = "Hello ADIOS2 Python" self.I8 = np.array([0, 1, -2, 3, -4, 5, -6, 7, -8, 9], dtype=np.int8) - self.I16 = np.array( - [512, 513, -510, 515, -508, 517, -506, 519, -504, 521], - dtype=np.int16) + self.I16 = np.array([512, 513, -510, 515, -508, 517, -506, 519, -504, 521], dtype=np.int16) self.I32 = np.array( - [131072, 131073, -131070, 131075, -131068, - 131077, -131066, 131079, -131064, 131081], - dtype=np.int32) + [131072, 131073, -131070, 131075, -131068, 131077, -131066, 131079, -131064, 131081], + dtype=np.int32, + ) self.I64 = np.array( - [8589934592, 8589934593, -8589934590, 8589934595, -8589934588, - 8589934597, -8589934586, 8589934599, -8589934584, 8589934601], - dtype=np.int64) + [ + 8589934592, + 8589934593, + -8589934590, + 8589934595, + -8589934588, + 8589934597, + -8589934586, + 8589934599, + -8589934584, + 8589934601, + ], + dtype=np.int64, + ) - self.U8 = np.array( - [128, 129, 130, 131, 132, 133, 134, 135, 136, 137], dtype=np.uint8) + self.U8 = np.array([128, 129, 130, 131, 132, 133, 134, 135, 136, 137], dtype=np.uint8) self.U16 = np.array( - [32768, 32769, 32770, 32771, 32772, 32773, 32774, 32775, 32776, - 32777], - dtype=np.uint16) + [32768, 32769, 32770, 32771, 32772, 32773, 32774, 32775, 32776, 32777], dtype=np.uint16 + ) self.U32 = np.array( - [2147483648, 2147483649, 2147483650, 2147483651, 2147483652, - 2147483653, 2147483654, 2147483655, 2147483656, 2147483657], - dtype=np.uint32) + [ + 2147483648, + 2147483649, + 2147483650, + 2147483651, + 2147483652, + 2147483653, + 2147483654, + 2147483655, + 2147483656, + 2147483657, + ], + dtype=np.uint32, + ) self.U64 = np.array( - [9223372036854775808, 9223372036854775809, 9223372036854775810, - 9223372036854775811, 9223372036854775812, 9223372036854775813, - 9223372036854775814, 9223372036854775815, 9223372036854775816, - 9223372036854775817], dtype=np.uint64) + [ + 9223372036854775808, + 9223372036854775809, + 9223372036854775810, + 9223372036854775811, + 9223372036854775812, + 9223372036854775813, + 9223372036854775814, + 9223372036854775815, + 9223372036854775816, + 9223372036854775817, + ], + dtype=np.uint64, + ) self.R32 = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32) - self.R64 = np.array([0, -1, -2, -3, -4, -5, -6, -7, -8, -9], - dtype=np.float64) + self.R64 = np.array([0, -1, -2, -3, -4, -5, -6, -7, -8, -9], dtype=np.float64) def update(self, rank, step, size): - self.I8 += 1 self.I16 += 1 self.I32 += 1 diff --git a/testing/adios2/python/CMakeLists.txt b/testing/adios2/python/CMakeLists.txt index a553327269..84ebb9b49d 100644 --- a/testing/adios2/python/CMakeLists.txt +++ b/testing/adios2/python/CMakeLists.txt @@ -32,4 +32,9 @@ if(ADIOS2_HAVE_MPI) if(ADIOS2_HAVE_ZFP) add_python_mpi_test(BPZfpHighLevelAPI) endif() + if(ADIOS2_HAVE_HDF5) + python_add_test(NAME Api.Python.BPWriteTypesHighLevelAPI_HDF5 SCRIPT TestBPWriteTypesHighLevelAPI_HDF5.py) + # MPI version currently fails in H5Fclose. + # add_python_mpi_test(BPWriteTypesHighLevelAPI_HDF5) + endif() endif() diff --git a/testing/adios2/python/TestBPWriteTypesHighLevelAPI.py b/testing/adios2/python/TestBPWriteTypesHighLevelAPI.py index e6da7abb6f..3b300fca55 100644 --- a/testing/adios2/python/TestBPWriteTypesHighLevelAPI.py +++ b/testing/adios2/python/TestBPWriteTypesHighLevelAPI.py @@ -19,7 +19,7 @@ size = comm.Get_size() # Test data -data = SmallTestData() +data = SmallTestData(rank) nx = data.Nx shape = [size * nx] @@ -33,6 +33,7 @@ s.write("rank", np.array(rank), shape=[LocalValueDim]) if rank == 0 and step.current_step() == 0: s.write("tag", "Testing ADIOS2 high-level API") + s.write("nx", data.Nx) s.write("gvarI8", np.array(data.i8[0])) s.write("gvarI16", np.array(data.i16[0])) s.write("gvarI32", np.array(data.i32[0])) @@ -43,8 +44,19 @@ s.write("gvarU64", np.array(data.u64[0])) s.write("gvarR32", np.array(data.r32[0])) s.write("gvarR64", np.array(data.r64[0])) - - # single value attributes + s.write("gvarC64", np.array(data.c64[0])) + i = data.int_list[0] + f = data.float_list[0] + c = data.complex_list[0] + print(f"type of i = {type(i)}, type of f = {type(f)}, type of c = {type(c)}") + s.write("an_int_value", i) + s.write("a_float_value", f) + s.write("a_complex_value", c) + s.write("an_int_list", data.int_list) + s.write("a_float_list", data.float_list) + s.write("a_complex_list", data.complex_list) + + # single value attributes with numpy variables s.write_attribute("attrStr", "Testing single string attribute") s.write_attribute("attrI8", np.array(data.i8[0])) s.write_attribute("attrI16", np.array(data.i16[0])) @@ -56,8 +68,21 @@ s.write_attribute("attrU64", np.array(data.u64[0])) s.write_attribute("attrR32", np.array(data.r32[0])) s.write_attribute("attrR64", np.array(data.r64[0])) - + s.write_attribute("attrC64", np.array(data.c64[0])) + + # single value attributes with Python variables + s.write_attribute("attrNx", data.Nx) + s.write_attribute("attr_int_value", i) + s.write_attribute("attr_float_value", f) + s.write_attribute("attr_complex_value", c) + + # array attributes with Python lists + s.write_attribute("attr_int_list", data.int_list) + s.write_attribute("attr_float_list", data.float_list) + s.write_attribute("attr_complex_list", data.complex_list) s.write_attribute("attrStrArray", ["string1", "string2", "string3"]) + + # array attributes with numpy arrays s.write_attribute("attrI8Array", data.i8) s.write_attribute("attrI16Array", data.i16) s.write_attribute("attrI32Array", data.i32) @@ -68,6 +93,7 @@ s.write_attribute("attrU64Array", data.u64) s.write_attribute("attrR32Array", data.r32) s.write_attribute("attrR64Array", data.r64) + s.write_attribute("attrC64Array", data.c64) s.write("steps", "Step:" + str(step.current_step())) s.write("varI8", data.i8, shape, start, count) @@ -80,8 +106,12 @@ s.write("varU64", data.u64, shape, start, count) s.write("varR32", data.r32, shape, start, count) s.write("varR64", data.r64, shape, start, count) + s.write("varC64", data.c64, shape, start, count) if rank == 0 and step.current_step() == 0: + # attribute assigned to variable + s.write_attribute("size", data.Nx, "varI8") + s.write_attribute("size", data.Nx, "varI16", "::") s.write_attribute("varattrStrArray", ["varattr1", "varattr2", "varattr3"], "steps") s.write_attribute("varattrI8Array", data.i8, "varI8") s.write_attribute("varattrI16Array", data.i16, "varI16") @@ -98,7 +128,7 @@ comm.Barrier() # Reader -data = SmallTestData() +data = SmallTestData(rank) with Stream("types_np.bp", "r", comm=comm) as fr: # file only @@ -116,8 +146,11 @@ # print("\t" + key + ": " + value) # print("\n") - if step == 0: + if rank == 0 and step == 0: inTag = fr_step.read("tag") + nx = fr_step.read("nx") + print(f"nx = {nx}") + assert nx == data.Nx inI8 = fr_step.read("gvarI8") inI16 = fr_step.read("gvarI16") inI32 = fr_step.read("gvarI32") @@ -165,6 +198,7 @@ # attributes inTag = fr_step.read_attribute("attrStr") + inNx = fr_step.read_attribute("attrNx") inI8 = fr_step.read_attribute("attrI8") inI16 = fr_step.read_attribute("attrI16") inI32 = fr_step.read_attribute("attrI32") @@ -179,6 +213,9 @@ if inTag[0] != "Testing single string attribute": raise ValueError("attr string read failed") + if inNx != data.Nx: + raise ValueError("attrNx read failed") + if inI8[0] != data.i8[0]: raise ValueError("attrI8 read failed") @@ -209,6 +246,37 @@ if inR64[0] != data.r64[0]: raise ValueError("attrR64 read failed") + in_an_int_value = fr_step.read("an_int_value") + print(f"an_int_value = {in_an_int_value} of type {type(in_an_int_value)}") + assert in_an_int_value == data.int_list[0] + + in_a_float_value = fr_step.read("a_float_value") + print(f"a_float_value = {in_a_float_value} of type {type(in_a_float_value)}") + assert in_a_float_value == data.float_list[0] + + inC64 = fr_step.read("gvarC64") + print(f"inC64 = {inC64} of type {type(inC64)}") + assert inC64 == data.c64[0] + + in_a_complex_value = fr_step.read("a_complex_value") + print(f"a_complex_value = {in_a_complex_value} of type {type(in_a_complex_value)}") + assert in_a_complex_value == data.complex_list[0] + + an_int_list = fr_step.read("an_int_list") + if not (an_int_list == data.int_list).all(): + raise ValueError("an_int_list array read failed") + print(f"an_int_list = {an_int_list} of type {type(an_int_list)}") + + a_float_list = fr_step.read("a_float_list") + if not (a_float_list == data.float_list).all(): + raise ValueError("a_float_list array read failed") + print(f"a_float_list = {a_float_list} of type {type(a_float_list)}") + + a_complex_list = fr_step.read("a_complex_list") + if not (a_complex_list == data.complex_list).all(): + raise ValueError("a_complex_list array read failed") + print(f"a_complex_list = {a_complex_list} of type {type(a_complex_list)}") + # Array attribute inTag = fr_step.read_attribute_string("attrStrArray") inI8 = fr_step.read_attribute("attrI8Array") @@ -225,36 +293,49 @@ if inTag != ["string1", "string2", "string3"]: raise ValueError("attrStrArray read failed") - if (inI8 == data.i8).all() is False: + if not (inI8 == data.i8).all(): raise ValueError("attrI8 array read failed") - if (inI16 == data.i16).all() is False: + if not (inI16 == data.i16).all(): raise ValueError("attrI16 array read failed") - if (inI32 == data.i32).all() is False: + if not (inI32 == data.i32).all(): raise ValueError("attrI32 array read failed") - if (inI64 == data.i64).all() is False: + if not (inI64 == data.i64).all(): raise ValueError("attrI64 array read failed") - if (inU8 == data.u8).all() is False: + if not (inU8 == data.u8).all(): raise ValueError("attrU8 array read failed") - if (inU16 == data.u16).all() is False: + if not (inU16 == data.u16).all(): raise ValueError("attrU16 array read failed") - if (inU32 == data.u32).all() is False: + if not (inU32 == data.u32).all(): raise ValueError("attrU32 array read failed") - if (inU64 == data.u64).all() is False: + if not (inU64 == data.u64).all(): raise ValueError("attrU64 array read failed") - if (inR32 == data.r32).all() is False: + if not (inR32 == data.r32).all(): raise ValueError("attrR32 array read failed") - if (inR64 == data.r64).all() is False: + if not (inR64 == data.r64).all(): raise ValueError("attrR64 array read failed") + # Array attributes (written as List) + in_attr_float_list = fr_step.read_attribute("attr_float_list") + in_attr_int_list = fr_step.read_attribute("attr_int_list") + + print(f"attr_float_list = {in_attr_float_list}") + print(f"attr_int_list = {in_attr_int_list}") + + if not (in_attr_float_list == np.array(data.float_list)).all(): + raise ValueError("attr_float_list array read failed") + + if not (in_attr_int_list == np.array(data.int_list)).all(): + raise ValueError("attr_int_list array read failed") + inTags = fr_step.read_attribute_string("varattrStrArray", "steps") inI8 = fr_step.read_attribute("varattrI8Array", "varI8") in16 = fr_step.read_attribute("varattrI16Array", "varI16") @@ -271,36 +352,71 @@ print(inTags) raise ValueError("var attrStrArray read failed") - if (inI8 == data.i8).all() is False: + if not (inI8 == data.i8).all(): raise ValueError("var attrI8 array read failed") - if (inI16 == data.i16).all() is False: + if not (inI16 == data.i16).all(): raise ValueError("var attrI16 array read failed") - if (inI32 == data.i32).all() is False: + if not (inI32 == data.i32).all(): raise ValueError("var attrI32 array read failed") - if (inI64 == data.i64).all() is False: + if not (inI64 == data.i64).all(): raise ValueError("var attrI64 array read failed") - if (inU8 == data.u8).all() is False: + if not (inU8 == data.u8).all(): raise ValueError("var attrU8 array read failed") - if (inU16 == data.u16).all() is False: + if not (inU16 == data.u16).all(): raise ValueError("var attrU16 array read failed") - if (inU32 == data.u32).all() is False: + if not (inU32 == data.u32).all(): raise ValueError("var attrU32 array read failed") - if (inU64 == data.u64).all() is False: + if not (inU64 == data.u64).all(): raise ValueError("var attrU64 array read failed") - if (inR32 == data.r32).all() is False: + if not (inR32 == data.r32).all(): raise ValueError("var attrR32 array read failed") - if (inR64 == data.r64).all() is False: + if not (inR64 == data.r64).all(): raise ValueError("var attrR64 array read failed") + # Attributes assigned to a variable + sizeI8 = fr_step.read_attribute("size", "varI8") + sizeI16 = fr_step.read_attribute("size", "varI16", "::") + + if sizeI8[0] != data.Nx: + raise ValueError("attribute varI8/size read failed") + + if sizeI16[0] != data.Nx: + raise ValueError("attribute varI16::size read failed") + + sizeI8 = fr_step.read_attribute("varI8/size") + sizeI16 = fr_step.read_attribute("varI16::size") + + if sizeI8[0] != data.Nx: + raise ValueError("attribute varI8/size read failed") + + if sizeI16[0] != data.Nx: + raise ValueError("attribute varI16::size read failed") + + step_attrs = fr_step.available_attributes() + # for name, info in step_attrs.items(): + # print(f"attribute {name} : {info}") + + step_attrs = fr_step.available_attributes("varI8") + # for name, info in step_attrs.items(): + # print(f"attribute {name} : {info}") + if not [*step_attrs] == ["size", "varattrI8Array"]: + raise ValueError("getting attributes of varI8 failed") + + step_attrs = fr_step.available_attributes("varI16", "::") + for name, info in step_attrs.items(): + print(f"attribute {name} : {info}") + if not [*step_attrs] == ["size"]: + raise ValueError("getting attributes of varI16 with separator :: failed") + stepStr = "Step:" + str(step) instepStr = fr_step.read("steps") @@ -309,7 +425,7 @@ indataRanks = fr_step.read("rank", [0], [size]) dataRanks = np.arange(0, size) - if (indataRanks == dataRanks).all() is False: + if not (indataRanks == dataRanks).all(): raise ValueError("Ranks read failed") indataI8 = fr_step.read("varI8", start, count) @@ -323,32 +439,32 @@ indataR32 = fr_step.read("varR32", start, count) indataR64 = fr_step.read("varR64", start, count) - if (indataI8 == data.i8).all() is False: + if not (indataI8 == data.i8).all(): raise ValueError("i8 array read failed") - if (indataI16 == data.i16).all() is False: + if not (indataI16 == data.i16).all(): raise ValueError("i16 array read failed") - if (indataI32 == data.i32).all() is False: + if not (indataI32 == data.i32).all(): raise ValueError("i32 array read failed") - if (indataI64 == data.i64).all() is False: + if not (indataI64 == data.i64).all(): raise ValueError("i64 array read failed") - if (indataU8 == data.u8).all() is False: + if not (indataU8 == data.u8).all(): raise ValueError("u8 array read failed") - if (indataU16 == data.u16).all() is False: + if not (indataU16 == data.u16).all(): raise ValueError("u16 array read failed") - if (indataU32 == data.u32).all() is False: + if not (indataU32 == data.u32).all(): raise ValueError("u32 array read failed") - if (indataU64 == data.u64).all() is False: + if not (indataU64 == data.u64).all(): raise ValueError("u64 array read failed") - if (indataR32 == data.r32).all() is False: + if not (indataR32 == data.r32).all(): raise ValueError("r32 array read failed") - if (indataR64 == data.r64).all() is False: + if not (indataR64 == data.r64).all(): raise ValueError("r64 array read failed") diff --git a/testing/adios2/python/TestBPWriteTypesHighLevelAPILocal.py b/testing/adios2/python/TestBPWriteTypesHighLevelAPILocal.py index 6a719b3ba9..d4eafcb259 100644 --- a/testing/adios2/python/TestBPWriteTypesHighLevelAPILocal.py +++ b/testing/adios2/python/TestBPWriteTypesHighLevelAPILocal.py @@ -14,7 +14,7 @@ def check_array(np1, np2, hint): - if (np1 == np2).all() is False: + if not (np1 == np2).all(): print("InData: " + str(np1)) print("Data: " + str(np2)) raise ValueError("Array read failed " + str(hint)) @@ -25,13 +25,14 @@ def check_array(np1, np2, hint): size = comm.Get_size() # Test data -data = SmallTestData() +data = SmallTestData(rank) nx = data.Nx shape = [] start = [] count = [nx] + # Writer with Stream("types_np_local.bp", "w", comm=comm) as s: for step in s.steps(5): @@ -46,35 +47,38 @@ def check_array(np1, np2, hint): s.write("varU64", data.u64, shape, start, count) s.write("varR32", data.r32, shape, start, count) s.write("varR64", data.r64, shape, start, count) - + s.write("an_int_list", data.int_list, shape, start, count) + s.write("a_float_list", data.float_list, shape, start, count) + s.write("a_complex_list", data.complex_list, shape, start, count) # Reader -data = SmallTestData() +data = SmallTestData(rank) with Stream("types_np_local.bp", "r", comm=comm) as s: for fr_step in s.steps(): step = fr_step.current_step() + data.update(rank, step, size) + indataI8 = fr_step.read("varI8", block_id=rank) + indataI16 = fr_step.read("varI16", block_id=rank) + indataI32 = fr_step.read("varI32", block_id=rank) + indataI64 = fr_step.read("varI64", block_id=rank) + indataU8 = fr_step.read("varU8", block_id=rank) + indataU16 = fr_step.read("varU16", block_id=rank) + indataU32 = fr_step.read("varU32", block_id=rank) + indataU64 = fr_step.read("varU64", block_id=rank) + indataR32 = fr_step.read("varR32", block_id=rank) + indataR64 = fr_step.read("varR64", block_id=rank) - for b in range(0, size): - data.update(b, step, size) + in_int_list = fr_step.read("an_int_list", block_id=rank) - indataI8 = fr_step.read("varI8", b) - indataI16 = fr_step.read("varI16", b) - indataI32 = fr_step.read("varI32", b) - indataI64 = fr_step.read("varI64", b) - indataU8 = fr_step.read("varU8", b) - indataU16 = fr_step.read("varU16", b) - indataU32 = fr_step.read("varU32", b) - indataU64 = fr_step.read("varU64", b) - indataR32 = fr_step.read("varR32", b) - indataR64 = fr_step.read("varR64", b) + print(f"step {step} rank {rank} I16={indataI16} data.I16 = {data.i16}", flush=True) - check_array(indataI8, data.i8, "i8") - check_array(indataI16, data.i16, "i16") - check_array(indataI32, data.i32, "i32") - check_array(indataI64, data.i64, "i64") - check_array(indataU8, data.u8, "u8") - check_array(indataU16, data.u16, "u16") - check_array(indataU32, data.u32, "u32") - check_array(indataU64, data.u64, "u64") - check_array(indataR32, data.r32, "r32") - check_array(indataR64, data.r64, "r64") + check_array(indataI8, data.i8, "i8") + check_array(indataI16, data.i16, "i16") + check_array(indataI32, data.i32, "i32") + check_array(indataI64, data.i64, "i64") + check_array(indataU8, data.u8, "u8") + check_array(indataU16, data.u16, "u16") + check_array(indataU32, data.u32, "u32") + check_array(indataU64, data.u64, "u64") + check_array(indataR32, data.r32, "r32") + check_array(indataR64, data.r64, "r64") diff --git a/testing/adios2/python/TestBPWriteTypesHighLevelAPI_HDF5.py b/testing/adios2/python/TestBPWriteTypesHighLevelAPI_HDF5.py index 00e72110a2..d95c160bc9 100644 --- a/testing/adios2/python/TestBPWriteTypesHighLevelAPI_HDF5.py +++ b/testing/adios2/python/TestBPWriteTypesHighLevelAPI_HDF5.py @@ -10,24 +10,26 @@ # Author: William F Godoy godoywf@ornl.gov from adios2NPTypes import SmallTestData -from mpi4py import MPI import numpy as np -import adios2.bindings as adios2 +from adios2 import Adios, Stream -comm = MPI.COMM_WORLD -rank = comm.Get_rank() -size = comm.Get_size() +rank = 0 +size = 1 # Test data -data = SmallTestData() +data = SmallTestData(rank) nx = data.Nx shape = [size * nx] start = [rank * nx] count = [nx] +adios = Adios() +io = adios.declare_io("writeh5") +io.set_engine("HDF5") + # Writer -with adios2.open("types_np.h5", "w", comm, "HDF5") as fw: +with Stream(io, "types_np.h5", "w") as fw: for i in range(0, 5): data.update(rank, i, size) @@ -97,12 +99,13 @@ fw.end_step() -comm.Barrier() - # Reader -data = SmallTestData() +data = SmallTestData(rank) + +io = adios.declare_io("readh5") +io.set_engine("HDF5") -with adios2.open("types_np.h5", "r", comm, "HDF5") as fr: +with Stream("types_np.h5", "r") as fr: for fr_step in fr: step = fr_step.current_step() data.update(rank, step, size) @@ -115,8 +118,8 @@ # print("\t" + key + ": " + value) # print("\n") - if step == 0: - inTag = fr_step.read_string("tag") + if rank == 0 and step == 0: + inTag = fr_step.read("tag") inI8 = fr_step.read("gvarI8") inI16 = fr_step.read("gvarI16") inI32 = fr_step.read("gvarI32") @@ -128,7 +131,7 @@ inR32 = fr_step.read("gvarR32") inR64 = fr_step.read("gvarR64") - if inTag[0] != "Testing ADIOS2 high-level API": + if inTag != "Testing ADIOS2 high-level API": print("InTag: " + str(inTag)) raise ValueError("tag variable read failed") @@ -163,7 +166,7 @@ raise ValueError("gvarR64 read failed") # attributes - inTag = fr_step.read_attribute_string("attrStr") + inTag = fr_step.read_attribute("attrStr") inI8 = fr_step.read_attribute("attrI8") inI16 = fr_step.read_attribute("attrI16") inI32 = fr_step.read_attribute("attrI32") @@ -302,8 +305,8 @@ stepStr = "Step:" + str(step) - instepStr = fr_step.read_string("steps") - if instepStr[0] != stepStr: + instepStr = fr_step.read("steps") + if instepStr != stepStr: raise ValueError("steps variable read failed: " + instepStr + " " + stepStr) indataI8 = fr_step.read("varI8", start, count) diff --git a/testing/adios2/python/TestEngine.py b/testing/adios2/python/TestEngine.py index 86ea86c670..5e48536e7a 100644 --- a/testing/adios2/python/TestEngine.py +++ b/testing/adios2/python/TestEngine.py @@ -17,7 +17,7 @@ def test_put(self): adios = Adios() with adios.declare_io("BPWriter") as io: pressure = io.define_variable("pressure") - temps = io.define_variable("temps", np.empty([4], dtype=np.int64)) + temps = io.define_variable("temps", np.empty([1], dtype=np.int64)) with io.open("pythontestengine.bp", bindings.Mode.Write) as engine: engine.put(pressure, "35PSI") temps_measures = np.array([35, 40, 30, 45], dtype=np.int64) @@ -29,7 +29,7 @@ def test_get(self): pressure = io.define_variable("pressure") temps = io.define_variable( name="temps", - content=np.empty([4], dtype=np.int64), + content=np.empty([1], dtype=np.int64), start=[0], shape=[4], count=[4], diff --git a/testing/adios2/python/adios2NPTypes.py b/testing/adios2/python/adios2NPTypes.py index df6ca200b7..711dd1a74a 100644 --- a/testing/adios2/python/adios2NPTypes.py +++ b/testing/adios2/python/adios2NPTypes.py @@ -7,10 +7,11 @@ # Author: William F Godoy godoywf@ornl.gov import numpy as np +import cmath class SmallTestData: - def __init__(self): + def __init__(self, rank=0): self.Nx = 10 self.Str = "Hello ADIOS2 Python" self.i8 = np.array([0, 1, -2, 3, -4, 5, -6, 7, -8, 9], dtype=np.int8) @@ -73,16 +74,64 @@ def __init__(self): self.r32 = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32) self.r64 = np.array([0, -1, -2, -3, -4, -5, -6, -7, -8, -9], dtype=np.float64) + self.c64 = np.array( + [ + complex(0, 1), + complex(2, 3), + complex(4, 5), + complex(6, 7), + complex(8, 9), + complex(0, -1), + complex(-2, -3), + complex(-4, -5), + complex(-6, -7), + complex(-8, -9), + ], + dtype=np.complex128, + ) + + self.int_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + self.float_list = [0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9] + self.complex_list = [ + complex(0.0, rank), + complex(1.0, rank), + complex(2.0, rank), + complex(3.0, rank), + complex(4.0, rank), + complex(5.0, rank), + complex(6.0, rank), + complex(7.0, rank), + complex(8.0, rank), + complex(9.0, rank), + ] + + self.i8 += rank + self.i16 += rank + self.i32 += rank + self.i64 += rank + self.u8 += rank + self.u16 += rank + self.u32 += rank + self.u64 += rank + self.r32 += rank + self.r64 += rank + self.c64 += complex(rank, rank) + self.int_list = [i + rank for i in self.int_list] + self.float_list = [f + rank for f in self.float_list] + self.complex_list = [c + complex(rank, 0) for c in self.complex_list] + def update(self, rank, step, size): self.i8 += 1 self.i16 += 1 self.i32 += 1 self.i64 += 1 - self.u8 += 1 self.u16 += 1 self.u32 += 1 self.u64 += 1 - - self.r32 += 1 - self.r64 += 1 + self.r32 += 1.0 + self.r64 += 1.0 + self.c64 += complex(1.0, 1.0) + self.int_list = [i + 1 for i in self.int_list] + self.float_list = [i + 1.0 for i in self.float_list] + self.complex_list = [i + complex(1, 0) for i in self.complex_list] diff --git a/thirdparty/EVPath/EVPath/CMakeLists.txt b/thirdparty/EVPath/EVPath/CMakeLists.txt index 003f31325f..132c650619 100644 --- a/thirdparty/EVPath/EVPath/CMakeLists.txt +++ b/thirdparty/EVPath/EVPath/CMakeLists.txt @@ -376,7 +376,7 @@ if (MSVC) set(EVPATH_USE_ZPL_ENET FALSE) endif() if(NOT (DEFINED EVPATH_USE_ZPL_ENET)) - option(EVPATH_USE_ZPL_ENET "Build the enet transport" "ON") + option(EVPATH_USE_ZPL_ENET "Build the enet transport" "OFF") endif() if(EVPATH_USE_ZPL_ENET) set(RUN_ZPL_ENET_TESTS TRUE) diff --git a/thirdparty/EVPath/EVPath/cmenet.c b/thirdparty/EVPath/EVPath/cmenet.c index eeac56f3e5..b33989de52 100644 --- a/thirdparty/EVPath/EVPath/cmenet.c +++ b/thirdparty/EVPath/EVPath/cmenet.c @@ -1414,7 +1414,7 @@ int err; * NT Sux. */ -int +static int pipe(filedes) SOCKET filedes[2]; { diff --git a/thirdparty/EVPath/EVPath/cmepoll.c b/thirdparty/EVPath/EVPath/cmepoll.c index b28fca2790..84d95470c9 100644 --- a/thirdparty/EVPath/EVPath/cmepoll.c +++ b/thirdparty/EVPath/EVPath/cmepoll.c @@ -114,10 +114,7 @@ static char*WSAerror_str(int err); #endif static void -init_select_data(svc, sdp, cm) -CMtrans_services svc; -select_data_ptr *sdp; -CManager cm; +init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) { select_data_ptr sd = malloc(sizeof(struct select_data)); *sdp = sd; @@ -157,9 +154,7 @@ typedef struct _periodic_task { } task_handle_s; static void -free_epoll_data(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +free_epoll_data(CMtrans_services svc, select_data_ptr *sdp) { periodic_task_handle tasks; select_data_ptr sd = *sdp; @@ -184,10 +179,7 @@ select_data_ptr *sdp; ((tvp)->tv_usec cmp (uvp)->tv_usec)))) static void -set_soonest_timeout(timeout, task_list, now) -struct timeval *timeout; -periodic_task_handle task_list; -struct timeval now; +set_soonest_timeout(struct timeval *timeout, periodic_task_handle task_list, struct timeval now) { struct timeval this_delay; if (task_list == NULL) return; @@ -210,10 +202,7 @@ struct timeval now; } static void -increment_time(time, increment_sec, increment_usec) -struct timeval *time; -int increment_sec; -int increment_usec; +increment_time(struct timeval *time, int increment_sec, int increment_usec) { time->tv_usec += increment_usec; time->tv_sec += increment_sec; @@ -227,11 +216,7 @@ static void shutdown_wake_mechanism(select_data_ptr sd); static void -socket_select(svc, sd, timeout_sec, timeout_usec) -CMtrans_services svc; -select_data_ptr sd; -int timeout_sec; -int timeout_usec; +socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int timeout_usec) { int i, res; int fd; @@ -475,13 +460,7 @@ int timeout_usec; } extern void -libcmepoll_LTX_add_select(svc, sdp, fd, func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_select(CMtrans_services svc, select_data_ptr *sdp, int fd, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); struct epoll_event ep_event; @@ -540,13 +519,7 @@ void *arg2; } extern void -libcmepoll_LTX_write_select(svc, sdp, fd, func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_write_select(CMtrans_services svc, select_data_ptr *sdp, int fd, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); struct epoll_event ep_event; @@ -616,15 +589,7 @@ void *arg2; } extern periodic_task_handle -libcmepoll_LTX_add_periodic(svc, sdp, interval_sec, interval_usec, - func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int interval_sec; -int interval_usec; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_periodic(CMtrans_services svc, select_data_ptr *sdp, int interval_sec, int interval_usec, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); periodic_task_handle handle = malloc(sizeof(struct _periodic_task)); @@ -671,15 +636,7 @@ void *arg2; extern periodic_task_handle -libcmepoll_LTX_add_delayed_task(svc, sdp, delay_sec, delay_usec, - func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int delay_sec; -int delay_usec; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_delayed_task(CMtrans_services svc, select_data_ptr *sdp, int delay_sec, int delay_usec, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); periodic_task_handle handle = malloc(sizeof(struct _periodic_task)); @@ -725,9 +682,7 @@ void *arg2; } static int -remove_periodic_task(sd, handle) -select_data_ptr sd; -periodic_task_handle handle; +remove_periodic_task(select_data_ptr sd, periodic_task_handle handle) { periodic_task_handle list, last = NULL; list = sd->periodic_task_list; @@ -765,10 +720,7 @@ periodic_task_handle handle; extern void -libcmepoll_LTX_remove_periodic(svc, sdp, handle) -CMtrans_services svc; -select_data_ptr *sdp; -periodic_task_handle handle; +libcmepoll_LTX_remove_periodic(CMtrans_services svc, select_data_ptr *sdp, periodic_task_handle handle) { select_data_ptr sd = *((select_data_ptr *)sdp); if (sd == NULL) return; @@ -778,10 +730,7 @@ periodic_task_handle handle; } extern void -libcmepoll_LTX_remove_select(svc, sdp, fd) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; +libcmepoll_LTX_remove_select(CMtrans_services svc, select_data_ptr *sdp, int fd) { select_data_ptr sd = *((select_data_ptr *)sdp); @@ -812,8 +761,7 @@ int fd; } static void -shutdown_wake_mechanism(sd) -select_data_ptr sd; +shutdown_wake_mechanism(select_data_ptr sd) { if (sd->wake_read_fd == -1) return; close(sd->wake_read_fd); @@ -821,9 +769,7 @@ select_data_ptr sd; sd->wake_read_fd = sd->wake_write_fd = -1; } -static void read_wake_fd(fd_as_ptr, junk) -void *fd_as_ptr; -void *junk; +static void read_wake_fd(void *fd_as_ptr, void *junk) { char buffer; int fd = (int) (long)fd_as_ptr; @@ -838,8 +784,7 @@ void *junk; #ifdef HAVE_WINDOWS_H static char* -WSAerror_str(err) -int err; +WSAerror_str(int err) { switch(err) { case WSAEINTR: return "WSAEINTR"; @@ -900,9 +845,8 @@ int err; * NT Sux. */ -int -pipe(filedes) -int filedes[2]; +static int +pipe(int filedes[2]) { int length; @@ -990,9 +934,7 @@ int filedes[2]; #endif static void -setup_wake_mechanism(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +setup_wake_mechanism(CMtrans_services svc, select_data_ptr *sdp) { int filedes[2]; @@ -1015,9 +957,7 @@ select_data_ptr *sdp; } extern void -libcmepoll_LTX_wake_function(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +libcmepoll_LTX_wake_function(CMtrans_services svc, select_data_ptr *sdp) { if (*sdp != NULL) { wake_server_thread(*sdp); @@ -1025,8 +965,7 @@ select_data_ptr *sdp; } static void -wake_server_thread(sd) -select_data_ptr sd; +wake_server_thread(select_data_ptr sd) { static char buffer = 'W'; /* doesn't matter what we write */ if (sd->wake_write_fd != -1) { @@ -1041,9 +980,7 @@ select_data_ptr sd; } extern void -libcmepoll_LTX_blocking_function(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_blocking_function(CMtrans_services svc, void *client_data) { select_data_ptr sd = *((select_data_ptr *)client_data); if (sd == NULL) { @@ -1058,9 +995,7 @@ void *client_data; } extern void -libcmepoll_LTX_polling_function(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_polling_function(CMtrans_services svc, void *client_data) { select_data_ptr sd = *((select_data_ptr *)client_data); if (sd == NULL) { @@ -1075,10 +1010,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_initialize(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_initialize(CMtrans_services svc, CManager cm, void *client_data) { if (*((select_data_ptr *)client_data) == NULL) { init_select_data(svc, (select_data_ptr*)client_data, cm); @@ -1086,10 +1018,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_shutdown(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_shutdown(CMtrans_services svc, CManager cm, void *client_data) { select_data_ptr *sdp = client_data; select_data_ptr sd = *sdp; @@ -1103,10 +1032,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_free(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_free(CMtrans_services svc, CManager cm, void *client_data) { select_data_ptr *sdp = client_data; select_data_ptr sd = *sdp; @@ -1119,9 +1045,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_stop(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_select_stop(CMtrans_services svc, void *client_data) { if (*((select_data_ptr *)client_data) != NULL) { (*((select_data_ptr*)client_data))->closed = 1; diff --git a/thirdparty/EVPath/EVPath/cmmulticast.c b/thirdparty/EVPath/EVPath/cmmulticast.c index 03acd641e7..3d0e1f0897 100644 --- a/thirdparty/EVPath/EVPath/cmmulticast.c +++ b/thirdparty/EVPath/EVPath/cmmulticast.c @@ -449,7 +449,7 @@ libcmmulticast_LTX_writev_func(CMtrans_services svc, mcast_conn_data_ptr mcd, st } #ifdef HAVE_WINDOWS_H -int socket_global_init = 0; +static int socket_global_init = 0; /* Winsock init stuff, ask for ver 1.1 */ static WORD wVersionRequested = MAKEWORD(1, 1); static WSADATA wsaData; diff --git a/thirdparty/EVPath/EVPath/cmselect.c b/thirdparty/EVPath/EVPath/cmselect.c index baf9409df6..ab0ad46a19 100644 --- a/thirdparty/EVPath/EVPath/cmselect.c +++ b/thirdparty/EVPath/EVPath/cmselect.c @@ -879,7 +879,7 @@ int err; * NT Sux. */ -int +static int pipe(SOCKET *filedes) { diff --git a/thirdparty/EVPath/EVPath/cmsockets.c b/thirdparty/EVPath/EVPath/cmsockets.c index a4bfb79688..5a70aded91 100644 --- a/thirdparty/EVPath/EVPath/cmsockets.c +++ b/thirdparty/EVPath/EVPath/cmsockets.c @@ -1135,7 +1135,7 @@ libcmsockets_LTX_NBwritev_func(CMtrans_services svc, socket_conn_data_ptr scd, v return init_bytes - left; } -int socket_global_init = 0; +static int socket_global_init = 0; #ifdef HAVE_WINDOWS_H /* Winsock init stuff, ask for ver 2.2 */ diff --git a/thirdparty/EVPath/EVPath/cmudp.c b/thirdparty/EVPath/EVPath/cmudp.c index d865034dde..4c6815f2ad 100644 --- a/thirdparty/EVPath/EVPath/cmudp.c +++ b/thirdparty/EVPath/EVPath/cmudp.c @@ -646,7 +646,7 @@ libcmudp_LTX_writev_func(CMtrans_services svc, udp_conn_data_ptr ucd, struct iov } #ifdef HAVE_WINDOWS_H -int socket_global_init = 0; +static int socket_global_init = 0; /* Winsock init stuff, ask for ver 1.1 */ static WORD wVersionRequested = MAKEWORD(1, 1); static WSADATA wsaData; diff --git a/thirdparty/EVPath/EVPath/dfg_tests/auto_tree_test.c b/thirdparty/EVPath/EVPath/dfg_tests/auto_tree_test.c index d4b1d781b6..97705efd4b 100644 --- a/thirdparty/EVPath/EVPath/dfg_tests/auto_tree_test.c +++ b/thirdparty/EVPath/EVPath/dfg_tests/auto_tree_test.c @@ -5,6 +5,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include #include "cod.h" @@ -71,6 +72,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/thirdparty/EVPath/EVPath/dfg_tests/fail_chain_test.c b/thirdparty/EVPath/EVPath/dfg_tests/fail_chain_test.c index a3673e6db4..e68cae7962 100755 --- a/thirdparty/EVPath/EVPath/dfg_tests/fail_chain_test.c +++ b/thirdparty/EVPath/EVPath/dfg_tests/fail_chain_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "evpath.h" #include "ev_dfg.h" #include "test_support.h" @@ -140,6 +141,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/thirdparty/EVPath/EVPath/dfg_tests/self_reconfig_test.c b/thirdparty/EVPath/EVPath/dfg_tests/self_reconfig_test.c index 4970d8d050..6484c79c2f 100644 --- a/thirdparty/EVPath/EVPath/dfg_tests/self_reconfig_test.c +++ b/thirdparty/EVPath/EVPath/dfg_tests/self_reconfig_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "evpath.h" #include "ev_dfg.h" #include "test_support.h" @@ -168,6 +169,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/thirdparty/EVPath/EVPath/dfg_tests/tree_test.c b/thirdparty/EVPath/EVPath/dfg_tests/tree_test.c index d157647986..5770de6eb4 100644 --- a/thirdparty/EVPath/EVPath/dfg_tests/tree_test.c +++ b/thirdparty/EVPath/EVPath/dfg_tests/tree_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "ev_dfg.h" #include "test_support.h" @@ -56,6 +57,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(300); #endif if (argc == 1) { diff --git a/thirdparty/EVPath/EVPath/ev_dfg.c b/thirdparty/EVPath/EVPath/ev_dfg.c index 3493e0a431..3720d401f8 100644 --- a/thirdparty/EVPath/EVPath/ev_dfg.c +++ b/thirdparty/EVPath/EVPath/ev_dfg.c @@ -1583,13 +1583,14 @@ INT_EVdfg_create(EVmaster master) extern char *INT_EVmaster_get_contact_list(EVmaster master) { attr_list contact_list = NULL; - atom_t CM_TRANSPORT = attr_atom_from_string("CM_TRANSPORT"); - atom_t CM_ENET_CONN_TIMEOUT = attr_atom_from_string("CM_ENET_CONN_TIMEOUT"); CManager cm = master->cm; char *tmp = NULL; /* use enet transport if available */ #if defined(ENET_FOUND) || defined(ZPL_ENET_AVAILABLE) + atom_t CM_ENET_CONN_TIMEOUT = attr_atom_from_string("CM_ENET_CONN_TIMEOUT"); + atom_t CM_TRANSPORT = attr_atom_from_string("CM_TRANSPORT"); + (void) CM_TRANSPORT; attr_list listen_list = create_attr_list(); #if defined(ENET_FOUND) add_string_attr(listen_list, CM_TRANSPORT, strdup("enet")); diff --git a/thirdparty/EVPath/EVPath/evp.c b/thirdparty/EVPath/EVPath/evp.c index f72ddb0cf8..d38ae3cc7c 100644 --- a/thirdparty/EVPath/EVPath/evp.c +++ b/thirdparty/EVPath/EVPath/evp.c @@ -3700,7 +3700,7 @@ INT_EVextract_stone_events(CManager cm, EVstone stone_id) stone_type stone; EVevent_list list = malloc(sizeof(list[0])); - list[0].length = -1; + list[0].length = (size_t)-1; stone = stone_struct(evp, stone_id); if (!stone) return NULL; list = extract_events_from_queue(cm, stone->queue, list); @@ -3764,7 +3764,7 @@ extract_events_from_queue(CManager cm, queue_ptr que, EVevent_list list) first = que->queue_head; last = que->queue_tail; - while (list[num_of_elements].length != -1) num_of_elements++; + while (list[num_of_elements].length != (size_t)-1) num_of_elements++; while(first != NULL && last != NULL) { list = (EVevent_list) realloc (list, (num_of_elements + 2) * sizeof(list[0])); current_entry = &list[num_of_elements]; @@ -3779,7 +3779,7 @@ extract_events_from_queue(CManager cm, queue_ptr que, EVevent_list list) num_of_elements++; first = first->next; } - list[num_of_elements].length = -1; + list[num_of_elements].length = (size_t)-1; return list; } diff --git a/thirdparty/EVPath/EVPath/mtests/cmconn.c b/thirdparty/EVPath/EVPath/mtests/cmconn.c index a2a3cafdd3..6b723b4fda 100644 --- a/thirdparty/EVPath/EVPath/mtests/cmconn.c +++ b/thirdparty/EVPath/EVPath/mtests/cmconn.c @@ -26,9 +26,8 @@ #include #endif #include "evpath.h" -#ifdef HAVE_SYS_WAIT_H #include -#endif + #ifdef _MSC_VER #define drand48() (((double)rand())/((double)RAND_MAX)) #define lrand48() rand() diff --git a/thirdparty/EVPath/EVPath/response.c b/thirdparty/EVPath/EVPath/response.c index fae5c44294..fad8f71cac 100644 --- a/thirdparty/EVPath/EVPath/response.c +++ b/thirdparty/EVPath/EVPath/response.c @@ -1974,7 +1974,7 @@ extern sm_ref cod_build_param_node(const char *id, sm_ref typ, int param_num); extern void cod_add_decl_to_parse_context(const char *name, sm_ref item, cod_parse_context context); -extern FFS_DECLSPEC void +extern void cod_add_param(const char *id, const char *typ, int param_num, cod_parse_context context); diff --git a/thirdparty/EVPath/EVPath/tests/extract_test.c b/thirdparty/EVPath/EVPath/tests/extract_test.c index 5ef1816aed..90247c7abd 100644 --- a/thirdparty/EVPath/EVPath/tests/extract_test.c +++ b/thirdparty/EVPath/EVPath/tests/extract_test.c @@ -321,7 +321,7 @@ main(int argc, char **argv) EVdrain_stone(cm, term1); events = EVextract_stone_events(cm, term1); count = 0; - while (events && (events[count].length != -1)) { + while (events && (events[count].length != (size_t)-1)) { EVsubmit_encoded(cm, term0, events[count].buffer, events[count].length, attrs); count++; } diff --git a/thirdparty/dill/dill/CMakeLists.txt b/thirdparty/dill/dill/CMakeLists.txt index b90f757087..0ac720b7fd 100644 --- a/thirdparty/dill/dill/CMakeLists.txt +++ b/thirdparty/dill/dill/CMakeLists.txt @@ -117,6 +117,9 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "i.86|x86_64|AMD64") if(NOT (CMAKE_SIZEOF_VOID_P EQUAL SIZEOF_LONG)) set(BASE_OPS_ARG "-msvc_long") endif() + if(BUILD_SHARED_LIBS) + set(BASE_OPS_ARG "${BASE_OPS_ARG} -build_shared") + endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.5.*") set(NATIVE_ARCH arm5) set(HOST_ARM5 1) @@ -281,6 +284,8 @@ add_custom_command( DEPENDS base.ops ) +message (STATUS "base.ops argument is ${BASE_OPS_ARG}") + option(DILL_MULTI_TARGET "Build all available target architectures" OFF) if(DILL_MULTI_TARGET) diff --git a/thirdparty/dill/dill/base.ops b/thirdparty/dill/dill/base.ops index cd7e3bf3c0..003b5b5138 100755 --- a/thirdparty/dill/dill/base.ops +++ b/thirdparty/dill/dill/base.ops @@ -6,9 +6,12 @@ $MSVC_LONG = 0; while ($_ = $ARGV[0]) { shift; last if /^--$/; - if (/^-msvc_long/) {$MSVC_LONG = 1;} + if (/-msvc_long/) {$MSVC_LONG = 1;} + if (/-build_shared/) {$BUILD_SHARED = 1;} } +print "BUILD_SHARED is $BUILD_SHARED\n"; + sub upperc { local($_) = pop(@_); tr/[a-z]/[A-Z]/; @@ -65,7 +68,11 @@ print HOUT "#define dill_jalp(s, return_addr_reg, target) (s->j->jal)(s, return_ print HOUT "#define dill_special(s, type, param) if (s->j->special) (s->j->special)(s, type, param)\n"; print HOUT "#if defined(_MSC_VER) && !defined(DILL_SRC)\n"; -print HOUT "#define DILL_DECLSPEC __declspec(dllimport)\n"; +if ($BUILD_SHARED) { + print HOUT "#define DILL_DECLSPEC __declspec(dllimport)\n"; +} else { + print HOUT "#define DILL_DECLSPEC\n"; +} print HOUT "#else\n"; print HOUT "#define DILL_DECLSPEC\n"; print HOUT "#endif\n"; diff --git a/thirdparty/ffs/ffs/.github/workflows/build-and-test.yml b/thirdparty/ffs/ffs/.github/workflows/build-and-test.yml index 0b9926ae9e..6614bcfe79 100644 --- a/thirdparty/ffs/ffs/.github/workflows/build-and-test.yml +++ b/thirdparty/ffs/ffs/.github/workflows/build-and-test.yml @@ -88,12 +88,15 @@ jobs: jobname: [ windows2019-vs2019-clang, windows2022-vs2022-msvc, + windows2022-vs2022-msvc-static, macos-clang ] include: - jobname: windows2019-vs2019-clang vm: windows-2019 - jobname: windows2022-vs2022-msvc vm: windows-2022 + - jobname: windows2022-vs2022-msvc-static + vm: windows-2022 - jobname: macos-clang vm: macos-latest diff --git a/thirdparty/ffs/ffs/CMakeLists.txt b/thirdparty/ffs/ffs/CMakeLists.txt index 7d8589f95e..c9f516988d 100644 --- a/thirdparty/ffs/ffs/CMakeLists.txt +++ b/thirdparty/ffs/ffs/CMakeLists.txt @@ -186,6 +186,10 @@ add_custom_command( add_custom_target(docs ALL DEPENDS "cod_node.c") +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET_SOURCE_FILES_PROPERTIES(cod.tab.c PROPERTIES COMPILE_FLAGS -Wno-unused-function) +endif() + add_custom_target(generated DEPENDS cod_node.c ${BISON_CODParser_OUTPUT_SOURCE}) list(APPEND COD_MASTER_SRC_LIST diff --git a/thirdparty/ffs/ffs/cod/cg.c b/thirdparty/ffs/ffs/cod/cg.c index 1b41d8d3af..e4642c9edc 100644 --- a/thirdparty/ffs/ffs/cod/cg.c +++ b/thirdparty/ffs/ffs/cod/cg.c @@ -148,6 +148,7 @@ cg_required_align(dill_stream s, sm_ref node) required_align = dill_type_align(s, DILL_P); break; default: + required_align = 0; //silence warning assert(0); } return required_align; @@ -1750,6 +1751,7 @@ execute_operator_cg(dill_stream s, operator_t op, int op_type, dill_reg result, } else if (typ->node_type == cod_array_type_decl) { size = typ->node.array_type_decl.cg_element_size; } else { + size = 1; // avoid warning assert(0); } } else if ((ptr->node_type == cod_operator) && (ptr->node.operator.op == op_address)) { @@ -1758,6 +1760,7 @@ execute_operator_cg(dill_stream s, operator_t op, int op_type, dill_reg result, if (cod_expr_is_string(ptr)) { size = 1; } else { + size = 1; // silence warning assert(FALSE); } } @@ -1898,6 +1901,7 @@ execute_operator_cg(dill_stream s, operator_t op, int op_type, dill_reg result, if (cod_expr_is_string(ptr)) { size = 1; } else { + size = 1; // avoid warning assert(FALSE); } } diff --git a/thirdparty/ffs/ffs/cod/cod.h b/thirdparty/ffs/ffs/cod/cod.h index 0a866ea8e8..41a611aceb 100644 --- a/thirdparty/ffs/ffs/cod/cod.h +++ b/thirdparty/ffs/ffs/cod/cod.h @@ -6,14 +6,6 @@ extern "C" { #endif -#ifndef FFS_DECL_SPEC -#if defined(_MSC_VER) && !defined(FFS_SRC) -#define FFS_DECLSPEC __declspec(dllimport) -#else -#define FFS_DECLSPEC -#endif -#endif - #include /*! @@ -112,7 +104,7 @@ typedef cod_extern_entry *cod_extern_list; * \return Will return a new initialized cod_parse_context unless there is * no available memory. */ -extern FFS_DECLSPEC cod_parse_context new_cod_parse_context(void); +extern cod_parse_context new_cod_parse_context(void); /*! * Free a handle to an cod_parse_context. @@ -121,7 +113,7 @@ extern FFS_DECLSPEC cod_parse_context new_cod_parse_context(void); * Calling this routine frees all memory associated with the parse context, * but not that of code that has been generated from this context. */ -extern FFS_DECLSPEC void cod_free_parse_context(cod_parse_context context); +extern void cod_free_parse_context(cod_parse_context context); /*! * Associate a set of "name, external address" pairs with a parse context @@ -135,7 +127,7 @@ extern FFS_DECLSPEC void cod_free_parse_context(cod_parse_context context); * \param externs the list of "name, external address" pairs to be * associated. This list should be terminated with a {NULL, 0} pair. */ -extern FFS_DECLSPEC void cod_assoc_externs(cod_parse_context context, +extern void cod_assoc_externs(cod_parse_context context, cod_extern_list externs); /*! @@ -151,7 +143,7 @@ extern FFS_DECLSPEC void cod_assoc_externs(cod_parse_context context, * "int proc(double d, int *i)" * */ -extern FFS_DECLSPEC void +extern void cod_subroutine_declaration(const char *decl, cod_parse_context context); /*! @@ -163,7 +155,7 @@ cod_subroutine_declaration(const char *decl, cod_parse_context context); * the structure. * \param context the context in which the type is to be made available. */ -extern FFS_DECLSPEC void cod_add_simple_struct_type(const char *name, FMFieldList field_list, +extern void cod_add_simple_struct_type(const char *name, FMFieldList field_list, cod_parse_context context); /*! @@ -174,7 +166,7 @@ extern FFS_DECLSPEC void cod_add_simple_struct_type(const char *name, FMFieldLis * the structures. * \param context the context in which the type is to be made available. */ -extern FFS_DECLSPEC void cod_add_struct_type(FMStructDescList format_list, +extern void cod_add_struct_type(FMStructDescList format_list, cod_parse_context context); /*! @@ -185,7 +177,7 @@ extern FFS_DECLSPEC void cod_add_struct_type(FMStructDescList format_list, * \param param_num the numeral of the new parameter (0 is first) * \param context the context in which the subroutine is being declared. */ -extern FFS_DECLSPEC void +extern void cod_add_param(const char *id, const char *typ, int param_num, cod_parse_context context); @@ -199,7 +191,7 @@ cod_add_param(const char *id, const char *typ, int param_num, * \param context the context in which the subroutine is being declared. */ #ifdef __FM__ -extern FFS_DECLSPEC void +extern void cod_add_encoded_param(const char *id, char *data, int param_num, FMContext c, cod_parse_context context); #endif @@ -210,7 +202,7 @@ cod_add_encoded_param(const char *id, char *data, int param_num, * \param typ the data type of the return value. * \param context the context in which the subroutine is being declared. */ -extern FFS_DECLSPEC void +extern void cod_set_return_type(char *typ, cod_parse_context context); /*! @@ -263,7 +255,7 @@ int cod_code_verify(char *code, cod_parse_context context); * * \param code the handle to the resources that will be free'd. */ -extern FFS_DECLSPEC void cod_code_free(cod_code code); +extern void cod_code_free(cod_code code); /*! * create an execution context associated with a code block @@ -271,7 +263,7 @@ extern FFS_DECLSPEC void cod_code_free(cod_code code); * \param code the handle to the code bloc * \return the created execution context */ -extern FFS_DECLSPEC cod_exec_context cod_create_exec_context(cod_code code); +extern cod_exec_context cod_create_exec_context(cod_code code); /*! * Free all resources associated with the generated code associated with the @@ -279,7 +271,7 @@ extern FFS_DECLSPEC cod_exec_context cod_create_exec_context(cod_code code); * * \param code the handle to the resources that will be free'd. */ -extern FFS_DECLSPEC void cod_exec_context_free(cod_exec_context ec); +extern void cod_exec_context_free(cod_exec_context ec); /*! * Associate application-level data with an execution context. This is @@ -291,7 +283,7 @@ extern FFS_DECLSPEC void cod_exec_context_free(cod_exec_context ec); * \param key the value that will serve as a key to retrieve the data * \param value the 'long' data that will be associated with the key */ -extern FFS_DECLSPEC void cod_assoc_client_data(cod_exec_context ec, int key, intptr_t value); +extern void cod_assoc_client_data(cod_exec_context ec, int key, intptr_t value); /*! * Retrieve application-level data with an execution context. This is @@ -305,7 +297,7 @@ extern FFS_DECLSPEC void cod_assoc_client_data(cod_exec_context ec, int key, int * \param key the value that will serve as a key to retrieve the data * \return the 'long' data that was associated with the key */ -extern FFS_DECLSPEC intptr_t cod_get_client_data(cod_exec_context ec, int key); +extern intptr_t cod_get_client_data(cod_exec_context ec, int key); /*! * Extract static state from an execution context. @@ -315,7 +307,7 @@ extern FFS_DECLSPEC intptr_t cod_get_client_data(cod_exec_context ec, int key); * the length of the returned state block * \return a pointer to the extracted state */ -extern FFS_DECLSPEC void *cod_extract_state(cod_exec_context ec, int *length_p); +extern void *cod_extract_state(cod_exec_context ec, int *length_p); /*! * Install static state into an execution context. @@ -325,7 +317,7 @@ extern FFS_DECLSPEC void *cod_extract_state(cod_exec_context ec, int *length_p); * \param state_size the size of the state block * \return 1 on success, 0 on failure */ -extern FFS_DECLSPEC int cod_install_state(cod_exec_context ec, void *state, int length); +extern int cod_install_state(cod_exec_context ec, void *state, int length); /*! * \brief This parses a string to determine what external @@ -356,7 +348,7 @@ int cod_parse_for_globals(char *code, cod_parse_context context); * * \param context the cod_parse_context to be duplicated. */ -extern FFS_DECLSPEC cod_parse_context cod_copy_context(cod_parse_context context); +extern cod_parse_context cod_copy_context(cod_parse_context context); /*! * Duplicate a handle to an cod_parse_context, specifically adapting the results to @@ -365,7 +357,7 @@ extern FFS_DECLSPEC cod_parse_context cod_copy_context(cod_parse_context context * * \param context the cod_parse_context to be duplicated. */ -extern FFS_DECLSPEC cod_parse_context cod_copy_globals(cod_parse_context context); +extern cod_parse_context cod_copy_globals(cod_parse_context context); /*! * err_out_func_t is a function pointer type. Functions matching this @@ -408,7 +400,7 @@ void cod_dump(cod_code code); * \param format2 the old format. This is the format of the output message. * \param xform_code The COD code string that transforms data from format1 to format2. */ -extern FFS_DECLSPEC cod_code +extern cod_code gen_rollback_code(FMStructDescList format1, FMStructDescList format2, char *xform_code); /*! @@ -417,7 +409,7 @@ gen_rollback_code(FMStructDescList format1, FMStructDescList format2, char *xfor * \param value The value of the constant * \param context the context in which this is to be created */ -extern FFS_DECLSPEC void cod_add_int_constant_to_parse_context(const char *id, int value, +extern void cod_add_int_constant_to_parse_context(const char *id, int value, cod_parse_context context); /*! @@ -426,7 +418,7 @@ extern FFS_DECLSPEC void cod_add_int_constant_to_parse_context(const char *id, i * \param value The value to send * \param context The context in which the subroutine has been declared. */ -extern FFS_DECLSPEC void cod_set_closure(char *name, void* value, cod_parse_context context); +extern void cod_set_closure(char *name, void* value, cod_parse_context context); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/thirdparty/ffs/ffs/cod/cod.y b/thirdparty/ffs/ffs/cod/cod.y index a4d0d17515..3d99807dcb 100644 --- a/thirdparty/ffs/ffs/cod/cod.y +++ b/thirdparty/ffs/ffs/cod/cod.y @@ -6447,7 +6447,7 @@ space_to_underscore(char *str){ while(*str != '\0'){ if(isspace(*str)) *str = '_'; - str++; + str++; } } @@ -6732,7 +6732,7 @@ evaluate_constant_return_expr(cod_parse_context context, sm_ref expr, int *free_ *free_result = 1; } else { /* we get an integer result */ - intptr_t left_val = 0, right_val = 0, value; + intptr_t left_val = 0, right_val = 0, value = 0; char str_val[40]; if (expr->node.operator.left) left_val = get_constant_long_value(context, left); diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l index 724916d39c..6b816a740f 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.l @@ -359,70 +359,9 @@ yywrap YY_PROTO(( void )) } -#ifndef input /* flex, not lex */ void yy_delete_buffer YY_PROTO((YY_BUFFER_STATE b)); -#ifdef WINNT -/* old Windows code for MKS Toolkit version of flex */ - -static void -terminate_string_parse() -{ - yyrestart(NULL); -} - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -static char* current_input_string; - -int my_yy_input(buf,result,max_size) { - - if (current_input_string == NULL) - { - - result = 0; - } - else - if (max_size < strlen(current_input_string)) - { - memcpy((void*)buf, current_input_string, max_size); - current_input_string += max_size; - result = max_size; - } else { - int n = strlen(current_input_string); - memcpy((void*)buf, current_input_string, n+1); - current_input_string = NULL; - result = n; - } - -/* printf("my_yy_input buf[%s],result[%d]\n",buf,result);*/ - return result; -} - -static void -setup_for_string_parse(string, defined_types, enum_constants) -const char *string; -char **defined_types; -char **enum_constants; -{ - type_count = defined_type_count; - types = defined_types; - enums = enum_constants; - - current_input_string = string; - lex_offset = 1; - line_count = 1; -} -#else static YY_BUFFER_STATE bb = NULL; @@ -455,5 +394,3 @@ terminate_string_parse() } } -#endif -#endif diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c index 531a170505..70198e7fba 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.c @@ -289,138 +289,7 @@ cod_dup_list(sm_list list) # endif # endif - -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token kinds. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - YYEMPTY = -2, - YYEOF = 0, /* "end of file" */ - YYerror = 256, /* error */ - YYUNDEF = 257, /* "invalid token" */ - ARROW = 258, /* ARROW */ - LPAREN = 259, /* LPAREN */ - RPAREN = 260, /* RPAREN */ - LCURLY = 261, /* LCURLY */ - RCURLY = 262, /* RCURLY */ - COLON = 263, /* COLON */ - QUESTION = 264, /* QUESTION */ - LBRACKET = 265, /* LBRACKET */ - RBRACKET = 266, /* RBRACKET */ - DOT = 267, /* DOT */ - STAR = 268, /* STAR */ - AT = 269, /* AT */ - SLASH = 270, /* SLASH */ - MODULUS = 271, /* MODULUS */ - PLUS = 272, /* PLUS */ - MINUS = 273, /* MINUS */ - TILDE = 274, /* TILDE */ - LEQ = 275, /* LEQ */ - LT = 276, /* LT */ - GEQ = 277, /* GEQ */ - GT = 278, /* GT */ - EQ = 279, /* EQ */ - NEQ = 280, /* NEQ */ - LEFT_SHIFT = 281, /* LEFT_SHIFT */ - RIGHT_SHIFT = 282, /* RIGHT_SHIFT */ - ASSIGN = 283, /* ASSIGN */ - MUL_ASSIGN = 284, /* MUL_ASSIGN */ - DIV_ASSIGN = 285, /* DIV_ASSIGN */ - MOD_ASSIGN = 286, /* MOD_ASSIGN */ - ADD_ASSIGN = 287, /* ADD_ASSIGN */ - SUB_ASSIGN = 288, /* SUB_ASSIGN */ - LEFT_ASSIGN = 289, /* LEFT_ASSIGN */ - RIGHT_ASSIGN = 290, /* RIGHT_ASSIGN */ - AND_ASSIGN = 291, /* AND_ASSIGN */ - XOR_ASSIGN = 292, /* XOR_ASSIGN */ - OR_ASSIGN = 293, /* OR_ASSIGN */ - LOG_OR = 294, /* LOG_OR */ - LOG_AND = 295, /* LOG_AND */ - ARITH_OR = 296, /* ARITH_OR */ - ARITH_AND = 297, /* ARITH_AND */ - ARITH_XOR = 298, /* ARITH_XOR */ - INC_OP = 299, /* INC_OP */ - DEC_OP = 300, /* DEC_OP */ - BANG = 301, /* BANG */ - SEMI = 302, /* SEMI */ - IF = 303, /* IF */ - ELSE = 304, /* ELSE */ - FOR = 305, /* FOR */ - DO = 306, /* DO */ - WHILE = 307, /* WHILE */ - CHAR = 308, /* CHAR */ - SHORT = 309, /* SHORT */ - INT = 310, /* INT */ - LONG = 311, /* LONG */ - UNSIGNED = 312, /* UNSIGNED */ - SIGNED = 313, /* SIGNED */ - FLOAT = 314, /* FLOAT */ - DOUBLE = 315, /* DOUBLE */ - VOID = 316, /* VOID */ - STRING = 317, /* STRING */ - STATIC = 318, /* STATIC */ - EXTERN_TOKEN = 319, /* EXTERN_TOKEN */ - STRUCT = 320, /* STRUCT */ - ENUM = 321, /* ENUM */ - UNION = 322, /* UNION */ - CONST = 323, /* CONST */ - SIZEOF = 324, /* SIZEOF */ - TYPEDEF = 325, /* TYPEDEF */ - RETURN_TOKEN = 326, /* RETURN_TOKEN */ - CONTINUE = 327, /* CONTINUE */ - BREAK = 328, /* BREAK */ - GOTO = 329, /* GOTO */ - PRINT = 330, /* PRINT */ - COMMA = 331, /* COMMA */ - DOTDOTDOT = 332, /* DOTDOTDOT */ - integer_constant = 333, /* integer_constant */ - character_constant = 334, /* character_constant */ - string_constant = 335, /* string_constant */ - floating_constant = 336, /* floating_constant */ - identifier_ref = 337, /* identifier_ref */ - type_identifier = 338, /* type_id */ - enumeration_constant = 339 /* enumeration_constant */ - }; - typedef enum yytokentype yytoken_kind_t; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE -{ -#line 201 "cod.y" - - lx_info info; - sm_ref reference; - operator_t operator; - sm_list list; - char *string; - -#line 409 "cod.tab.c" - -}; -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - - -int yyparse (void); - - - +#include "cod.tab.h" /* Symbol kind. */ enum yysymbol_kind_t { @@ -508,7 +377,7 @@ enum yysymbol_kind_t YYSYMBOL_string_constant = 80, /* string_constant */ YYSYMBOL_floating_constant = 81, /* floating_constant */ YYSYMBOL_identifier_ref = 82, /* identifier_ref */ - YYSYMBOL_type_identifier = 83, /* type_id */ + YYSYMBOL_type_identifier = 83, /* type_identifier */ YYSYMBOL_enumeration_constant = 84, /* enumeration_constant */ YYSYMBOL_YYACCEPT = 85, /* $accept */ YYSYMBOL_start = 86, /* start */ @@ -1019,18 +888,19 @@ static const char *const yytname[] = "ENUM", "UNION", "CONST", "SIZEOF", "TYPEDEF", "RETURN_TOKEN", "CONTINUE", "BREAK", "GOTO", "PRINT", "COMMA", "DOTDOTDOT", "integer_constant", "character_constant", "string_constant", - "floating_constant", "identifier_ref", "type_identifier", "enumeration_constant", - "$accept", "start", "primary_expression", "postfix_expression", - "argument_expression_list", "unary_expression", "unary_operator", - "cast_expression", "multiplicative_expression", "additive_expression", - "shift_expression", "relational_expression", "equality_expression", - "and_expression", "exclusive_or_expression", "inclusive_or_expression", - "logical_and_expression", "logical_or_expression", - "conditional_expression", "assignment_operator", "assignment_expression", - "expression", "constant_expression", "init_declarator_list", - "declaration", "$@1", "@2", "declaration_specifiers", "init_declarator", - "storage_class_specifier", "type_specifier", "struct_or_union_specifier", - "struct_or_union", "struct_declaration_list", "struct_declaration", + "floating_constant", "identifier_ref", "type_identifier", + "enumeration_constant", "$accept", "start", "primary_expression", + "postfix_expression", "argument_expression_list", "unary_expression", + "unary_operator", "cast_expression", "multiplicative_expression", + "additive_expression", "shift_expression", "relational_expression", + "equality_expression", "and_expression", "exclusive_or_expression", + "inclusive_or_expression", "logical_and_expression", + "logical_or_expression", "conditional_expression", "assignment_operator", + "assignment_expression", "expression", "constant_expression", + "init_declarator_list", "declaration", "$@1", "@2", + "declaration_specifiers", "init_declarator", "storage_class_specifier", + "type_specifier", "struct_or_union_specifier", "struct_or_union", + "struct_declaration_list", "struct_declaration", "struct_declarator_list", "struct_declarator", "specifier_qualifier_list", "enum_specifier", "enumerator_list", "enumerator", "type_qualifier", "declarator", "direct_declarator", @@ -1928,7 +1798,7 @@ yyparse (void) { yyparse_value = (sm_ref)(yyvsp[0].list); } -#line 1932 "cod.tab.c" +#line 1802 "cod.tab.c" break; case 3: /* start: compound_statement */ @@ -1936,7 +1806,7 @@ yyparse (void) { yyparse_value = (yyvsp[0].reference); } -#line 1940 "cod.tab.c" +#line 1810 "cod.tab.c" break; case 4: /* primary_expression: identifier_ref */ @@ -1946,13 +1816,13 @@ yyparse (void) (yyval.reference)->node.identifier.id = (yyvsp[0].info).string; (yyval.reference)->node.identifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 1950 "cod.tab.c" +#line 1820 "cod.tab.c" break; case 6: /* primary_expression: LPAREN expression RPAREN */ #line 377 "cod.y" { (yyval.reference) = (yyvsp[-1].reference); } -#line 1956 "cod.tab.c" +#line 1826 "cod.tab.c" break; case 8: /* postfix_expression: postfix_expression LBRACKET expression RBRACKET */ @@ -1963,7 +1833,7 @@ yyparse (void) (yyval.reference)->node.element_ref.expression = (yyvsp[-1].reference); (yyval.reference)->node.element_ref.array_ref = (yyvsp[-3].reference); } -#line 1967 "cod.tab.c" +#line 1837 "cod.tab.c" break; case 9: /* postfix_expression: postfix_expression DOT identifier_ref */ @@ -1974,7 +1844,7 @@ yyparse (void) (yyval.reference)->node.field_ref.lx_field = (yyvsp[0].info).string; (yyval.reference)->node.field_ref.struct_ref = (yyvsp[-2].reference); } -#line 1978 "cod.tab.c" +#line 1848 "cod.tab.c" break; case 10: /* postfix_expression: postfix_expression LPAREN argument_expression_list RPAREN */ @@ -1985,7 +1855,7 @@ yyparse (void) (yyval.reference)->node.subroutine_call.arguments = (yyvsp[-1].list); (yyval.reference)->node.subroutine_call.sm_func_ref = (yyvsp[-3].reference); } -#line 1989 "cod.tab.c" +#line 1859 "cod.tab.c" break; case 11: /* postfix_expression: postfix_expression LPAREN RPAREN */ @@ -1996,7 +1866,7 @@ yyparse (void) (yyval.reference)->node.subroutine_call.arguments = NULL; (yyval.reference)->node.subroutine_call.sm_func_ref = (yyvsp[-2].reference); } -#line 2000 "cod.tab.c" +#line 1870 "cod.tab.c" break; case 12: /* postfix_expression: postfix_expression ARROW identifier_ref */ @@ -2007,7 +1877,7 @@ yyparse (void) (yyval.reference)->node.field_ref.lx_field = (yyvsp[0].info).string; (yyval.reference)->node.field_ref.struct_ref = (yyvsp[-2].reference); } -#line 2011 "cod.tab.c" +#line 1881 "cod.tab.c" break; case 13: /* postfix_expression: postfix_expression INC_OP */ @@ -2019,7 +1889,7 @@ yyparse (void) (yyval.reference)->node.operator.right = NULL; (yyval.reference)->node.operator.left = (yyvsp[-1].reference); } -#line 2023 "cod.tab.c" +#line 1893 "cod.tab.c" break; case 14: /* postfix_expression: postfix_expression DEC_OP */ @@ -2031,7 +1901,7 @@ yyparse (void) (yyval.reference)->node.operator.right = NULL; (yyval.reference)->node.operator.left = (yyvsp[-1].reference); } -#line 2035 "cod.tab.c" +#line 1905 "cod.tab.c" break; case 15: /* argument_expression_list: assignment_expression */ @@ -2041,7 +1911,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 2045 "cod.tab.c" +#line 1915 "cod.tab.c" break; case 16: /* argument_expression_list: argument_expression_list COMMA assignment_expression */ @@ -2056,7 +1926,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-2].list); } -#line 2060 "cod.tab.c" +#line 1930 "cod.tab.c" break; case 18: /* unary_expression: INC_OP unary_expression */ @@ -2068,7 +1938,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = NULL; } -#line 2072 "cod.tab.c" +#line 1942 "cod.tab.c" break; case 19: /* unary_expression: DEC_OP unary_expression */ @@ -2080,7 +1950,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = NULL; } -#line 2084 "cod.tab.c" +#line 1954 "cod.tab.c" break; case 20: /* unary_expression: unary_operator cast_expression */ @@ -2092,7 +1962,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = NULL; } -#line 2096 "cod.tab.c" +#line 1966 "cod.tab.c" break; case 21: /* unary_expression: SIZEOF unary_expression */ @@ -2104,7 +1974,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = NULL; } -#line 2108 "cod.tab.c" +#line 1978 "cod.tab.c" break; case 22: /* unary_expression: SIZEOF LPAREN type_name RPAREN */ @@ -2122,7 +1992,7 @@ yyparse (void) (yyval.reference)->node.operator.right = cast; (yyval.reference)->node.operator.left = NULL; } -#line 2126 "cod.tab.c" +#line 1996 "cod.tab.c" break; case 23: /* unary_operator: ARITH_AND */ @@ -2130,7 +2000,7 @@ yyparse (void) { (yyval.info).op = op_address; } -#line 2134 "cod.tab.c" +#line 2004 "cod.tab.c" break; case 24: /* unary_operator: STAR */ @@ -2138,7 +2008,7 @@ yyparse (void) { (yyval.info).op = op_deref; } -#line 2142 "cod.tab.c" +#line 2012 "cod.tab.c" break; case 25: /* unary_operator: PLUS */ @@ -2146,7 +2016,7 @@ yyparse (void) { (yyval.info).op = op_plus; } -#line 2150 "cod.tab.c" +#line 2020 "cod.tab.c" break; case 26: /* unary_operator: MINUS */ @@ -2154,7 +2024,7 @@ yyparse (void) { (yyval.info).op = op_minus; } -#line 2158 "cod.tab.c" +#line 2028 "cod.tab.c" break; case 27: /* unary_operator: TILDE */ @@ -2162,7 +2032,7 @@ yyparse (void) { (yyval.info).op = op_not; } -#line 2166 "cod.tab.c" +#line 2036 "cod.tab.c" break; case 28: /* unary_operator: BANG */ @@ -2170,7 +2040,7 @@ yyparse (void) { (yyval.info).op = op_log_neg; } -#line 2174 "cod.tab.c" +#line 2044 "cod.tab.c" break; case 30: /* cast_expression: LPAREN type_name RPAREN cast_expression */ @@ -2181,7 +2051,7 @@ yyparse (void) (yyval.reference)->node.cast.type_spec = (yyvsp[-2].list); (yyval.reference)->node.cast.expression = (yyvsp[0].reference); } -#line 2185 "cod.tab.c" +#line 2055 "cod.tab.c" break; case 32: /* multiplicative_expression: multiplicative_expression STAR cast_expression */ @@ -2193,7 +2063,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2197 "cod.tab.c" +#line 2067 "cod.tab.c" break; case 33: /* multiplicative_expression: multiplicative_expression SLASH cast_expression */ @@ -2205,7 +2075,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2209 "cod.tab.c" +#line 2079 "cod.tab.c" break; case 34: /* multiplicative_expression: multiplicative_expression MODULUS cast_expression */ @@ -2217,7 +2087,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2221 "cod.tab.c" +#line 2091 "cod.tab.c" break; case 36: /* additive_expression: additive_expression PLUS multiplicative_expression */ @@ -2229,7 +2099,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2233 "cod.tab.c" +#line 2103 "cod.tab.c" break; case 37: /* additive_expression: additive_expression MINUS multiplicative_expression */ @@ -2241,7 +2111,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2245 "cod.tab.c" +#line 2115 "cod.tab.c" break; case 39: /* shift_expression: shift_expression LEFT_SHIFT additive_expression */ @@ -2253,7 +2123,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2257 "cod.tab.c" +#line 2127 "cod.tab.c" break; case 40: /* shift_expression: shift_expression RIGHT_SHIFT additive_expression */ @@ -2265,7 +2135,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2269 "cod.tab.c" +#line 2139 "cod.tab.c" break; case 42: /* relational_expression: relational_expression LT shift_expression */ @@ -2277,7 +2147,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2281 "cod.tab.c" +#line 2151 "cod.tab.c" break; case 43: /* relational_expression: relational_expression GT shift_expression */ @@ -2289,7 +2159,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2293 "cod.tab.c" +#line 2163 "cod.tab.c" break; case 44: /* relational_expression: relational_expression LEQ shift_expression */ @@ -2301,7 +2171,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2305 "cod.tab.c" +#line 2175 "cod.tab.c" break; case 45: /* relational_expression: relational_expression GEQ shift_expression */ @@ -2313,7 +2183,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2317 "cod.tab.c" +#line 2187 "cod.tab.c" break; case 47: /* equality_expression: equality_expression EQ relational_expression */ @@ -2325,7 +2195,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2329 "cod.tab.c" +#line 2199 "cod.tab.c" break; case 48: /* equality_expression: equality_expression NEQ relational_expression */ @@ -2337,7 +2207,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2341 "cod.tab.c" +#line 2211 "cod.tab.c" break; case 50: /* and_expression: and_expression ARITH_AND equality_expression */ @@ -2349,7 +2219,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2353 "cod.tab.c" +#line 2223 "cod.tab.c" break; case 52: /* exclusive_or_expression: exclusive_or_expression ARITH_XOR and_expression */ @@ -2361,7 +2231,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2365 "cod.tab.c" +#line 2235 "cod.tab.c" break; case 54: /* inclusive_or_expression: inclusive_or_expression ARITH_OR exclusive_or_expression */ @@ -2373,7 +2243,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2377 "cod.tab.c" +#line 2247 "cod.tab.c" break; case 56: /* logical_and_expression: logical_and_expression LOG_AND inclusive_or_expression */ @@ -2385,7 +2255,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2389 "cod.tab.c" +#line 2259 "cod.tab.c" break; case 58: /* logical_or_expression: logical_or_expression LOG_OR logical_and_expression */ @@ -2397,7 +2267,7 @@ yyparse (void) (yyval.reference)->node.operator.right = (yyvsp[0].reference); (yyval.reference)->node.operator.left = (yyvsp[-2].reference); } -#line 2401 "cod.tab.c" +#line 2271 "cod.tab.c" break; case 60: /* conditional_expression: logical_or_expression QUESTION expression COLON conditional_expression */ @@ -2409,79 +2279,79 @@ yyparse (void) (yyval.reference)->node.conditional_operator.e1 = (yyvsp[-2].reference); (yyval.reference)->node.conditional_operator.e2 = (yyvsp[0].reference); } -#line 2413 "cod.tab.c" +#line 2283 "cod.tab.c" break; case 61: /* assignment_operator: ASSIGN */ #line 746 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_eq;} -#line 2419 "cod.tab.c" +#line 2289 "cod.tab.c" break; case 62: /* assignment_operator: MUL_ASSIGN */ #line 748 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_mult;} -#line 2425 "cod.tab.c" +#line 2295 "cod.tab.c" break; case 63: /* assignment_operator: DIV_ASSIGN */ #line 750 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_div;} -#line 2431 "cod.tab.c" +#line 2301 "cod.tab.c" break; case 64: /* assignment_operator: MOD_ASSIGN */ #line 752 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_modulus;} -#line 2437 "cod.tab.c" +#line 2307 "cod.tab.c" break; case 65: /* assignment_operator: ADD_ASSIGN */ #line 754 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_plus;} -#line 2443 "cod.tab.c" +#line 2313 "cod.tab.c" break; case 66: /* assignment_operator: SUB_ASSIGN */ #line 756 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_minus;} -#line 2449 "cod.tab.c" +#line 2319 "cod.tab.c" break; case 67: /* assignment_operator: LEFT_ASSIGN */ #line 758 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_left_shift;} -#line 2455 "cod.tab.c" +#line 2325 "cod.tab.c" break; case 68: /* assignment_operator: RIGHT_ASSIGN */ #line 760 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_right_shift;} -#line 2461 "cod.tab.c" +#line 2331 "cod.tab.c" break; case 69: /* assignment_operator: AND_ASSIGN */ #line 762 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_arith_and;} -#line 2467 "cod.tab.c" +#line 2337 "cod.tab.c" break; case 70: /* assignment_operator: XOR_ASSIGN */ #line 764 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_arith_xor;} -#line 2473 "cod.tab.c" +#line 2343 "cod.tab.c" break; case 71: /* assignment_operator: OR_ASSIGN */ #line 766 "cod.y" { (yyval.info) = (yyvsp[0].info); (yyval.info).op = op_arith_or;} -#line 2479 "cod.tab.c" +#line 2349 "cod.tab.c" break; case 72: /* assignment_expression: conditional_expression */ #line 771 "cod.y" { (yyval.reference) = (yyvsp[0].reference);} -#line 2485 "cod.tab.c" +#line 2355 "cod.tab.c" break; case 73: /* assignment_expression: unary_expression assignment_operator assignment_expression */ @@ -2493,13 +2363,13 @@ yyparse (void) (yyval.reference)->node.assignment_expression.right = (yyvsp[0].reference); (yyval.reference)->node.assignment_expression.op = (yyvsp[-1].info).op; } -#line 2497 "cod.tab.c" +#line 2367 "cod.tab.c" break; case 74: /* expression: assignment_expression */ #line 785 "cod.y" {(yyval.reference) = (yyvsp[0].reference);} -#line 2503 "cod.tab.c" +#line 2373 "cod.tab.c" break; case 75: /* expression: expression COMMA assignment_expression */ @@ -2510,7 +2380,7 @@ yyparse (void) (yyval.reference)->node.comma_expression.left = (yyvsp[-2].reference); (yyval.reference)->node.comma_expression.right = (yyvsp[0].reference); } -#line 2514 "cod.tab.c" +#line 2384 "cod.tab.c" break; case 77: /* init_declarator_list: init_declarator */ @@ -2520,7 +2390,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 2524 "cod.tab.c" +#line 2394 "cod.tab.c" break; case 78: /* init_declarator_list: init_declarator_list COMMA init_declarator */ @@ -2536,7 +2406,7 @@ yyparse (void) tmp->next = NULL; (yyval.list) = (yyvsp[-2].list); } -#line 2540 "cod.tab.c" +#line 2410 "cod.tab.c" break; case 79: /* $@1: %empty */ @@ -2547,7 +2417,7 @@ yyparse (void) YYACCEPT; } } -#line 2551 "cod.tab.c" +#line 2421 "cod.tab.c" break; case 80: /* @2: %empty */ @@ -2579,7 +2449,7 @@ yyparse (void) YYACCEPT; } } -#line 2583 "cod.tab.c" +#line 2453 "cod.tab.c" break; case 81: /* declaration: declaration_specifiers $@1 init_declarator_list @2 SEMI */ @@ -2639,7 +2509,7 @@ yyparse (void) } (void)(yyvsp[-1].reference); } -#line 2643 "cod.tab.c" +#line 2513 "cod.tab.c" break; case 82: /* declaration: declaration_specifiers SEMI */ @@ -2647,7 +2517,7 @@ yyparse (void) { (yyval.list) = (yyvsp[-1].list); } -#line 2651 "cod.tab.c" +#line 2521 "cod.tab.c" break; case 83: /* declaration_specifiers: storage_class_specifier */ @@ -2657,7 +2527,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 2661 "cod.tab.c" +#line 2531 "cod.tab.c" break; case 84: /* declaration_specifiers: storage_class_specifier declaration_specifiers */ @@ -2668,7 +2538,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = tmp; } -#line 2672 "cod.tab.c" +#line 2542 "cod.tab.c" break; case 85: /* declaration_specifiers: type_specifier */ @@ -2678,7 +2548,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 2682 "cod.tab.c" +#line 2552 "cod.tab.c" break; case 86: /* declaration_specifiers: type_specifier declaration_specifiers */ @@ -2689,7 +2559,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = tmp; } -#line 2693 "cod.tab.c" +#line 2563 "cod.tab.c" break; case 87: /* declaration_specifiers: type_qualifier */ @@ -2699,7 +2569,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 2703 "cod.tab.c" +#line 2573 "cod.tab.c" break; case 88: /* declaration_specifiers: type_qualifier declaration_specifiers */ @@ -2710,7 +2580,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = tmp; } -#line 2714 "cod.tab.c" +#line 2584 "cod.tab.c" break; case 90: /* init_declarator: declarator ASSIGN initializer */ @@ -2727,7 +2597,7 @@ yyparse (void) tmp->node.declaration.init_value = (yyvsp[0].reference); } } -#line 2731 "cod.tab.c" +#line 2601 "cod.tab.c" break; case 91: /* storage_class_specifier: TYPEDEF */ @@ -2737,7 +2607,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = TYPEDEF; } -#line 2741 "cod.tab.c" +#line 2611 "cod.tab.c" break; case 92: /* storage_class_specifier: STATIC */ @@ -2747,7 +2617,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = STATIC; } -#line 2751 "cod.tab.c" +#line 2621 "cod.tab.c" break; case 93: /* storage_class_specifier: EXTERN_TOKEN */ @@ -2757,7 +2627,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = EXTERN_TOKEN; } -#line 2761 "cod.tab.c" +#line 2631 "cod.tab.c" break; case 94: /* type_specifier: CHAR */ @@ -2767,7 +2637,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = CHAR; } -#line 2771 "cod.tab.c" +#line 2641 "cod.tab.c" break; case 95: /* type_specifier: SHORT */ @@ -2777,7 +2647,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = SHORT; } -#line 2781 "cod.tab.c" +#line 2651 "cod.tab.c" break; case 96: /* type_specifier: INT */ @@ -2787,7 +2657,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = INT; } -#line 2791 "cod.tab.c" +#line 2661 "cod.tab.c" break; case 97: /* type_specifier: LONG */ @@ -2797,7 +2667,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = LONG; } -#line 2801 "cod.tab.c" +#line 2671 "cod.tab.c" break; case 98: /* type_specifier: FLOAT */ @@ -2807,7 +2677,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = FLOAT; } -#line 2811 "cod.tab.c" +#line 2681 "cod.tab.c" break; case 99: /* type_specifier: DOUBLE */ @@ -2817,7 +2687,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = DOUBLE; } -#line 2821 "cod.tab.c" +#line 2691 "cod.tab.c" break; case 100: /* type_specifier: VOID */ @@ -2827,7 +2697,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = VOID; } -#line 2831 "cod.tab.c" +#line 2701 "cod.tab.c" break; case 101: /* type_specifier: SIGNED */ @@ -2837,7 +2707,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = SIGNED; } -#line 2841 "cod.tab.c" +#line 2711 "cod.tab.c" break; case 102: /* type_specifier: UNSIGNED */ @@ -2847,7 +2717,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = UNSIGNED; } -#line 2851 "cod.tab.c" +#line 2721 "cod.tab.c" break; case 103: /* type_specifier: STRING */ @@ -2857,17 +2727,17 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = STRING; } -#line 2861 "cod.tab.c" +#line 2731 "cod.tab.c" break; case 104: /* type_specifier: type_identifier */ #line 1042 "cod.y" - { + { (yyval.reference) = cod_new_identifier(); (yyval.reference)->node.identifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.identifier.id = (yyvsp[0].info).string; } -#line 2871 "cod.tab.c" +#line 2741 "cod.tab.c" break; case 105: /* type_specifier: struct_or_union_specifier */ @@ -2875,7 +2745,7 @@ yyparse (void) { (yyval.reference) = (yyvsp[0].reference); } -#line 2879 "cod.tab.c" +#line 2749 "cod.tab.c" break; case 106: /* type_specifier: enum_specifier */ @@ -2883,7 +2753,7 @@ yyparse (void) { (yyval.reference) = (yyvsp[0].reference); } -#line 2887 "cod.tab.c" +#line 2757 "cod.tab.c" break; case 107: /* struct_or_union_specifier: struct_or_union identifier_ref LCURLY struct_declaration_list RCURLY */ @@ -2891,7 +2761,7 @@ yyparse (void) { (yyval.reference) = cod_build_parsed_type_node(yycontext, (yyvsp[-3].info).string, (yyvsp[-1].list)); } -#line 2895 "cod.tab.c" +#line 2765 "cod.tab.c" break; case 108: /* struct_or_union_specifier: struct_or_union LCURLY struct_declaration_list RCURLY */ @@ -2899,7 +2769,7 @@ yyparse (void) { (yyval.reference) = cod_build_parsed_type_node(yycontext, strdup("anon"), (yyvsp[-1].list)); } -#line 2903 "cod.tab.c" +#line 2773 "cod.tab.c" break; case 109: /* struct_or_union_specifier: struct_or_union identifier_ref */ @@ -2907,7 +2777,7 @@ yyparse (void) { (yyval.reference) = cod_build_parsed_type_node(yycontext, (yyvsp[0].info).string, NULL); } -#line 2911 "cod.tab.c" +#line 2781 "cod.tab.c" break; case 111: /* struct_or_union: UNION */ @@ -2915,7 +2785,7 @@ yyparse (void) { yyerror("UNIONs not supported!"); } -#line 2919 "cod.tab.c" +#line 2789 "cod.tab.c" break; case 113: /* struct_declaration_list: struct_declaration_list struct_declaration */ @@ -2928,13 +2798,13 @@ yyparse (void) tmp->next =(yyvsp[0].list); (yyval.list) = (yyvsp[-1].list); } -#line 2932 "cod.tab.c" +#line 2802 "cod.tab.c" break; case 114: /* struct_declaration: specifier_qualifier_list SEMI */ #line 1088 "cod.y" { } -#line 2938 "cod.tab.c" +#line 2808 "cod.tab.c" break; case 115: /* struct_declaration: specifier_qualifier_list struct_declarator_list SEMI */ @@ -2986,7 +2856,7 @@ yyparse (void) } } } -#line 2990 "cod.tab.c" +#line 2860 "cod.tab.c" break; case 116: /* struct_declarator_list: struct_declarator */ @@ -2996,7 +2866,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3000 "cod.tab.c" +#line 2870 "cod.tab.c" break; case 117: /* struct_declarator_list: struct_declarator_list COMMA struct_declarator */ @@ -3011,7 +2881,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-2].list); } -#line 3015 "cod.tab.c" +#line 2885 "cod.tab.c" break; case 119: /* specifier_qualifier_list: type_specifier specifier_qualifier_list */ @@ -3022,7 +2892,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = tmp; } -#line 3026 "cod.tab.c" +#line 2896 "cod.tab.c" break; case 120: /* specifier_qualifier_list: type_specifier */ @@ -3032,7 +2902,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3036 "cod.tab.c" +#line 2906 "cod.tab.c" break; case 121: /* specifier_qualifier_list: type_qualifier specifier_qualifier_list */ @@ -3043,7 +2913,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = tmp; } -#line 3047 "cod.tab.c" +#line 2917 "cod.tab.c" break; case 122: /* specifier_qualifier_list: type_qualifier */ @@ -3053,7 +2923,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3057 "cod.tab.c" +#line 2927 "cod.tab.c" break; case 123: /* enum_specifier: ENUM LCURLY enumerator_list RCURLY */ @@ -3065,7 +2935,7 @@ yyparse (void) (yyval.reference)->node.enum_type_decl.lx_srcpos = (yyvsp[-3].info).lx_srcpos; // cod_add_defined_type(decl->node.declaration.id, yycontext); } -#line 3069 "cod.tab.c" +#line 2939 "cod.tab.c" break; case 124: /* enum_specifier: ENUM LCURLY enumerator_list COMMA RCURLY */ @@ -3077,7 +2947,7 @@ yyparse (void) (yyval.reference)->node.enum_type_decl.lx_srcpos = (yyvsp[-4].info).lx_srcpos; // cod_add_defined_type(decl->node.declaration.id, yycontext); } -#line 3081 "cod.tab.c" +#line 2951 "cod.tab.c" break; case 125: /* enum_specifier: ENUM identifier_ref LCURLY enumerator_list RCURLY */ @@ -3089,7 +2959,7 @@ yyparse (void) (yyval.reference)->node.enum_type_decl.lx_srcpos = (yyvsp[-4].info).lx_srcpos; // cod_add_defined_type(decl->node.declaration.id, yycontext); } -#line 3093 "cod.tab.c" +#line 2963 "cod.tab.c" break; case 126: /* enum_specifier: ENUM identifier_ref LCURLY enumerator_list COMMA RCURLY */ @@ -3101,7 +2971,7 @@ yyparse (void) (yyval.reference)->node.enum_type_decl.lx_srcpos = (yyvsp[-5].info).lx_srcpos; // cod_add_defined_type(decl->node.declaration.id, yycontext); } -#line 3105 "cod.tab.c" +#line 2975 "cod.tab.c" break; case 127: /* enum_specifier: ENUM identifier_ref */ @@ -3113,7 +2983,7 @@ yyparse (void) (yyval.reference)->node.enum_type_decl.lx_srcpos = (yyvsp[-1].info).lx_srcpos; // cod_add_defined_type(decl->node.declaration.id, yycontext); } -#line 3117 "cod.tab.c" +#line 2987 "cod.tab.c" break; case 128: /* enumerator_list: enumerator */ @@ -3124,7 +2994,7 @@ yyparse (void) tmp->next = NULL; (yyval.list) = tmp; } -#line 3128 "cod.tab.c" +#line 2998 "cod.tab.c" break; case 129: /* enumerator_list: enumerator_list COMMA enumerator */ @@ -3135,7 +3005,7 @@ yyparse (void) tmp->next = (yyvsp[-2].list); (yyval.list) = tmp; } -#line 3139 "cod.tab.c" +#line 3009 "cod.tab.c" break; case 130: /* enumerator: identifier_ref ASSIGN constant_expression */ @@ -3145,7 +3015,7 @@ yyparse (void) (yyval.reference)->node.enumerator.id = (yyvsp[-2].info).string; (yyval.reference)->node.enumerator.const_expression = (yyvsp[0].reference); } -#line 3149 "cod.tab.c" +#line 3019 "cod.tab.c" break; case 131: /* enumerator: identifier_ref */ @@ -3155,7 +3025,7 @@ yyparse (void) (yyval.reference)->node.enumerator.id = (yyvsp[0].info).string; (yyval.reference)->node.enumerator.const_expression = NULL; } -#line 3159 "cod.tab.c" +#line 3029 "cod.tab.c" break; case 132: /* type_qualifier: CONST */ @@ -3165,7 +3035,7 @@ yyparse (void) (yyval.reference)->node.type_specifier.lx_srcpos = (yyvsp[0].info).lx_srcpos; (yyval.reference)->node.type_specifier.token = CONST; } -#line 3169 "cod.tab.c" +#line 3039 "cod.tab.c" break; case 134: /* declarator: pointer direct_declarator */ @@ -3181,7 +3051,7 @@ yyparse (void) cod_print((yyval.reference)); } } -#line 3185 "cod.tab.c" +#line 3055 "cod.tab.c" break; case 135: /* direct_declarator: identifier_ref */ @@ -3195,7 +3065,7 @@ yyparse (void) (yyval.reference)->node.declaration.is_subroutine = 0; (yyval.reference)->node.declaration.params = NULL; } -#line 3199 "cod.tab.c" +#line 3069 "cod.tab.c" break; case 136: /* direct_declarator: LPAREN declarator RPAREN */ @@ -3203,7 +3073,7 @@ yyparse (void) { (yyval.reference) = (yyvsp[-1].reference); } -#line 3207 "cod.tab.c" +#line 3077 "cod.tab.c" break; case 137: /* direct_declarator: identifier_ref LPAREN parameter_type_list RPAREN */ @@ -3217,7 +3087,7 @@ yyparse (void) (yyval.reference)->node.declaration.is_subroutine = 1; (yyval.reference)->node.declaration.params = (yyvsp[-1].list); } -#line 3221 "cod.tab.c" +#line 3091 "cod.tab.c" break; case 138: /* direct_declarator: identifier_ref LPAREN RPAREN */ @@ -3231,7 +3101,7 @@ yyparse (void) (yyval.reference)->node.declaration.is_subroutine = 1; (yyval.reference)->node.declaration.params = NULL; } -#line 3235 "cod.tab.c" +#line 3105 "cod.tab.c" break; case 139: /* direct_declarator: direct_declarator LBRACKET constant_expression RBRACKET */ @@ -3243,7 +3113,7 @@ yyparse (void) (yyval.reference)->node.array_type_decl.element_ref = (yyvsp[-3].reference); (yyval.reference)->node.array_type_decl.sm_dynamic_size = NULL; } -#line 3247 "cod.tab.c" +#line 3117 "cod.tab.c" break; case 140: /* direct_declarator: direct_declarator LBRACKET RBRACKET */ @@ -3255,7 +3125,7 @@ yyparse (void) (yyval.reference)->node.array_type_decl.element_ref = (yyvsp[-2].reference); (yyval.reference)->node.array_type_decl.sm_dynamic_size = NULL; } -#line 3259 "cod.tab.c" +#line 3129 "cod.tab.c" break; case 141: /* pointer: STAR */ @@ -3268,7 +3138,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = NULL; } -#line 3272 "cod.tab.c" +#line 3142 "cod.tab.c" break; case 142: /* pointer: STAR type_qualifier_list */ @@ -3281,7 +3151,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[0].list); } -#line 3285 "cod.tab.c" +#line 3155 "cod.tab.c" break; case 143: /* pointer: STAR pointer */ @@ -3294,7 +3164,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[0].list); } -#line 3298 "cod.tab.c" +#line 3168 "cod.tab.c" break; case 144: /* pointer: STAR type_qualifier_list pointer */ @@ -3313,7 +3183,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[-1].list); } -#line 3317 "cod.tab.c" +#line 3187 "cod.tab.c" break; case 145: /* pointer: AT */ @@ -3329,7 +3199,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = NULL; } -#line 3333 "cod.tab.c" +#line 3203 "cod.tab.c" break; case 146: /* pointer: AT type_qualifier_list */ @@ -3345,7 +3215,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[0].list); } -#line 3349 "cod.tab.c" +#line 3219 "cod.tab.c" break; case 147: /* pointer: AT pointer */ @@ -3361,7 +3231,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[0].list); } -#line 3365 "cod.tab.c" +#line 3235 "cod.tab.c" break; case 148: /* pointer: AT type_qualifier_list pointer */ @@ -3383,7 +3253,7 @@ yyparse (void) (yyval.list)->node = star; (yyval.list)->next = (yyvsp[-1].list); } -#line 3387 "cod.tab.c" +#line 3257 "cod.tab.c" break; case 149: /* type_qualifier_list: type_qualifier */ @@ -3393,7 +3263,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3397 "cod.tab.c" +#line 3267 "cod.tab.c" break; case 150: /* type_qualifier_list: type_qualifier_list type_qualifier */ @@ -3408,7 +3278,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-1].list); } -#line 3412 "cod.tab.c" +#line 3282 "cod.tab.c" break; case 152: /* parameter_type_list: parameter_list COMMA DOTDOTDOT */ @@ -3425,7 +3295,7 @@ yyparse (void) id->node.declaration.id = strdup("..."); (yyval.list) = (yyvsp[-2].list); } -#line 3429 "cod.tab.c" +#line 3299 "cod.tab.c" break; case 153: /* parameter_list: parameter_declaration */ @@ -3435,7 +3305,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3439 "cod.tab.c" +#line 3309 "cod.tab.c" break; case 154: /* parameter_list: parameter_list COMMA parameter_declaration */ @@ -3450,7 +3320,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-2].list); } -#line 3454 "cod.tab.c" +#line 3324 "cod.tab.c" break; case 155: /* parameter_declaration: declaration_specifiers */ @@ -3464,7 +3334,7 @@ yyparse (void) (yyval.reference)->node.declaration.params = NULL; (yyval.reference)->node.declaration.type_spec = (yyvsp[0].list); } -#line 3468 "cod.tab.c" +#line 3338 "cod.tab.c" break; case 156: /* parameter_declaration: declaration_specifiers declarator */ @@ -3506,7 +3376,7 @@ yyparse (void) printf("unexpected node in parameter_declaration"); } } -#line 3510 "cod.tab.c" +#line 3380 "cod.tab.c" break; case 158: /* type_name: specifier_qualifier_list abstract_declarator */ @@ -3519,7 +3389,7 @@ yyparse (void) tmp->next = (yyvsp[0].list); (yyval.list) = (yyvsp[-1].list); } -#line 3523 "cod.tab.c" +#line 3393 "cod.tab.c" break; case 160: /* initializer: LCURLY initializer_list RCURLY */ @@ -3528,7 +3398,7 @@ yyparse (void) (yyval.reference) = cod_new_initializer_list(); (yyval.reference)->node.initializer_list.initializers = (yyvsp[-1].list); } -#line 3532 "cod.tab.c" +#line 3402 "cod.tab.c" break; case 161: /* initializer: LCURLY initializer_list COMMA RCURLY */ @@ -3537,13 +3407,13 @@ yyparse (void) (yyval.reference) = cod_new_initializer_list(); (yyval.reference)->node.initializer_list.initializers = (yyvsp[-2].list); } -#line 3541 "cod.tab.c" +#line 3411 "cod.tab.c" break; case 162: /* initializer: assignment_expression */ #line 1579 "cod.y" { (yyval.reference) = (yyvsp[0].reference);} -#line 3547 "cod.tab.c" +#line 3417 "cod.tab.c" break; case 163: /* initializer_list: designation initializer */ @@ -3556,7 +3426,7 @@ yyparse (void) (yyval.list)->node = initializer; (yyval.list)->next = NULL; } -#line 3560 "cod.tab.c" +#line 3430 "cod.tab.c" break; case 164: /* initializer_list: initializer */ @@ -3569,7 +3439,7 @@ yyparse (void) (yyval.list)->node = initializer; (yyval.list)->next = NULL; } -#line 3573 "cod.tab.c" +#line 3443 "cod.tab.c" break; case 165: /* initializer_list: initializer_list COMMA designation initializer */ @@ -3587,7 +3457,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-3].list); } -#line 3591 "cod.tab.c" +#line 3461 "cod.tab.c" break; case 166: /* initializer_list: initializer_list COMMA initializer */ @@ -3605,13 +3475,13 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-2].list); } -#line 3609 "cod.tab.c" +#line 3479 "cod.tab.c" break; case 167: /* designation: designator_list ASSIGN */ #line 1630 "cod.y" { (yyval.list) = (yyvsp[-1].list);} -#line 3615 "cod.tab.c" +#line 3485 "cod.tab.c" break; case 168: /* designator_list: designator */ @@ -3621,7 +3491,7 @@ yyparse (void) (yyval.list)->node = (yyvsp[0].reference); (yyval.list)->next = NULL; } -#line 3625 "cod.tab.c" +#line 3495 "cod.tab.c" break; case 169: /* designator_list: designator_list designator */ @@ -3636,7 +3506,7 @@ yyparse (void) tmp->next->next = NULL; (yyval.list) = (yyvsp[-1].list); } -#line 3640 "cod.tab.c" +#line 3510 "cod.tab.c" break; case 170: /* designator: LBRACKET constant_expression RBRACKET */ @@ -3646,7 +3516,7 @@ yyparse (void) (yyval.reference)->node.designator.expression = (yyvsp[-1].reference); (yyval.reference)->node.designator.id = NULL; } -#line 3650 "cod.tab.c" +#line 3520 "cod.tab.c" break; case 171: /* designator: DOT identifier_ref */ @@ -3656,7 +3526,7 @@ yyparse (void) (yyval.reference)->node.designator.expression = NULL; (yyval.reference)->node.designator.id = (yyvsp[0].info).string; } -#line 3660 "cod.tab.c" +#line 3530 "cod.tab.c" break; case 172: /* decls_stmts_list: statement */ @@ -3667,7 +3537,7 @@ yyparse (void) tmp->next = NULL; (yyval.list) = tmp; } -#line 3671 "cod.tab.c" +#line 3541 "cod.tab.c" break; case 173: /* decls_stmts_list: declaration */ @@ -3675,7 +3545,7 @@ yyparse (void) { (yyval.list) = (yyvsp[0].list); } -#line 3679 "cod.tab.c" +#line 3549 "cod.tab.c" break; case 174: /* decls_stmts_list: error SEMI */ @@ -3683,7 +3553,7 @@ yyparse (void) { (yyval.list) = NULL; } -#line 3687 "cod.tab.c" +#line 3557 "cod.tab.c" break; case 175: /* decls_stmts_list: decls_stmts_list statement */ @@ -3694,7 +3564,7 @@ yyparse (void) tmp->next = NULL; (yyval.list) = cod_append_list((yyvsp[-1].list), tmp); } -#line 3698 "cod.tab.c" +#line 3568 "cod.tab.c" break; case 176: /* decls_stmts_list: decls_stmts_list declaration */ @@ -3702,7 +3572,7 @@ yyparse (void) { (yyval.list) = cod_append_list((yyvsp[-1].list), (yyvsp[0].list)); } -#line 3706 "cod.tab.c" +#line 3576 "cod.tab.c" break; case 183: /* labeled_statement: identifier_ref COLON statement */ @@ -3712,7 +3582,7 @@ yyparse (void) (yyval.reference)->node.label_statement.name = (yyvsp[-2].info).string; (yyval.reference)->node.label_statement.statement = (yyvsp[0].reference); } -#line 3716 "cod.tab.c" +#line 3586 "cod.tab.c" break; case 184: /* compound_statement: LCURLY RCURLY */ @@ -3720,7 +3590,7 @@ yyparse (void) { (yyval.reference) = cod_new_compound_statement(); } -#line 3724 "cod.tab.c" +#line 3594 "cod.tab.c" break; case 185: /* compound_statement: LCURLY decls_stmts_list RCURLY */ @@ -3731,13 +3601,13 @@ yyparse (void) (yyval.reference)->node.compound_statement.decls = (yyvsp[-1].list); cod_remove_defined_types(yycontext, count); } -#line 3735 "cod.tab.c" +#line 3605 "cod.tab.c" break; case 186: /* declaration_list: declaration */ #line 1720 "cod.y" { (yyval.list) = (yyvsp[0].list); } -#line 3741 "cod.tab.c" +#line 3611 "cod.tab.c" break; case 187: /* declaration_list: declaration_list declaration */ @@ -3754,7 +3624,7 @@ yyparse (void) (yyval.list) = (yyvsp[-1].list); } } -#line 3758 "cod.tab.c" +#line 3628 "cod.tab.c" break; case 188: /* jump_statement: RETURN_TOKEN expression SEMI */ @@ -3764,7 +3634,7 @@ yyparse (void) (yyval.reference)->node.return_statement.expression = (yyvsp[-1].reference); (yyval.reference)->node.return_statement.lx_srcpos = (yyvsp[-2].info).lx_srcpos; } -#line 3768 "cod.tab.c" +#line 3638 "cod.tab.c" break; case 189: /* jump_statement: RETURN_TOKEN SEMI */ @@ -3774,7 +3644,7 @@ yyparse (void) (yyval.reference)->node.return_statement.expression = NULL; (yyval.reference)->node.return_statement.lx_srcpos = (yyvsp[-1].info).lx_srcpos; } -#line 3778 "cod.tab.c" +#line 3648 "cod.tab.c" break; case 190: /* jump_statement: CONTINUE SEMI */ @@ -3785,7 +3655,7 @@ yyparse (void) (yyval.reference)->node.jump_statement.goto_target = NULL; (yyval.reference)->node.jump_statement.lx_srcpos = (yyvsp[-1].info).lx_srcpos; } -#line 3789 "cod.tab.c" +#line 3659 "cod.tab.c" break; case 191: /* jump_statement: BREAK SEMI */ @@ -3796,7 +3666,7 @@ yyparse (void) (yyval.reference)->node.jump_statement.goto_target = NULL; (yyval.reference)->node.jump_statement.lx_srcpos = (yyvsp[-1].info).lx_srcpos; } -#line 3800 "cod.tab.c" +#line 3670 "cod.tab.c" break; case 192: /* jump_statement: GOTO identifier_ref SEMI */ @@ -3807,7 +3677,7 @@ yyparse (void) (yyval.reference)->node.jump_statement.goto_target = (yyvsp[-1].info).string; (yyval.reference)->node.jump_statement.lx_srcpos = (yyvsp[-2].info).lx_srcpos; } -#line 3811 "cod.tab.c" +#line 3681 "cod.tab.c" break; case 193: /* expression_statement: SEMI */ @@ -3815,7 +3685,7 @@ yyparse (void) { (yyval.reference) = NULL; } -#line 3819 "cod.tab.c" +#line 3689 "cod.tab.c" break; case 194: /* expression_statement: expression SEMI */ @@ -3824,7 +3694,7 @@ yyparse (void) (yyval.reference) = cod_new_expression_statement(); (yyval.reference)->node.expression_statement.expression = (yyvsp[-1].reference); } -#line 3828 "cod.tab.c" +#line 3698 "cod.tab.c" break; case 195: /* selection_statement: IF LPAREN expression RPAREN statement */ @@ -3836,7 +3706,7 @@ yyparse (void) (yyval.reference)->node.selection_statement.then_part = (yyvsp[0].reference); (yyval.reference)->node.selection_statement.else_part = NULL; } -#line 3840 "cod.tab.c" +#line 3710 "cod.tab.c" break; case 196: /* selection_statement: IF LPAREN expression RPAREN statement ELSE statement */ @@ -3848,7 +3718,7 @@ yyparse (void) (yyval.reference)->node.selection_statement.then_part = (yyvsp[-2].reference); (yyval.reference)->node.selection_statement.else_part = (yyvsp[0].reference); } -#line 3852 "cod.tab.c" +#line 3722 "cod.tab.c" break; case 197: /* iteration_statement: FOR LPAREN expression_opt SEMI expression_opt SEMI expression_opt RPAREN statement */ @@ -3861,7 +3731,7 @@ yyparse (void) (yyval.reference)->node.iteration_statement.iter_expr = (yyvsp[-2].reference); (yyval.reference)->node.iteration_statement.statement = (yyvsp[0].reference); } -#line 3865 "cod.tab.c" +#line 3735 "cod.tab.c" break; case 198: /* iteration_statement: WHILE LPAREN expression RPAREN statement */ @@ -3874,7 +3744,7 @@ yyparse (void) (yyval.reference)->node.iteration_statement.iter_expr = NULL; (yyval.reference)->node.iteration_statement.statement = (yyvsp[0].reference); } -#line 3878 "cod.tab.c" +#line 3748 "cod.tab.c" break; case 199: /* iteration_statement: DO statement WHILE LPAREN expression RPAREN SEMI */ @@ -3888,13 +3758,13 @@ yyparse (void) (yyval.reference)->node.iteration_statement.iter_expr = NULL; (yyval.reference)->node.iteration_statement.statement = (yyvsp[-5].reference); } -#line 3892 "cod.tab.c" +#line 3762 "cod.tab.c" break; case 200: /* expression_opt: %empty */ #line 1841 "cod.y" { (yyval.reference) = NULL; } -#line 3898 "cod.tab.c" +#line 3768 "cod.tab.c" break; case 202: /* constant: integer_constant */ @@ -3905,7 +3775,7 @@ yyparse (void) (yyval.reference)->node.constant.const_val = (yyvsp[0].info).string; (yyval.reference)->node.constant.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 3909 "cod.tab.c" +#line 3779 "cod.tab.c" break; case 203: /* constant: floating_constant */ @@ -3916,7 +3786,7 @@ yyparse (void) (yyval.reference)->node.constant.const_val = (yyvsp[0].info).string; (yyval.reference)->node.constant.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 3920 "cod.tab.c" +#line 3790 "cod.tab.c" break; case 204: /* constant: string_constant */ @@ -3927,7 +3797,7 @@ yyparse (void) (yyval.reference)->node.constant.const_val = (yyvsp[0].info).string; (yyval.reference)->node.constant.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 3931 "cod.tab.c" +#line 3801 "cod.tab.c" break; case 205: /* constant: character_constant */ @@ -3938,7 +3808,7 @@ yyparse (void) (yyval.reference)->node.constant.const_val = (yyvsp[0].info).string; (yyval.reference)->node.constant.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 3942 "cod.tab.c" +#line 3812 "cod.tab.c" break; case 206: /* constant: enumeration_constant */ @@ -3949,11 +3819,11 @@ yyparse (void) (yyval.reference)->node.constant.const_val = (yyvsp[0].info).string; (yyval.reference)->node.constant.lx_srcpos = (yyvsp[0].info).lx_srcpos; } -#line 3953 "cod.tab.c" +#line 3823 "cod.tab.c" break; -#line 3957 "cod.tab.c" +#line 3827 "cod.tab.c" default: break; } @@ -8715,7 +8585,7 @@ space_to_underscore(char *str){ while(*str != '\0'){ if(isspace(*str)) *str = '_'; - str++; + str++; } } @@ -9000,7 +8870,7 @@ evaluate_constant_return_expr(cod_parse_context context, sm_ref expr, int *free_ *free_result = 1; } else { /* we get an integer result */ - intptr_t left_val = 0, right_val = 0, value; + intptr_t left_val = 0, right_val = 0, value = 0; char str_val[40]; if (expr->node.operator.left) left_val = get_constant_long_value(context, left); @@ -9079,7 +8949,7 @@ evaluate_constant_return_expr(cod_parse_context context, sm_ref expr, int *free_ } ret = cod_new_constant(); ret->node.constant.token = integer_constant; - sprintf(str_val, "%Id", value); + sprintf(str_val, "%zd", value); ret->node.constant.const_val = strdup(str_val); *free_result = 1; } diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h index 9dfb351295..f291f75d49 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.tab.h @@ -1,14 +1,14 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. - This program is free software; you can redistribute it and/or modify + This program 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 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,9 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -33,200 +31,140 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* Tokens. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + +#ifndef YY_YY_COD_TAB_H_INCLUDED +# define YY_YY_COD_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ARROW = 258, - LPAREN = 259, - RPAREN = 260, - LCURLY = 261, - RCURLY = 262, - COLON = 263, - QUESTION = 264, - LBRACKET = 265, - RBRACKET = 266, - DOT = 267, - STAR = 268, - AT = 269, - SLASH = 270, - MODULUS = 271, - PLUS = 272, - MINUS = 273, - TILDE = 274, - LEQ = 275, - LT = 276, - GEQ = 277, - GT = 278, - EQ = 279, - NEQ = 280, - LEFT_SHIFT = 281, - RIGHT_SHIFT = 282, - ASSIGN = 283, - MUL_ASSIGN = 284, - DIV_ASSIGN = 285, - MOD_ASSIGN = 286, - ADD_ASSIGN = 287, - SUB_ASSIGN = 288, - LEFT_ASSIGN = 289, - RIGHT_ASSIGN = 290, - AND_ASSIGN = 291, - XOR_ASSIGN = 292, - OR_ASSIGN = 293, - LOG_OR = 294, - LOG_AND = 295, - ARITH_OR = 296, - ARITH_AND = 297, - ARITH_XOR = 298, - INC_OP = 299, - DEC_OP = 300, - BANG = 301, - SEMI = 302, - IF = 303, - ELSE = 304, - FOR = 305, - DO = 306, - WHILE = 307, - CHAR = 308, - SHORT = 309, - INT = 310, - LONG = 311, - UNSIGNED = 312, - SIGNED = 313, - FLOAT = 314, - DOUBLE = 315, - VOID = 316, - STRING = 317, - STATIC = 318, - EXTERN_TOKEN = 319, - STRUCT = 320, - ENUM = 321, - UNION = 322, - CONST = 323, - SIZEOF = 324, - TYPEDEF = 325, - RETURN_TOKEN = 326, - CONTINUE = 327, - BREAK = 328, - GOTO = 329, - PRINT = 330, - COMMA = 331, - DOTDOTDOT = 332, - integer_constant = 333, - character_constant = 334, - string_constant = 335, - floating_constant = 336, - identifier_ref = 337, - type_identifier = 338, - enumeration_constant = 339 - }; + enum yytokentype + { + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + ARROW = 258, /* ARROW */ + LPAREN = 259, /* LPAREN */ + RPAREN = 260, /* RPAREN */ + LCURLY = 261, /* LCURLY */ + RCURLY = 262, /* RCURLY */ + COLON = 263, /* COLON */ + QUESTION = 264, /* QUESTION */ + LBRACKET = 265, /* LBRACKET */ + RBRACKET = 266, /* RBRACKET */ + DOT = 267, /* DOT */ + STAR = 268, /* STAR */ + AT = 269, /* AT */ + SLASH = 270, /* SLASH */ + MODULUS = 271, /* MODULUS */ + PLUS = 272, /* PLUS */ + MINUS = 273, /* MINUS */ + TILDE = 274, /* TILDE */ + LEQ = 275, /* LEQ */ + LT = 276, /* LT */ + GEQ = 277, /* GEQ */ + GT = 278, /* GT */ + EQ = 279, /* EQ */ + NEQ = 280, /* NEQ */ + LEFT_SHIFT = 281, /* LEFT_SHIFT */ + RIGHT_SHIFT = 282, /* RIGHT_SHIFT */ + ASSIGN = 283, /* ASSIGN */ + MUL_ASSIGN = 284, /* MUL_ASSIGN */ + DIV_ASSIGN = 285, /* DIV_ASSIGN */ + MOD_ASSIGN = 286, /* MOD_ASSIGN */ + ADD_ASSIGN = 287, /* ADD_ASSIGN */ + SUB_ASSIGN = 288, /* SUB_ASSIGN */ + LEFT_ASSIGN = 289, /* LEFT_ASSIGN */ + RIGHT_ASSIGN = 290, /* RIGHT_ASSIGN */ + AND_ASSIGN = 291, /* AND_ASSIGN */ + XOR_ASSIGN = 292, /* XOR_ASSIGN */ + OR_ASSIGN = 293, /* OR_ASSIGN */ + LOG_OR = 294, /* LOG_OR */ + LOG_AND = 295, /* LOG_AND */ + ARITH_OR = 296, /* ARITH_OR */ + ARITH_AND = 297, /* ARITH_AND */ + ARITH_XOR = 298, /* ARITH_XOR */ + INC_OP = 299, /* INC_OP */ + DEC_OP = 300, /* DEC_OP */ + BANG = 301, /* BANG */ + SEMI = 302, /* SEMI */ + IF = 303, /* IF */ + ELSE = 304, /* ELSE */ + FOR = 305, /* FOR */ + DO = 306, /* DO */ + WHILE = 307, /* WHILE */ + CHAR = 308, /* CHAR */ + SHORT = 309, /* SHORT */ + INT = 310, /* INT */ + LONG = 311, /* LONG */ + UNSIGNED = 312, /* UNSIGNED */ + SIGNED = 313, /* SIGNED */ + FLOAT = 314, /* FLOAT */ + DOUBLE = 315, /* DOUBLE */ + VOID = 316, /* VOID */ + STRING = 317, /* STRING */ + STATIC = 318, /* STATIC */ + EXTERN_TOKEN = 319, /* EXTERN_TOKEN */ + STRUCT = 320, /* STRUCT */ + ENUM = 321, /* ENUM */ + UNION = 322, /* UNION */ + CONST = 323, /* CONST */ + SIZEOF = 324, /* SIZEOF */ + TYPEDEF = 325, /* TYPEDEF */ + RETURN_TOKEN = 326, /* RETURN_TOKEN */ + CONTINUE = 327, /* CONTINUE */ + BREAK = 328, /* BREAK */ + GOTO = 329, /* GOTO */ + PRINT = 330, /* PRINT */ + COMMA = 331, /* COMMA */ + DOTDOTDOT = 332, /* DOTDOTDOT */ + integer_constant = 333, /* integer_constant */ + character_constant = 334, /* character_constant */ + string_constant = 335, /* string_constant */ + floating_constant = 336, /* floating_constant */ + identifier_ref = 337, /* identifier_ref */ + type_identifier = 338, /* type_identifier */ + enumeration_constant = 339 /* enumeration_constant */ + }; + typedef enum yytokentype yytoken_kind_t; #endif -/* Tokens. */ -#define ARROW 258 -#define LPAREN 259 -#define RPAREN 260 -#define LCURLY 261 -#define RCURLY 262 -#define COLON 263 -#define QUESTION 264 -#define LBRACKET 265 -#define RBRACKET 266 -#define DOT 267 -#define STAR 268 -#define AT 269 -#define SLASH 270 -#define MODULUS 271 -#define PLUS 272 -#define MINUS 273 -#define TILDE 274 -#define LEQ 275 -#define LT 276 -#define GEQ 277 -#define GT 278 -#define EQ 279 -#define NEQ 280 -#define LEFT_SHIFT 281 -#define RIGHT_SHIFT 282 -#define ASSIGN 283 -#define MUL_ASSIGN 284 -#define DIV_ASSIGN 285 -#define MOD_ASSIGN 286 -#define ADD_ASSIGN 287 -#define SUB_ASSIGN 288 -#define LEFT_ASSIGN 289 -#define RIGHT_ASSIGN 290 -#define AND_ASSIGN 291 -#define XOR_ASSIGN 292 -#define OR_ASSIGN 293 -#define LOG_OR 294 -#define LOG_AND 295 -#define ARITH_OR 296 -#define ARITH_AND 297 -#define ARITH_XOR 298 -#define INC_OP 299 -#define DEC_OP 300 -#define BANG 301 -#define SEMI 302 -#define IF 303 -#define ELSE 304 -#define FOR 305 -#define DO 306 -#define WHILE 307 -#define CHAR 308 -#define SHORT 309 -#define INT 310 -#define LONG 311 -#define UNSIGNED 312 -#define SIGNED 313 -#define FLOAT 314 -#define DOUBLE 315 -#define VOID 316 -#define STRING 317 -#define STATIC 318 -#define EXTERN_TOKEN 319 -#define STRUCT 320 -#define ENUM 321 -#define UNION 322 -#define CONST 323 -#define SIZEOF 324 -#define TYPEDEF 325 -#define RETURN_TOKEN 326 -#define CONTINUE 327 -#define BREAK 328 -#define GOTO 329 -#define PRINT 330 -#define COMMA 331 -#define DOTDOTDOT 332 -#define integer_constant 333 -#define character_constant 334 -#define string_constant 335 -#define floating_constant 336 -#define identifier_ref 337 -#define type_identifier 338 -#define enumeration_constant 339 - - - +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 187 "cod/cod.y" +union YYSTYPE { +#line 201 "cod.y" + lx_info info; sm_ref reference; operator_t operator; sm_list list; char *string; -} -/* Line 1529 of yacc.c. */ -#line 225 "/Users/eisen/prog/ffs/build/cod.tab.h" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 + +#line 156 "cod.tab.h" + +}; +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 #endif + extern YYSTYPE yylval; + +int yyparse (void); + + +#endif /* !YY_YY_COD_TAB_H_INCLUDED */ diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y index 264b112904..3d99807dcb 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/cod.y @@ -6447,7 +6447,7 @@ space_to_underscore(char *str){ while(*str != '\0'){ if(isspace(*str)) *str = '_'; - str++; + str++; } } @@ -6732,7 +6732,7 @@ evaluate_constant_return_expr(cod_parse_context context, sm_ref expr, int *free_ *free_result = 1; } else { /* we get an integer result */ - intptr_t left_val = 0, right_val = 0, value; + intptr_t left_val = 0, right_val = 0, value = 0; char str_val[40]; if (expr->node.operator.left) left_val = get_constant_long_value(context, left); @@ -6811,7 +6811,7 @@ evaluate_constant_return_expr(cod_parse_context context, sm_ref expr, int *free_ } ret = cod_new_constant(); ret->node.constant.token = integer_constant; - sprintf(str_val, "%Id", value); + sprintf(str_val, "%zd", value); ret->node.constant.const_val = strdup(str_val); *free_result = 1; } diff --git a/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c b/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c index 100cc2fc18..0daf24e1f1 100644 --- a/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c +++ b/thirdparty/ffs/ffs/cod/pregen_source/Windows/lex.yy.c @@ -2728,70 +2728,9 @@ yywrap YY_PROTO(( void )) } -#ifndef input /* flex, not lex */ void yy_delete_buffer YY_PROTO((YY_BUFFER_STATE b)); -#ifdef WINNT -/* old Windows code for MKS Toolkit version of flex */ - -static void -terminate_string_parse() -{ - yyrestart(NULL); -} - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -static char* current_input_string; - -int my_yy_input(buf,result,max_size) { - - if (current_input_string == NULL) - { - - result = 0; - } - else - if (max_size < strlen(current_input_string)) - { - memcpy((void*)buf, current_input_string, max_size); - current_input_string += max_size; - result = max_size; - } else { - int n = strlen(current_input_string); - memcpy((void*)buf, current_input_string, n+1); - current_input_string = NULL; - result = n; - } - -/* printf("my_yy_input buf[%s],result[%d]\n",buf,result);*/ - return result; -} - -static void -setup_for_string_parse(string, defined_types, enum_constants) -const char *string; -char **defined_types; -char **enum_constants; -{ - type_count = defined_type_count; - types = defined_types; - enums = enum_constants; - - current_input_string = string; - lex_offset = 1; - line_count = 1; -} -#else static YY_BUFFER_STATE bb = NULL; @@ -2824,6 +2763,4 @@ terminate_string_parse() } } -#endif -#endif diff --git a/thirdparty/ffs/ffs/cod/standard.c b/thirdparty/ffs/ffs/cod/standard.c index 2735741153..df9c7145dd 100644 --- a/thirdparty/ffs/ffs/cod/standard.c +++ b/thirdparty/ffs/ffs/cod/standard.c @@ -199,6 +199,10 @@ typedef struct timeval { long tv_usec; } timeval; #endif +typedef struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of DST correction */ +} timezone; int gettimeofday(struct timeval* tp, struct timezone* tzp) { @@ -464,7 +468,7 @@ cod_add_standard_elements(cod_parse_context context) } #endif /* LINUX_KERNEL_MODULE */ -#if NO_DYNAMIC_LINKING +#if defined(NO_DYNAMIC_LINKING) && !defined(_MSC_VER) #define sym(x) (void*)(intptr_t)x #else #define sym(x) (void*)0 diff --git a/thirdparty/ffs/ffs/cod/tests/CMakeLists.txt b/thirdparty/ffs/ffs/cod/tests/CMakeLists.txt index 7da5c38893..2ade40f9da 100644 --- a/thirdparty/ffs/ffs/cod/tests/CMakeLists.txt +++ b/thirdparty/ffs/ffs/cod/tests/CMakeLists.txt @@ -15,7 +15,10 @@ foreach (TEST ${TESTS} ) TARGET_LINK_LIBRARIES(${TEST} ${ATL_LIBRARIES} ) ADD_TEST(NAME ${TEST} COMMAND ${TEST}) endforeach() -SET_SOURCE_FILES_PROPERTIES(general.c PROPERTIES COMPILE_FLAGS -O0) + +if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET_SOURCE_FILES_PROPERTIES(general.c PROPERTIES COMPILE_FLAGS -O0) +endif() set_tests_properties (t2 PROPERTIES PASS_REGULAR_EXPRESSION "Expect -> .values are is 5, 3.14159, hello!. diff --git a/thirdparty/ffs/ffs/cod/tests/general.ops b/thirdparty/ffs/ffs/cod/tests/general.ops index a3a2d588f7..5f5570fedf 100644 --- a/thirdparty/ffs/ffs/cod/tests/general.ops +++ b/thirdparty/ffs/ffs/cod/tests/general.ops @@ -906,6 +906,7 @@ EOF $cnt = $cnt + 3; } } + print COUT " (void) rand1_p;\n (void) rand2_p;\n"; foreach $dr_type (split(' ', "f d c s i l uc us u ul")) { $rand_type = $rand_types{$dr_type}; $c_type = $c_types{$dr_type}; diff --git a/thirdparty/ffs/ffs/cod/tests/t1.c b/thirdparty/ffs/ffs/cod/tests/t1.c index 194d005822..8307f6a369 100644 --- a/thirdparty/ffs/ffs/cod/tests/t1.c +++ b/thirdparty/ffs/ffs/cod/tests/t1.c @@ -223,7 +223,7 @@ main(int argc, char**argv) str.j = 4; str.k = 10; str.l = 3; - long tmp = func(EC_param1 param); + (void) func(EC_param1 param); assert(func(EC_param1 param) == 90); cod_exec_context_free(ec); cod_code_free(gen_code); diff --git a/thirdparty/ffs/ffs/ffs/ffs.c b/thirdparty/ffs/ffs/ffs/ffs.c index 2bc61274c8..4b1f0e85f6 100755 --- a/thirdparty/ffs/ffs/ffs/ffs.c +++ b/thirdparty/ffs/ffs/ffs/ffs.c @@ -1563,6 +1563,8 @@ add_to_tmp_buffer(FFSBuffer buf, size_t size) } #if SIZEOF_LONG != 8 +#ifndef WORDS_BIGENDIAN + static int words_bigendian = -1; static int @@ -1577,7 +1579,6 @@ set_bigendian () { words_bigendian = (u.c[sizeof (long) - 1] == 1); return words_bigendian; } -#ifndef WORDS_BIGENDIAN #define WORDS_BIGENDIAN ((words_bigendian == -1) ? set_bigendian() : words_bigendian) #endif #endif diff --git a/thirdparty/ffs/ffs/ffs/ffs.h.in b/thirdparty/ffs/ffs/ffs/ffs.h.in index 3708464633..21640793cc 100644 --- a/thirdparty/ffs/ffs/ffs/ffs.h.in +++ b/thirdparty/ffs/ffs/ffs/ffs.h.in @@ -51,13 +51,13 @@ typedef struct _FFSTypeHandle *FFSTypeHandle; typedef struct _FFSIndexItem *FFSIndexItem; #define create_FFSContext() create_FFSContext_FM(NULL) -extern FFS_DECLSPEC FFSContext create_FFSContext_FM(FMContext fmc); +extern FFSContext create_FFSContext_FM(FMContext fmc); -extern FFS_DECLSPEC FFSBuffer create_FFSBuffer(); -extern FFS_DECLSPEC FFSBuffer create_fixed_FFSBuffer(char *buffer, size_t size); -extern FFS_DECLSPEC void free_FFSBuffer(FFSBuffer buf); +extern FFSBuffer create_FFSBuffer(); +extern FFSBuffer create_fixed_FFSBuffer(char *buffer, size_t size); +extern void free_FFSBuffer(FFSBuffer buf); -extern FFS_DECLSPEC char * +extern char * FFSencode(FFSBuffer b, FMFormat ioformat, void *data, size_t *buf_size); typedef struct FFSEncodeVec { @@ -65,133 +65,133 @@ typedef struct FFSEncodeVec { @UIO_SIZE_T_TYPE@ iov_len; } *FFSEncodeVector; -extern FFS_DECLSPEC FFSEncodeVector +extern FFSEncodeVector FFSencode_vector(FFSBuffer b, FMFormat fmformat, void *data); -extern FFS_DECLSPEC char * +extern char * FFSencode_no_leaf_copy(FFSBuffer b, FMFormat fmformat, void *data, size_t *buf_size); -extern FFS_DECLSPEC int FFSdecode_in_place_possible(FFSTypeHandle); +extern int FFSdecode_in_place_possible(FFSTypeHandle); -extern FFS_DECLSPEC FFSTypeHandle FFSTypeHandle_from_encode(FFSContext c, char *b); +extern FFSTypeHandle FFSTypeHandle_from_encode(FFSContext c, char *b); -extern FFS_DECLSPEC FFSTypeHandle FFSTypeHandle_by_index(FFSContext c, int index); +extern FFSTypeHandle FFSTypeHandle_by_index(FFSContext c, int index); -extern FFS_DECLSPEC char * FFSTypeHandle_name(FFSTypeHandle f); +extern char * FFSTypeHandle_name(FFSTypeHandle f); -extern FFS_DECLSPEC void +extern void establish_conversion(FFSContext c, FFSTypeHandle f, FMStructDescList struct_list); -extern FFS_DECLSPEC int +extern int FFShas_conversion(FFSTypeHandle format); -extern FFS_DECLSPEC size_t +extern size_t FFS_est_decode_length(FFSContext context, char *encoded, size_t record_length); -extern FFS_DECLSPEC int +extern int FFSdecode_in_place(FFSContext context, char *encode, void **dest_ptr); -extern FFS_DECLSPEC int +extern int FFSdecode_to_buffer(FFSContext context, char *encode, void *dest); -extern FFS_DECLSPEC int +extern int FFSdecode(FFSContext context, char *encode, char *dest); -extern FFS_DECLSPEC FFSTypeHandle +extern FFSTypeHandle FFSset_fixed_target(FFSContext c, FMStructDescList struct_list); -extern FFS_DECLSPEC FFSTypeHandle +extern FFSTypeHandle FFS_target_from_encode(FFSContext c, char *data); -extern FFS_DECLSPEC FMFormat +extern FMFormat FMFormat_of_original(FFSTypeHandle h); -extern FFS_DECLSPEC FFSEncodeVector +extern FFSEncodeVector copy_all_to_FFSBuffer(FFSBuffer buf, FFSEncodeVector vec); -extern FFS_DECLSPEC FFSEncodeVector +extern FFSEncodeVector copy_vector_to_FFSBuffer(FFSBuffer buf, FFSEncodeVector vec); -extern FFS_DECLSPEC FMContext +extern FMContext FMContext_from_FFS(FFSContext c); -extern FFS_DECLSPEC void +extern void free_FFSContext(FFSContext c); -extern FFS_DECLSPEC FMStructDescList +extern FMStructDescList get_localized_formats(FMFormat f); /* file interface follows*/ -extern FFS_DECLSPEC FFSFile +extern FFSFile open_FFSfile(const char *path, const char *flags); -extern FFS_DECLSPEC FFSFile +extern FFSFile open_FFSfd(void *fd, const char *flags); -extern FFS_DECLSPEC void +extern void close_FFSfile(FFSFile file); -extern FFS_DECLSPEC void +extern void free_FFSfile(FFSFile file); -extern FFS_DECLSPEC int +extern int write_FFSfile(FFSFile f, FMFormat format, void *data); -extern FFS_DECLSPEC int +extern int write_FFSfile_attrs(FFSFile f, FMFormat format, void *data, attr_list attrs); -extern FFS_DECLSPEC int +extern int write_comment_FFSfile(FFSFile f, const char *comment); -extern FFS_DECLSPEC size_t +extern size_t FFSfile_next_decode_length(FFSFile iofile); typedef enum { FFSerror=1, FFSend=2, FFSdata=4, FFSformat=8, FFScomment=16, FFSindex=32 } FFSRecordType; -extern FFS_DECLSPEC void +extern void FFSset_visible(FFSFile ffsfile, int bitmap); -extern FFS_DECLSPEC FFSRecordType +extern FFSRecordType FFSnext_record_type(FFSFile ffsfile); -extern FFS_DECLSPEC size_t +extern size_t FFSnext_data_length(FFSFile file); -extern FFS_DECLSPEC FFSTypeHandle +extern FFSTypeHandle FFSnext_type_handle(FFSFile ffsfile); -extern FFS_DECLSPEC char * +extern char * FFSread_comment(FFSFile ffsfile); -extern FFS_DECLSPEC int +extern int FFSread(FFSFile ffsfile, void *dest); -extern FFS_DECLSPEC int +extern int FFSread_attr(FFSFile file, void *dest, attr_list *attr); -extern FFS_DECLSPEC int +extern int FFSread_to_buffer(FFSFile file, FFSBuffer b, void **dest); -extern FFS_DECLSPEC attr_list +extern attr_list FFSattrs_from_last_read(FFSFile file); -extern FFS_DECLSPEC FFSTypeHandle +extern FFSTypeHandle FFSread_format(FFSFile ffsfile); -extern FFS_DECLSPEC FFSIndexItem +extern FFSIndexItem FFSread_index(FFSFile ffsfile); -extern FFS_DECLSPEC FFSContext +extern FFSContext FFSContext_of_file(FFSFile f); -extern FFS_DECLSPEC FMContext +extern FMContext FMContext_of_file(FFSFile f); -extern FFS_DECLSPEC int +extern int FFSseek(FFSFile file, int data_item); #if defined(__cplusplus) || defined(c_plusplus) diff --git a/thirdparty/ffs/ffs/fm/fm.h b/thirdparty/ffs/ffs/fm/fm.h index cba86f288a..aa8df30fa7 100755 --- a/thirdparty/ffs/ffs/fm/fm.h +++ b/thirdparty/ffs/ffs/fm/fm.h @@ -9,18 +9,12 @@ extern "C" { typedef struct _FMContextStruct *FMContext; -#if defined(_MSC_VER) && !defined(FFS_SRC) -#define FFS_DECLSPEC __declspec(dllimport) -#else -#define FFS_DECLSPEC -#endif - -extern FFS_DECLSPEC FMContext create_FMcontext(); -extern FFS_DECLSPEC FMContext create_local_FMcontext(); -extern FFS_DECLSPEC void free_FMcontext(FMContext c); -extern FFS_DECLSPEC void add_ref_FMcontext(FMContext c); -extern FFS_DECLSPEC void FMcontext_allow_self_formats(FMContext fmc); -extern FFS_DECLSPEC int +extern FMContext create_FMcontext(); +extern FMContext create_local_FMcontext(); +extern void free_FMcontext(FMContext c); +extern void add_ref_FMcontext(FMContext c); +extern void FMcontext_allow_self_formats(FMContext fmc); +extern int FMcontext_get_format_server_identifier(FMContext fmc); @@ -85,19 +79,19 @@ typedef enum { typedef struct _FMFormatBody *FMFormatBodyPtr; typedef FMFormatBodyPtr FMFormat; -extern FFS_DECLSPEC char * +extern char * get_server_rep_FMformat(FMFormat ioformat, int *rep_length); -extern FFS_DECLSPEC char * +extern char * get_server_ID_FMformat(FMFormat ioformat, int *id_length); -extern FFS_DECLSPEC FMContext +extern FMContext FMContext_from_FMformat(FMFormat ioformat); -extern FFS_DECLSPEC int +extern int get_rep_len_format_ID(void *format_ID); -extern FFS_DECLSPEC void +extern void set_array_order_FMContext(FMContext iofile, int column_major); FMFormat @@ -109,23 +103,23 @@ FMformat_index(FMFormat f); FMFormat FMformat_by_index(FMContext c, int index); -extern FFS_DECLSPEC FMFormat +extern FMFormat load_external_format_FMcontext(FMContext iocontext, char *server_id, int id_size, char *server_rep); -extern FFS_DECLSPEC void +extern void add_opt_info_FMformat(FMFormat format, int typ, int len, void *block); -extern FFS_DECLSPEC FMFormat +extern FMFormat FMregister_simple_format(FMContext context, char *format_name, FMFieldList field_list, int struct_size); -extern FFS_DECLSPEC FMFormat +extern FMFormat register_data_format(FMContext context, FMStructDescList struct_list); -extern FFS_DECLSPEC FMFormat +extern FMFormat FMregister_data_format(FMContext context, FMStructDescList struct_list); -extern FFS_DECLSPEC void free_FMfield_list(FMFieldList list); +extern void free_FMfield_list(FMFieldList list); /*! * lookup the FMFormat associated with a particular FMStructDescList @@ -148,7 +142,7 @@ extern FFS_DECLSPEC void free_FMfield_list(FMFieldList list); * address. Normally if you use static format lists, the addresses will * be unique. */ -extern FFS_DECLSPEC FMFormat +extern FMFormat FMlookup_format(FMContext context, FMStructDescList struct_list); typedef enum {Format_Less, Format_Greater, Format_Equal, @@ -161,125 +155,125 @@ typedef struct compat_formats { char *xform_code; } *FMcompat_formats; -extern FFS_DECLSPEC FMcompat_formats +extern FMcompat_formats FMget_compat_formats(FMFormat ioformat); -extern FFS_DECLSPEC char * +extern char * name_of_FMformat(FMFormat format); -extern FFS_DECLSPEC FMStructDescList +extern FMStructDescList format_list_of_FMFormat(FMFormat format); -extern FFS_DECLSPEC void +extern void FMlocalize_structs(FMStructDescList list); -extern FFS_DECLSPEC char * +extern char * global_name_of_FMFormat(FMFormat format); -extern FFS_DECLSPEC FMFieldList +extern FMFieldList copy_field_list(FMFieldList list); -extern FFS_DECLSPEC FMStructDescList +extern FMStructDescList FMcopy_struct_list(FMStructDescList list); -extern FFS_DECLSPEC void +extern void FMfree_struct_list(FMStructDescList list); -extern FFS_DECLSPEC int +extern int FMstruct_size_field_list(FMFieldList list, int pointer_size); -extern FFS_DECLSPEC FMStructDescList +extern FMStructDescList FMlocalize_formats(FMStructDescList list); -extern FFS_DECLSPEC int +extern int count_FMfield(FMFieldList list); -extern FFS_DECLSPEC void print_server_ID(unsigned char *ID); -extern FFS_DECLSPEC void print_format_ID(FMFormat ioformat); -extern FFS_DECLSPEC void fprint_server_ID(void * file,unsigned char *ID); +extern void print_server_ID(unsigned char *ID); +extern void print_format_ID(FMFormat ioformat); +extern void fprint_server_ID(void * file,unsigned char *ID); -extern FFS_DECLSPEC int FMformatID_len(char *buffer); +extern int FMformatID_len(char *buffer); -extern FFS_DECLSPEC int +extern int FMdump_data(FMFormat format, void *data, int character_limit); -extern FFS_DECLSPEC int +extern int FMdump_encoded_data(FMFormat format, void *data, int character_limit); -extern FFS_DECLSPEC void +extern void FMdump_XML(FMFormat format, void *data, int encoded); -extern FFS_DECLSPEC void +extern void FMdump_encoded_XML(FMContext c, void *data, int character_limit); -extern FFS_DECLSPEC int +extern int FMfdump_data(void *file, FMFormat format, void *data, int character_limit); -extern FFS_DECLSPEC int +extern int FMfdump_encoded_data(void *file, FMFormat format, void *data, int character_limit); -extern FFS_DECLSPEC void +extern void FMfdump_XML(void *file, FMFormat format, void *data, int encoded); -extern FFS_DECLSPEC void +extern void FMfdump_encoded_XML(void *file, FMContext c, void *data, int character_limit); -extern FFS_DECLSPEC char* +extern char* FMunencoded_to_XML_string(FMContext fmcontext, FMFormat format, void *data); -extern FFS_DECLSPEC void +extern void FMfree_var_rec_elements(FMFormat format, void *data); -extern FFS_DECLSPEC char *FMbase_type(const char *field_type); +extern char *FMbase_type(const char *field_type); #define XML_OPT_INFO 0x584D4C20 #define COMPAT_OPT_INFO 0x45564F4C #define COMPAT_OPT_INFO_FMFILE 0x45564F4D typedef struct _FMgetFieldStruct *FMFieldPtr; -extern FFS_DECLSPEC FMFieldPtr get_FMfieldPtrFromList(FMFieldList field_list, +extern FMFieldPtr get_FMfieldPtrFromList(FMFieldList field_list, const char *fieldname); -extern FFS_DECLSPEC void * +extern void * get_FMfieldAddr_by_name(FMFieldList field_list, const char *fieldname, void *data); -extern FFS_DECLSPEC void * +extern void * get_FMPtrField_by_name(FMFieldList field_list, const char *fieldname, void *data, int encode); -extern FFS_DECLSPEC int +extern int set_FMPtrField_by_name(FMFieldList field_list, const char *fieldname, void *data, void *ptr_value); -extern FFS_DECLSPEC int +extern int get_FMfieldInt_by_name(FMFieldList field_list, const char *fieldname, void *data); -extern FFS_DECLSPEC size_t +extern size_t get_FMfieldLong_by_name(FMFieldList field_list, const char *fieldname, void *data); -extern FFS_DECLSPEC void * FMheader_skip(FMContext c, void *data); -extern FFS_DECLSPEC char *get_FMstring_base(FMFieldPtr iofield, void *data, void *string_base); -extern FFS_DECLSPEC void *get_FMFieldAddr(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC void *get_FMaddr (FMFieldPtr iofield, void *data, void *string_base, int encode); -extern FFS_DECLSPEC void *put_FMaddr (FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC float get_FMfloat(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC double get_FMdouble(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC short get_FMshort(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC int get_FMint(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC size_t get_FMlong(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC void get_FMlong8(FMFieldPtr iofield, void *data, unsigned long *low_long, long *high_long); +extern void * FMheader_skip(FMContext c, void *data); +extern char *get_FMstring_base(FMFieldPtr iofield, void *data, void *string_base); +extern void *get_FMFieldAddr(FMFieldPtr iofield, void *data); +extern void *get_FMaddr (FMFieldPtr iofield, void *data, void *string_base, int encode); +extern void *put_FMaddr (FMFieldPtr iofield, void *data); +extern float get_FMfloat(FMFieldPtr iofield, void *data); +extern double get_FMdouble(FMFieldPtr iofield, void *data); +extern short get_FMshort(FMFieldPtr iofield, void *data); +extern int get_FMint(FMFieldPtr iofield, void *data); +extern size_t get_FMlong(FMFieldPtr iofield, void *data); +extern void get_FMlong8(FMFieldPtr iofield, void *data, unsigned long *low_long, long *high_long); #if defined(SIZEOF_LONG_LONG) #if SIZEOF_LONG_LONG != 0 -extern FFS_DECLSPEC long long get_FMlong_long(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC unsigned long long get_FMulong_long(FMFieldPtr iofield, void *data); +extern long long get_FMlong_long(FMFieldPtr iofield, void *data); +extern unsigned long long get_FMulong_long(FMFieldPtr iofield, void *data); #endif #endif #if defined(SIZEOF_LONG_DOUBLE) #if SIZEOF_LONG_DOUBLE != 0 -extern FFS_DECLSPEC long double get_FMlong_double(FMFieldPtr iofield, void *data); +extern long double get_FMlong_double(FMFieldPtr iofield, void *data); #endif #endif -extern FFS_DECLSPEC unsigned short get_FMushort(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC unsigned int get_FMuint(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC size_t get_FMulong(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC int get_FMulong8(FMFieldPtr iofield, void *data, unsigned long *low_long, unsigned long *high_long); -extern FFS_DECLSPEC char *get_FMstring(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC char get_FMchar(FMFieldPtr iofield, void *data); -extern FFS_DECLSPEC int get_FMenum(FMFieldPtr iofield, void *data); +extern unsigned short get_FMushort(FMFieldPtr iofield, void *data); +extern unsigned int get_FMuint(FMFieldPtr iofield, void *data); +extern size_t get_FMulong(FMFieldPtr iofield, void *data); +extern int get_FMulong8(FMFieldPtr iofield, void *data, unsigned long *low_long, unsigned long *high_long); +extern char *get_FMstring(FMFieldPtr iofield, void *data); +extern char get_FMchar(FMFieldPtr iofield, void *data); +extern int get_FMenum(FMFieldPtr iofield, void *data); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/thirdparty/ffs/ffs/fm/fm_dump.c b/thirdparty/ffs/ffs/fm/fm_dump.c index 2c77715be3..8fd7e28d46 100644 --- a/thirdparty/ffs/ffs/fm/fm_dump.c +++ b/thirdparty/ffs/ffs/fm/fm_dump.c @@ -109,6 +109,7 @@ dump_output(dstate s, size_t length_estimate, char *format, ...) } #if SIZEOF_LONG != 8 +#ifndef WORDS_BIGENDIAN static int words_bigendian = -1; static int @@ -123,7 +124,6 @@ set_bigendian () { words_bigendian = (u.c[sizeof (long) - 1] == 1); return words_bigendian; } -#ifndef WORDS_BIGENDIAN #define WORDS_BIGENDIAN ((words_bigendian == -1) ? set_bigendian() : words_bigendian) #endif #endif diff --git a/thirdparty/ffs/ffs/fm/io_interface.h b/thirdparty/ffs/ffs/fm/io_interface.h index e0f635bdec..d17200cfad 100644 --- a/thirdparty/ffs/ffs/fm/io_interface.h +++ b/thirdparty/ffs/ffs/fm/io_interface.h @@ -1,4 +1,4 @@ -#if defined(HAVE_WINDOWS_H) && !defined(NEED_IOVEC_DEFINE) && !defined(_STRUCT_IOVEC) +#if defined(_MSC_VER) && !defined(_STRUCT_IOVEC) #define _STRUCT_IOVEC struct iovec { const void *iov_base; diff --git a/thirdparty/ffs/ffs/fm/nt_io.c b/thirdparty/ffs/ffs/fm/nt_io.c index c0d047c808..d33155826e 100755 --- a/thirdparty/ffs/ffs/fm/nt_io.c +++ b/thirdparty/ffs/ffs/fm/nt_io.c @@ -82,7 +82,7 @@ char **result_p; (tmp != WSAEINTR)) { /* serious error */ fprintf(stderr, "WINSOCK ERROR during receive, %i on socket %p\n", - tmp, conn); + (int)tmp, conn); return -1; } else { if (tmp == WSAECONNRESET) @@ -110,7 +110,7 @@ char **result_p; /* serious error */ fprintf(stderr, "WINSOCK ERROR during receive2, %i on socket %p\n", - tmp, conn); + (int) tmp, conn); return (length - left); } else { if (tmp == WSAECONNRESET) @@ -141,10 +141,9 @@ char **result_p; while (left > 0) { bResult = WriteFile((HANDLE) conn, (char *) buffer + length - left, - left, &iget, NULL); + left, (unsigned long *)&iget, NULL); if (!bResult) { DWORD tmp = GetLastError(); - if (errno_p) tmp = tmp; if ((tmp != WSAEWOULDBLOCK) && (tmp != WSAEINPROGRESS) && (tmp != WSAEINTR)) { @@ -277,7 +276,7 @@ char **result_p; int i = 0; for (; i < icount; i++) { - if (nt_socket_read_func(conn, iov[i].iov_base, iov[i].iov_len, + if (nt_socket_read_func(conn, (void*)iov[i].iov_base, iov[i].iov_len, errno_p, result_p) != iov[i].iov_len) { return i; } @@ -297,7 +296,7 @@ char **result_p; int i = 0; for (; i < icount; i++) { - if (nt_file_read_func(conn, iov[i].iov_base, iov[i].iov_len, errno_p, + if (nt_file_read_func(conn, (void*)iov[i].iov_base, iov[i].iov_len, errno_p, result_p) != iov[i].iov_len) { return i; } @@ -316,7 +315,7 @@ char** result_p; int i = 0; for (; i < icount; i++) { - if (nt_file_write_func(conn, iov[i].iov_base, iov[i].iov_len, errno_p, + if (nt_file_write_func(conn, (void*)iov[i].iov_base, iov[i].iov_len, errno_p, result_p) != iov[i].iov_len) { return i; } diff --git a/thirdparty/ffs/ffs/fm/tests/scale_test.c b/thirdparty/ffs/ffs/fm/tests/scale_test.c index 5e06f7f20b..a3190d8c9c 100644 --- a/thirdparty/ffs/ffs/fm/tests/scale_test.c +++ b/thirdparty/ffs/ffs/fm/tests/scale_test.c @@ -41,7 +41,7 @@ main(int argc, char **argv) { FMStructDescRec str_list[5]; - struct timespec start, stop; + struct timespec start = {0,0}, stop = {0,0}; FMContext context; int field_count = 20000; diff --git a/thirdparty/ffs/ffs/scripts/ci/cmake/windows-common.cmake b/thirdparty/ffs/ffs/scripts/ci/cmake/windows-common.cmake index 1b227e5395..d5ab37c858 100644 --- a/thirdparty/ffs/ffs/scripts/ci/cmake/windows-common.cmake +++ b/thirdparty/ffs/ffs/scripts/ci/cmake/windows-common.cmake @@ -4,4 +4,9 @@ string(APPEND dashboard_cache " ") list(APPEND CTEST_UPDATE_NOTES_FILES "${CMAKE_CURRENT_LIST_FILE}") + +# the two lines below shouldn't be necessary, but something wrong with vcpkg maybe +set(ENV{dill_DIR} "${CMAKE_CURRENT_LIST_DIR}/../../../../dill/install/lib/cmake/dill") +set(ENV{atl_DIR} "${CMAKE_CURRENT_LIST_DIR}/../../../../atl/install/lib/cmake/atl") + include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) diff --git a/thirdparty/ffs/ffs/scripts/ci/cmake/windows2022-vs2022-msvc-static.cmake b/thirdparty/ffs/ffs/scripts/ci/cmake/windows2022-vs2022-msvc-static.cmake new file mode 100644 index 0000000000..cdb9e59d4e --- /dev/null +++ b/thirdparty/ffs/ffs/scripts/ci/cmake/windows2022-vs2022-msvc-static.cmake @@ -0,0 +1,8 @@ +# Client maintainer: chuck.atkins@kitware.com + +set(CTEST_CMAKE_GENERATOR "Visual Studio 17 2022") +set(CTEST_CMAKE_GENERATOR_PLATFORM x64) +set(BUILD_SHARED_LIBS off) + +list(APPEND CTEST_UPDATE_NOTES_FILES "${CMAKE_CURRENT_LIST_FILE}") +include(${CMAKE_CURRENT_LIST_DIR}/windows-common.cmake)