Commit df902575 authored by Ben Avison's avatar Ben Avison
Browse files

Tweak TCPIP headers for more GCC friendliness

This is still a long way from being possible to compile with GCC. The main
aim here is to facilitate preprocessing of TCPIPLibs clients so that we can
run `cppcheck` on them.

The problem being addressed is that the GCC preprocessor always looks
preferentially for include files in the same directory as the one that
features the `#include` statement. This means that when

* `machine/limits.h` does `#include <limits.h>`
* `machine/stdarg.h` does `#include <stdarg.h>`
* `sys/signal.h` does `#include <signal.h>`
* `sys/time.h` does `#include <time.h>`

then, rather than including the top-level version of the header, as intended,
GCC ends up in an infinite loop of inclusion.

To deal with this with the minimum of side-effects, the recursive includes
are now conditional on `__GNUC__` bein undefined - except `machine/stdarg.h`
which adds nothing to `stdarg.h` (so it's recommended that where GCC
compatibility is required, it is simply changed to `#include <stdarg.h>`).

Where possible, instances of `#include <machine/limits.h>` within the
TCPIPLibs headers have been prefixed with `#include <limits.h>`, and
similarly for the others. The extra inclusion of the top-level header
should be harmless for Norcroft compilation, but ensures that clients of
those second-tier headers are less likely to need an additional `#include`
of a top-level header in order to enable `cppcheck`.
parent 2a3b7b3f
Pipeline #2413 passed with stages
in 4 minutes and 49 seconds
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __GNUC__
#include <limits.h>
#endif
#define _POSIX2_LINE_MAX 256
......@@ -42,6 +42,7 @@
* helps userland compatability. (struct timeval ifi_lastchange)
*/
#ifndef KERNEL
#include <time.h>
#include <sys/time.h>
#endif
......
......@@ -83,6 +83,7 @@ extern void _rpclib_free(void *);
#ifndef makedev /* ie, we haven't already included it */
#include <sys/types.h>
#endif
#include <time.h>
#include <sys/time.h>
#ifndef __riscos
......
......@@ -23,6 +23,7 @@
*/
#include <rpc/types.h>
#include <time.h>
#include <sys/time.h>
#include <sys/errno.h>
#ifndef __riscos
......
......@@ -88,6 +88,7 @@
/* Machine type dependent parameters. */
#include <machine/param.h>
#include <limits.h>
#include <machine/limits.h>
/*
......
......@@ -47,7 +47,7 @@
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
#endif
#ifdef __riscos
#if defined __riscos && !defined __GNUC__
#include <signal.h>
#endif
#define SIGHUP 1 /* hangup */
......
......@@ -42,7 +42,7 @@
#define _SYS_SYSTM_H_
#include <machine/cpufunc.h>
#include <machine/stdarg.h>
#include <stdarg.h>
#include <sys/callout.h>
/*
......
......@@ -117,7 +117,9 @@ void timevaladd(struct timeval *, struct timeval *);
void timevalfix(struct timeval *);
void timevalsub(struct timeval *, struct timeval *);
#else /* !KERNEL */
#ifndef __GNUC__
#include <time.h>
#endif
#ifndef _POSIX_SOURCE
#include <sys/cdefs.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment