Skip to content

Conversation

thesummer
Copy link
Contributor

We started to use plog in a project which uses multiple OSes among them RTEMS.
The port was pretty straight forward. In case you don't mind supporting RTEMS upstream this commit adds the necessary includes and defnitions for the mutex.

It also fixed a few warnings due to missing defines.

@SergiusTheBest
Copy link
Owner

It looks good. Can you suggest a good guide about setting up a crosscompiler for RTMES so I could add it into the current CI?

@SergiusTheBest SergiusTheBest added this to the 1.1.4 milestone Mar 13, 2018
@thesummer
Copy link
Contributor Author

For building the cross-compiler there is the rtems-source-builder. It does essentially everything for you you can find the quick start tutorial here: https://docs.rtems.org/branches/master/rsb/quick-start.html#
The second step would then be to compile the rtems kernel with the cross-compiler. There is a guide (https://devel.rtems.org/wiki/TBR/UserManual/Quick_Start) which does it for the sparc architecture. It should also enable you to run a test application using a simulated target in gdb.

@@ -24,7 +24,7 @@
# define PLOG_GET_FUNC() __PRETTY_FUNCTION__
#endif

#if PLOG_CAPTURE_FILE
#ifdef PLOG_CAPTURE_FILE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any problem with #if instead of #ifdef on RTEMS? I compiled fine without thease changes (rtems4.11/gcc4.9.3).

Copy link
Contributor Author

@thesummer thesummer Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably because we compile with a quite pedantic compiler setting. I got a "-Wundef" warning during compilation. As far as I see it by default the PLOG_CAPTURE_FILE is not defined by default, so I thought ifdef would be the better choice here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll add -Wundef to the flags.

@@ -18,6 +18,8 @@ namespace plog
m_stdoutHandle = GetStdHandle(stdHandle::kOutput);
}
}
#elif __rtems__
ConsoleAppender() : m_isatty(true) {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using isatty check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you compile rtems without the --enable-posix option then isatty is not available. At least I got an undefined reference. I will check when I am back in the office.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked fine without --enable-posix.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thesummer Could you check that on your setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I investigated a bit further. It appears that in the current setup we have (rtems4.10) the fileno function is not declared in stdio.h.
If I replace m_isatty(!!isatty(fileno(stdout))) with m_isatty(!!isatty(STDOUT_FILENO)) everything works fine.
STDOUT_FILENO is defined in unistd.h

I will have to check if we have a system with rtems4.11 running somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with another setup with rtems4.12 with the fileno version. Everything builds fine.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on 4.11 and it worked with fileno.

Copy link
Contributor Author

@thesummer thesummer Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I removed the change here. We will phase out rtems4.10 soon hopefully and I can have the change locally for the time being.

I also replaced the #elif __rtems__ with #elif defined(__rtems__) as I was getting more undef warnings in Linux with that.

@thesummer thesummer force-pushed the master branch 3 times, most recently from 1037a5b to 9f23fef Compare March 20, 2018 12:38
@SergiusTheBest SergiusTheBest merged commit df2d720 into SergiusTheBest:master Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants