Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filesystem operations when unregistering elements #983

Merged
merged 6 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions config/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 15
#serial 18

dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
Expand Down Expand Up @@ -104,9 +104,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
dnl MSVC needs -std:c++NN for C++17 and later (default is C++14)
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
if test x"$switch" = xMSVC; then
dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide
dnl with -std=c++17. We suffix the cache variable name with _MSVC to
dnl avoid this.
switch=-std:c++${alternative}
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC])
else
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
fi
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
Expand All @@ -116,6 +125,10 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
Expand Down Expand Up @@ -1003,4 +1016,3 @@ namespace cxx20
#endif // __cplusplus < 202002L && !defined _MSC_VER

]])

117 changes: 0 additions & 117 deletions config/ax_cxx_compile_stdcxx_04.m4

This file was deleted.

95 changes: 0 additions & 95 deletions config/ax_cxx_compile_stdcxx_14.m4

This file was deleted.

62 changes: 31 additions & 31 deletions config/ax_cxx_compile_stdcxx_17.m4
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# =============================================================================
# Elements://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html
# =============================================================================
# #
# # SYNOPSIS
# #
# # AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional])
# #
# # DESCRIPTION
# #
# # Check for baseline language coverage in the compiler for the C++17
# # standard; if necessary, add switches to CXX and CXXCPP to enable
# # support.
# #
# # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# # macro with the version set to C++17. The two optional arguments are
# # forwarded literally as the second and third argument respectively.
# # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# # more information. If you want to use this macro, you also need to
# # download the ax_cxx_compile_stdcxx.m4 file.
# #
# # LICENSE
# #
# # Copyright (c) 2015 Moritz Klammler <[email protected]>
# # Copyright (c) 2016 Krzesimir Nowak <[email protected]>
# #
# # Copying and distribution of this file, with or without modification, are
# # permitted in any medium without royalty provided the copyright notice
# # and this notice are preserved. This file is offered as-is, without any
# # warranty.
#
# #serial 2
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++17
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++17. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <[email protected]>
# Copyright (c) 2016 Krzesimir Nowak <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 2

AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])])
27 changes: 18 additions & 9 deletions src/sst/core/sstregistertool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,12 @@ sstRegister(char* argv[])
void
sstUnregister(const std::string& element)
{
std::string str1;
std::string s = "";
std::string tempfile;
int found = 0;

// setup element names to look for
str1 = START_DELIMITER + element + STOP_DELIMITER;
tempfile = "/tmp/sstsimulator.conf";
const std::string str1 = START_DELIMITER + element + STOP_DELIMITER;
const auto tempfile = std::tmpnam(nullptr);

std::string s = "";
int found = 0;

std::ifstream infile(cfgPath);
std::ofstream outfile(tempfile);
Expand All @@ -174,11 +172,22 @@ sstUnregister(const std::string& element)

if ( found ) { std::cout << "\tModel " << element << " has been unregistered!\n"; }
else
std::cout << "Model " << element << " not found\n\n";
std::cout << "\tModel " << element << " not found\n\n";

infile.close();
outfile.close();
rename(tempfile.c_str(), cfgPath);

if ( std::remove(cfgPath) != 0 ) {
std::cerr << "\tError removing " << cfgPath << " before moving updated config\n";
return;
}
infile = std::ifstream(tempfile, std::ios::binary);
outfile = std::ofstream(cfgPath, std::ios::binary);
outfile << infile.rdbuf();
if ( std::remove(tempfile) != 0 ) {
std::cerr << "\tError removing " << tempfile << " after moving updated config\n";
return;
}
}

// listModels
Expand Down
Loading