Bug 296 - real time scheduler not compiling in MingW
real time scheduler not compiling in MingW
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
pre-release
PC Windows
: P3 major
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-28 07:35 UTC by Gustavo J. A. M. Carneiro
Modified: 2008-09-07 00:27 UTC (History)
0 users

See Also:


Attachments
mingw fix (1.76 KB, patch)
2008-09-06 10:43 UTC, Gustavo J. A. M. Carneiro
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo J. A. M. Carneiro 2008-08-28 07:35:43 UTC
ns-3-dev is currently not compiling on MingW due to the real time scheduler merge:

[261/506] cxx: src\simulator\wall-clock-synchronizer.cc -> build\debug\src\simul
ator\wall-clock-synchronizer_1.o
..\src\simulator\wall-clock-synchronizer.cc:21:19: sched.h: No such file or dire
ctory
..\src\simulator\wall-clock-synchronizer.cc: In constructor `ns3::WallClockSynch
ronizer::WallClockSynchronizer()':
..\src\simulator\wall-clock-synchronizer.cc:59: error: aggregate `ns3::timespec
ts' has incomplete type and cannot be defined
..\src\simulator\wall-clock-synchronizer.cc:60: error: `CLOCK_REALTIME' was not
declared in this scope
..\src\simulator\wall-clock-synchronizer.cc:60: error: `clock_getres' was not de
clared in this scope
..\src\simulator\wall-clock-synchronizer.cc:60: warning: unused variable 'CLOCK_
REALTIME'
..\src\simulator\wall-clock-synchronizer.cc:60: warning: unused variable 'clock_
getres'
..\src\simulator\wall-clock-synchronizer.cc: In member function `void ns3::WallC
lockSynchronizer::NsToTimespec(int64_t, ns3::timespec*)':
..\src\simulator\wall-clock-synchronizer.cc:430: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:431: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc: In member function `uint64_t ns3::W
allClockSynchronizer::TimespecToNs(ns3::timespec*)':
..\src\simulator\wall-clock-synchronizer.cc:445: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:445: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc: In member function `void ns3::WallC
lockSynchronizer::TimespecAdd(ns3::timespec*, ns3::timespec*, ns3::timespec*)':
..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:466: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:468: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.cc:469: error: invalid use of undefined
 type `struct ns3::timespec'
..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s
truct ns3::timespec'
Build failed
 -> task failed (err #129): [bld://P:\ns-3\ns-3-dev\src\simulator\wall-clock-syn
chronizer_1.o]

P:\ns-3\ns-3-dev>
Comment 1 Tom Henderson 2008-08-28 09:09:02 UTC
same problem in os x powerpc:
[262/487] cxx: src/simulator/wall-clock-synchronizer.cc -> build/debug/src/simulator/wall-clock-synchronizer_1.o
../src/simulator/wall-clock-synchronizer.cc: In constructor 'ns3::WallClockSynchronizer::WallClockSynchronizer()':
../src/simulator/wall-clock-synchronizer.cc:60: error: 'CLOCK_REALTIME' was not declared in this scope
../src/simulator/wall-clock-synchronizer.cc:60: error: 'clock_getres' was not declared in this scope
Build failed
 -> task failed (err #129): [bld:///scratch/hg/ns-3-dev/src/simulator/wall-clock-synchronizer_1.o] 
 
Comment 2 Mathieu Lacage 2008-08-28 11:21:13 UTC
same on osX

Comment 3 Craig Dowell 2008-08-28 19:08:13 UTC
works now on cygwin, osx but don't have mingw to test on.  Does mingw not even know what a struct timespec is?


Comment 4 Mathieu Lacage 2008-08-29 11:34:31 UTC
confirm fix on osX intel.
Comment 5 Gustavo J. A. M. Carneiro 2008-09-06 10:43:49 UTC
Created attachment 243 [details]
mingw fix

I have code ready to commit that leaves out the real time simulator components if the include file "<sched.h>" is not available.  OK to commit?
Comment 6 Craig Dowell 2008-09-06 13:40:49 UTC
The file <sched.h> (posix process priority and cpu affiniity) really doesn't have anything to do with this, right?

The important part is that MinGW apparently doesn't know what a timespec is, right?  I'm installing MinGW to see for myself, but if this was the problem, I just checked in some code to not use timespec at all in the case that CLOCK_REALTIME isn't defined.

Please check it for me since I cannot yet.
Comment 7 Gustavo J. A. M. Carneiro 2008-09-06 14:31:47 UTC
[269/533] cxx: src\simulator\wall-clock-synchronizer.cc -> build\debug\src\simul
ator\wall-clock-synchronizer_1.o
..\src\simulator\wall-clock-synchronizer.cc:21:19: sched.h: No such file or dire
ctory
Build failed
 -> task failed (err #129): [bld://P:\ns\ns-3-dev\src\simulator\wall-clock-synch
ronizer_1.o]

About your commit, you can #ifdef out certain methods and the real time scheduler still works?  If so, what is the point of having those methods?
Comment 8 Gustavo J. A. M. Carneiro 2008-09-06 18:00:57 UTC
OK, two more data points:

 1. Removing the #include <sched.h> makes the code compile both in mingw and linux.  Apparently sched.h is only used for some code inside #if 0 ... #endif.

 2. In wall-clock-synchronizer.h you use #ifdef CLOCK_REALTIME.  However, since that header file doesn't include <time.h> won't CLOCK_REALTIME be always undefined (unless by luck whoever includes wall-clock-synchronizer.h had already included time.h first) ?

3. The "#ifdef CLOCK_REALTIME"'ed methods, TimespecToNs and TimespecAdd are protected and currently unused, so I reiterate my suggestion to remove them completely; they are causing portability problems and have no use.
Comment 9 Craig Dowell 2008-09-07 00:27:27 UTC
Removed the high resolution clocks since the expected use case did not materialize.

Verified builds correctly on MinGW-5.1.4