xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #1749: 32bit.patch

File 32bit.patch, 1.9 KB (added by Mike, 3 years ago)
  • src/xpra/codecs/xor/cyxor.pyx

     
    66#cython: wraparound=False
    77from __future__ import absolute_import
    88
    9 from libc.stdint cimport uint64_t
     9from libc.stdint cimport uint32_t
    1010from xpra.buffers.membuf cimport getbuf, object_as_buffer, MemBuf
    1111
    1212
    1313def xor_str(a, b):
    1414    assert len(a)==len(b), "cyxor cannot xor strings of different lengths (%s:%s vs %s:%s)" % (type(a), len(a), type(b), len(b))
    15     cdef uint64_t *abuf
    16     cdef uint64_t *bbuf
     15    cdef uint32_t *abuf
     16    cdef uint32_t *bbuf
    1717    cdef Py_ssize_t alen = 0, blen = 0
    1818    assert object_as_buffer(a, <const void**> &abuf, &alen)==0, "cannot get buffer pointer for %s" % type(a)
    1919    assert object_as_buffer(b, <const void**> &bbuf, &blen)==0, "cannot get buffer pointer for %s" % type(b)
    2020    assert alen == blen, "python or cython bug? buffers don't have the same length?"
    2121    cdef MemBuf out_buf = getbuf(alen)
    22     cdef uint64_t *obuf = <uint64_t*> out_buf.get_mem()
    23     #64 bits at a time (8 bytes):
    24     cdef unsigned int steps = alen//8
     22    cdef uint32_t *obuf = <uint32_t*> out_buf.get_mem()
     23    #32 bits at a time (4 bytes):
     24    cdef unsigned int steps = alen//4
    2525    cdef unsigned int i,j
    26     for 0 <= i < steps:
     26    for 0 < i < steps:
    2727        obuf[i] = abuf[i] ^ bbuf[i]
    2828    #only used for the few remaining bytes at the end:
    29     cdef unsigned int char_steps = alen % 8
     29    cdef unsigned int char_steps = alen % 4
    3030    cdef unsigned char *acbuf
    3131    cdef unsigned char *bcbuf
    3232    cdef unsigned char *ocbuf
     
    3535        bcbuf = <unsigned char *> bbuf
    3636        ocbuf = <unsigned char *> obuf
    3737        for 0 <= i < char_steps:
    38             j = steps*8 + i
     38            j = steps*4 + i
    3939            ocbuf[j] = acbuf[j] ^ bcbuf[j]
    4040    return memoryview(out_buf)