lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lightning] [PATCH 1/3] misc: Make jit_note and related functions ta


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] [PATCH 1/3] misc: Make jit_note and related functions take a const argument
Date: Mon, 27 Oct 2014 00:19:42 -0200

2014-10-26 19:21 GMT-02:00 Holger Hans Peter Freyther <address@hidden>:
> From: Holger Hans Peter Freyther <address@hidden>
>
> Make jit_memcpy, jit_memmove, jit_data take const pointers to
> allow jit_note to be used with a const string (e.g. a string
> literal, __FILE__ or __func__). This is needed for GNU Smalltalk
> to silence compiler warnings.

  Actually, I think the jit_data() prototype call could be moved to
jit_private.h, because there is not much point in calling it (it would
still be available, but no longer have a prototype). It is used to
create an entry in a hash of unique data, used to store read only
strings and literals.

> Sadly "const jit_pointer_t" is not the same as "typedef const void *"
> so I introduced a new typedef for a const jit pointer. The other
> option would be to replace jit_pointer_t with void*.

  Are you patching the prototypes not from lightning.h because of
bundling lightning? Anyway I think it is a good idea to silence those
warnings.

  If you are rediffing the series (due to comment in patch 3), I would
prefer to have jit_const_pointer_t only in jit_private.h, and jit_data
prototype moved there, could as well use "const void*".

> ---
>  include/lightning.h             | 5 +++--
>  include/lightning/jit_private.h | 4 ++--
>  lib/jit_memory.c                | 4 ++--
>  lib/jit_note.c                  | 2 +-
>  lib/lightning.c                 | 8 ++++----
>  5 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/include/lightning.h b/include/lightning.h
> index b495af8..ad48af8 100644
> --- a/include/lightning.h
> +++ b/include/lightning.h
> @@ -120,6 +120,7 @@ typedef jit_uint64_t                jit_uword_t;
>  typedef float                  jit_float32_t;
>  typedef double                 jit_float64_t;
>  typedef void*                  jit_pointer_t;
> +typedef const void*            jit_const_pointer_t;
>  typedef jit_int32_t            jit_bool_t;
>  typedef jit_int32_t            jit_gpr_t;
>  typedef jit_int32_t            jit_fpr_t;
> @@ -856,10 +857,10 @@ extern void _jit_destroy_state(jit_state_t*);
>
>  #define jit_address(node)      _jit_address(_jit, node)
>  extern jit_pointer_t _jit_address(jit_state_t*, jit_node_t*);
> -extern jit_node_t *_jit_data(jit_state_t*, jit_pointer_t,
> +extern jit_node_t *_jit_data(jit_state_t*, jit_const_pointer_t,
>                              jit_word_t, jit_int32_t);
>  extern jit_node_t *_jit_name(jit_state_t*, char*);
> -extern jit_node_t *_jit_note(jit_state_t*, char*, int);
> +extern jit_node_t *_jit_note(jit_state_t*, const char*, int);
>  extern jit_node_t *_jit_label(jit_state_t*);
>  extern jit_node_t *_jit_forward(jit_state_t*);
>  extern jit_node_t *_jit_indirect(jit_state_t*);
> diff --git a/include/lightning/jit_private.h b/include/lightning/jit_private.h
> index 128bd1a..a92a69a 100644
> --- a/include/lightning/jit_private.h
> +++ b/include/lightning/jit_private.h
> @@ -611,8 +611,8 @@ extern void _jit_set_note(jit_state_t*, jit_note_t*, 
> char*, int, jit_int32_t);
>  #define jit_annotate()         _jit_annotate(_jit)
>  extern void _jit_annotate(jit_state_t*);
>
> -extern jit_pointer_t jit_memcpy(jit_pointer_t,jit_pointer_t,jit_word_t);
> -extern jit_pointer_t jit_memmove(jit_pointer_t,jit_pointer_t,jit_word_t);
> +extern jit_pointer_t 
> jit_memcpy(jit_pointer_t,jit_const_pointer_t,jit_word_t);
> +extern jit_pointer_t 
> jit_memmove(jit_pointer_t,jit_const_pointer_t,jit_word_t);
>  extern void jit_alloc(jit_pointer_t*, jit_word_t);
>  extern void jit_realloc(jit_pointer_t*, jit_word_t, jit_word_t);
>  void jit_free(jit_pointer_t*);
> diff --git a/lib/jit_memory.c b/lib/jit_memory.c
> index b4193e4..491a42f 100644
> --- a/lib/jit_memory.c
> +++ b/lib/jit_memory.c
> @@ -39,7 +39,7 @@ static jit_free_func_ptr jit_free_ptr = 
> jit_default_free_func;
>   * Implementation
>   */
>  jit_pointer_t
> -jit_memcpy(jit_pointer_t dst, jit_pointer_t src, jit_word_t size)
> +jit_memcpy(jit_pointer_t dst, jit_const_pointer_t src, jit_word_t size)
>  {
>      if (size)
>         return (memcpy(dst, src, size));
> @@ -47,7 +47,7 @@ jit_memcpy(jit_pointer_t dst, jit_pointer_t src, jit_word_t 
> size)
>  }
>
>  jit_pointer_t
> -jit_memmove(jit_pointer_t dst, jit_pointer_t src , jit_word_t size)
> +jit_memmove(jit_pointer_t dst, jit_const_pointer_t src , jit_word_t size)
>  {
>      if (size)
>         return (memmove(dst, src, size));
> diff --git a/lib/jit_note.c b/lib/jit_note.c
> index f3d35fa..b8a18ce 100644
> --- a/lib/jit_note.c
> +++ b/lib/jit_note.c
> @@ -70,7 +70,7 @@ _jit_name(jit_state_t *_jit, char *name)
>  }
>
>  jit_node_t *
> -_jit_note(jit_state_t *_jit, char *name, int line)
> +_jit_note(jit_state_t *_jit, const char *name, int line)
>  {
>      jit_node_t         *node;
>
> diff --git a/lib/lightning.c b/lib/lightning.c
> index 7240f6b..883d652 100644
> --- a/lib/lightning.c
> +++ b/lib/lightning.c
> @@ -44,7 +44,7 @@
>  /*
>   * Prototypes
>   */
> -static jit_word_t hash_data(jit_pointer_t, jit_word_t);
> +static jit_word_t hash_data(jit_const_pointer_t, jit_word_t);
>
>  #define new_pool()                     _new_pool(_jit)
>  static void _new_pool(jit_state_t*);
> @@ -536,9 +536,9 @@ _jit_load(jit_state_t *_jit, jit_int32_t reg)
>  }
>
>  static jit_word_t
> -hash_data(jit_pointer_t data, jit_word_t length)
> +hash_data(jit_const_pointer_t data, jit_word_t length)
>  {
> -    jit_uint8_t                *ptr;
> +    const jit_uint8_t          *ptr;
>      jit_word_t          i, key;
>      for (i = key = 0, ptr = data; i < length; i++)
>         key = (key << (key & 1)) ^ ptr[i];
> @@ -558,7 +558,7 @@ _jit_address(jit_state_t *_jit, jit_node_t *node)
>  }
>
>  jit_node_t *
> -_jit_data(jit_state_t *_jit, jit_pointer_t data,
> +_jit_data(jit_state_t *_jit, jit_const_pointer_t data,
>           jit_word_t length, jit_int32_t align)
>  {
>      jit_word_t          key;
> --
> 2.1.1

Thanks,
Paulo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]