On 11/5/18 7:37 PM, Michael Matz wrote:
> Hi,
> 
> On Fri, 2 Nov 2018, Martin Liška wrote:
> 
>> V2 of the patch.
>>
>> Thoughts?
> 

Hi.

> Whereever the new function belongs it certainly isn't system.h.  Also the 
> definition in a header seems excessive.  Sure, it enables inlining of it, 
> but that seems premature optimization.  It contains a loop, and inlining 
> anything with loops that aren't very likely to loop just once or never 
> just blows code for no gain.  Also as the function is leaf there won't be 
> any second-order effect from inlining.

Ok, works for me. As you know my main motivation was to provide stronger type
declaration that can be used for 'const char *'. So what about providing 2 
wrappers
and poisoning the implementation?

Martin

> 
> 
> Ciao,
> Michael.
> 

diff --git a/gcc/system.h b/gcc/system.h
index 100feb567c9..fb781645350 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -879,6 +879,23 @@ extern void fancy_abort (const char *, int, const char *)
 #undef strerror
  #pragma GCC poison strerror
 
+/* Define new hash string wappers that will allow to poison
+   the implementation.  */
+
+static inline hashval_t
+hash_string_vptr (const void *p)
+{
+  return htab_hash_string (p);
+}
+
+static inline hashval_t
+hash_string (const char *str)
+{
+  return htab_hash_string ((const char *)str);
+}
+
+#pragma GCC poison htab_hash_string
+
 /* loc_t is defined on some systems and too inviting for some
    programmers to avoid.  */
 #undef loc_t

Reply via email to