Sha256: 88db961453c729f3c3407103f85817442d39519c0cdd39c86a4fd1c352c482e4

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

/* 
 * File:   AbstractMemory.h
 * Author: wayne
 *
 * Created on August 28, 2008, 5:52 PM
 */

#ifndef _ABSTRACTMEMORY_H
#define	_ABSTRACTMEMORY_H

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct {
    caddr_t address;
    long size;
} AbstractMemory;

static inline void
checkBounds(AbstractMemory* mem, long off, long len)
{
    if ((off | len | (off + len) | (mem->size - (off + len))) < 0) {
        rb_raise(rb_eIndexError, "Memory access offset=%ld size=%ld is out of bounds",
                off, len);
    }
}

#ifdef	__cplusplus
}
#endif

#endif	/* _ABSTRACTMEMORY_H */

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-0.1.0 ext/AbstractMemory.h
ffi-0.1.1 ext/AbstractMemory.h
ffi-0.2.0 ext/AbstractMemory.h