cinvoke-arch.h

Go to the documentation of this file.
00001 /*
00002 C/Invoke Source Code File
00003 
00004 Copyright (c) 2006 Will Weisser
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009    1. Redistributions of source code must retain the above copyright notice,
00010 this list of conditions and the following disclaimer.
00011    2. Redistributions in binary form must reproduce the above copyright notice,
00012 this list of conditions and the following disclaimer in the documentation
00013 and/or other materials provided with the distribution.
00014    3. The name of the author may not be used to endorse or promote products
00015 derived from this software without specific prior written permission.
00016 
00017 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00018 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00020 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00021 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00022 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
00023 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026 POSSIBILITY OF SUCH DAMAGE.
00027 */
00028 #ifndef _ARCH_H
00029 #define _ARCH_H
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00042 typedef enum _cinv_status_t {
00043         CINV_ERROR = 0, 
00044         CINV_SUCCESS  = 1 
00045 } cinv_status_t;
00046 
00049 typedef enum _cinv_type_t {
00050         CINV_T_CHAR = 0, 
00051         CINV_T_SHORT = 1, 
00052         CINV_T_INT = 2, 
00053         CINV_T_LONG = 3, 
00054         CINV_T_EXTRALONG = 4, 
00055         CINV_T_FLOAT = 5, 
00056         CINV_T_DOUBLE = 6, 
00057         CINV_T_PTR = 7, 
00059         CINV_NUM_TYPES = 8
00060 } cinv_type_t;
00061 
00064 typedef enum _cinv_callconv_t {
00065         CINV_CC_CDECL = 0, 
00066         CINV_CC_STDCALL = 1, 
00067         CINV_CC_FASTCALL = 2 
00068 } cinv_callconv_t;
00069 
00070 #ifdef ARCH_GCC_X86_UNIX
00071 #include "arch/gcc_x86_unix.h"
00072 #endif
00073 #ifdef ARCH_GCC_X64_UNIX
00074 #include "arch/gcc_x64_unix.h"
00075 #endif
00076 #ifdef ARCH_CL_X86_WIN
00077 #include "arch/cl_x86_win.h"
00078 #endif
00079 #ifndef CINVOKE_BUILD
00080 #include "cinvoke-archspec.h"
00081 #endif
00082 
00083 typedef struct _CInvContext {
00084         cinv_int32_t errorcode;
00085         char *errormsg;
00086         int needsfree;
00087 } CInvContext;
00088 
00089 void arch_free_errstr(char *str);
00090 
00091 cinv_status_t arch_library_create(CInvContext *context, const char *path,
00092         ArchLibrary *library_out);
00093 cinv_status_t arch_library_get_entrypoint(CInvContext *context,
00094         ArchLibrary *library, const char *name, void **entrypoint_out);
00095 cinv_status_t arch_library_delete(CInvContext *context, ArchLibrary *library);
00096 
00097 char *arch_callback_stub(void *functionp, void *param, short stacksize, cinv_callconv_t cc);
00098 void arch_free_stub(char *stub);
00099 
00100 int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
00101         int num_params, cinv_type_t types[]);
00102 void arch_set_register_parms(ArchRegParms *regparms, 
00103         cinv_callconv_t callingconvention, int num_params, void *parameters[], 
00104         cinv_type_t types[]);
00105 void arch_get_register_parms(ArchRegParms *regparms,
00106         cinv_callconv_t callingconvention, int num_params, void *parameters_out[],
00107         cinv_type_t types[]);
00108 
00109 void arch_getval_char(ArchRetValue *archval, char *outval);
00110 void arch_getval_short(ArchRetValue *archval, short *outval);
00111 void arch_getval_int(ArchRetValue *archval, int *outval);
00112 void arch_getval_long(ArchRetValue *archval, long int *outval);
00113 void arch_getval_extralong(ArchRetValue *archval, long long int *outval);
00114 void arch_getval_float(ArchRetValue *archval, float *outval);
00115 void arch_getval_double(ArchRetValue *archval, double *outval);
00116 void arch_getval_ptr(ArchRetValue *archval, void **outval);
00117 
00118 void arch_setval_char(ArchRetValue *archval, char val);
00119 void arch_setval_short(ArchRetValue *archval, short val);
00120 void arch_setval_int(ArchRetValue *archval, int val);
00121 void arch_setval_long(ArchRetValue *archval, long int val);
00122 void arch_setval_extralong(ArchRetValue *archval, long long int val);
00123 void arch_setval_float(ArchRetValue *archval, float val);
00124 void arch_setval_double(ArchRetValue *archval, double val);
00125 void arch_setval_ptr(ArchRetValue *archval, void *val);
00126 
00127 void arch_size_char(int *stacksize_out, int *structsize_out,
00128         int *stackalign_out, int *structalign_out);
00129 void arch_size_short(int *stacksize_out, int *structsize_out,
00130         int *stackalign_out, int *structalign_out);
00131 void arch_size_int(int *stacksize_out, int *structsize_out,
00132         int *stackalign_out, int *structalign_out);
00133 void arch_size_long(int *stacksize_out, int *structsize_out,
00134         int *stackalign_out, int *structalign_out);
00135 void arch_size_extralong(int *stacksize_out, int *structsize_out,
00136         int *stackalign_out, int *structalign_out);
00137 void arch_size_float(int *stacksize_out, int *structsize_out,
00138         int *stackalign_out, int *structalign_out);
00139 void arch_size_double(int *stacksize_out, int *structsize_out,
00140         int *stackalign_out, int *structalign_out);
00141 void arch_size_ptr(int *stacksize_out, int *structsize_out,
00142         int *stackalign_out, int *structalign_out);
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #endif

Generated on Sun Jul 2 23:50:42 2006 for C/Invoke by  doxygen 1.4.7