[Openmp-commits] [openmp] daefb1b - [OpenMP] Make `omp.h` work when compiled with `-ffreestanding` (#125618)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Feb 4 04:48:27 PST 2025
Author: Joseph Huber
Date: 2025-02-04T06:48:23-06:00
New Revision: daefb1b0121498ea48a0ed6514f11fb66872bafc
URL: https://github.com/llvm/llvm-project/commit/daefb1b0121498ea48a0ed6514f11fb66872bafc
DIFF: https://github.com/llvm/llvm-project/commit/daefb1b0121498ea48a0ed6514f11fb66872bafc.diff
LOG: [OpenMP] Make `omp.h` work when compiled with `-ffreestanding` (#125618)
Summary:
Freestanding builds have `stddef.h` and `stdint.h` but not `stdlib.h`.
We don't actually use any `stdlib.h` definitions in the OpenMP headers,
and some definitions from this header are usable without the OpenMP
runtime (allocators) so we should be able to do this. This ignores the
include if possible, removing the implicit include would possibly break
some applications so it stays here.
Added:
Modified:
openmp/runtime/src/include/omp.h.var
Removed:
################################################################################
diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var
index dee46e51d6b340c..82f9d07657ffbe4 100644
--- a/openmp/runtime/src/include/omp.h.var
+++ b/openmp/runtime/src/include/omp.h.var
@@ -15,8 +15,14 @@
#ifndef __OMP_H
# define __OMP_H
+# ifndef __has_include
+# define __has_include(x) 0
+# endif
+
# include <stddef.h>
-# include <stdlib.h>
+# if (__has_include(<stdlib.h>))
+# include <stdlib.h>
+# endif
# include <stdint.h>
# define KMP_VERSION_MAJOR @LIBOMP_VERSION_MAJOR@
More information about the Openmp-commits
mailing list