void __attribute__((overloadable)) fpcrtl_writeLn(File f, string255 s) { FIX_STRING(s); // filthy hack to write to stderr if (!f->fp) fprintf(stderr, "%s\n", s.str); else fprintf(f->fp, "%s\n", s.str); }
bool fpcrtl_fileExists(string255 filename) { FIX_STRING(filename); IOResult = IO_NO_ERROR; FILE *fp = fopen(filename.str, "r"); if (fp) { fclose(fp); return true; } return false; }
SEA_EXPORT void ITTAPI __itt_api_init(__itt_global* pGlob, __itt_group_id id) { if (!g_bInitialized) { g_bInitialized = true; __itt_global* pGlobal = GetITTGlobal(); __itt_mutex_init(&pGlobal->mutex); pGlobal->mutex_initialized = 1; sea::CIttLocker locker; __itt_api_init(pGlobal, id); pGlobal->api_initialized = 1; } const char* procname = sea::GetProcessName(true); sea::SModuleInfo mdlinfo = sea::Fn2Mdl(pGlob); VerbosePrint("IntelSEAPI init is called from process '%s' at module '%s'\n", procname, mdlinfo.path.c_str()); if (GetITTGlobal() != pGlob) ChainGlobal(pGlob); sea::FillApiList(pGlob->api_list_ptr); for (___itt_domain* pDomain = pGlob->domain_list; pDomain; pDomain = pDomain->next) { FIX_DOMAIN(pDomain); sea::InitDomain(pDomain); } for (__itt_string_handle* pStr = pGlob->string_list; pStr; pStr = pStr->next) { FIX_STRING(pStr); sea::ReportString(const_cast<__itt_string_handle *>(pStr)); } if (pGlob->version_build > 20120000) //counter_list was not yet invented that time { for (__itt_counter_info_t* pCounter = pGlob->counter_list; pCounter; pCounter = pCounter->next) { FIX_COUNTER(pCounter); VerbosePrint("Fixed counter: %s | %s\n", pCounter->domainA, pCounter->nameA); } } sea::ReportModule(pGlob); static bool bInitialized = false; if (!bInitialized) { bInitialized = true; sea::InitSEA(); #ifdef _WIN32 EventRegisterIntelSEAPI(); #endif atexit(AtExit); } }
bool fpcrtl_directoryExists(string255 dir) { struct stat st; FIX_STRING(dir); IOResult = IO_NO_ERROR; #ifdef FPCRTL_DEBUG printf("Warning: directoryExists is called. This may not work when compiled to js.\n"); #endif if (stat(dir.str, &st) == 0) { return true; } return false; }
void fpcrtl_assign__vars(File *f, string255 name) { FIX_STRING(name); *f = (File) malloc(sizeof(file_wrapper_t)); strcpy((*f)->file_name, name.str); init(*f); }
void __attribute__((overloadable)) fpcrtl_writeLn(FILE *f, string255 s) { FIX_STRING(s); fprintf(f, "%s\n", s.str); }
void __attribute__((overloadable)) fpcrtl_write(File f, string255 s) { FIX_STRING(s); fprintf(f->fp, "%s", s.str); }