mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-03 09:16:30 -04:00
Cleanup __func__ detection
First of all __func__ is not a macro, it is char[] array, so the code that we had before in cmake, was incorrect, i.e.: #if defined (__func__) #define EVENT____func__ __func__ #elif defined(__FUNCTION__) #define EVENT____func__ __FUNCTION__ #else #define EVENT____func__ __FILE__ #endif So just detect do we have __func__/__FUNCTION__ in configure/cmake before build and define EVENT__HAVE___func__/EVENT__HAVE___FUNCTION__ to use the later to choose which should be used as a __func__ (if it is not presented). Closes: #644 (cherry picked from commit e85818d24850540d220e6d7bc0a30653ba2135f2)
This commit is contained in:
parent
21bfaa702f
commit
b3af7bdde3
@ -412,7 +412,7 @@ endif()
|
||||
check_function_keywords("inline" "__inline" "__inline__")
|
||||
|
||||
if (HAVE_INLINE)
|
||||
set (EVENT__inline inline)
|
||||
set(EVENT__inline inline)
|
||||
elseif (HAVE___INLINE)
|
||||
set(EVENT__inline __inline)
|
||||
elseif(HAVE___INLINE__)
|
||||
@ -421,6 +421,10 @@ else()
|
||||
set(EVENT__inline)
|
||||
endif()
|
||||
|
||||
# __func__/__FUNCTION__ is not a macros in general
|
||||
CHECK_SYMBOL_EXISTS("__func__" "" EVENT__HAVE___func__)
|
||||
CHECK_SYMBOL_EXISTS("__FUNCTION__" "" EVENT__HAVE___FUNCTION__)
|
||||
|
||||
CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH)
|
||||
CHECK_CONST_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN)
|
||||
CHECK_CONST_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND)
|
||||
|
@ -337,9 +337,6 @@
|
||||
/* Version number of package */
|
||||
#define EVENT__VERSION "2.1.8-stable"
|
||||
|
||||
/* Define to appropriate substitue if compiler doesnt have __func__ */
|
||||
#define EVENT____func__ __FUNCTION__
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#define EVENT__inline __inline
|
||||
|
28
configure.ac
28
configure.ac
@ -739,21 +739,23 @@ AC_TRY_COMPILE([
|
||||
[Define to unsigned int if you dont have it])]
|
||||
)
|
||||
|
||||
# __func__/__FUNCTION__ is not a macros in general
|
||||
AC_MSG_CHECKING([whether our compiler supports __func__])
|
||||
AC_TRY_COMPILE([],
|
||||
[ const char *cp = __func__; ],
|
||||
AC_MSG_RESULT([yes]),
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
|
||||
AC_TRY_COMPILE([],
|
||||
[ const char *cp = __FUNCTION__; ],
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(__func__, __FUNCTION__,
|
||||
[Define to appropriate substitue if compiler doesnt have __func__]),
|
||||
AC_MSG_RESULT([no])
|
||||
AC_DEFINE(__func__, __FILE__,
|
||||
[Define to appropriate substitue if compiler doesnt have __func__])))
|
||||
|
||||
[ const char *cp = __func__; ],
|
||||
[ AC_DEFINE(HAVE___func__, 1, [Define to 1 if compiler have __func__])
|
||||
AC_MSG_RESULT([yes])
|
||||
],
|
||||
AC_MSG_RESULT([no])
|
||||
)
|
||||
AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
|
||||
AC_TRY_COMPILE([],
|
||||
[ const char *cp = __FUNCTION__; ],
|
||||
[ AC_DEFINE(HAVE___FUNCTION__, 1, [Define to 1 if compiler have __FUNCTION__])
|
||||
AC_MSG_RESULT([yes])
|
||||
],
|
||||
AC_MSG_RESULT([no])
|
||||
)
|
||||
|
||||
# check if we can compile with pthreads
|
||||
have_pthreads=no
|
||||
|
@ -470,16 +470,6 @@
|
||||
/* The size of 'void *', as computer by sizeof */
|
||||
#define EVENT__SIZEOF_VOID_P @EVENT__SIZEOF_VOID_P@
|
||||
|
||||
/* set an alias for whatever __func__ __FUNCTION__ is, what sillyness */
|
||||
#if defined (__func__)
|
||||
#define EVENT____func__ __func__
|
||||
#elif defined(__FUNCTION__)
|
||||
#define EVENT____func__ __FUNCTION__
|
||||
#else
|
||||
#define EVENT____func__ __FILE__
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
@ -496,6 +486,9 @@
|
||||
#define EVENT__inline @EVENT__inline@
|
||||
#endif
|
||||
|
||||
#cmakedefine EVENT__HAVE___func__ 1
|
||||
#cmakedefine EVENT__HAVE___FUNCTION__ 1
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#define EVENT__size_t @EVENT__size_t@
|
||||
|
||||
|
@ -1582,8 +1582,14 @@ class CCodeGenerator:
|
||||
'#include <event2/event.h>\n'
|
||||
'#include <event2/buffer.h>\n'
|
||||
'#include <event2/tag.h>\n\n'
|
||||
'#if defined(EVENT____func__) && !defined(__func__)\n'
|
||||
'#define __func__ EVENT____func__\n'
|
||||
'#if defined(EVENT__HAVE___func__)\n'
|
||||
'# ifndef __func__\n'
|
||||
'# define __func__ __func__\n'
|
||||
'# endif\n'
|
||||
'#elif defined(EVENT__HAVE___FUNCTION__)\n'
|
||||
'# define __func__ __FUNCTION__\n'
|
||||
'#else\n'
|
||||
'# define __func__ __FILE__\n'
|
||||
'#endif\n\n'
|
||||
)
|
||||
|
||||
|
@ -68,8 +68,16 @@ extern "C" {
|
||||
#ifdef EVENT__inline
|
||||
#define inline EVENT__inline
|
||||
#endif
|
||||
#if defined(EVENT____func__) && !defined(__func__)
|
||||
#define __func__ EVENT____func__
|
||||
|
||||
/* Define to appropriate substitute if compiler doesnt have __func__ */
|
||||
#if defined(EVENT__HAVE___func__)
|
||||
# ifndef __func__
|
||||
# define __func__ __func__
|
||||
# endif
|
||||
#elif defined(EVENT__HAVE___FUNCTION__)
|
||||
# define __func__ __FUNCTION__
|
||||
#else
|
||||
# define __func__ __FILE__
|
||||
#endif
|
||||
|
||||
/* A good no-op to use in macro definitions. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user