00001 #ifndef FIDDLE_H
00002 #define FIDDLE_H
00003
00004 #include <ruby.h>
00005 #include <errno.h>
00006
00007 #if defined(_WIN32)
00008 #include <windows.h>
00009 #endif
00010
00011 #ifdef HAVE_SYS_MMAN_H
00012 #include <sys/mman.h>
00013 #endif
00014
00015 #ifdef USE_HEADER_HACKS
00016 #include <ffi/ffi.h>
00017 #else
00018 #include <ffi.h>
00019 #endif
00020
00021 #undef ffi_type_uchar
00022 #undef ffi_type_schar
00023 #undef ffi_type_ushort
00024 #undef ffi_type_sshort
00025 #undef ffi_type_uint
00026 #undef ffi_type_sint
00027 #undef ffi_type_ulong
00028 #undef ffi_type_slong
00029
00030 #if CHAR_BIT == 8
00031 # define ffi_type_uchar ffi_type_uint8
00032 # define ffi_type_schar ffi_type_sint8
00033 #else
00034 # error "CHAR_BIT not supported"
00035 #endif
00036
00037 # if SIZEOF_SHORT == 2
00038 # define ffi_type_ushort ffi_type_uint16
00039 # define ffi_type_sshort ffi_type_sint16
00040 # elif SIZEOF_SHORT == 4
00041 # define ffi_type_ushort ffi_type_uint32
00042 # define ffi_type_sshort ffi_type_sint32
00043 # else
00044 # error "short size not supported"
00045 # endif
00046
00047 # if SIZEOF_INT == 2
00048 # define ffi_type_uint ffi_type_uint16
00049 # define ffi_type_sint ffi_type_sint16
00050 # elif SIZEOF_INT == 4
00051 # define ffi_type_uint ffi_type_uint32
00052 # define ffi_type_sint ffi_type_sint32
00053 # elif SIZEOF_INT == 8
00054 # define ffi_type_uint ffi_type_uint64
00055 # define ffi_type_sint ffi_type_sint64
00056 # else
00057 # error "int size not supported"
00058 # endif
00059
00060 # if SIZEOF_LONG == 4
00061 # define ffi_type_ulong ffi_type_uint32
00062 # define ffi_type_slong ffi_type_sint32
00063 # elif SIZEOF_LONG == 8
00064 # define ffi_type_ulong ffi_type_uint64
00065 # define ffi_type_slong ffi_type_sint64
00066 # else
00067 # error "long size not supported"
00068 # endif
00069
00070 #include <closure.h>
00071 #include <conversions.h>
00072 #include <function.h>
00073
00074
00075
00076
00077
00078
00079 #define TYPE_VOID 0
00080 #define TYPE_VOIDP 1
00081 #define TYPE_CHAR 2
00082 #define TYPE_SHORT 3
00083 #define TYPE_INT 4
00084 #define TYPE_LONG 5
00085 #if HAVE_LONG_LONG
00086 #define TYPE_LONG_LONG 6
00087 #endif
00088 #define TYPE_FLOAT 7
00089 #define TYPE_DOUBLE 8
00090
00091 extern VALUE mFiddle;
00092
00093 #endif
00094
00095