Win: Can now use "static inline" on Windows (i.e. no code mods).
authorIan Elliott <ian@LunarG.com>
Wed, 18 Feb 2015 19:38:04 +0000 (12:38 -0700)
committerIan Elliott <ian@LunarG.com>
Wed, 18 Feb 2015 22:47:24 +0000 (15:47 -0700)
icd/common/icd-format.h
icd/common/icd-utils.h
icd/nulldrv/nulldrv.h
include/xglIcd.h
include/xglPlatform.h
xgl-generate.py
xgl_helper.py

index 7aa5001..28c2dca 100644 (file)
 #include <stdbool.h>
 #include "icd.h"
 
-STATIC_INLINE bool icd_format_is_undef(XGL_FORMAT format)
+static inline bool icd_format_is_undef(XGL_FORMAT format)
 {
     return (format == XGL_FMT_UNDEFINED);
 }
 
 bool icd_format_is_ds(XGL_FORMAT format);
 
-STATIC_INLINE bool icd_format_is_color(XGL_FORMAT format)
+static inline bool icd_format_is_color(XGL_FORMAT format)
 {
     return !(icd_format_is_undef(format) || icd_format_is_ds(format));
 }
@@ -53,13 +53,13 @@ bool icd_format_is_srgb(XGL_FORMAT format);
 
 bool icd_format_is_compressed(XGL_FORMAT format);
 
-STATIC_INLINE int icd_format_get_block_width(XGL_FORMAT format)
+static inline int icd_format_get_block_width(XGL_FORMAT format)
 {
     /* all compressed formats use 4x4 blocks */
     return (icd_format_is_compressed(format)) ? 4 : 1;
 }
 
-STATIC_INLINE bool icd_blend_mode_is_dual_src(XGL_BLEND mode)
+static inline bool icd_blend_mode_is_dual_src(XGL_BLEND mode)
 {
     return (mode == XGL_BLEND_SRC1_COLOR) ||
            (mode == XGL_BLEND_SRC1_ALPHA) ||
@@ -67,7 +67,7 @@ STATIC_INLINE bool icd_blend_mode_is_dual_src(XGL_BLEND mode)
            (mode == XGL_BLEND_ONE_MINUS_SRC1_ALPHA);
 }
 
-STATIC_INLINE bool icd_pipeline_cb_att_needs_dual_source_blending(const XGL_PIPELINE_CB_ATTACHMENT_STATE *att)
+static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const XGL_PIPELINE_CB_ATTACHMENT_STATE *att)
 {
     if (icd_blend_mode_is_dual_src(att->srcBlendColor) ||
         icd_blend_mode_is_dual_src(att->srcBlendAlpha) ||
index aad6c3e..fa9c323 100644 (file)
 /**
  * Return true if val is power of two, or zero.
  */
-STATIC_INLINE bool u_is_pow2(unsigned int val)
+static inline bool u_is_pow2(unsigned int val)
 {
     return ((val & (val - 1)) == 0);
 }
 
-STATIC_INLINE int u_ffs(int val)
+static inline int u_ffs(int val)
 {
 #if defined(PLATFORM_LINUX)
        return ffs(val);
@@ -79,18 +79,18 @@ STATIC_INLINE int u_ffs(int val)
 #endif
 }
 
-STATIC_INLINE unsigned int u_align(unsigned int val, unsigned alignment)
+static inline unsigned int u_align(unsigned int val, unsigned alignment)
 {
     assert(alignment && u_is_pow2(alignment));
     return (val + alignment - 1) & ~(alignment - 1);
 }
 
-STATIC_INLINE unsigned int u_minify(unsigned int val, unsigned level)
+static inline unsigned int u_minify(unsigned int val, unsigned level)
 {
     return (val >> level) ? val >> level : 1;
 }
 
-STATIC_INLINE uint32_t u_fui(float f)
+static inline uint32_t u_fui(float f)
 {
     union {
         float f;
@@ -100,7 +100,7 @@ STATIC_INLINE uint32_t u_fui(float f)
     return u.ui;
 }
 
-STATIC_INLINE float u_uif(uint32_t ui)
+static inline float u_uif(uint32_t ui)
 {
     union {
         float f;
@@ -110,7 +110,7 @@ STATIC_INLINE float u_uif(uint32_t ui)
     return u.f;
 }
 
-STATIC_INLINE int u_iround(float f)
+static inline int u_iround(float f)
 {
     if (f >= 0.0f)
         return (int) (f + 0.5f);
index b32cbb7..70168c3 100644 (file)
 #include <xglWsiWinExt.h>
 #endif
 
-#ifndef STATIC_INLINE
-#if defined(PLATFORM_LINUX)
-#define STATIC_INLINE static inline
-#else
-#define STATIC_INLINE static
-#endif
-#endif
-
 #include "icd.h"
 #include "icd-alloc.h"
 
index 3efffe6..1c25936 100644 (file)
@@ -18,12 +18,12 @@ typedef union _XGL_LOADER_DATA {
   void *loaderData;
 } XGL_LOADER_DATA;
 
-STATIC_INLINE void set_loader_magic_value(void *pNewObject) {
+static inline void set_loader_magic_value(void *pNewObject) {
     XGL_LOADER_DATA *loader_info = (XGL_LOADER_DATA *) pNewObject;
     loader_info->loaderMagic = ICD_LOADER_MAGIC;
 }
 
-STATIC_INLINE bool valid_loader_magic_value(void *pNewObject) {
+static inline bool valid_loader_magic_value(void *pNewObject) {
     const XGL_LOADER_DATA *loader_info = (XGL_LOADER_DATA *) pNewObject;
     return loader_info->loaderMagic == ICD_LOADER_MAGIC;
 }
index af006a2..aff2e5b 100644 (file)
@@ -44,13 +44,13 @@ extern "C"
     #define XGLAPI   __stdcall
 
     // C99:
-    #define STATIC_INLINE static
+#ifndef __cplusplus
+    #undef inline
+    #define inline __inline
+#endif // __cplusplus
 #elif defined(__GNUC__)
     // On other platforms using GCC, XGLAPI stays undefined
     #define XGLAPI
-
-    // C99:
-    #define STATIC_INLINE static inline
 #else
     // Unsupported Platform!
     #error "Unsupported OS Platform detected!"
index 202b30f..9164cda 100755 (executable)
@@ -275,7 +275,7 @@ class DispatchTableOpsSubcommand(Subcommand):
         stmts.append("#endif")
 
         func = []
-        func.append("STATIC_INLINE void %s_initialize_dispatch_table(XGL_LAYER_DISPATCH_TABLE *table,"
+        func.append("static inline void %s_initialize_dispatch_table(XGL_LAYER_DISPATCH_TABLE *table,"
                 % self.prefix)
         func.append("%s                                              xglGetProcAddrType gpa,"
                 % (" " * len(self.prefix)))
@@ -298,7 +298,7 @@ class DispatchTableOpsSubcommand(Subcommand):
         lookups.append("#endif")
 
         func = []
-        func.append("STATIC_INLINE void *%s_lookup_dispatch_table(const XGL_LAYER_DISPATCH_TABLE *table,"
+        func.append("static inline void *%s_lookup_dispatch_table(const XGL_LAYER_DISPATCH_TABLE *table,"
                 % self.prefix)
         func.append("%s                                           const char *name)"
                 % (" " * len(self.prefix)))
@@ -419,7 +419,7 @@ class LayerInterceptProcSubcommand(Subcommand):
         lookups.append("#endif")
 
         body = []
-        body.append("STATIC_INLINE %s layer_intercept_proc(const char *name)" %
+        body.append("static inline %s layer_intercept_proc(const char *name)" %
                 self.gpa.ret)
         body.append("{")
         body.append(generate_get_proc_addr_check("name"))
index 630a6c4..19dbc43 100755 (executable)
@@ -1015,7 +1015,7 @@ class EnumCodeGen:
         body = []
         for bet in self.et_dict:
             fet = self.tf_dict[bet]
-            body.append("STATIC_INLINE uint32_t validate_%s(%s input_value)\n{\n    switch ((%s)input_value)\n    {" % (fet, fet, fet))
+            body.append("static inline uint32_t validate_%s(%s input_value)\n{\n    switch ((%s)input_value)\n    {" % (fet, fet, fet))
             for e in sorted(self.et_dict[bet]):
                 if (self.ev_dict[e]['unique']):
                     body.append('        case %s:' % (e))
@@ -1028,7 +1028,7 @@ class EnumCodeGen:
             # bet == base_enum_type, fet == final_enum_type
         for bet in self.et_dict:
             fet = self.tf_dict[bet]
-            body.append("STATIC_INLINE const char* string_%s(%s input_value)\n{\n    switch ((%s)input_value)\n    {" % (fet, fet, fet))
+            body.append("static inline const char* string_%s(%s input_value)\n{\n    switch ((%s)input_value)\n    {" % (fet, fet, fet))
             for e in sorted(self.et_dict[bet]):
                 if (self.ev_dict[e]['unique']):
                     body.append('        case %s:\n            return "%s";' % (e, e))
@@ -1038,12 +1038,7 @@ class EnumCodeGen:
     def _generateSHHeader(self):
         header = []
         header.append('#pragma once\n')
-        header.append('#include <%s>\n' % self.in_file)
-        header.append('#if defined(_WIN32)')
-        header.append('#define STATIC_INLINE static')
-        header.append('#else  // defined(_WIN32)')
-        header.append('#define STATIC_INLINE static inline')
-        header.append('#endif // defined(_WIN32)\n\n\n')
+        header.append('#include <%s>\n\n\n' % self.in_file)
         return "\n".join(header)