Method: ConcurrentSHM::Region#as_intptr

Defined in:
ext/concurrent-shm/posix.c

#as_intptrValue::IntPtr

Returns a pointer to the region as a signed integer pointer of the same width as the region.

Returns:

  • the interger pointer

Raises:

  • if the region is not 1, 2, 4, or 8 bytes wide



455
456
457
458
459
460
461
462
463
464
465
# File 'ext/concurrent-shm/posix.c', line 455

static VALUE region_as_intptr(VALUE self)
{
    region_t * r = value_as_region(self);
    switch (r->len) {
    case 1: return Int8Ptr2Value ((int8_t *) r->data);
    case 2: return Int16Ptr2Value((int16_t *)r->data);
    case 4: return Int32Ptr2Value((int32_t *)r->data);
    case 8: return Int64Ptr2Value((int64_t *)r->data);
    default: rb_raise(rb_eRangeError, "Region length must be 1, 2, 4, or 8 bytes to use as an integer pointer");
    }
}