gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated (55aa3677 -> f924cbde)


From: gnunet
Subject: [libmicrohttpd] branch master updated (55aa3677 -> f924cbde)
Date: Mon, 01 May 2023 13:34:25 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 55aa3677 {md5,sha256}_ext.c: fixed processing of initialisation error 
with NULL handler
     new 06ff7165 autoinit_funcs.h: fixed harmless typos
     new 81ef7ab0 autoinit_funcs.h: added support for non-x86 arches for MSVC
     new b92f7d97 autoinit_funcs.h: updated to use (semi-)official documented 
sections
     new f924cbde autoinit_funcs.h: unified English spelling (prefer GB over US)

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/autoinit_funcs.h | 182 ++++++++++++++++++++++++++-----------------
 1 file changed, 111 insertions(+), 71 deletions(-)

diff --git a/src/include/autoinit_funcs.h b/src/include/autoinit_funcs.h
index 1636db7f..e2453e40 100644
--- a/src/include/autoinit_funcs.h
+++ b/src/include/autoinit_funcs.h
@@ -1,6 +1,6 @@
 /*
  *  AutoinitFuncs: Automatic Initialization and Deinitialization Functions
- *  Copyright(C) 2014-2022 Karlson2k (Evgeny Grin)
+ *  Copyright(C) 2014-2023 Karlson2k (Evgeny Grin)
  *
  *  This header is free software; you can redistribute it and / or
  *  modify it under the terms of the GNU Lesser General Public
@@ -20,11 +20,11 @@
 /*
    General usage is simple: include this header, declare or define two
    functions with zero parameters (void) and any return type: one for
-   initialization and one for deinitialization, add
+   initialisation and one for deinitialisation, add
    _SET_INIT_AND_DEINIT_FUNCS(FuncInitName, FuncDeInitName) to the code
    and functions will be automatically called during application startup
    and shutdown.
-   This is useful for libraries as libraries doesn't have direct access
+   This is useful for libraries as libraries don't have direct access
    to main() functions.
    Example:
    -------------------------------------------------
@@ -48,14 +48,14 @@
    _SET_INIT_AND_DEINIT_FUNCS(libInit,libDeinit);
    -------------------------------------------------
 
-   If initializer or deinitializer function is not needed, just define
+   If initialiser or deinitialiser function is not needed, just define
    it as empty function.
 
    This header should work with GCC, clang, MSVC (2010 or later) and
    SunPro / Sun Studio / Oracle Solaris Studio / Oracle Developer Studio
    compiler.
    Supported C and C++ languages; application, static and dynamic (DLL)
-   libraries; non-optimized (Debug) and optimized (Release) compilation
+   libraries; non-optimized (Debug) and optimised (Release) compilation
    and linking.
 
    For more information see header code and comments in code.
@@ -67,7 +67,7 @@
 * Current version of the header in packed BCD form.
 * 0x01093001 = 1.9.30-1.
 */
-#define AUTOINIT_FUNCS_VERSION 0x01000500
+#define AUTOINIT_FUNCS_VERSION 0x01000800
 
 #if defined(__GNUC__) || defined(__clang__)
 /* if possible - check for supported attribute */
@@ -78,7 +78,7 @@
 #endif /* __has_attribute */
 #endif /* __GNUC__ */
 
-/* "_attribute__ ((constructor))" is supported by GCC, clang and
+/* "__has_attribute__ ((constructor))" is supported by GCC, clang and
    Sun/Oracle compiler starting from version 12.1. */
 #if ((defined(__GNUC__) || defined(__clang__)) && \
   ! defined(_GNUC_ATTR_CONSTR_NOT_SUPPORTED)) || \
@@ -104,18 +104,16 @@
    not defined both _LIB and _USRDLL if building an application */
 
 /* Define AUTOINIT_FUNCS_DECLARE_STATIC_REG if you need macro declaration
-   for registering static initialization functions even if you building DLL */
+   for registering static initialisation functions even if you building DLL */
 /* Define AUTOINIT_FUNCS_FORCE_STATIC_REG if you want to set main macro
-   _SET_INIT_AND_DEINIT_FUNCS to static version even if building a DLL*/
+   _SET_INIT_AND_DEINIT_FUNCS to static version even if building a DLL */
 
 /* Stringify macros */
 #define _INSTRMACRO(a) #a
 #define _STRMACRO(a) _INSTRMACRO (a)
 
-#if ! defined(_USRDLL) || defined(AUTOINIT_FUNCS_DECLARE_STATIC_REG)
-
-/* required for atexit() */
-#include <stdlib.h>
+#if ! defined(_USRDLL) || defined(AUTOINIT_FUNCS_DECLARE_STATIC_REG) \
+  || defined(AUTOINIT_FUNCS_FORCE_STATIC_REG)
 
 /* Use "C" linkage for variable to simplify variable decoration */
 #ifdef __cplusplus
@@ -125,14 +123,17 @@
 #endif
 
 /* How variable is decorated by compiler */
-#if defined(_M_X64) || defined(_M_AMD64)
+#if (defined(_WIN32) || defined(_WIN64)) && ! defined(_M_IX86)
+#if ! defined(_M_X64) && ! defined (_M_ARM) && ! defined (_M_ARM64)
+#warning Untested architecture, linker may fail with unresolved symbol
+#endif /* ! _M_X64 && ! _M_ARM && ! _M_ARM64 */
 #define W32_VARDECORPREFIX
 #define W32_DECORVARNAME(v) v
-#define W32_VARDECORPEFIXSTR ""
-#elif defined(_M_IX86) || defined(_X86_)
+#define W32_VARDECORPREFIXSTR ""
+#elif defined(_WIN32) && defined(_M_IX86)
 #define W32_VARDECORPREFIX _
 #define W32_DECORVARNAME(v) _ ## v
-#define W32_VARDECORPEFIXSTR "_"
+#define W32_VARDECORPREFIXSTR "_"
 #else
 #error Do not know how to decorate symbols for this architecture
 #endif
@@ -140,81 +141,120 @@
 /* Internal variable prefix (can be any) */
 #define W32_INITHELPERVARNAME(f) _initHelperDummy_ ## f
 #define W32_INITHELPERVARNAMEDECORSTR(f) \
-  W32_VARDECORPEFIXSTR _STRMACRO (W32_INITHELPERVARNAME (f))
+  W32_VARDECORPREFIXSTR _STRMACRO (W32_INITHELPERVARNAME (f))
 
 /* Declare section (segment), put variable pointing to init function to chosen 
segment,
-   force linker to include variable to avoid omitting by optimizer */
-/* Initialization function must be declared as
-   int __cdecl FuncName(void) */
-/* Return value is ignored for C++ initializers */
-/* For C initializers: startup process is aborted if initializer return 
non-zero */
-#define W32_FPTR_IN_SEG(S,F) \
+   force linker to always include variable to avoid omitting by optimiser */
+/* Initialisation function must be declared as
+   void __cdecl FuncName(void)
+/* "extern" with initialisation value means that variable is declared AND 
defined. */
+#define W32_VFPTR_IN_SEG(S,F) \
+  __pragma (section (S,long,read)) \
+  __pragma (comment (linker, "/INCLUDE:" W32_INITHELPERVARNAMEDECORSTR (F))) \
+  W32_INITVARDECL __declspec(allocate (S))void \
+    (__cdecl * W32_INITHELPERVARNAME (F))(void) = &F
+
+/* Sections (segments) for pointers to initialisers/deinitialisers */
+
+/* Semi-officially suggested section for early initialisers (called before
+   C++ objects initialisers), "void" return type */
+#define W32_SEG_INIT_EARLY      ".CRT$XCT"
+/* Semi-officially suggested section for late initialisers (called after
+   C++ objects initialisers), "void" return type */
+#define W32_SEG_INIT_LATE       ".CRT$XCV"
+
+/* Unsafe sections (segments) for pointers to initialisers/deinitialisers */
+
+/* C++ lib initialisers, "void" return type (reserved by the system!) */
+#define W32_SEG_INIT_CXX_LIB    ".CRT$XCL"
+/* C++ user initialisers, "void" return type (reserved by the system!) */
+#define W32_SEG_INIT_CXX_USER   ".CRT$XCU"
+
+
+/* Declare section (segment), put variable pointing to init function to chosen 
segment,
+   force linker to always include variable to avoid omitting by optimiser */
+/* Initialisation function must be declared as
+   int __cdecl FuncName(void)
+/* Startup process is aborted if initialiser returns non-zero */
+/* "extern" with initialisation value means that variable is declared AND 
defined. */
+#define W32_IFPTR_IN_SEG(S,F) \
   __pragma (section (S,long,read)) \
   __pragma (comment (linker, "/INCLUDE:" W32_INITHELPERVARNAMEDECORSTR (F))) \
   W32_INITVARDECL __declspec(allocate (S))int \
     (__cdecl * W32_INITHELPERVARNAME (F))(void) = &F
 
-/* Section (segment) names for pointers to initializers */
-#define W32_SEG_INIT_C_USER   ".CRT$XCU"
-#define W32_SEG_INIT_C_LIB    ".CRT$XCL"
-#define W32_SEG_INIT_CXX_USER ".CRT$XIU"
-#define W32_SEG_INIT_CXX_LIB  ".CRT$XIL"
+/* Unsafe sections (segments) for pointers to initialisers with
+   "int" return type */
+
+/* C lib initialisers, "int" return type (reserved by the system!).
+   These initialisers are called before others. */
+#define W32_SEG_INIT_C_LIB      ".CRT$XIL"
+/* C user initialisers, "int" return type (reserved by the system!).
+   These initialisers are called before others. */
+#define W32_SEG_INIT_C_USER     ".CRT$XIU"
 
-/* Declare macro for different initializers sections */
-/* Macro can be used several times to register several initializers */
-/* Once function is registered as initializer, it will be called automatically
+
+/* Declare macro for different initialisers sections */
+/* Macro can be used several times to register several initialisers */
+/* Once function is registered as initialiser, it will be called automatically
    during application startup */
-/* "lib" initializers are called before "user" initializers */
-/* "C" initializers are called before "C++" initializers */
-#define W32_REG_INIT_C_USER(F) W32_FPTR_IN_SEG (W32_SEG_INIT_C_USER,F)
-#define W32_REG_INIT_C_LIB(F) W32_FPTR_IN_SEG (W32_SEG_INIT_C_LIB,F)
+#define W32_REG_INIT_EARLY(F) W32_VFPTR_IN_SEG (W32_SEG_INIT_EARLY,F)
+#define W32_REG_INIT_LATE(F)  W32_VFPTR_IN_SEG (W32_SEG_INIT_LATE,F)
+
+
+/* Not recommended / unsafe */
+/* "lib" initialisers are called before "user" initialisers */
+/* "C" initialisers are called before "C++" initialisers */
+#define W32_REG_INIT_C_USER(F)   W32_FPTR_IN_SEG (W32_SEG_INIT_C_USER,F)
+#define W32_REG_INIT_C_LIB(F)    W32_FPTR_IN_SEG (W32_SEG_INIT_C_LIB,F)
 #define W32_REG_INIT_CXX_USER(F) W32_FPTR_IN_SEG (W32_SEG_INIT_CXX_USER,F)
-#define W32_REG_INIT_CXX_LIB(F) W32_FPTR_IN_SEG (W32_SEG_INIT_CXX_LIB,F)
+#define W32_REG_INIT_CXX_LIB(F)  W32_FPTR_IN_SEG (W32_SEG_INIT_CXX_LIB,F)
 
 /* Choose main register macro based on language and program type */
 /* Assuming that _LIB or _USRDLL is defined for static or DLL-library */
-/* Macro can be used several times to register several initializers */
-/* Once function is registered as initializer, it will be called automatically
+/* Macro can be used several times to register several initialisers */
+/* Once function is registered as initialiser, it will be called automatically
    during application startup */
-/* Define AUTOINIT_FUNCS_FORCE_USER_LVL_INIT to register initializers
-   at user level even if building library */
-#ifdef __cplusplus
-#if ((defined(_LIB) && ! defined(_CONSOLE)) || defined(_USRDLL)) && \
-  ! defined(AUTOINIT_FUNCS_FORCE_USER_LVL_INIT)
-#define W32_REGISTER_INIT(F) W32_REG_INIT_CXX_LIB (F)
-#else  /* ! _LIB && ! _DLL */
-#define W32_REGISTER_INIT(F) W32_REG_INIT_CXX_USER (F)
-#endif /* ! _LIB && ! _DLL */
-#else  /* !__cplusplus*/
-#if ((defined(_LIB) && ! defined(_CONSOLE)) || defined(_USRDLL)) && \
-  ! defined(AUTOINIT_FUNCS_FORCE_USER_LVL_INIT)
-#define W32_REGISTER_INIT(F) W32_REG_INIT_C_LIB (F)
-#else  /* ! _LIB && ! _DLL */
-#define W32_REGISTER_INIT(F) W32_REG_INIT_C_USER (F)
-#endif /* ! _LIB && ! _DLL */
-#endif /* !__cplusplus*/
-
-#else /* _USRDLL */
+/* Define AUTOINIT_FUNCS_FORCE_EARLY_INIT to force register as early
+   initialiser */
+/* Define AUTOINIT_FUNCS_FORCE_LATE_INIT to force register as late
+   initialiser */
+/* By default C++ static or DLL-library code and any C code and will be
+   registered as early initialiser, while C++ non-library code will be
+   registered as late initialiser */
+#if (! defined(__cplusplus) || \
+  ((defined(_LIB) && ! defined(_CONSOLE)) || defined(_USRDLL)) || \
+  defined(AUTOINIT_FUNCS_FORCE_EARLY_INIT)) && \
+  ! defined(AUTOINIT_FUNCS_FORCE_LATE_INIT)
+#define W32_REGISTER_INIT(F) W32_REG_INIT_EARLY(F)
+#else
+#define W32_REGISTER_INIT(F) W32_REG_INIT_LATE(F)
+#endif
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif /* WIN32_LEAN_AND_MEAN */
-/* Required for DllMain */
-#include <Windows.h>
-#endif /* _USRDLL */
+#endif /* ! _USRDLL || ! AUTOINIT_FUNCS_DECLARE_STATIC_REG
+          || AUTOINIT_FUNCS_FORCE_STATIC_REG */
 
 
 #if ! defined(_USRDLL) || defined(AUTOINIT_FUNCS_FORCE_STATIC_REG)
+
+#include <stdlib.h> /* required for atexit() */
+
 #define W32_SET_INIT_AND_DEINIT(FI,FD) \
-  int __cdecl _W32_init_helper_ ## FI (void);    \
+  void __cdecl _W32_init_helper_ ## FI (void);    \
   void __cdecl _W32_deinit_helper_ ## FD (void); \
+  void __cdecl _W32_init_helper_ ## FI (void)     \
+  { (void) (FI) (); atexit (_W32_deinit_helper_ ## FD); } \
   void __cdecl _W32_deinit_helper_ ## FD (void)  \
   { (void) (FD) (); } \
-  int __cdecl _W32_init_helper_ ## FI (void)     \
-  { (void) (FI) (); atexit (_W32_deinit_helper_ ## FD); return 0; } \
   W32_REGISTER_INIT (_W32_init_helper_ ## FI)
 #else  /* _USRDLL */
 
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* WIN32_LEAN_AND_MEAN */
+
+#include <Windows.h> /* Required for DllMain */
+
 /* If DllMain is already present in code, define 
AUTOINIT_FUNCS_CALL_USR_DLLMAIN
    and rename DllMain to usr_DllMain */
 #ifndef AUTOINIT_FUNCS_CALL_USR_DLLMAIN
@@ -239,21 +279,21 @@
 #endif /* _USRDLL */
 
 #define _SET_INIT_AND_DEINIT_FUNCS(FI,FD) W32_SET_INIT_AND_DEINIT (FI,FD)
-/* Indicate that automatic initializers/deinitializers are supported */
+/* Indicate that automatic initialisers/deinitialisers are supported */
 #define _AUTOINIT_FUNCS_ARE_SUPPORTED 1
 
 #else  /* !__GNUC__ && !_MSC_FULL_VER */
 
 /* Define EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED before inclusion of 
header to
-   abort compilation if automatic initializers/deinitializers are not 
supported */
+   abort compilation if automatic initialisers/deinitialisers are not 
supported */
 #ifdef EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED
 #error \
-  Compiler/platform don not support automatic calls of user-defined 
initializer and deinitializer
+  Compiler/platform does not support automatic calls of user-defined 
initializer and deinitializer
 #endif /* EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED */
 
 /* Do nothing */
 #define _SET_INIT_AND_DEINIT_FUNCS(FI,FD)
-/* Indicate that automatic initializers/deinitializers are not supported */
+/* Indicate that automatic initialisers/deinitialisers are not supported */
 #define _AUTOINIT_FUNCS_ARE_NOT_SUPPORTED 1
 
 #endif /* !__GNUC__ && !_MSC_FULL_VER */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]