From a742a62dd06b3bdca2f92263648714dd3188bfe7 Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Wed, 18 Feb 2015 12:38:04 -0700 Subject: [PATCH] Win: Can now use "static inline" on Windows (i.e. no code mods). --- icd/common/icd-format.h | 10 +++++----- icd/common/icd-utils.h | 14 +++++++------- icd/nulldrv/nulldrv.h | 8 -------- include/xglIcd.h | 4 ++-- include/xglPlatform.h | 8 ++++---- xgl-generate.py | 6 +++--- xgl_helper.py | 11 +++-------- 7 files changed, 24 insertions(+), 37 deletions(-) diff --git a/icd/common/icd-format.h b/icd/common/icd-format.h index 7aa5001..28c2dca 100644 --- a/icd/common/icd-format.h +++ b/icd/common/icd-format.h @@ -31,14 +31,14 @@ #include #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) || diff --git a/icd/common/icd-utils.h b/icd/common/icd-utils.h index aad6c3e..fa9c323 100644 --- a/icd/common/icd-utils.h +++ b/icd/common/icd-utils.h @@ -65,12 +65,12 @@ /** * 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); diff --git a/icd/nulldrv/nulldrv.h b/icd/nulldrv/nulldrv.h index b32cbb7..70168c3 100644 --- a/icd/nulldrv/nulldrv.h +++ b/icd/nulldrv/nulldrv.h @@ -40,14 +40,6 @@ #include #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" diff --git a/include/xglIcd.h b/include/xglIcd.h index 3efffe6..1c25936 100644 --- a/include/xglIcd.h +++ b/include/xglIcd.h @@ -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; } diff --git a/include/xglPlatform.h b/include/xglPlatform.h index af006a2..aff2e5b 100644 --- a/include/xglPlatform.h +++ b/include/xglPlatform.h @@ -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!" diff --git a/xgl-generate.py b/xgl-generate.py index 202b30f..9164cda 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -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")) diff --git a/xgl_helper.py b/xgl_helper.py index 630a6c4..19dbc43 100755 --- a/xgl_helper.py +++ b/xgl_helper.py @@ -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) -- 2.7.4