/* SHLIB-INIT funtab &optional (version -1) (oldest version) */ LVAL xshlibinit() { LVAL subr, val, sym; xlshlib_modinfo_t *info = getnpaddr(xlganatptr()); FUNDEF *p = info->funs; FIXCONSTDEF *pfix = info->fixconsts; FLOCONSTDEF *pflo = info->floconsts; STRCONSTDEF *pstr = info->strconsts; struct version_info defversion; defversion.current = moreargs()?getfixnum(xlgafixnum()):-1; defversion.oldest = moreargs()?getfixnum(xlgafixnum()):defversion.current; xllastarg(); if (! check_version(&defsysversion, &(info->sysversion))) xlfail("shared library not compatible with current system"); if (defversion.current >= 0 && ! check_version(&defversion, &(info->modversion))) xlfail("module not compatible with requested version"); xlsave1(val); val = NIL; if (p != NULL) for (val = NIL; (p->fd_subr) != (LVAL(*)(void)) NULL; p++) { subr = cvsubr(p->fd_subr, p->fd_type & TYPEFIELD, 0); setmulvalp(subr, (p->fd_type & (TYPEFIELD + 1)) ? TRUE : FALSE); val = cons(subr, val); if (p->fd_name != NULL) { sym = xlenter(p->fd_name); setfunction(sym, subr); } } if (pfix != NULL) for (; pfix->name != NULL; pfix++) { sym = xlenter(pfix->name); defconstant(sym, cvfixnum(pfix->val)); } if (pflo != NULL) for (; pflo->name != NULL; pflo++) { sym = xlenter(pflo->name); defconstant(sym, cvflonum(pflo->val)); } if (pstr != NULL) for (; pstr->name != NULL; pstr++) { sym = xlenter(pstr->name); defconstant(sym, cvstring(pstr->val)); } if (info->sysversion.current >= MAKEVERSION(0,1)) { ULONGCONSTDEF *pulong = info->ulongconsts; if (pulong != NULL) for (; pulong->name != NULL; pulong++) { sym = xlenter(pulong->name); defconstant(sym, ulong2lisp(pulong->val)); } } xlpop(); return xlnreverse(val); }
/* SHLIB-INFO funtab */ LVAL xshlibinfo() { LVAL val; xlshlib_modinfo_t *info = getnpaddr(xlganatptr()); FUNDEF *p = info->funs; FIXCONSTDEF *pfix = info->fixconsts; FLOCONSTDEF *pflo = info->floconsts; STRCONSTDEF *pstr = info->strconsts; xllastarg(); if (! check_version(&defsysversion, &(info->sysversion))) xlfail("shared library not compatible with current system"); xlsave1(val); val = cons(cvfixnum((FIXTYPE) info->modversion.current), NIL); val = cons(cvfixnum((FIXTYPE) info->modversion.oldest), val); val = cons(NIL, val); if (p != NULL) { for (; (p->fd_subr) != (LVAL(*)(void)) NULL; p++) rplaca(val, cons(cvstring(p->fd_name), car(val))); rplaca(val, xlnreverse(car(val))); } val = cons(NIL, val); if (pfix != NULL) for (; pfix->name != NULL; pfix++) rplaca(val, cons(cvstring(pfix->name), car(val))); if (pflo != NULL) for (; pflo->name != NULL; pflo++) rplaca(val, cons(cvstring(pflo->name), car(val))); if (pstr != NULL) for (; pstr->name != NULL; pstr++) rplaca(val, cons(cvstring(pstr->name), car(val))); if (info->sysversion.current >= MAKEVERSION(0,1)) { ULONGCONSTDEF *pulong = info->ulongconsts; for (; pulong->name != NULL; pulong++) rplaca(val, cons(cvstring(pulong->name), car(val))); } rplaca(val, xlnreverse(car(val))); xlpop(); return xlnreverse(val); }
#ifndef __LOG_INTERFACE_HPP__ #define __LOG_INTERFACE_HPP__ #include "type_define.hpp" const LIBVERSION log_libversion = MAKEVERSION(2, 0, 0, 0); enum ELogLevel { LOG_LEVEL_NONE = 0x0000, LOG_LEVEL_DBG = 0x0001, LOG_LEVEL_INF = (0x0001<< 1), LOG_LEVEL_WRN = (0x0001<< 2), LOG_LEVEL_CRI = (0x0001<< 3) }; class IFileLog { public: virtual void OpenLevel(ELogLevel eLogLV) = 0; virtual void CloseLevel(ELogLevel eLogLV) = 0; virtual bool IsLevelOpen(ELogLevel eLogLV) = 0; virtual void Flush(void) = 0; virtual bool LogCri(const char* szFormat, ...) = 0; virtual bool LogWrn(const char* szFormat, ...) = 0; virtual bool LogInf(const char* szFormat, ...) = 0; virtual bool LogDbg(const char* szFormat, ...) = 0; virtual void Release(void) = 0; };
/* * ======== store_interface_fxns ======== * Purpose: * Copy the Bridge's interface functions into the device object, * ensuring that fxn_not_implemented() is set for: * * 1. All Bridge function pointers which are NULL; and * 2. All function slots in the struct dev_object structure which have no * corresponding slots in the the Bridge's interface, because the Bridge * is of an *older* version. * Parameters: * intf_fxns: Interface fxn Structure of the Bridge's Dev Object. * drv_fxns: Interface Fxns offered by the Bridge during DEV_Create(). * Returns: * Requires: * Input pointers are valid. * Bridge driver is *not* written for a newer DSP API. * Ensures: * All function pointers in the dev object's fxn interface are not NULL. */ static void store_interface_fxns(struct bridge_drv_interface *drv_fxns, struct bridge_drv_interface *intf_fxns) { u32 bridge_version; /* Local helper macro: */ #define STORE_FXN(cast, pfn) \ (intf_fxns->pfn = ((drv_fxns->pfn != NULL) ? drv_fxns->pfn : \ (cast)fxn_not_implemented)) DBC_REQUIRE(intf_fxns != NULL); DBC_REQUIRE(drv_fxns != NULL); DBC_REQUIRE(MAKEVERSION(drv_fxns->brd_api_major_version, drv_fxns->brd_api_minor_version) <= BRD_API_VERSION); bridge_version = MAKEVERSION(drv_fxns->brd_api_major_version, drv_fxns->brd_api_minor_version); intf_fxns->brd_api_major_version = drv_fxns->brd_api_major_version; intf_fxns->brd_api_minor_version = drv_fxns->brd_api_minor_version; /* Install functions up to DSP API version .80 (first alpha): */ if (bridge_version > 0) { STORE_FXN(fxn_dev_create, pfn_dev_create); STORE_FXN(fxn_dev_destroy, pfn_dev_destroy); STORE_FXN(fxn_dev_ctrl, pfn_dev_cntrl); STORE_FXN(fxn_brd_monitor, pfn_brd_monitor); STORE_FXN(fxn_brd_start, pfn_brd_start); STORE_FXN(fxn_brd_stop, pfn_brd_stop); STORE_FXN(fxn_brd_status, pfn_brd_status); STORE_FXN(fxn_brd_read, pfn_brd_read); STORE_FXN(fxn_brd_write, pfn_brd_write); STORE_FXN(fxn_brd_setstate, pfn_brd_set_state); STORE_FXN(fxn_brd_memcopy, pfn_brd_mem_copy); STORE_FXN(fxn_brd_memwrite, pfn_brd_mem_write); STORE_FXN(fxn_brd_memmap, pfn_brd_mem_map); STORE_FXN(fxn_brd_memunmap, pfn_brd_mem_un_map); STORE_FXN(fxn_chnl_create, pfn_chnl_create); STORE_FXN(fxn_chnl_destroy, pfn_chnl_destroy); STORE_FXN(fxn_chnl_open, pfn_chnl_open); STORE_FXN(fxn_chnl_close, pfn_chnl_close); STORE_FXN(fxn_chnl_addioreq, pfn_chnl_add_io_req); STORE_FXN(fxn_chnl_getioc, pfn_chnl_get_ioc); STORE_FXN(fxn_chnl_cancelio, pfn_chnl_cancel_io); STORE_FXN(fxn_chnl_flushio, pfn_chnl_flush_io); STORE_FXN(fxn_chnl_getinfo, pfn_chnl_get_info); STORE_FXN(fxn_chnl_getmgrinfo, pfn_chnl_get_mgr_info); STORE_FXN(fxn_chnl_idle, pfn_chnl_idle); STORE_FXN(fxn_chnl_registernotify, pfn_chnl_register_notify); STORE_FXN(fxn_io_create, pfn_io_create); STORE_FXN(fxn_io_destroy, pfn_io_destroy); STORE_FXN(fxn_io_onloaded, pfn_io_on_loaded); STORE_FXN(fxn_io_getprocload, pfn_io_get_proc_load); STORE_FXN(fxn_msg_create, pfn_msg_create); STORE_FXN(fxn_msg_createqueue, pfn_msg_create_queue); STORE_FXN(fxn_msg_delete, pfn_msg_delete); STORE_FXN(fxn_msg_deletequeue, pfn_msg_delete_queue); STORE_FXN(fxn_msg_get, pfn_msg_get); STORE_FXN(fxn_msg_put, pfn_msg_put); STORE_FXN(fxn_msg_registernotify, pfn_msg_register_notify); STORE_FXN(fxn_msg_setqueueid, pfn_msg_set_queue_id); } /* Add code for any additional functions in newerBridge versions here */ /* Ensure postcondition: */ DBC_ENSURE(intf_fxns->pfn_dev_create != NULL); DBC_ENSURE(intf_fxns->pfn_dev_destroy != NULL); DBC_ENSURE(intf_fxns->pfn_dev_cntrl != NULL); DBC_ENSURE(intf_fxns->pfn_brd_monitor != NULL); DBC_ENSURE(intf_fxns->pfn_brd_start != NULL); DBC_ENSURE(intf_fxns->pfn_brd_stop != NULL); DBC_ENSURE(intf_fxns->pfn_brd_status != NULL); DBC_ENSURE(intf_fxns->pfn_brd_read != NULL); DBC_ENSURE(intf_fxns->pfn_brd_write != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_create != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_destroy != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_open != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_close != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_add_io_req != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_get_ioc != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_cancel_io != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_flush_io != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_get_info != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_get_mgr_info != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_idle != NULL); DBC_ENSURE(intf_fxns->pfn_chnl_register_notify != NULL); DBC_ENSURE(intf_fxns->pfn_io_create != NULL); DBC_ENSURE(intf_fxns->pfn_io_destroy != NULL); DBC_ENSURE(intf_fxns->pfn_io_on_loaded != NULL); DBC_ENSURE(intf_fxns->pfn_io_get_proc_load != NULL); DBC_ENSURE(intf_fxns->pfn_msg_set_queue_id != NULL); #undef STORE_FXN }