[Pyrex] probably bug with extern ctypedef in Pyrex 0.9.5.1a

Alexander Belchenko bialix at ukr.net
Wed Aug 1 12:47:12 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here is small example (snippet from bzr sources):

cdef extern from "stdint.h":
    ctypedef int intptr_t


cdef int _is_aligned(void *ptr):
    """Is this pointer aligned to an integer size offset?

    :return: 1 if this pointer is aligned, 0 otherwise.
    """
    return ((<intptr_t>ptr) & ((sizeof(int))-1)) == 0


For this example Pyrex generate correct
#include "stdint.h"

But also for some reason substitute in generated C-code
intptr_t with int. I think it's incorrect.

static int __pyx_f_4test__is_aligned(void (*__pyx_v_ptr)) {
  int __pyx_r;

  /* "E:\work\111\test.pyx":6 */
  __pyx_k1;

  /* "E:\work\111\test.pyx":10 */
  __pyx_r = ((((int )__pyx_v_ptr) & ((sizeof(int )) - 1)) == 0);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}


[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGsGSvzYr338mxwCURApQ9AJ0Z/9CfZR2OMDM2nsx/ZOdS/OyymACfXm1q
oDPAdMbRd3BO2MiqkvTJ2xs=
=y8js
-----END PGP SIGNATURE-----




More information about the Pyrex mailing list