void SidUsage::writeSMM (FILE *file, const sid2_usage_t &usage) { Smm_v0 smm(0); uint8_t tmp[4] = {0}; uint_least32_t length = 4; fpos_t pos; // Write out header endian_big32 (tmp, FORM_ID); if (!fwrite (&tmp, sizeof (tmp), 1, file)) goto writeSMM_error; fgetpos (file, &pos); endian_big32 (tmp, 0); if (!fwrite (&tmp, sizeof (tmp), 1, file)) goto writeSMM_error; endian_big32 (tmp, SMM0_ID); if (!fwrite (&tmp, sizeof (tmp), 1, file)) goto writeSMM_error; // Write file if (!smm.write (file, usage, length)) goto writeSMM_error; // Write final length fsetpos (file, &pos); endian_big32 (tmp, length); if (!fwrite (&tmp, sizeof (tmp), 1, file)) goto writeSMM_error; m_status = true; return; writeSMM_error: m_errorString = txt_writing; }
void U2Panel::initClipBoard(){ cout<<"initClipBoard"<<endl; QFile ff(cache_file); QCString cs; if(ff.open(IO_ReadOnly)){ QTextStream smm(&ff); smm>>cs; clipBd=QString::fromUtf8(cs); }
bool SidUsage::readSMM (FILE *file, sid2_usage_t &usage, const char *) { uint8_t tmp[4] = {0}; uint_least32_t length, id; // Read header chunk fread (&tmp, sizeof (tmp), 1, file); if (endian_big32 (tmp) != FORM_ID) return false; // Read file length if (!fread (&tmp, sizeof (tmp), 1, file)) return false; length = endian_big32 (tmp); if (length < (sizeof(uint8_t) * 4)) return false; length -= (sizeof(uint8_t) * 4); // Read smm version if (!fread (&tmp, sizeof (tmp), 1, file)) return false; id = endian_big32 (tmp); // Determine SMM version switch (id) { case SMM0_ID: { Smm_v0 smm(0); m_status = smm.read (file, usage, length); if (!m_status) m_errorString = txt_corrupt; break; } case SMM1_ID: case SMM2_ID: case SMM3_ID: case SMM4_ID: case SMM5_ID: case SMM6_ID: case SMM7_ID: case SMM8_ID: case SMM9_ID: default: m_errorString = txt_supported; break; } return true; }
int main() { PF_Manager pfm; RM_Manager rmm(pfm); IX_Manager ixm(pfm); SM_Manager smm(ixm, rmm); smm.OpenDb(DBNAME); AttrInfo attrs[3]; attrs[0].attrType = STRING; attrs[0].attrLength = 30; attrs[0].attrName = "departmentName"; attrs[1].attrType = INT; attrs[1].attrLength = 4; attrs[1].attrName = "buildYear"; attrs[2].attrType = FLOAT; attrs[2].attrLength = 4; attrs[2].attrName = "budget"; RC rc; // if(rc = smm.DropTable("departments")) { // SM_PrintError(rc); // exit(1); // } if(rc = smm.CreateTable("departments", 3, attrs)) { SM_PrintError(rc); } if(rc = smm.CreateTable("departments", 3, attrs)) { SM_PrintError(rc); } // if(rc = smm.CreateIndex("departments", "departmentName")) printf("rc=%d\n", rc); // if(rc = smm.CreateIndex("departments", "buildYear")) printf("rc=%d\n", rc); // if(rc = smm.CreateIndex("departments", "budget")) printf("rc=%d\n", rc); if(rc = smm.DropIndex("departments", "departmentName")) { SM_PrintError(rc); } // smm.DropTable("departments"); // smm.Load("departments", "/Users/dddong/workspace/ClionProjects/miniSqlFrom0/dep.data"); smm.Print("departments"); smm.Print("relcat"); smm.Print("attrcat"); if(rc = smm.CloseDb()) { SM_PrintError(rc); exit(1); } }
int main(int argc, char *argv[]) { int pid = getpid(); float beta = 1.0f; init(); for (;;) { int start = uptime(); smm(beta); beta = -beta; int end = uptime(); long elapsed = (long) end - (long) start; long ops = 3 * N * N * N; printf(1, "%d %d FrutaFLOPS\n", pid, (int) (ops / elapsed)); } printf(1, "%f\n", c[0][0]); exit(); }