diff mbox

[1/2] fix including odp_std_types.h

Message ID 1414779930-17602-1-git-send-email-mike.holmes@linaro.org
State Rejected
Headers show

Commit Message

Mike Holmes Oct. 31, 2014, 6:25 p.m. UTC
The public ODP API should not directly call Linux system  headers

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/api/odp_byteorder.h | 1 -
 platform/linux-generic/include/api/odp_debug.h     | 3 +--
 platform/linux-generic/include/api/odp_std_types.h | 4 +++-
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Savolainen, Petri (NSN - FI/Espoo) Nov. 3, 2014, 8:03 a.m. UTC | #1
> -----Original Message-----
> From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
> bounces@lists.linaro.org] On Behalf Of ext Mike Holmes
> Sent: Friday, October 31, 2014 8:25 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [PATCH 1/2] fix including odp_std_types.h
> 
> The public ODP API should not directly call Linux system  headers

API headers should not include Linux headers at all, only C std lib headers.


> 
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>  platform/linux-generic/include/api/odp_byteorder.h | 1 -
>  platform/linux-generic/include/api/odp_debug.h     | 3 +--
>  platform/linux-generic/include/api/odp_std_types.h | 4 +++-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/platform/linux-generic/include/api/odp_byteorder.h
> b/platform/linux-generic/include/api/odp_byteorder.h
> index 79ddd75..6834ad9 100644
> --- a/platform/linux-generic/include/api/odp_byteorder.h
> +++ b/platform/linux-generic/include/api/odp_byteorder.h
> @@ -18,7 +18,6 @@
>  extern "C" {
>  #endif
> 
> -#include <endian.h>
>  #include <odp_std_types.h>
>  #include <odp_compiler.h>
> 
> diff --git a/platform/linux-generic/include/api/odp_debug.h
> b/platform/linux-generic/include/api/odp_debug.h
> index 0a20430..dad57a8 100644
> --- a/platform/linux-generic/include/api/odp_debug.h
> +++ b/platform/linux-generic/include/api/odp_debug.h
> @@ -12,8 +12,7 @@
>  #ifndef ODP_DEBUG_H_
>  #define ODP_DEBUG_H_
> 
> -#include <stdio.h>
> -#include <stdlib.h>
> +#include <odp_std_types.h>
> 
>  #ifdef __cplusplus
>  extern "C" {
> diff --git a/platform/linux-generic/include/api/odp_std_types.h
> b/platform/linux-generic/include/api/odp_std_types.h
> index b12a2f3..af8c35d 100644
> --- a/platform/linux-generic/include/api/odp_std_types.h
> +++ b/platform/linux-generic/include/api/odp_std_types.h
> @@ -26,7 +26,9 @@ extern "C" {
>  #include <stdint.h>
>  #include <inttypes.h>
>  #include <limits.h>
> -
> +#include <endian.h>

This is not a standard C header and should not be included here. Endian implementation uses some definitions (e.g. _BYTE_ORDER) from endian.h. It's part of implementation and better keep the include in odp_byteorder.h. We could instead remove endian.h and implement the same definitions in the build system.

-Petri


> +#include <stdio.h>
> +#include <stdlib.h>
> 
> 
> 
> --
> 2.1.0
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Bill Fischofer Nov. 3, 2014, 11:36 a.m. UTC | #2
If we move endian config to the build system, I'd think we'd also want to
move the 32-bit vs. 64-bit there as well.  There are a lot of places in the
linux-generic code where uint64_t is used without qualification and that's
not going to work on 32-bit implementations.

On Mon, Nov 3, 2014 at 2:03 AM, Savolainen, Petri (NSN - FI/Espoo) <
petri.savolainen@nsn.com> wrote:

>
>
> > -----Original Message-----
> > From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
> > bounces@lists.linaro.org] On Behalf Of ext Mike Holmes
> > Sent: Friday, October 31, 2014 8:25 PM
> > To: lng-odp@lists.linaro.org
> > Subject: [lng-odp] [PATCH 1/2] fix including odp_std_types.h
> >
> > The public ODP API should not directly call Linux system  headers
>
> API headers should not include Linux headers at all, only C std lib
> headers.
>
>
> >
> > Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> > ---
> >  platform/linux-generic/include/api/odp_byteorder.h | 1 -
> >  platform/linux-generic/include/api/odp_debug.h     | 3 +--
> >  platform/linux-generic/include/api/odp_std_types.h | 4 +++-
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/platform/linux-generic/include/api/odp_byteorder.h
> > b/platform/linux-generic/include/api/odp_byteorder.h
> > index 79ddd75..6834ad9 100644
> > --- a/platform/linux-generic/include/api/odp_byteorder.h
> > +++ b/platform/linux-generic/include/api/odp_byteorder.h
> > @@ -18,7 +18,6 @@
> >  extern "C" {
> >  #endif
> >
> > -#include <endian.h>
> >  #include <odp_std_types.h>
> >  #include <odp_compiler.h>
> >
> > diff --git a/platform/linux-generic/include/api/odp_debug.h
> > b/platform/linux-generic/include/api/odp_debug.h
> > index 0a20430..dad57a8 100644
> > --- a/platform/linux-generic/include/api/odp_debug.h
> > +++ b/platform/linux-generic/include/api/odp_debug.h
> > @@ -12,8 +12,7 @@
> >  #ifndef ODP_DEBUG_H_
> >  #define ODP_DEBUG_H_
> >
> > -#include <stdio.h>
> > -#include <stdlib.h>
> > +#include <odp_std_types.h>
> >
> >  #ifdef __cplusplus
> >  extern "C" {
> > diff --git a/platform/linux-generic/include/api/odp_std_types.h
> > b/platform/linux-generic/include/api/odp_std_types.h
> > index b12a2f3..af8c35d 100644
> > --- a/platform/linux-generic/include/api/odp_std_types.h
> > +++ b/platform/linux-generic/include/api/odp_std_types.h
> > @@ -26,7 +26,9 @@ extern "C" {
> >  #include <stdint.h>
> >  #include <inttypes.h>
> >  #include <limits.h>
> > -
> > +#include <endian.h>
>
> This is not a standard C header and should not be included here. Endian
> implementation uses some definitions (e.g. _BYTE_ORDER) from endian.h. It's
> part of implementation and better keep the include in odp_byteorder.h. We
> could instead remove endian.h and implement the same definitions in the
> build system.
>
> -Petri
>
>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> >
> >
> >
> > --
> > 2.1.0
> >
> >
> > _______________________________________________
> > 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/platform/linux-generic/include/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h
index 79ddd75..6834ad9 100644
--- a/platform/linux-generic/include/api/odp_byteorder.h
+++ b/platform/linux-generic/include/api/odp_byteorder.h
@@ -18,7 +18,6 @@ 
 extern "C" {
 #endif
 
-#include <endian.h>
 #include <odp_std_types.h>
 #include <odp_compiler.h>
 
diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h
index 0a20430..dad57a8 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -12,8 +12,7 @@ 
 #ifndef ODP_DEBUG_H_
 #define ODP_DEBUG_H_
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <odp_std_types.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/platform/linux-generic/include/api/odp_std_types.h b/platform/linux-generic/include/api/odp_std_types.h
index b12a2f3..af8c35d 100644
--- a/platform/linux-generic/include/api/odp_std_types.h
+++ b/platform/linux-generic/include/api/odp_std_types.h
@@ -26,7 +26,9 @@  extern "C" {
 #include <stdint.h>
 #include <inttypes.h>
 #include <limits.h>
-
+#include <endian.h>
+#include <stdio.h>
+#include <stdlib.h>