Skip to content

Commit 83ead1c

Browse files
Alexandre OlivaAlexandre Oliva
authored andcommitted
[vxworks] wrap base/b_NULL.h to override NULL
Some versions of vxworks define NULL to __nullptr in C++, assuming C++11, which breaks at least a number of analyzer tests that get exercised in C++98 mode. Wrap the header that defines NULL so that, after including it, we override the NULL definition with the one provided by stddef.h. That required some infrastructure to enable subdirectories in extra headers. Since USER_H filenames appear as dependencies, that limits the possibilities or markup, so I went for a filesystem-transparent sequence that doesn't appear in any extra_headers whatsoever, namely /././, to mark the beginning of the desired install name. Co-Authored-By: Olivier Hainque <hainque@adacore.com> for gcc/ChangeLog * config/vxworks/base/b_NULL.h: New. * config.gcc (extra_headers) <*-*-vxworks*>: Add it. * Makefile.in (stmp-int-hdrs): Support /././ markers in USER_H to mark the beginning of the install name. Document. * doc/sourcebuild.texi (Headers): Document /././ marker.
1 parent 9ab4d75 commit 83ead1c

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

gcc/Makefile.in

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,9 +3534,10 @@ gcov-tool$(exeext): $(GCOV_TOOL_OBJS) $(LIBDEPS)
35343534
stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_list
35353535
# Copy in the headers provided with gcc.
35363536
#
3537-
# The sed command gets just the last file name component;
3538-
# this is necessary because VPATH could add a dirname.
3539-
# Using basename would be simpler, but some systems don't have it.
3537+
# If the sequence /././ appears somewhere after srcdir in a USER_H
3538+
# name, install the header with the name after the marker, even if
3539+
# that name involves subdirectories. Otherwise, install it as the
3540+
# basename (but some systems don't have the basename program).
35403541
#
35413542
# The touch command is here to workaround an AIX/Linux NFS bug.
35423543
#
@@ -3547,10 +3548,20 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_
35473548
-if [ -d include-fixed ] ; then true; else mkdir include-fixed; chmod a+rx include-fixed; fi
35483549
for file in .. $(USER_H); do \
35493550
if [ X$$file != X.. ]; then \
3550-
realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
3551+
case $$file in \
3552+
"$(srcdir)"*/././*) \
3553+
realfile=`echo $$file | sed -e 's|^.*/\./\./||'`; \
3554+
case $$realfile in \
3555+
*/*) \
3556+
realdir=`echo $$realfile | sed -e 's|/[^/]*$$||'`; \
3557+
$(install_sh) -d include/$$realdir;; \
3558+
esac;; \
3559+
*) \
3560+
realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`;; \
3561+
esac; \
35513562
$(STAMP) include/$$realfile; \
35523563
rm -f include/$$realfile; \
3553-
cp $$file include; \
3564+
cp $$file include/$$realfile; \
35543565
chmod a+r include/$$realfile; \
35553566
fi; \
35563567
done

gcc/config.gcc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,9 @@ case ${target} in
11401140
extra_headers="${extra_headers} ../vxworks/math.h ../vxworks/complex.h"
11411141
extra_headers="${extra_headers} ../vxworks/inttypes.h ../vxworks/setjmp.h"
11421142

1143+
# The /././ sequence marks the beginning of the install name.
1144+
extra_headers="${extra_headers} ../vxworks/././base/b_NULL.h"
1145+
11431146
# We provide (a tailored version of) stdint.h
11441147
tm_file="${tm_file} vxworks-stdint.h"
11451148
use_gcc_stdint=provide

gcc/config/vxworks/base/b_NULL.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* This file is part of GCC.
2+
3+
GCC is free software; you can redistribute it and/or modify it under
4+
the terms of the GNU General Public License as published by the Free
5+
Software Foundation; either version 3, or (at your option) any later
6+
version.
7+
8+
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
9+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11+
for more details.
12+
13+
Under Section 7 of GPL version 3, you are granted additional
14+
permissions described in the GCC Runtime Library Exception, version
15+
3.1, as published by the Free Software Foundation.
16+
17+
You should have received a copy of the GNU General Public License and
18+
a copy of the GCC Runtime Library Exception along with this program;
19+
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
20+
<http://www.gnu.org/licenses/>. */
21+
22+
/* This header wrapper addresses the issue that some versions of VxWorks have
23+
started defining NULL in a way that doesn't work with C++ < 11, so we override
24+
it with GCC's own stddef's NULL. Include the VxWorks version of this header
25+
nevertheless, as it might do other things than defining NULL, and beware that
26+
it usually defines NULL unconditionally without undefining it first, unlike
27+
what stddef.h does. */
28+
29+
#undef NULL
30+
#include_next <base/b_NULL.h>
31+
#define __need_NULL
32+
#include <stddef.h>

gcc/doc/sourcebuild.texi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ In addition to these headers and those generated by fixing system
343343
headers to work with GCC, some other headers may also be installed in
344344
@file{@var{libsubdir}/include}. @file{config.gcc} may set
345345
@code{extra_headers}; this specifies additional headers under
346-
@file{config} to be installed on some systems.
346+
@file{config} to be installed on some systems. They're installed at the
347+
top of the @file{include} tree, unless the optional @samp{/././}
348+
sequence appears in the name, marking the beginning of the name under
349+
which the header should be installed.
347350

348351
GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}.
349352
This is done to cope with command-line options that change the

0 commit comments

Comments
 (0)