[waffle] [PATCH] android: Don't specify -std=gnu99 for C++ builds -- it breaks clang

2015-04-09 Thread Emil Velikov
From: Bernhard Rosenkränzer bernhard.rosenkran...@linaro.org

Signed-off-by: Bernhard Rosenkränzer bernhard.rosenkran...@linaro.org
[Emil Velikov: Apply the workaround for kitkat and older]
Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 Android.mk | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Android.mk b/Android.mk
index d29a16a..abfe4ff 100644
--- a/Android.mk
+++ b/Android.mk
@@ -13,6 +13,7 @@ waffle_api_version := 0x0106
 
 waffle_android_major_version := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
 waffle_android_minor_version := $(word 2, $(subst ., , $(PLATFORM_VERSION)))
+waffle_android_version := 
$(waffle_android_major_version).$(waffle_android_minor_version)
 
 $(waffle_top)/include/waffle/waffle_version.h: \
 $(waffle_top)/Android.mk \
@@ -36,7 +37,13 @@ LOCAL_CFLAGS := \
 -DWAFFLE_ANDROID_MINOR_VERSION=$(waffle_android_minor_version) \
 -Wno-pointer-arith
 
-LOCAL_CFLAGS += -std=c99 -fvisibility=hidden
+ifeq ($(shell echo $(waffle_android_version) = 4.4 | bc),1)
+LOCAL_CONLYFLAGS := -std=c99
+else
+LOCAL_CFLAGS += -std=c99
+endif
+
+LOCAL_CFLAGS += -fvisibility=hidden
 
 LOCAL_C_INCLUDES := \
 $(LOCAL_PATH)/include \
-- 
2.3.1

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 01/10] api/core: annotate structs/functions for C linkage

2015-04-09 Thread Tapani

Reviewed-by: Tapani Pälli tapani.pa...@intel.com

On 03/24/2015 05:56 PM, Emil Velikov wrote:

Annotate as extern C when included in C++ files to prevent issues due
to conflicting linkage - C vs C++. With follow up commits we'll remove
the extern C { #include header.h } pattern which we currently use.

Conditionally including system headers (either directly or not) in such
a construct in a bad idea as they might include C++ symbols.

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
  src/waffle/api/api_object.h  | 8 
  src/waffle/core/wcore_config.h   | 8 
  src/waffle/core/wcore_config_attrs.h | 8 
  src/waffle/core/wcore_display.h  | 8 
  src/waffle/core/wcore_error.h| 8 
  src/waffle/core/wcore_util.h | 8 
  6 files changed, 48 insertions(+)

diff --git a/src/waffle/api/api_object.h b/src/waffle/api/api_object.h
index d417d0a..ef11c5b 100644
--- a/src/waffle/api/api_object.h
+++ b/src/waffle/api/api_object.h
@@ -27,6 +27,10 @@
  
  #include waffle.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  // This header is so sad and lonely... but there is no other appropriate place
  // to define this struct.
  
@@ -36,3 +40,7 @@ struct api_object {

  /// For consistency, a `waffle_display` belongs to itself.
  size_t display_id;
  };
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/core/wcore_config.h b/src/waffle/core/wcore_config.h
index 27534af..2fc02d5 100644
--- a/src/waffle/core/wcore_config.h
+++ b/src/waffle/core/wcore_config.h
@@ -36,6 +36,10 @@
  #include wcore_config_attrs.h
  #include wcore_util.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  struct wcore_config;
  union waffle_native_config;
  
@@ -77,3 +81,7 @@ wcore_config_teardown(struct wcore_config *self)

  assert(self);
  return true;
  }
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/core/wcore_config_attrs.h 
b/src/waffle/core/wcore_config_attrs.h
index 0eaa4a1..cca5e8b 100644
--- a/src/waffle/core/wcore_config_attrs.h
+++ b/src/waffle/core/wcore_config_attrs.h
@@ -28,6 +28,10 @@
  #include stdbool.h
  #include stdint.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  /// @brief Encodes the attribute list received by waffle_config_choose().
  struct wcore_config_attrs {
  int32_t context_api;
@@ -84,3 +88,7 @@ bool
  wcore_config_attrs_version_le(
const struct wcore_config_attrs *attrs,
int merged_version);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h
index de6ca5e..53f7d08 100644
--- a/src/waffle/core/wcore_display.h
+++ b/src/waffle/core/wcore_display.h
@@ -32,6 +32,10 @@
  
  #include wcore_util.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  struct wcore_display;
  struct wcore_platform;
  union waffle_native_display;
@@ -63,3 +67,7 @@ wcore_display_teardown(struct wcore_display *self)
  assert(self);
  return true;
  }
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/core/wcore_error.h b/src/waffle/core/wcore_error.h
index 0a9767c..cee5bd1 100644
--- a/src/waffle/core/wcore_error.h
+++ b/src/waffle/core/wcore_error.h
@@ -29,6 +29,10 @@
  
  #include waffle.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  /// @brief Thread-local info for the wcore_error module.
  struct wcore_error_tinfo;
  
@@ -92,3 +96,7 @@ _wcore_error_internal(const char *file, int line, const char *format, ...);
  
  void _wcore_error_enable(void);

  void _wcore_error_disable(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/core/wcore_util.h b/src/waffle/core/wcore_util.h
index 183134f..b823b21 100644
--- a/src/waffle/core/wcore_util.h
+++ b/src/waffle/core/wcore_util.h
@@ -28,6 +28,10 @@
  #include stddef.h
  #include c99_compat.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  #define container_of(ptr, type, member) ({  \
  const __typeof__(((type *)0)-member ) *__mptr = (ptr); \
  (type*)((void*)__mptr - offsetof(type, member));\
@@ -107,3 +111,7 @@ wcore_calloc(size_t size);
  
  const char*

  wcore_enum_to_string(int32_t e);
+
+#ifdef __cplusplus
+}
+#endif


___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2 07/10] nacl: untangle header inclusions

2015-04-09 Thread Tapani

Reviewed-by: Tapani Pälli tapani.pa...@intel.com

On 03/25/2015 03:56 PM, Emil Velikov wrote:

Use direct inclusion of the header providing the symbol. This improves
the overall readability and allows us to easily track which headers are
actually included via C++ files. This way we can add the proper notation.

v2: Do not use api_platform but context-display-platform.

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
  src/waffle/nacl/nacl_config.c  |  5 -
  src/waffle/nacl/nacl_config.h  | 11 +++
  src/waffle/nacl/nacl_container.cpp |  4 
  src/waffle/nacl/nacl_container.h   |  5 +++--
  src/waffle/nacl/nacl_context.c | 14 +++---
  src/waffle/nacl/nacl_context.h |  5 ++---
  src/waffle/nacl/nacl_display.c |  2 ++
  src/waffle/nacl/nacl_display.h |  4 +++-
  src/waffle/nacl/nacl_platform.c|  5 +
  src/waffle/nacl/nacl_platform.h|  7 ---
  src/waffle/nacl/nacl_window.c  |  6 +++---
  src/waffle/nacl/nacl_window.h  |  4 ++--
  12 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c
index 16adc66..9017775 100644
--- a/src/waffle/nacl/nacl_config.c
+++ b/src/waffle/nacl/nacl_config.c
@@ -24,9 +24,12 @@
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
  #include ppapi/c/pp_graphics_3d.h

-#include nacl_config.h
+
+#include wcore_config_attrs.h
  #include wcore_error.h
  
+#include nacl_config.h

+
  bool
  nacl_config_destroy(struct wcore_config *wc_self)
  {
diff --git a/src/waffle/nacl/nacl_config.h b/src/waffle/nacl/nacl_config.h
index 47fa252..d461d43 100644
--- a/src/waffle/nacl/nacl_config.h
+++ b/src/waffle/nacl/nacl_config.h
@@ -25,9 +25,16 @@
  
  #pragma once
  
+#include stdbool.h

+#include stdint.h
+
  #include wcore_config.h
  #include wcore_util.h
  
+#ifdef __cplusplus

+extern C {
+#endif
+
  struct wcore_config_attrs;
  struct wcore_platform;
  
@@ -48,3 +55,7 @@ nacl_config_choose(struct wcore_platform *wc_plat,
  
  bool

  nacl_config_destroy(struct wcore_config *wc_self);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/nacl/nacl_container.cpp 
b/src/waffle/nacl/nacl_container.cpp
index 524d1d9..e3d89fd 100644
--- a/src/waffle/nacl/nacl_container.cpp
+++ b/src/waffle/nacl/nacl_container.cpp
@@ -29,6 +29,10 @@
  #include ppapi/cpp/instance.h
  #include ppapi/cpp/module.h
  #include ppapi/c/pp_errors.h
+
+#include wcore_error.h
+
+#include nacl_config.h
  #include nacl_container.h
  #include nacl_swap_thread.h
  
diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h

index 6a864a4..055928a 100644
--- a/src/waffle/nacl/nacl_container.h
+++ b/src/waffle/nacl/nacl_container.h
@@ -23,8 +23,8 @@
  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
-#include nacl_config.h

-#include wcore_error.h
+#include stdbool.h
+#include stdint.h
  
  #ifdef __cplusplus

  extern C {
@@ -33,6 +33,7 @@ extern C {
  #define NACL_GLES2_LIBRARY libppapi_gles2.so
  
  struct nacl_container;

+struct nacl_config;
  
  struct nacl_container *nacl_container_init();

  void nacl_container_teardown(struct nacl_container *nc);
diff --git a/src/waffle/nacl/nacl_context.c b/src/waffle/nacl/nacl_context.c
index e67a913..52015c2 100644
--- a/src/waffle/nacl/nacl_context.c
+++ b/src/waffle/nacl/nacl_context.c
@@ -23,24 +23,24 @@
  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
+#include nacl_config.h

+#include nacl_container.h
  #include nacl_context.h
-#include api_priv.h
+#include nacl_platform.h
  
  bool

  nacl_context_destroy(struct wcore_context *wc_self)
  {
-struct nacl_context *self;
+struct nacl_context *self = nacl_context(wc_self);
+struct nacl_platform *plat;
  bool ok = true;
  
  if (!wc_self)

  return ok;
  
-struct nacl_platform *nacl_plat =

-nacl_platform(api_platform);
-
-self = nacl_context(wc_self);
+plat = nacl_platform(wc_self-display-platform);
  
-nacl_container_context_fini(nacl_plat-nacl);

+nacl_container_context_fini(plat-nacl);
  
  ok = wcore_context_teardown(wc_self);

  free(self);
diff --git a/src/waffle/nacl/nacl_context.h b/src/waffle/nacl/nacl_context.h
index bb4481a..1330e27 100644
--- a/src/waffle/nacl/nacl_context.h
+++ b/src/waffle/nacl/nacl_context.h
@@ -25,12 +25,11 @@
  
  #pragma once
  
+#include stdbool.h

+
  #include wcore_context.h
  #include wcore_util.h
  
-#include nacl_display.h

-#include nacl_platform.h
-
  struct wcore_config;
  struct wcore_platform;
  
diff --git a/src/waffle/nacl/nacl_display.c b/src/waffle/nacl/nacl_display.c

index d1906fe..7e18ba3 100644
--- a/src/waffle/nacl/nacl_display.c
+++ b/src/waffle/nacl/nacl_display.c
@@ -23,6 +23,8 @@
  // OR TORT (INCLUDING 

Re: [waffle] [PATCH 00/10] nacl dl rework and header cleanups et all

2015-04-09 Thread Chad Versace

On Tue 24 Mar 2015, Emil Velikov wrote:

Hi all,

Was pondering on the trivial nacl_dl* nitpick I was talking about
earlier and I've noticed something more interesting along the way.
Namely: in some places in waffle we include headers explicitly wrapped
for C linkage (extern C { #include foo.h }).

As mentioned by Jose over at mesa-dev and Oracle's acticle [1] one
should avoid doing so as the system headers might have C++ symbols.

So with this series I've added added extra guards where needed, reworked
the header inclusion, and nacl_cl similar to other parts in waffle and
added a few missing pragma once guards.

Patch 6 is slightly on the bikeshed side, so I won't object it people
want to take it out the back and shoot it :-P


Emil, these cleanups look good to me. And I agree that bike-sheddy patch
6 does make the code a bit more readable. All patches are

Reviewed-by: Chad Versace chad.vers...@intel.com

Please add mine and Tapani's r-b's to your patches and send a pull
request. (I tried applying and pushing the patches myself, but
encountered some git-am conflicts I didn't understand).
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle