Skip to content

Commit daefb1b

Browse files
authored
[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.
1 parent d7aa6e3 commit daefb1b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

openmp/runtime/src/include/omp.h.var

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
#ifndef __OMP_H
1616
# define __OMP_H
1717

18+
# ifndef __has_include
19+
# define __has_include(x) 0
20+
# endif
21+
1822
# include <stddef.h>
19-
# include <stdlib.h>
23+
# if (__has_include(<stdlib.h>))
24+
# include <stdlib.h>
25+
# endif
2026
# include <stdint.h>
2127

2228
# define KMP_VERSION_MAJOR @LIBOMP_VERSION_MAJOR@

0 commit comments

Comments
 (0)