bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#65491: [PATCH] Improve performance allocating vectors


From: Eli Zaretskii
Subject: bug#65491: [PATCH] Improve performance allocating vectors
Date: Sat, 16 Sep 2023 19:54:02 +0300

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Sat, 16 Sep 2023 18:32:31 +0200
> Cc: 65491@debbugs.gnu.org,
>  monnier@iro.umontreal.ca
> 
> The new XUNTAG is:
> 
> #define XUNTAG(a, type, ctype) ((ctype *) \
>                               ((uintptr_t) XLP (a) - LISP_WORD_TAG (type)))
> 
> so you get a warning from what, conversion of a 64-bit number to (ctype *)?

Yes, I think so:

  In file included from dispnew.c:27:
  lisp.h: In function 'PSEUDOVECTORP':
  lisp.h:813:33: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
    813 | #define XUNTAG(a, type, ctype) ((ctype *) \
        |                                 ^
  lisp.h:374:6: note: in expansion of macro 'XUNTAG'
    374 |    ((XUNTAG ((a), Lisp_Vectorlike, union vectorlike_header)->size     
\
        |      ^~~~~~
  lisp.h:1127:10: note: in expansion of macro 'lisp_h_PSEUDOVECTORP'
   1127 |   return lisp_h_PSEUDOVECTORP (a, code);
        |          ^~~~~~~~~~~~~~~~~~~~
  lisp.h: In function 'XSYMBOL_WITH_POS':
  lisp.h:813:33: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
    813 | #define XUNTAG(a, type, ctype) ((ctype *) \
        |                                 ^
  lisp.h:1152:12: note: in expansion of macro 'XUNTAG'
   1152 |     return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Symbol_With_Pos);
        |            ^~~~~~
  lisp.h: In function 'XBARE_SYMBOL':
  lisp.h:813:33: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
    813 | #define XUNTAG(a, type, ctype) ((ctype *) \
        |                                 ^
  lisp.h:1159:27: note: in expansion of macro 'XUNTAG'
   1159 |   intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol);
      |                           ^~~~~~

> Does changing the definition to
> 
> #define XUNTAG(a, type, ctype) \
>   ((ctype *) ((uintptr_t) XLP (a) - (uintptr_t)LISP_WORD_TAG (type)))
> 
> help? (That is, cast the LISP_WORD_TAG return value to uintptr_t.)

It does, but LISP_WORD_TAG(type) is a 64=bit type with the only bits
set above 32 bit, so how casting it to uintptr_t is TRT?

Why did you need to change the original cast in the first place?





reply via email to

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