Anton Samsonov has uploaded this change for review.

View Change

Remove dependency on C23's __has_include()

Change-Id: Ifaeb46127785af86e69852152783f75d241b1266
---
M include/cli_classic.h
M include/platform/pci.h
2 files changed, 22 insertions(+), 4 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/43/77043/1
diff --git a/include/cli_classic.h b/include/cli_classic.h
index e651cc6..5b1ab6b 100644
--- a/include/cli_classic.h
+++ b/include/cli_classic.h
@@ -15,9 +15,21 @@
#ifndef CLI_CLASSIC_H
#define CLI_CLASSIC_H

-#if __has_include(<getopt.h>)
+#if HAVE_GETOPT_H
#include <getopt.h>
+#elif !defined(HAVE_GETOPT_H)
+#if !defined(__has_include) || (__STDC_VERSION__ < 202300L)
+#include <getopt.h>
+#define HAVE_GETOPT_H 1
+#elif __has_include(<getopt.h>)
+#include <getopt.h>
+#define HAVE_GETOPT_H 1
#else
+#define HAVE_GETOPT_H 0
+#endif /* __has_include() */
+#endif /* HAVE_GETOPT_H */
+
+#if !HAVE_GETOPT_H

#define no_argument 0
#define required_argument 1
@@ -39,5 +51,5 @@
int getopt_long_only (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);

-#endif /* __has_include() */
+#endif /* HAVE_GETOPT_H */
#endif /* CLI_CLASSIC_H */
diff --git a/include/platform/pci.h b/include/platform/pci.h
index 4ac108f..5e350ac 100644
--- a/include/platform/pci.h
+++ b/include/platform/pci.h
@@ -22,10 +22,16 @@
* e.g. NetBSD 9.0 on sparc64 pciutils-3.7.0nb2.
* Other NetBSD platforms and versions uses the default path under pci/pci.h
*/
-#if __has_include(<pciutils/pci.h>)
+#if !defined(__has_include) && (__STDC_VERSION__ < 202300L)
+#if HAVE_PCIUTILS_PCI_H
#include <pciutils/pci.h>
#else
#include <pci/pci.h>
-#endif
+#endif /* HAVE_PCIUTILS_PCI_H */
+#elif __has_include(<pciutils/pci.h>)
+#include <pciutils/pci.h>
+#else
+#include <pci/pci.h>
+#endif /* __has_include(<pciutils/pci.h>) */

#endif /* __PLATFORM_PCI_H__ */

To view, visit change 77043. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ifaeb46127785af86e69852152783f75d241b1266
Gerrit-Change-Number: 77043
Gerrit-PatchSet: 1
Gerrit-Owner: Anton Samsonov <devel@zxlab.ru>
Gerrit-MessageType: newchange