Ruby 1.9.3p327(2012-11-10revision37606)
ext/fiddle/fiddle.h
Go to the documentation of this file.
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 #if HAVE_LONG_LONG
00071 # if SIZEOF_LONG_LONG == 8
00072 #   define ffi_type_slong_long ffi_type_sint64
00073 #   define ffi_type_ulong_long ffi_type_uint64
00074 # else
00075 #  error "long long size not supported"
00076 # endif
00077 #endif
00078 
00079 #include <closure.h>
00080 #include <conversions.h>
00081 #include <function.h>
00082 
00083 /* FIXME
00084  * These constants need to match up with DL. We need to refactor this to use
00085  * the DL header files or vice versa.
00086  */
00087 
00088 #define TYPE_VOID  0
00089 #define TYPE_VOIDP 1
00090 #define TYPE_CHAR  2
00091 #define TYPE_SHORT 3
00092 #define TYPE_INT   4
00093 #define TYPE_LONG  5
00094 #if HAVE_LONG_LONG
00095 #define TYPE_LONG_LONG 6
00096 #endif
00097 #define TYPE_FLOAT 7
00098 #define TYPE_DOUBLE 8
00099 
00100 extern VALUE mFiddle;
00101 
00102 #endif
00103 /* vim: set noet sws=4 sw=4: */
00104