aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/commandqueue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mhmake/src/commandqueue.cpp')
-rw-r--r--tools/mhmake/src/commandqueue.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/mhmake/src/commandqueue.cpp b/tools/mhmake/src/commandqueue.cpp
index 6f3fd4d1a..8ca842362 100644
--- a/tools/mhmake/src/commandqueue.cpp
+++ b/tools/mhmake/src/commandqueue.cpp
@@ -21,7 +21,7 @@
#include "stdafx.h"
#include "commandqueue.h"
-#include "mhmakeparser.h"
+#include "mhmakefileparser.h"
#ifndef WIN32
@@ -64,24 +64,29 @@ commandqueue::commandqueue() :
m_DummyWaitHandle=(mh_pid_t)CreateEvent(NULL,TRUE,FALSE,NULL);
#else
FILE *pFile=fopen("/proc/cpuinfo","r");
- const char *pProc="\nprocessor";
- int cur=1;
+ const char szProc[]="processor";
+ int cur=0;
int NrProcs=0;
while (!feof(pFile))
{
char In=fgetc(pFile);
- if (In==pProc[cur])
+ if (In=='\n')
{
- cur++;
- if (!pProc[cur])
+ cur=0;
+ }
+ else
+ {
+ if (cur<=sizeof(szProc) && In==szProc[cur])
{
+ if (!szProc[cur+1])
+ {
NrProcs++;
- cur=0;
}
}
- else
- cur=0;
+ cur++;
+ }
}
+
m_MaxNrCommandsInParallel=NrProcs;
m_DummyWaitHandle=(mh_pid_t)-1;