bool QgsServerSettings::load( const QString &envVarName ) { bool rc( false ); const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() ); const int value = metaEnum.keyToValue( envVarName.toStdString().c_str() ); if ( value >= 0 ) { const QString envValue( getenv( envVarName.toStdString().c_str() ) ); prioritize( QMap<QgsServerSettingsEnv::EnvVar, QString> { {( QgsServerSettingsEnv::EnvVar ) value, envValue } } ); rc = true; } return rc; }
void QgsServerSettings::load() { // init settings each time to take into account QgsApplication and // QCoreApplication configuration for some default values initSettings(); // store environment variables QMap<QgsServerSettingsEnv::EnvVar, QString> env = getEnv(); // load QSettings if QGIS_OPTIONS_PATH is defined loadQSettings( env[ QgsServerSettingsEnv::QGIS_OPTIONS_PATH ] ); // prioritize values: 'env var' -> 'ini file' -> 'default value' prioritize( env ); }
/** * Reschedule processor to next ready process. * Upon entry, currpid gives current process id. Proctab[currpid].pstate * gives correct NEXT state for current process if other than PRREADY. * @return OK when the process is context switched back */ syscall resched(void) { irqmask im; pcb *oldproc; /* pointer to old process entry */ pcb *newproc; /* pointer to new process entry */ short head, tail; im = disable(); oldproc = &proctab[ currpid ]; /* Aging implemented */ if(AGING) { head = queuehead(readylist); head = queuetab[head].next; tail = queuetail(readylist); while(head != tail) { queuetab[head].key++; head = queuetab[head].next; } } /* place current process at end of ready queue */ if (PRCURR == oldproc->state) { oldproc->state = PRREADY; prioritize(currpid, readylist, oldproc->priority); } /* remove first process in ready queue */ currpid = dequeue(readylist); newproc = &proctab[ currpid ]; newproc->state = PRCURR; /* mark it currently running */ #if PREEMPT preempt = QUANTUM; /* reset preemption counter */ #endif ctxsw(&oldproc->stkptr, &newproc->stkptr); /* The OLD process returns here when resumed. */ restore(im); return OK; }
void AggrTypeBuilder::addAggregate( AggregateDeclaration *ad, const AggrTypeBuilder::VarInitMap *explicitInits, AggrTypeBuilder::Aliases aliases) { const size_t n = ad->fields.dim; if (n == 0) return; // prioritize overlapping fields LLSmallVector<FieldPriority, 16> priorities; priorities.reserve(n); for (auto f : ad->fields) { priorities.push_back(prioritize(f, explicitInits)); IF_LOG Logger::println("Field priority for %s: %d", f->toChars(), priorities.back()); } // mirror the ad->fields array but only fill in contributors LLSmallVector<VarDeclaration *, 16> data(n, nullptr); // list of pairs: alias => actual field (same offset, same LL type) LLSmallVector<std::pair<VarDeclaration *, VarDeclaration *>, 16> aliasPairs; // one pass per priority in descending order const auto minMaxPriority = std::minmax_element(priorities.begin(), priorities.end()); for (int p = *minMaxPriority.second; p >= *minMaxPriority.first; p--) { // iterate over fields of that priority, in declaration order for (size_t index = 0; index < n; ++index) { if (priorities[index] != p) continue; VarDeclaration *field = ad->fields[index]; const size_t f_begin = field->offset; const size_t f_end = f_begin + field->type->size(); // skip empty fields if (f_begin == f_end) continue; // check for overlapping existing fields bool overlaps = false; if (field->overlapped) { for (const auto vd : data) { if (!vd) continue; const size_t v_begin = vd->offset; const size_t v_end = v_begin + vd->type->size(); if (v_begin < f_end && v_end > f_begin) { if (aliases == Aliases::AddToVarGEPIndices && v_begin == f_begin && DtoMemType(vd->type) == DtoMemType(field->type)) { aliasPairs.push_back(std::make_pair(field, vd)); } overlaps = true; break; } } } if (!overlaps) data[index] = field; } } // Now we can build a list of LLVM types for the actual LL fields. // Make sure to zero out any padding and set the GEP indices for the directly // indexable variables. // first we sort the list by offset std::sort(data.begin(), data.end(), var_offset_sort_cb); for (const auto vd : data) { if (!vd) continue; assert(vd->offset >= m_offset && "Variable overlaps previous field."); // Add an explicit field for any padding so we can zero it, as per TDPL // §7.1.1. if (m_offset < vd->offset) { m_fieldIndex += add_zeros(m_defaultTypes, m_offset, vd->offset); m_offset = vd->offset; } // add default type m_defaultTypes.push_back(DtoMemType(vd->type)); // advance offset to right past this field m_offset += getMemberSize(vd->type); // set the field index m_varGEPIndices[vd] = m_fieldIndex; // let any aliases reuse this field/GEP index for (const auto &pair : aliasPairs) { if (pair.second == vd) m_varGEPIndices[pair.first] = m_fieldIndex; } ++m_fieldIndex; } }