diff mbox

[PATCHv3] Add autoconf for --enable-allow-unimplemented (default is no)

Message ID 1415402359-7796-1-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Nov. 7, 2014, 11:19 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 configure.ac                                        | 11 +++++++++++
 platform/linux-generic/include/odp_debug_internal.h | 11 +++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

Comments

Bill Fischofer Nov. 7, 2014, 11:21 p.m. UTC | #1
Sorry for the confusion.  Patch skill rusty :)

This one should be good.  This patch will fail compilation if
ODP_UNIMPLEMENTED is called anywhere.  To override and allow these to just
log, use ./configure --enable-allow-unimplemented

Bill

On Fri, Nov 7, 2014 at 5:19 PM, Bill Fischofer <bill.fischofer@linaro.org>
wrote:

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>  configure.ac                                        | 11 +++++++++++
>  platform/linux-generic/include/odp_debug_internal.h | 11 +++++++++--
>  2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1c061e9..cca76bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -110,6 +110,17 @@ AC_ARG_ENABLE([debug],
>  ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG"
>
>  ##########################################################################
> +# Enable/disable ODP_ALLOW_UNIMPLEMENTED
> +##########################################################################
> +ODP_ALLOW_UNIMPLEMENTED=0
> +AC_ARG_ENABLE([allow-unimplemented],
> +    [  --enable-allow-unimplemented  Enable/disable allow unimplemented],
> +    [if test "x$enableval" = "xyes"; then
> +        ODP_ALLOW_UNIMPLEMENTED=1
> +    fi])
> +ODP_CFLAGS="$ODP_CFLAGS
> -DODP_ALLOW_UNIMPLEMENTED=$ODP_ALLOW_UNIMPLEMENTED"
> +
> +##########################################################################
>  # Check for pthreads availability
>  ##########################################################################
>
> diff --git a/platform/linux-generic/include/odp_debug_internal.h
> b/platform/linux-generic/include/odp_debug_internal.h
> index a87552f..8ae0b01 100644
> --- a/platform/linux-generic/include/odp_debug_internal.h
> +++ b/platform/linux-generic/include/odp_debug_internal.h
> @@ -25,8 +25,15 @@ extern "C" {
>  /**
>   * This macro is used to indicate when a given function is not implemented
>   */
> -#define ODP_UNIMPLEMENTED(fmt, ...) \
> -               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
> +#if ODP_ALLOW_UNIMPLEMENTED
> +#define ODP_UNIMPLEMENTED(fmt, ...)                                    \
> +       ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
> +#else
> +#define ODP_UNIMPLEMENTED(fmt, ...) do {                                \
> +               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__);     \
> +               odp_unimplemented();                                    \
> +       } while (0)
> +#endif
>
>  #ifdef __cplusplus
>  }
> --
> 1.8.3.2
>
>
Mike Holmes Nov. 10, 2014, 6:31 p.m. UTC | #2
On 7 November 2014 18:19, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>  configure.ac                                        | 11 +++++++++++
>  platform/linux-generic/include/odp_debug_internal.h | 11 +++++++++--
>  2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1c061e9..cca76bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -110,6 +110,17 @@ AC_ARG_ENABLE([debug],
>  ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG"
>
>  ##########################################################################
> +# Enable/disable ODP_ALLOW_UNIMPLEMENTED
> +##########################################################################
> +ODP_ALLOW_UNIMPLEMENTED=0
> +AC_ARG_ENABLE([allow-unimplemented],
> +    [  --enable-allow-unimplemented  Enable/disable allow unimplemented],
> +    [if test "x$enableval" = "xyes"; then
> +        ODP_ALLOW_UNIMPLEMENTED=1
> +    fi])
> +ODP_CFLAGS="$ODP_CFLAGS
> -DODP_ALLOW_UNIMPLEMENTED=$ODP_ALLOW_UNIMPLEMENTED"
> +
> +##########################################################################
>  # Check for pthreads availability
>  ##########################################################################
>
> diff --git a/platform/linux-generic/include/odp_debug_internal.h
> b/platform/linux-generic/include/odp_debug_internal.h
> index a87552f..8ae0b01 100644
> --- a/platform/linux-generic/include/odp_debug_internal.h
> +++ b/platform/linux-generic/include/odp_debug_internal.h
> @@ -25,8 +25,15 @@ extern "C" {
>  /**
>   * This macro is used to indicate when a given function is not implemented
>

nit: does this need to indicate why there are two implementations ?
This macro is used to indicate when a given function is not implemented, it
can be configured to generate a compile time error or runtime notification.


>   */
> -#define ODP_UNIMPLEMENTED(fmt, ...) \
> -               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
> +#if ODP_ALLOW_UNIMPLEMENTED
> +#define ODP_UNIMPLEMENTED(fmt, ...)                                    \
>

The tabs to the continuing backslash are not in keeping with the macros in
other files (odp_debug.h) where they have just a single space before the
backslash
Multiple instances.


> +       ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
> +#else
> +#define ODP_UNIMPLEMENTED(fmt, ...) do {                                \
> +               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__);     \
> +               odp_unimplemented();                                    \
> +       } while (0)
> +#endif
>
>  #ifdef __cplusplus
>  }
> --
> 1.8.3.2
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Nov. 10, 2014, 9:33 p.m. UTC | #3
Main propose is stop compilation, right? So there should be some 
readable message. We can pass messages with #error and #warning.
Usage of ODP_LOG is not needed if we can not compile code.

I think we need to do simple:

#if ODP_ALLOW_UNIMPLEMENTED
#define ODP_UNIMPLEMENTED(fmt, ...)                        \
     ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
#else
#error    "Function is not implemented. If you still want to build try  
--enable-allow-unimplemented"
#endif

In that case compilation will trap like this:
make[2]: Entering directory 
`/opt/LINARO/ODPrelease/ReleaseCommit2/odp2.git/platform/linux-generic'
   CC     odp_classification.lo
In file included from odp_classification.c:5:0:
./include/odp_debug_internal.h:32:2: error: #error "Function is not 
implemented. If you still want to build try --enable-allow-unimplemented"
odp_classification.c: In function 'odp_cos_create':
odp_classification.c:11:2: error: implicit declaration of function 
'ODP_UNIMPLEMENTED' [-Werror=implicit-function-declaration]
odp_classification.c:11:2: error: nested extern declaration of 
'ODP_UNIMPLEMENTED' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[2]: *** [odp_classification.lo] Error 1

Maxim.


On 11/10/2014 09:31 PM, Mike Holmes wrote:
>
>
> On 7 November 2014 18:19, Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>> wrote:
>
>     Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org
>     <mailto:bill.fischofer@linaro.org>>
>     ---
>     configure.ac <http://configure.ac>                     | 11
>     +++++++++++
>      platform/linux-generic/include/odp_debug_internal.h | 11 +++++++++--
>      2 files changed, 20 insertions(+), 2 deletions(-)
>
>     diff --git a/configure.ac <http://configure.ac> b/configure.ac
>     <http://configure.ac>
>     index 1c061e9..cca76bb 100644
>     --- a/configure.ac <http://configure.ac>
>     +++ b/configure.ac <http://configure.ac>
>     @@ -110,6 +110,17 @@ AC_ARG_ENABLE([debug],
>      ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG"
>
>      ##########################################################################
>     +# Enable/disable ODP_ALLOW_UNIMPLEMENTED
>     +##########################################################################
>     +ODP_ALLOW_UNIMPLEMENTED=0
>     +AC_ARG_ENABLE([allow-unimplemented],
>     +    [  --enable-allow-unimplemented  Enable/disable allow
>     unimplemented],
>     +    [if test "x$enableval" = "xyes"; then
>     +        ODP_ALLOW_UNIMPLEMENTED=1
>     +    fi])
>     +ODP_CFLAGS="$ODP_CFLAGS
>     -DODP_ALLOW_UNIMPLEMENTED=$ODP_ALLOW_UNIMPLEMENTED"
>     +
>     +##########################################################################
>      # Check for pthreads availability
>      ##########################################################################
>
>     diff --git a/platform/linux-generic/include/odp_debug_internal.h
>     b/platform/linux-generic/include/odp_debug_internal.h
>     index a87552f..8ae0b01 100644
>     --- a/platform/linux-generic/include/odp_debug_internal.h
>     +++ b/platform/linux-generic/include/odp_debug_internal.h
>     @@ -25,8 +25,15 @@ extern "C" {
>      /**
>       * This macro is used to indicate when a given function is not
>     implemented
>
>
> nit: does this need to indicate why there are two implementations ?
> This macro is used to indicate when a given function is not 
> implemented, it can be configured to generate a compile time error or 
> runtime notification.
>
>       */
>     -#define ODP_UNIMPLEMENTED(fmt, ...) \
>     -               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
>     +#if ODP_ALLOW_UNIMPLEMENTED
>     +#define ODP_UNIMPLEMENTED(fmt, ...)                   \
>
>
> The tabs to the continuing backslash are not in keeping with the 
> macros in other files (odp_debug.h) where they have just a single 
> space before the backslash
> Multiple instances.
>
>     +       ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
>     +#else
>     +#define ODP_UNIMPLEMENTED(fmt, ...) do {                   \
>     +               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt,
>     ##__VA_ARGS__);     \
>     +               odp_unimplemented();                   \
>     +       } while (0)
>     +#endif
>
>      #ifdef __cplusplus
>      }
>     --
>     1.8.3.2
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Mike Holmes Nov. 10, 2014, 9:51 p.m. UTC | #4
On 10 November 2014 16:33, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Main propose is stop compilation, right? So there should be some readable
> message. We can pass messages with #error and #warning.
> Usage of ODP_LOG is not needed if we can not compile code.
>
> I think we need to do simple:
>
> #if ODP_ALLOW_UNIMPLEMENTED
> #define ODP_UNIMPLEMENTED(fmt, ...)                        \
>     ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
> #else
> #error    "Function is not implemented. If you still want to build try
> --enable-allow-unimplemented"
>

I like this, much cleaner for the purpose of stopping on compile



> #endif
>
> In that case compilation will trap like this:
> make[2]: Entering directory `/opt/LINARO/ODPrelease/
> ReleaseCommit2/odp2.git/platform/linux-generic'
>   CC     odp_classification.lo
> In file included from odp_classification.c:5:0:
> ./include/odp_debug_internal.h:32:2: error: #error "Function is not
> implemented. If you still want to build try --enable-allow-unimplemented"
> odp_classification.c: In function 'odp_cos_create':
> odp_classification.c:11:2: error: implicit declaration of function
> 'ODP_UNIMPLEMENTED' [-Werror=implicit-function-declaration]
> odp_classification.c:11:2: error: nested extern declaration of
> 'ODP_UNIMPLEMENTED' [-Werror=nested-externs]
> cc1: all warnings being treated as errors
> make[2]: *** [odp_classification.lo] Error 1
>
> Maxim.
>
>
> On 11/10/2014 09:31 PM, Mike Holmes wrote:
>
>>
>>
>> On 7 November 2014 18:19, Bill Fischofer <bill.fischofer@linaro.org
>> <mailto:bill.fischofer@linaro.org>> wrote:
>>
>>     Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org
>>     <mailto:bill.fischofer@linaro.org>>
>>     ---
>>     configure.ac <http://configure.ac>                     | 11
>>     +++++++++++
>>      platform/linux-generic/include/odp_debug_internal.h | 11 +++++++++--
>>      2 files changed, 20 insertions(+), 2 deletions(-)
>>
>>     diff --git a/configure.ac <http://configure.ac> b/configure.ac
>>     <http://configure.ac>
>>     index 1c061e9..cca76bb 100644
>>     --- a/configure.ac <http://configure.ac>
>>     +++ b/configure.ac <http://configure.ac>
>>
>>     @@ -110,6 +110,17 @@ AC_ARG_ENABLE([debug],
>>      ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG"
>>
>>      ############################################################
>> ##############
>>     +# Enable/disable ODP_ALLOW_UNIMPLEMENTED
>>     +###########################################################
>> ###############
>>     +ODP_ALLOW_UNIMPLEMENTED=0
>>     +AC_ARG_ENABLE([allow-unimplemented],
>>     +    [  --enable-allow-unimplemented  Enable/disable allow
>>     unimplemented],
>>     +    [if test "x$enableval" = "xyes"; then
>>     +        ODP_ALLOW_UNIMPLEMENTED=1
>>     +    fi])
>>     +ODP_CFLAGS="$ODP_CFLAGS
>>     -DODP_ALLOW_UNIMPLEMENTED=$ODP_ALLOW_UNIMPLEMENTED"
>>     +
>>     +###########################################################
>> ###############
>>      # Check for pthreads availability
>>      ############################################################
>> ##############
>>
>>     diff --git a/platform/linux-generic/include/odp_debug_internal.h
>>     b/platform/linux-generic/include/odp_debug_internal.h
>>     index a87552f..8ae0b01 100644
>>     --- a/platform/linux-generic/include/odp_debug_internal.h
>>     +++ b/platform/linux-generic/include/odp_debug_internal.h
>>     @@ -25,8 +25,15 @@ extern "C" {
>>      /**
>>       * This macro is used to indicate when a given function is not
>>     implemented
>>
>>
>> nit: does this need to indicate why there are two implementations ?
>> This macro is used to indicate when a given function is not implemented,
>> it can be configured to generate a compile time error or runtime
>> notification.
>>
>>       */
>>     -#define ODP_UNIMPLEMENTED(fmt, ...) \
>>     -               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
>>     +#if ODP_ALLOW_UNIMPLEMENTED
>>     +#define ODP_UNIMPLEMENTED(fmt, ...)                   \
>>
>>
>> The tabs to the continuing backslash are not in keeping with the macros
>> in other files (odp_debug.h) where they have just a single space before the
>> backslash
>> Multiple instances.
>>
>>     +       ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
>>     +#else
>>     +#define ODP_UNIMPLEMENTED(fmt, ...) do {                   \
>>     +               ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt,
>>     ##__VA_ARGS__);     \
>>     +               odp_unimplemented();                   \
>>     +       } while (0)
>>     +#endif
>>
>>      #ifdef __cplusplus
>>      }
>>     --
>>     1.8.3.2
>>
>>
>>     _______________________________________________
>>     lng-odp mailing list
>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>
>> --
>> *Mike Holmes*
>> Linaro  Sr Technical Manager
>> LNG - ODP
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 1c061e9..cca76bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,17 @@  AC_ARG_ENABLE([debug],
 ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG"
 
 ##########################################################################
+# Enable/disable ODP_ALLOW_UNIMPLEMENTED
+##########################################################################
+ODP_ALLOW_UNIMPLEMENTED=0
+AC_ARG_ENABLE([allow-unimplemented],
+    [  --enable-allow-unimplemented  Enable/disable allow unimplemented],
+    [if test "x$enableval" = "xyes"; then
+        ODP_ALLOW_UNIMPLEMENTED=1
+    fi])
+ODP_CFLAGS="$ODP_CFLAGS -DODP_ALLOW_UNIMPLEMENTED=$ODP_ALLOW_UNIMPLEMENTED"
+
+##########################################################################
 # Check for pthreads availability
 ##########################################################################
 
diff --git a/platform/linux-generic/include/odp_debug_internal.h b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..8ae0b01 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,15 @@  extern "C" {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-		ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#if ODP_ALLOW_UNIMPLEMENTED
+#define ODP_UNIMPLEMENTED(fmt, ...)				        \
+	ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#else
+#define ODP_UNIMPLEMENTED(fmt, ...) do {                                \
+		ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__);	\
+		odp_unimplemented();					\
+	} while (0)
+#endif
 
 #ifdef __cplusplus
 }