-
Notifications
You must be signed in to change notification settings - Fork 215
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
OSAL "common_types.h" is not completely reliable #24
Comments
Imported from trac issue 1. Created by jphickey on 2014-12-16T21:25:05, last modified: 2015-11-20T16:22:16 |
Trac comment by jphickey on 2014-12-16 21:53:03: Pushed branch "trac-1-common_types-fix" to address these issues |
Trac comment by glimes on 2014-12-17 11:03:43: We can hotlink from tickets to changesets with ![changeset:baa27c0] which gives [changeset:baa27c0]. I wish we could deprecate ALL of the types defined in "common_types.h" in favor of using the ones that were common enough 25 years ago that the standards committee nailed them into INCITS ISO/IEC 9899:1999 (E) "The C Programming Language" Section 7.18 "Integer types" ... |
Trac comment by jphickey on 2014-12-18 16:00:47: Agreed - would be nice to not reinvent the types at all but now you are talking about asking people to run something to the effect of But doing it this way has the advantage of making uint32_t and uint32 interchangeable for the time being, so one day in the future after everyone has moved to the OSAL with this change, we can run that big sed script on CFE/CFS and be done with it. |
Trac comment by glimes on 2015-01-29 14:51:20: Click [changeset:79ca34a here] to see the changeset. |
Trac comment by glimes on 2015-01-29 15:42:04: I have reviewed this change, and recommend ACCEPT with the following minor caveats carried forward.
Any code broken by any of the above effects should be trivial to repair, and I would expect few external projects to see any impact. |
Trac comment by jphickey on 2015-01-30 11:58:57: Greg - Thanks for the feedback -- some good points there. Accepting this change by itself should not have much effect on existing missions //unless// they happen to already define {{{HAVE_STDINT}}} in their build system (unlikely). In the case of an existing build that does //not// define that symbol, the only effective change here is the addition of cpusize, cpussize, and osalbool types. Specifically note that in this case {{{<stdint.h>}}} is also not included because it is inside the conditional, so this reduces the chance of any inadvertent name clash with something else in "stdint.h"; one must explicitly tell their build system to use the stdint.h file before it will be included. One easy thought -- I could change the {{{HAVE_STDINT}}} conditional to be {{{OSAL_HAVE_STDINT}}} to even further reduce the likelihood that this is inadvertently defined in an existing build. Other thoughts on the points you made:
|
Trac comment by mlogan on 2015-01-30 18:02:44: I have reviewed changes per this ticket and ACCEPT as well. I also had concerns about type "boolean" as they are used in LADEE and RP missions code bases. I believe these are mitigated by the developer. |
Trac comment by dheater on 2015-02-03 17:44:49: Could you also define standard int types for systems fail to do so? That would mean that new code could use the standard int types instead of the locally defined ones. |
Trac comment by jphickey on 2015-02-05 13:41:22: FYI - I have done some more testing with the various permutations of compiler toolchains that I have available to me, and I had to make a couple minor changes to this commit. Issue 1: The "size_t" type is not always available via {{{<stdint.h>}}}. It is officially defined in {{{<stddef.h>}}}, so the change is modified to include both stdint.h and stddef.h when compiling with the HAVE_STDINT flag. (On some toolchains you got it implicitly with stdint.h, on others you did not, so this makes it work on all.) Issue 2: The "ssize_t" is actually not in either of those files, but actually in {{{<unistd.h>}}} and/or possibly {{{<stdio.h>}}} (seems to vary). It seems this may also be a POSIX extension that became de-facto standard for read/write calls. The main use-case for the C library "ssize_t" is to support a "-1" error return code for functions that need to return a size when successful (i.e. read/write). However (particularly with trac #35 fixed) the OSAL will not actually need anything like this. The more likely use-case for application code is to express offsets or distance between objects in memory. In this sense I have renamed the type to be "cpudiff" as an alias to the C-standard type "ptrdiff_t" which is defined in {{{<stddef.h>}}} (along with size_t) for this exact purpose. With respect to the earlier comment about aliasing the C99-standard type names to the legacy type names, I like this idea. However my thought would be to just get this changeset merged in first, then I'll add that as another separate commit on top of this. The updated changeset is now [changeset:b70692d] |
Trac comment by glimes on 2015-02-05 16:54:42: I've updated the Change Set link in the wiki page I'm using I have reviewed Joe's updated edits and continue to recommend ACCEPT. Interesting points about |
Trac comment by acudmore on 2015-02-11 14:05:14: I think it is a good idea to move to the standard types.
Can anyone check to see if recent vxWorks has the stdint.h header? If it does, then most of the code should use these standard types. One nit about the comment on 129:
On systems that have stdint, do we have an equivalent of the _STUCT_HIGH/LOW_BIT_FIRST macro? Is that needed anymore? In ospi-os-core.h, does the use of OS_PRINTF bypass the OS_printf function? |
Trac comment by jphickey on 2015-02-11 14:54:34: Alan - I agree with your thoughts on the comment line - it is definitely the TARGET toolchain that needs to have the header. I can fix this up to be clear. Regarding the STRUCT_HIGH_BIT/LOW_BIT_FIRST: My vote is that this is not needed any more and should be deprecated. There is no code that I am aware of that is actually using it. But more importantly, simply knowing the architecture (i.e. ARM or PPC) does not necessarily imply endianness. For sure there are little and big endian variants of ARM architectures. In general we should always prefer code that is endian neutral and make all efforts to have code that will work the same on either type of system. If code MUST be endian-specific, then I prefer to do a runtime check i.e. check which byte is first after storing a uint16 with value "0x0102". If even that is not feasible, then the #define can go in the specific BSP/PSP as a compile-time option. |
Trac comment by glimes on 2015-02-12 14:58:04: Accepted by #41 for integration candidate. |
Trac comment by glimes on 2015-03-04 14:54:06: Confirmed that the fix from [changeset:b70692d] is present in the |
Add extra compile options for mission scope and arch scope. These are separated to support cross compile environments that do not/cannot use the same flags on both builds. For "mission" build the targets are never cross compiled, only built for the native host machine. It should be safe to assume a compiler in the GCC family and the strict warnings should _always_ be applicable here. For "arch" build the options are compiler vendor dependent. The file as-supplied can only be used if all the target cross compilers are in the same family and support the same warning options. However, this file can be modified without affecting the options used for the host side tools.
Add a _custom suffix to differentiate the customization file from the base file in the cmake directory.
Include in the basic warning set. Note that at this time the CFE does not build cleanly on all architectures with this warning enabled, pending resolution of issue nasa#313.
Fix nasa#24, Add compiler option examples
On some systems (particularly 64-bit) the types defined in OSAL "common_types.h" file do not always match their expected widths.
There is currently a very helpful compile-time assert to catch this if it does go wrong but we need it to not go wrong in the first place.
The best way to solve this is to leverage the C "stdint.h" file - this has been standard since C99. For any C library that does not have this header it can fall back to using the existing defines.
The text was updated successfully, but these errors were encountered: