*** empty log message ***
[chuck-blob.git] / v2 / chuck_dl.h
blob2076d6314bd214565cf1c693a4970ffd5fc26563
1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 U.S.A.
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // name: chuck_dl.h
27 // desc: chuck dynamic linking header
29 // authors: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 // Ari Lazier (alazier@cs.princeton.edu)
32 // mac os code based on apple's open source
34 // date: spring 2004 - 1.1
35 // spring 2005 - 1.2
36 //-----------------------------------------------------------------------------
37 #ifndef __CHUCK_DL_H__
38 #define __CHUCK_DL_H__
40 #include "chuck_def.h"
41 #include "chuck_oo.h"
42 #include <string>
43 #include <vector>
44 #include <map>
47 // forward references
48 struct Chuck_DL_Query;
49 struct Chuck_DL_Class;
50 struct Chuck_DL_Func;
51 struct Chuck_DL_Value;
52 struct Chuck_DL_Ctrl;
53 union Chuck_DL_Return;
54 struct Chuck_DLL;
55 struct Chuck_UGen;
56 struct Chuck_UAna;
57 struct Chuck_UAnaBlobProxy;
60 // param conversion - to extract values from ARGS to functions
61 #define GET_CK_FLOAT(ptr) (*(t_CKFLOAT *)ptr)
62 #define GET_CK_SINGLE(ptr) (*(float *)ptr)
63 #define GET_CK_DOUBLE(ptr) (*(double *)ptr)
64 #define GET_CK_INT(ptr) (*(t_CKINT *)ptr)
65 #define GET_CK_UINT(ptr) (*(t_CKUINT *)ptr)
66 #define GET_CK_TIME(ptr) (*(t_CKTIME *)ptr)
67 #define GET_CK_DUR(ptr) (*(t_CKDUR *)ptr)
68 #define GET_CK_COMPLEX(ptr) (*(t_CKCOMPLEX *)ptr)
69 #define GET_CK_POLAR(ptr) (*(t_CKPOLAR *)ptr)
70 #define GET_CK_OBJECT(ptr) (*(Chuck_Object **)ptr)
71 #define GET_CK_STRING(ptr) (*(Chuck_String **)ptr)
73 // param conversion with pointer advance
74 #define GET_NEXT_FLOAT(ptr) (*((t_CKFLOAT *&)ptr)++)
75 #define GET_NEXT_SINGLE(ptr) (*((float *&)ptr)++)
76 #define GET_NEXT_DOUBLE(ptr) (*((double *&)ptr)++)
77 #define GET_NEXT_INT(ptr) (*((t_CKINT *&)ptr)++)
78 #define GET_NEXT_UINT(ptr) (*((t_CKUINT *&)ptr)++)
79 #define GET_NEXT_TIME(ptr) (*((t_CKTIME *&)ptr)++)
80 #define GET_NEXT_DUR(ptr) (*((t_CKDUR *&)ptr)++)
81 #define GET_NEXT_COMPLEX(ptr) (*((t_CKCOMPLEX *&)ptr)++)
82 #define GET_NEXT_POLAR(ptr) (*((t_CKPOLAR *&)ptr)++)
83 #define GET_NEXT_OBJECT(ptr) (*((Chuck_Object **&)ptr)++)
84 #define GET_NEXT_STRING(ptr) (*((Chuck_String **&)ptr)++)
86 // param conversion
87 #define SET_CK_FLOAT(ptr,v) (*(t_CKFLOAT *&)ptr=v)
88 #define SET_CK_SINGLE(ptr,v) (*(float *&)ptr=v)
89 #define SET_CK_DOUBLE(ptr,v) (*(double *&)ptr=v)
90 #define SET_CK_INT(ptr,v) (*(t_CKINT *&)ptr=v)
91 #define SET_CK_UINT(ptr,v) (*(t_CKUINT *&)ptr=v)
92 #define SET_CK_TIME(ptr,v) (*(t_CKTIME *&)ptr=v)
93 #define SET_CK_DUR(ptr,v) (*(t_CKDUR *&)ptr=v)
94 #define SET_CK_STRING(ptr,v) (*(Chuck_String **&)ptr=v)
96 // param conversion with pointer advance
97 #define SET_NEXT_FLOAT(ptr,v) (*((t_CKFLOAT *&)ptr)++=v)
98 #define SET_NEXT_SINGLE(ptr,v) (*((float *&)ptr)++=v)
99 #define SET_NEXT_DOUBLE(ptr,v) (*((double *&)ptr)++=v)
100 #define SET_NEXT_INT(ptr,v) (*((t_CKINT *&)ptr)++=v)
101 #define SET_NEXT_UINT(ptr,v) (*((t_CKUINT *&)ptr)++=v)
102 #define SET_NEXT_TIME(ptr,v) (*((t_CKTIME *&)ptr)++=v)
103 #define SET_NEXT_DUR(ptr,v) (*((t_CKDUR *&)ptr)++=v)
104 #define SET_NEXT_STRING(ptr,v) (*((Chuck_String **&)ptr)++=v)
106 // param conversion - to extract values from object's data segment
107 #define OBJ_MEMBER_DATA(obj,offset) (obj->data + offset)
108 #define OBJ_MEMBER_FLOAT(obj,offset) (*(t_CKFLOAT *)OBJ_MEMBER_DATA(obj,offset))
109 #define OBJ_MEMBER_SINGLE(obj,offset) (*(float *)OBJ_MEMBER_DATA(obj,offset))
110 #define OBJ_MEMBER_DOUBLE(obj,offset) (*(double *)OBJ_MEMBER_DATA(obj,offset))
111 #define OBJ_MEMBER_INT(obj,offset) (*(t_CKINT *)OBJ_MEMBER_DATA(obj,offset))
112 #define OBJ_MEMBER_UINT(obj,offset) (*(t_CKUINT *)OBJ_MEMBER_DATA(obj,offset))
113 #define OBJ_MEMBER_TIME(obj,offset) (*(t_CKTIME *)OBJ_MEMBER_DATA(obj,offset))
114 #define OBJ_MEMBER_DUR(obj,offset) (*(t_CKDUR *)OBJ_MEMBER_DATA(obj,offset))
115 #define OBJ_MEMBER_OBJECT(obj,offset) (*(Chuck_Object **)OBJ_MEMBER_DATA(obj,offset))
116 #define OBJ_MEMBER_STRING(obj,offset) (*(Chuck_String **)OBJ_MEMBER_DATA(obj,offset))
119 // chuck dll export linkage and calling convention
120 #if defined (__PLATFORM_WIN32__)
121 #define CK_DLL_LINKAGE extern "C" __declspec( dllexport )
122 #else
123 #define CK_DLL_LINKAGE extern "C"
124 #endif
126 // calling convention of functions provided by chuck to the dll
127 #if defined(__WINDOWS_DS__)
128 #define CK_DLL_CALL _cdecl
129 #else
130 #define CK_DLL_CALL
131 #endif
133 // macro for defining ChucK DLL export functions
134 // example: CK_DLL_EXPORT(int) foo() { return 1; }
135 #define CK_DLL_EXPORT(type) CK_DLL_LINKAGE type CK_DLL_CALL
136 // macro for defining ChucK DLL export query-functions
137 // example: CK_DLL_QUERY
138 #define CK_DLL_QUERY CK_DLL_EXPORT(t_CKBOOL) ck_query( Chuck_DL_Query * QUERY )
139 // macro for defining ChucK DLL export constructors
140 // example: CK_DLL_CTOR(foo)
141 #define CK_DLL_CTOR(name) CK_DLL_EXPORT(void) name( Chuck_Object * SELF, void * ARGS, Chuck_VM_Shred * SHRED )
142 // macro for defining ChucK DLL export destructors
143 // example: CK_DLL_DTOR(foo)
144 #define CK_DLL_DTOR(name) CK_DLL_EXPORT(void) name( Chuck_Object * SELF, Chuck_VM_Shred * SHRED )
145 // macro for defining ChucK DLL export member functions
146 // example: CK_DLL_MFUN(foo)
147 #define CK_DLL_MFUN(name) CK_DLL_EXPORT(void) name( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED )
148 // macro for defining ChucK DLL export static functions
149 // example: CK_DLL_SFUN(foo)
150 #define CK_DLL_SFUN(name) CK_DLL_EXPORT(void) name( void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED )
151 // macro for defining ChucK DLL export ugen tick functions
152 // example: CK_DLL_TICK(foo)
153 #define CK_DLL_TICK(name) CK_DLL_EXPORT(t_CKBOOL) name( Chuck_Object * SELF, SAMPLE in, SAMPLE * out, Chuck_VM_Shred * SHRED )
154 // macro for defining ChucK DLL export ugen ctrl functions
155 // example: CK_DLL_CTRL(foo)
156 #define CK_DLL_CTRL(name) CK_DLL_EXPORT(void) name( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED )
157 // macro for defining ChucK DLL export ugen cget functions
158 // example: CK_DLL_CGET(foo)
159 #define CK_DLL_CGET(name) CK_DLL_EXPORT(void) name( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED )
160 // macro for defining ChucK DLL export ugen pmsg functions
161 // example: CK_DLL_PMSG(foo)
162 #define CK_DLL_PMSG(name) CK_DLL_EXPORT(t_CKBOOL) name( Chuck_Object * SELF, const char * MSG, void * ARGS, Chuck_VM_Shred * SHRED )
163 // macro for defining ChucK DLL export uana tock functions
164 // example: CK_DLL_TOCK(foo)
165 #define CK_DLL_TOCK(name) CK_DLL_EXPORT(t_CKBOOL) name( Chuck_Object * SELF, Chuck_UAna * UANA, Chuck_UAnaBlobProxy * BLOB, Chuck_VM_Shred * SHRED )
168 // macros for DLL exports
169 // example: DLL_QUERY query( Chuck_DL_Query * QUERY )
170 // example: DLL_FUNC foo( void * ARGS, Chuck_DL_Return * RETURN )
171 // example: DLL_UGEN_F foo_tick( Chuck_UGen * SELF, SAMPLE, SAMPLE * out );
172 #define DLL_QUERY CK_DLL_EXPORT(t_CKBOOL)
173 #define DLL_FUNC CK_DLL_EXPORT(void)
174 #define UGEN_CTOR CK_DLL_EXPORT(void *)
175 #define UGEN_DTOR CK_DLL_EXPORT(void)
176 #define UGEN_TICK CK_DLL_EXPORT(t_CKBOOL)
177 #define UGEN_PMSG CK_DLL_EXPORT(t_CKBOOL)
178 #define UGEN_CTRL CK_DLL_EXPORT(t_CKVOID)
179 #define UGEN_CGET CK_DLL_EXPORT(t_CKVOID)
180 #define UANA_TOCK CK_DLL_EXPORT(t_CKBOOL)
183 //-----------------------------------------------------------------------------
184 // dynamic linking class interface prototypes
185 //-----------------------------------------------------------------------------
186 extern "C" {
187 // query
188 typedef t_CKBOOL (CK_DLL_CALL * f_ck_query)( Chuck_DL_Query * QUERY );
189 // object
190 typedef t_CKVOID (CK_DLL_CALL * f_ctor)( Chuck_Object * SELF, void * ARGS, Chuck_VM_Shred * SHRED );
191 typedef t_CKVOID (CK_DLL_CALL * f_dtor)( Chuck_Object * SELF, Chuck_VM_Shred * SHRED );
192 typedef t_CKVOID (CK_DLL_CALL * f_mfun)( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED );
193 typedef t_CKVOID (CK_DLL_CALL * f_sfun)( void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED );
194 // ugen specific
195 typedef t_CKBOOL (CK_DLL_CALL * f_tick)( Chuck_Object * SELF, SAMPLE in, SAMPLE * out, Chuck_VM_Shred * SHRED );
196 typedef t_CKVOID (CK_DLL_CALL * f_ctrl)( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED );
197 typedef t_CKVOID (CK_DLL_CALL * f_cget)( Chuck_Object * SELF, void * ARGS, Chuck_DL_Return * RETURN, Chuck_VM_Shred * SHRED );
198 typedef t_CKBOOL (CK_DLL_CALL * f_pmsg)( Chuck_Object * SELF, const char * MSG, void * ARGS, Chuck_VM_Shred * SHRED );
199 // uana specific
200 typedef t_CKBOOL (CK_DLL_CALL * f_tock)( Chuck_Object * SELF, Chuck_UAna * UANA, Chuck_UAnaBlobProxy * BLOB, Chuck_VM_Shred * SHRED );
204 // default name in DLL/ckx to look for
205 #define CK_QUERY_FUNC "ck_query"
206 // bad object data offset
207 #define CK_INVALID_OFFSET 0xffffffff
210 //-----------------------------------------------------------------------------
211 // chuck DLL query functions, implemented on chuck side for portability
212 //-----------------------------------------------------------------------------
213 extern "C" {
214 // set name of ckx
215 typedef void ( CK_DLL_CALL * f_setname)( Chuck_DL_Query * query, const char * name );
217 // begin class/namespace, can be nested
218 typedef void (CK_DLL_CALL * f_begin_class)( Chuck_DL_Query * query, const char * name, const char * parent );
219 // add constructor, must be betwen begin/end_class : use f_add_arg to add arguments immediately after
220 typedef void (CK_DLL_CALL * f_add_ctor)( Chuck_DL_Query * query, f_ctor ctor );
221 // add destructor - cannot have args
222 typedef void (CK_DLL_CALL * f_add_dtor)( Chuck_DL_Query * query, f_dtor dtor );
223 // add member function - args to follow
224 typedef void (CK_DLL_CALL * f_add_mfun)( Chuck_DL_Query * query, f_mfun mfun, const char * type, const char * name );
225 // add static function - args to follow
226 typedef void (CK_DLL_CALL * f_add_sfun)( Chuck_DL_Query * query, f_sfun sfun, const char * type, const char * name );
227 // add member variable
228 typedef void (CK_DLL_CALL * f_add_mvar)( Chuck_DL_Query * query,
229 const char * type, const char * name, t_CKBOOL is_const ); // TODO: public/protected/private
230 // add static variable
231 typedef void (CK_DLL_CALL * f_add_svar)( Chuck_DL_Query * query,
232 const char * type, const char * name,
233 t_CKBOOL is_const, void * static_addr ); // TODO: public/protected/private
234 // add arg - follows ctor mfun sfun
235 typedef void (CK_DLL_CALL * f_add_arg)( Chuck_DL_Query * query, const char * type, const char * name );
236 // ** functions for adding unit generators, must extend ugen
237 typedef void (CK_DLL_CALL * f_add_ugen_func)( Chuck_DL_Query * query, f_tick tick, f_pmsg pmsg );
238 // ** add a ugen control
239 typedef void (CK_DLL_CALL * f_add_ugen_ctrl)( Chuck_DL_Query * query, f_ctrl ctrl, f_cget cget,
240 const char * type, const char * name );
241 // end class/namespace - must correspondent with begin_class. returns false on error
242 typedef t_CKBOOL (CK_DLL_CALL * f_end_class)( Chuck_DL_Query * query );
246 //-----------------------------------------------------------------------------
247 // name: struct Chuck_DL_Query
248 // desc: passed to module
249 //-----------------------------------------------------------------------------
250 struct Chuck_DL_Query
252 // function pointers - to be called from client module
253 // QUERY->setname( QUERY, ... );
255 // set the name of the module
256 f_setname setname;
257 // begin class/namespace, can be nexted
258 f_begin_class begin_class;
259 // add constructor, can be followed by add_arg
260 f_add_ctor add_ctor;
261 // add destructor, no args allowed
262 f_add_dtor add_dtor;
263 // add member function, can be followed by add_arg
264 f_add_mfun add_mfun;
265 // add static function, can be followed by add_arg
266 f_add_sfun add_sfun;
267 // add member variable
268 f_add_mvar add_mvar;
269 // add static variable
270 f_add_svar add_svar;
271 // add argument to function
272 f_add_arg add_arg;
273 // (ugen only) add tick and pmsg functions
274 f_add_ugen_func add_ugen_func;
275 // (ugen only) add ctrl parameters
276 f_add_ugen_ctrl add_ugen_ctrl;
277 // end class/namespace, compile it
278 f_end_class end_class;
280 // name
281 std::string name;
282 // current class
283 Chuck_DL_Class * curr_class;
284 // current function
285 Chuck_DL_Func * curr_func;
286 // collection of class
287 std::vector<Chuck_DL_Class *> classes;
288 // stack
289 std::vector<Chuck_DL_Class * >stack;
291 // name of dll
292 std::string dll_name;
293 // dll
294 Chuck_DLL * dll_ref;
295 // reserved
296 void * reserved;
297 // sample rate
298 t_CKUINT srate;
299 // bsize
300 t_CKUINT bufsize;
301 // line pos
302 int linepos;
304 // constructor
305 Chuck_DL_Query();
306 // desctructor
307 ~Chuck_DL_Query() { this->clear(); }
308 // clear
309 void clear();
313 //-----------------------------------------------------------------------------
314 // name: struct Chuck_DL_Class
315 // desc: class built from module
316 //-----------------------------------------------------------------------------
317 struct Chuck_DL_Class
319 // the name of the class
320 std::string name;
321 // the name of the parent
322 std::string parent;
323 // ctor
324 std::vector<Chuck_DL_Func *> ctors;
325 // dtor
326 Chuck_DL_Func * dtor;
327 // mfun
328 std::vector<Chuck_DL_Func *> mfuns;
329 // sfun
330 std::vector<Chuck_DL_Func *> sfuns;
331 // mdata
332 std::vector<Chuck_DL_Value *> mvars;
333 // sdata
334 std::vector<Chuck_DL_Value *> svars;
335 // ugen_tick
336 f_tick ugen_tick;
337 // ugen_pmsg
338 f_pmsg ugen_pmsg;
339 // ugen_ctrl/cget
340 std::vector<Chuck_DL_Ctrl *> ugen_ctrl;
341 // uana_tock
342 f_tock uana_tock;
343 // collection of recursive classes
344 std::vector<Chuck_DL_Class *> classes;
346 // constructor
347 Chuck_DL_Class() { dtor = NULL; ugen_tick = NULL; ugen_pmsg = NULL; uana_tock = NULL; ugen_pmsg = NULL; }
348 // destructor
349 ~Chuck_DL_Class();
353 //-----------------------------------------------------------------------------
354 // name: struct Chuck_DL_Value
355 // desc: value from module
356 //-----------------------------------------------------------------------------
357 struct Chuck_DL_Value
359 // the name of the value
360 std::string name;
361 // the type of the value
362 std::string type;
363 // is const
364 t_CKBOOL is_const;
365 // addr static
366 void * static_addr;
368 // constructor
369 Chuck_DL_Value() { is_const = FALSE; static_addr = NULL; }
370 Chuck_DL_Value( const char * t, const char * n, t_CKBOOL c = FALSE, void * a = NULL )
371 { name = n; type = t; is_const = c; static_addr = a; }
375 //-----------------------------------------------------------------------------
376 // name: struct Chuck_DL_Func
377 // desc: function from module
378 //-----------------------------------------------------------------------------
379 struct Chuck_DL_Func
381 // the name of the function
382 std::string name;
383 // the return type
384 std::string type;
385 // the pointer
386 union { f_ctor ctor; f_dtor dtor; f_mfun mfun; f_sfun sfun; t_CKUINT addr; };
387 // arguments
388 std::vector<Chuck_DL_Value *> args;
390 // constructor
391 Chuck_DL_Func() { ctor = NULL; }
392 Chuck_DL_Func( const char * t, const char * n, t_CKUINT a )
393 { name = n; type = t; addr = a; }
394 // destructor
395 ~Chuck_DL_Func();
396 // add arg
397 void add_arg( const char * t, const char * n )
398 { args.push_back( new Chuck_DL_Value( t, n ) ); }
402 //-----------------------------------------------------------------------------
403 // name: struct Chuck_DL_Ctrl
404 // desc: ctrl for ugen
405 //-----------------------------------------------------------------------------
406 struct Chuck_DL_Ctrl
408 // the name of the ctrl
409 std::string name;
410 // the first type
411 std::string type;
412 // the types of the value
413 std::vector<std::string> types;
414 // ctrl
415 f_ctrl ctrl;
416 // cget
417 f_cget cget;
421 //------------------------------------------------------------------------------
422 // alternative functions to make stuff
423 //------------------------------------------------------------------------------
424 Chuck_DL_Func * make_new_mfun( const char * t, const char * n, f_mfun mfun );
425 Chuck_DL_Func * make_new_sfun( const char * t, const char * n, f_sfun sfun );
426 Chuck_DL_Value * make_new_arg( const char * t, const char * n );
427 Chuck_DL_Value * make_new_mvar( const char * t, const char * n, t_CKBOOL c = FALSE );
428 Chuck_DL_Value * make_new_svar( const char * t, const char * n, t_CKBOOL c, void * a );
431 //------------------------------------------------------------------------------
432 // name: union Chuck_DL_Return
433 // desc: dynamic link return function return struct
434 //------------------------------------------------------------------------------
435 union Chuck_DL_Return
437 t_CKINT v_int;
438 t_CKUINT v_uint;
439 t_CKFLOAT v_float;
440 t_CKDUR v_dur;
441 t_CKTIME v_time;
442 t_CKCOMPLEX v_complex;
443 t_CKPOLAR v_polar;
444 Chuck_Object * v_object;
445 Chuck_String * v_string;
447 Chuck_DL_Return() { v_complex.re = 0.0; v_complex.im = 0.0; }
451 //-----------------------------------------------------------------------------
452 // name: struct Chuck_DLL
453 // desc: dynamic link library
454 //-----------------------------------------------------------------------------
455 struct Chuck_DLL : public Chuck_VM_Object
457 public:
458 // load dynamic ckx/dll from filename
459 t_CKBOOL load( const char * filename,
460 const char * func = CK_QUERY_FUNC,
461 t_CKBOOL lazy = FALSE );
462 t_CKBOOL load( f_ck_query query_func, t_CKBOOL lazy = FALSE );
463 // get address in loaded ckx
464 void * get_addr( const char * symbol );
465 // get last error
466 const char * last_error() const;
467 // unload the ckx
468 t_CKBOOL unload( );
469 // query the content of the dll
470 const Chuck_DL_Query * query( );
471 // is good
472 t_CKBOOL good() const;
473 // name
474 const char * name() const;
476 public:
477 // constructor
478 Chuck_DLL( const char * xid = NULL )
479 : m_handle(NULL), m_id(xid ? xid : ""),
480 m_done_query(FALSE), m_query_func(NULL)
482 // destructor
483 ~Chuck_DLL() { this->unload(); }
485 protected:
486 // data
487 void * m_handle;
488 std::string m_last_error;
489 std::string m_filename;
490 std::string m_id;
491 std::string m_func;
492 t_CKBOOL m_done_query;
494 f_ck_query m_query_func;
495 Chuck_DL_Query m_query;
501 // dlfcn interface
502 #if defined(__MACOSX_CORE__)
503 #include <AvailabilityMacros.h>
504 #endif
506 // dlfcn interface, panther or below
507 #if defined(__MACOSX_CORE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= 1030
509 #ifdef __cplusplus
510 extern "C" {
511 #endif
513 void * dlopen( const char * path, int mode );
514 void * dlsym( void * handle, const char * symbol );
515 const char * dlerror( void );
516 int dlclose( void * handle );
518 #define RTLD_LAZY 0x1
519 #define RTLD_NOW 0x2
520 #define RTLD_LOCAL 0x4
521 #define RTLD_GLOBAL 0x8
522 #define RTLD_NOLOAD 0x10
523 #define RTLD_SHARED 0x20 /* not used, the default */
524 #define RTLD_UNSHARED 0x40
525 #define RTLD_NODELETE 0x80
526 #define RTLD_LAZY_UNDEF 0x100
528 #ifdef __cplusplus
530 #endif
532 #elif defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
534 #ifdef __cplusplus
535 extern "C" {
536 #endif
538 #define RTLD_LAZY 0x1
539 #define RTLD_NOW 0x2
540 #define RTLD_LOCAL 0x4
541 #define RTLD_GLOBAL 0x8
542 #define RTLD_NOLOAD 0x10
543 #define RTLD_SHARED 0x20 /* not used, the default */
544 #define RTLD_UNSHARED 0x40
545 #define RTLD_NODELETE 0x80
546 #define RTLD_LAZY_UNDEF 0x100
548 void * dlopen( const char * path, int mode );
549 void * dlsym( void * handle, const char * symbol );
550 const char * dlerror( void );
551 int dlclose( void * handle );
552 static char dlerror_buffer[128];
554 #ifdef __cplusplus
556 #endif
558 #else
559 #include "dlfcn.h"
560 #endif
565 #endif