This is a discussion on [PATCH] __func__ and __FUNCTION__ in configure script within the OpenSSH Development forums, part of the Networking and Network Related category; This is a multi-part message in MIME format. --------------060503080102070709040106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This is a multi-part message in MIME format.
--------------060503080102070709040106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi everybody, I'm Kris. A little background: I've been contributing to Nmap for over a year, and am an SoC student for it this summer. But on to the patch.. Currently: __func__ and __FUNCTION__ are checked for in the configure script, but if one or the other doesn't exist, it is changed in defines.h. Patched: They are both still checked for in configure, but this is done in the configure script as well: 1) If __func__ exists, it's used 2) If not, but __FUNCTION__ exists, define __func__ to __FUNCTION__ 3) If neither exist, define __func__ to __FILE__ So this eliminates the need for the HAVE___func__ and HAVE___FUNCTION__ defines, the checking/modifying in defines.h, and it's all done in one spot in configure. I implemented pretty much the same thing in Nmap, and I thought it'd be helpful here as well I didn't run autoconf before I diff'd it because it probably would've made the patch huge. Please CC me on any replies, as I'm not subscribed. Thanks, Kris Katterjohn --------------060503080102070709040106 Content-Type: text/x-patch; name="func.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="func.patch" --- x/config.h.in 2007-03-06 04:39:55.000000000 -0600 +++ y/config.h.in 2007-07-16 14:00:36.000000000 -0500 @@ -1045,9 +1045,6 @@ /* Define to 1 if you have the `__b64_pton' function. */ #undef HAVE___B64_PTON -/* Define if compiler implements __FUNCTION__ */ -#undef HAVE___FUNCTION__ - /* Define if libc defines __progname */ #undef HAVE___PROGNAME @@ -1057,9 +1054,6 @@ /* Define if __va_copy exists */ #undef HAVE___VA_COPY -/* Define if compiler implements __func__ */ -#undef HAVE___func__ - /* Define this if you are using the Heimdal version of Kerberos V5 */ #undef HEIMDAL --- x/configure.ac 2007-03-04 18:51:27.000000000 -0600 +++ y/configure.ac 2007-07-16 14:01:20.000000000 -0500 @@ -2960,31 +2960,29 @@ if test "x$ac_cv_libc_defines___progname AC_DEFINE(HAVE___PROGNAME, 1, [Define if libc defines __progname]) fi -AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [ - AC_TRY_LINK([ -#include <stdio.h> -], - [ printf("%s", __FUNCTION__); ], - [ ac_cv_cc_implements___FUNCTION__="yes" ], - [ ac_cv_cc_implements___FUNCTION__="no" ] - ) -]) -if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then - AC_DEFINE(HAVE___FUNCTION__, 1, - [Define if compiler implements __FUNCTION__]) -fi +AC_MSG_CHECKING(for __func__) +AC_TRY_COMPILE( + [ #include <stdio.h> ], + [ printf ("%s", __func__); ], + have_func=yes, have_func=no) -AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [ - AC_TRY_LINK([ -#include <stdio.h> -], - [ printf("%s", __func__); ], - [ ac_cv_cc_implements___func__="yes" ], - [ ac_cv_cc_implements___func__="no" ] - ) -]) -if test "x$ac_cv_cc_implements___func__" = "xyes" ; then - AC_DEFINE(HAVE___func__, 1, [Define if compiler implements __func__]) +if test "x$have_func" = "xyes"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(for __FUNCTION__) + AC_TRY_COMPILE( + [ #include <stdio.h> ], + [ printf ("%s", __FUNCTION__); ], + have_function=yes, have_function=no) + + if test "x$have_function" = "xyes"; then + AC_MSG_RESULT(yes) + AC_DEFINE(__func__, __FUNCTION__) + else + AC_MSG_RESULT(no) + AC_DEFINE(__func__, __FILE__) + fi fi AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ --- x/defines.h 2006-09-21 08:13:30.000000000 -0500 +++ y/defines.h 2007-07-16 14:00:47.000000000 -0500 @@ -570,12 +570,6 @@ struct winsize { # define OPENSSL_free(x) Free(x) #endif -#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) -# define __func__ __FUNCTION__ -#elif !defined(HAVE___func__) -# define __func__ "" -#endif - #if defined(KRB5) && !defined(HEIMDAL) # define krb5_get_err_text(context,code) error_message(code) #endif --------------060503080102070709040106 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@mindrot.org https://lists.mindrot.org/mailman/li...enssh-unix-dev --------------060503080102070709040106-- |