]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[vxworks] wrap base/b_NULL.h to override NULL
authorAlexandre Oliva <oliva@adacore.com>
Thu, 13 Nov 2025 22:54:01 +0000 (19:54 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 13 Nov 2025 22:54:01 +0000 (19:54 -0300)
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.

gcc/Makefile.in
gcc/config.gcc
gcc/config/vxworks/base/b_NULL.h [new file with mode: 0644]
gcc/doc/sourcebuild.texi

index 5c24a9aab00a54ad9182dd4852db06f9cb90ba14..d05e15e2b6ce1a17094fbe0e516147cd2f1442ea 100644 (file)
@@ -3534,9 +3534,10 @@ gcov-tool$(exeext): $(GCOV_TOOL_OBJS) $(LIBDEPS)
 stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_list
 # Copy in the headers provided with gcc.
 #
-# The sed command gets just the last file name component;
-# this is necessary because VPATH could add a dirname.
-# Using basename would be simpler, but some systems don't have it.
+# If the sequence /././ appears somewhere after srcdir in a USER_H
+# name, install the header with the name after the marker, even if
+# that name involves subdirectories.  Otherwise, install it as the
+# basename (but some systems don't have the basename program).
 #
 # The touch command is here to workaround an AIX/Linux NFS bug.
 #
@@ -3547,10 +3548,20 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_
        -if [ -d include-fixed ] ; then true; else mkdir include-fixed; chmod a+rx include-fixed; fi
        for file in .. $(USER_H); do \
          if [ X$$file != X.. ]; then \
-           realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
+           case $$file in \
+             "$(srcdir)"*/././*) \
+               realfile=`echo $$file | sed -e 's|^.*/\./\./||'`; \
+               case $$realfile in \
+                 */*) \
+                   realdir=`echo $$realfile | sed -e 's|/[^/]*$$||'`; \
+                   $(install_sh) -d include/$$realdir;; \
+               esac;; \
+             *) \
+               realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`;; \
+           esac; \
            $(STAMP) include/$$realfile; \
            rm -f include/$$realfile; \
-           cp $$file include; \
+           cp $$file include/$$realfile; \
            chmod a+r include/$$realfile; \
          fi; \
        done
index b0fa43b5eba73a2f6b4eac609f09a2449c2edd2f..d2770ea556b2e4dd8ece4a691f9fac6e45da0f1a 100644 (file)
@@ -1140,6 +1140,9 @@ case ${target} in
   extra_headers="${extra_headers} ../vxworks/math.h ../vxworks/complex.h"
   extra_headers="${extra_headers} ../vxworks/inttypes.h ../vxworks/setjmp.h"
 
+  # The /././ sequence marks the beginning of the install name.
+  extra_headers="${extra_headers} ../vxworks/././base/b_NULL.h"
+
   # We provide (a tailored version of) stdint.h
   tm_file="${tm_file} vxworks-stdint.h"
   use_gcc_stdint=provide
diff --git a/gcc/config/vxworks/base/b_NULL.h b/gcc/config/vxworks/base/b_NULL.h
new file mode 100644 (file)
index 0000000..3d677f9
--- /dev/null
@@ -0,0 +1,32 @@
+/* This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* This header wrapper addresses the issue that some versions of VxWorks have
+   started defining NULL in a way that doesn't work with C++ < 11, so we override
+   it with GCC's own stddef's NULL.  Include the VxWorks version of this header
+   nevertheless, as it might do other things than defining NULL, and beware that
+   it usually defines NULL unconditionally without undefining it first, unlike
+   what stddef.h does.  */
+
+#undef NULL
+#include_next <base/b_NULL.h>
+#define __need_NULL
+#include <stddef.h>
index 29742e26d8b9577a0ff080d896964c97bcd0e16b..fc1d52c42c9ed828bd3088edcaeba13546f5975b 100644 (file)
@@ -343,7 +343,10 @@ In addition to these headers and those generated by fixing system
 headers to work with GCC, some other headers may also be installed in
 @file{@var{libsubdir}/include}.  @file{config.gcc} may set
 @code{extra_headers}; this specifies additional headers under
-@file{config} to be installed on some systems.
+@file{config} to be installed on some systems.  They're installed at the
+top of the @file{include} tree, unless the optional @samp{/././}
+sequence appears in the name, marking the beginning of the name under
+which the header should be installed.
 
 GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}.
 This is done to cope with command-line options that change the