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

remove unused functions in Lib::System #535

Merged
merged 2 commits into from
Mar 14, 2024
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
8 changes: 0 additions & 8 deletions CASC/PortfolioMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,8 @@ void PortfolioMode::runSlice(Options& strategyOpt)
if (env.statistics->terminationReason == Statistics::REFUTATION ||
env.statistics->terminationReason == Statistics::SATISFIABLE) {
resultValue=0;

/*
env.beginOutput();
lineOutput() << " found solution " << endl;
env.endOutput();
*/
}

System::ignoreSIGHUP(); // don't interrupt now, we need to finish printing the proof !

bool outputResult = false;
if (!resultValue) {
// only successfull vampires get here
Expand Down
67 changes: 0 additions & 67 deletions Lib/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
// TODO these should probably be guarded
// for getpid, _exit
#include <unistd.h>
// for listing directory items
// C++17: use std::filesystem
#include <dirent.h>

#ifdef __linux__
#include <sys/prctl.h>
Expand All @@ -49,8 +46,6 @@ namespace Lib {

using namespace std;

bool System::s_shouldIgnoreSIGINT = false;
bool System::s_shouldIgnoreSIGHUP = false;
const char* System::s_argv0 = 0;

const char* signalToString (int sigNum)
Expand Down Expand Up @@ -132,18 +127,12 @@ void handleSignal (int sigNum)
# endif

case SIGINT:
if(System::shouldIgnoreSIGINT()) {
return;
}
haveSigInt=true;
System::terminateImmediately(VAMP_RESULT_STATUS_SIGINT);
// exit(0);
// return;

case SIGHUP:
if(System::shouldIgnoreSIGHUP()) {
return;
}
case SIGILL:
case SIGFPE:
case SIGSEGV:
Expand Down Expand Up @@ -274,15 +263,6 @@ void System::registerForSIGHUPOnParentDeath()
#endif
}

vstring System::extractFileNameFromPath(vstring str)
{
size_t index=str.find_last_of("\\/")+1;
if(index==vstring::npos) {
return str;
}
return vstring(str, index);
}

/**
* If directory name can be extracted from @c path, assign it into
* @c dir and return true; otherwise return false.
Expand All @@ -305,51 +285,4 @@ bool System::fileExists(vstring fname)
return ifile.good();
}

// C++17: use std::filesystem
void System::readDir(vstring dirName, Stack<vstring>& filenames)
{
DIR *dirp;
struct dirent *dp;

static Stack<vstring> todo;
ASS(todo.isEmpty());
todo.push(dirName);

while (todo.isNonEmpty()) {
vstring dir = todo.pop();

dirp = opendir(dir.c_str());

if (!dirp) {
// cout << "Cannot open dir " << dir << endl;
continue;
}

while ((dp = readdir(dirp)) != NULL) {
if (strncmp(dp->d_name, ".", 1) == 0) {
continue;
}
if (strncmp(dp->d_name, "..", 2) == 0) {
continue;
}

switch (dp->d_type) {
case DT_REG:
filenames.push(dir+"/"+dp->d_name);
break;
case DT_DIR:
// cout << "seen dir " << dp->d_name << endl;
todo.push(dir+"/"+dp->d_name);
break;
default:
;
// cout << "weird file type" << endl;
}
}
(void)closedir(dirp);
}

todo.reset();
}

};
18 changes: 0 additions & 18 deletions Lib/System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,14 @@ namespace Lib {
class System {
public:
static void setSignalHandlers();
static vstring extractFileNameFromPath(vstring str);
static bool extractDirNameFromPath(vstring path, vstring& dir);

static void ignoreSIGINT() { s_shouldIgnoreSIGINT=true; }
static void heedSIGINT() { s_shouldIgnoreSIGINT=false; }
static bool shouldIgnoreSIGINT() { return s_shouldIgnoreSIGINT; }

static void ignoreSIGHUP() { s_shouldIgnoreSIGHUP=true; }
static void heedSIGHUP() { s_shouldIgnoreSIGHUP=false; }
static bool shouldIgnoreSIGHUP() { return s_shouldIgnoreSIGHUP; }

static void addTerminationHandler(VoidFunc proc, unsigned priority=0);
static void onTermination();
[[noreturn]] static void terminateImmediately(int resultStatus);

static void registerForSIGHUPOnParentDeath();

/**
* Collect filenames of all the files occurring in the given directory.
* Recursive traverse subdirs.
*/
static void readDir(vstring dirName, Stack<vstring>& filenames);

/**
* Register the value of the argv[0] argument of the main function, so that
* it can be later used to determine the executable directory
Expand All @@ -76,9 +61,6 @@ class System {
*/
static ZIArray<List<VoidFunc>*>& terminationHandlersArray();

static bool s_shouldIgnoreSIGINT;
static bool s_shouldIgnoreSIGHUP;

static const char* s_argv0;
};

Expand Down
7 changes: 7 additions & 0 deletions Shell/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,13 @@ Options::OptionProblemConstraintUP Options::isRandSat(){
* @since 16/10/2003 Manchester, relativeName changed to string from char*
* @since 07/08/2014 Manchester, relativeName changed to vstring
*/
// TODO this behaviour isn't quite right, at least:
// 1. we use the *root* file to resolve relative paths, which won't work if we have an axiom file that includes another
// 2. checks current directory, which spec doesn't ask for
// 3. checks our "-include" option, which isn't in the spec either (OK if someone relies on it, I guess)
// cf https://tptp.org/TPTP/TR/TPTPTR.shtml#IncludeSection
// probable solution: move all this logic into TPTP parser and do it properly there

vstring Options::includeFileName (const vstring& relativeName)
{
if (relativeName[0] == '/') { // absolute name
Expand Down