commit 797cfc8b8c6edae5202fd5dd4355de023c911295
parent 814bdffaca18849aca00a2d2707e5fc3316faed2
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 25 Jul 2025 13:34:43 +0200
Used new internal header sys_sizet_type.h
Diffstat:
4 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/mhd2/mhd_atomic_counter.h b/src/mhd2/mhd_atomic_counter.h
@@ -30,7 +30,7 @@
#include "mhd_sys_options.h"
-#include "sys_base_types.h" /* for size_t */
+#include "sys_sizet_type.h"
/* Use 'size_t' to make sure it would never overflow when used for
* MHD needs. */
diff --git a/src/mhd2/sha256_ext.h b/src/mhd2/sha256_ext.h
@@ -26,11 +26,9 @@
#ifndef MHD_SHA256_EXT_H
#define MHD_SHA256_EXT_H 1
-#include "mhd_options.h"
+#include "mhd_sys_options.h"
#include <stdint.h>
-#ifdef HAVE_STDDEF_H
-#include <stddef.h> /* for size_t */
-#endif /* HAVE_STDDEF_H */
+#include "sys_sizet_type.h"
/**
* Size of SHA-256 resulting digest in bytes
diff --git a/src/mhd2/sys_base_types.h b/src/mhd2/sys_base_types.h
@@ -38,13 +38,10 @@
# include <unistd.h> /* should provide ssize_t */
#endif
#include <stdint.h> /* uint_fast_XXt, int_fast_XXt */
-#if defined(HAVE_STDDEF_H)
-# include <stddef.h> /* size_t, NULL */
-#elif defined(HAVE_STDLIB_H)
-# include <stdlib.h> /* should provide size_t, NULL */
-#else
-# include <stdio.h> /* should provide size_t, NULL */
-#endif
+
+#include "sys_null_macro.h"
+#include "sys_sizet_type.h"
+
#ifdef HAVE_CRTDEFS_H
# include <crtdefs.h> /* W32-specific header */
#endif
diff --git a/src/mhd2/sys_null_macro.h b/src/mhd2/sys_null_macro.h
@@ -1,6 +1,6 @@
/*
This file is part of GNU libmicrohttpd
- Copyright (C) 2024 Evgeny Grin (Karlson2k)
+ Copyright (C) 2024-2025 Evgeny Grin (Karlson2k)
GNU libmicrohttpd is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,10 +20,10 @@
/**
* @file src/mhd2/sys_null_macro.h
- * @brief The header for the system NULL constant
+ * @brief The header for the system 'NULL' constant
* @author Karlson2k (Evgeny Grin)
*
- * This header tries to include the minimal header that defines NULL.
+ * This header tries to include the minimal header that defines 'NULL' macro.
*/
#ifndef MHD_SYS_NULL_MACRO_H
@@ -31,10 +31,22 @@
#include "mhd_sys_options.h"
-#if defined(HAVE_STDDEF_H)
-# include <stddef.h> /* NULL */
-#else
-# include <string.h> /* should provide NULL */
+#include "sys_sizet_type.h" /* Should provide NULL */
+
+#ifndef NULL
+# ifndef __cplusplus
+# if defined(__STDC_VERSION__) && ((__STDC_VERSION__ + 0) >= 202311)
+# define NULL nullptr
+# else /* < C23 */
+# define NULL ((void *) 0)
+# endif /* < C23 */
+# else /* __cplusplus */
+# if defined(__cpp_nullptr) && ((__cpp_nullptr + 0) >= 200704)
+# define NULL nullptr
+# else
+# define NULL 0
+# endif
+# endif /* __cplusplus */
#endif
#endif /* ! MHD_SYS_NULL_MACRO_H */