示例#1
0
static void replace_in_db(QStringList &value_clauses,
                          uint chanid, uint eventid, uint64_t sig)
{
    value_clauses << QString("(%1,%2,%3,%4,%5)")
        .arg(chanid).arg(eventid).arg(extract_table_id(sig))
        .arg(extract_version(sig)).arg(extract_endtime(sig));
}
 static std::size_t one_time_init_major_version()
 {
   std::size_t version{0};
   char const * cpu_info_path{"/proc/cpuinfo"};
   char const board_version_label[]{"Revision"};
   char const * eof_label{"###"};
   std::size_t const board_version_size{sizeof(board_version_label)};
   bool not_done{true};
   char buffer[board_version_size];
   std::size_t const board_version_length{board_version_size-1};
   char const * label{nullptr};
   FILE * info_file{fopen(cpu_info_path, "r")};
   do
     {
       label = get_label(info_file, buffer, board_version_length, eof_label);
       not_done = std::strcmp(label, eof_label)!=0;
       if (not_done)
         {
           not_done = std::strcmp(label, board_version_label)!=0;
           if (not_done)
             {
               skip_to_next_line( info_file );
             }
           else
             {
               version = extract_version( info_file );
             }
         }
     }
   while (not_done);
   if ( info_file )
     {
       fclose( info_file );
     }
   if (version>0&&version<=3) return 1;
   else if (version>3&&version<=0xf) return 2;
   else if (version==0x10 || version==0x12) return 3; // 0x10:B+, 0x12:A+
   else if (version==0x11) return 4; // Compute module
   else
     {
       throw std::runtime_error( "rpi_init::init_major_version: Unable to "
                                 "deduce board version from /proc/cpuinfo."
                               );
     }
 }
示例#3
0
static void replace_in_db(int chanid, uint eventid, uint64_t sig)
{

    MSqlQuery query(MSqlQuery::InitCon());

    QString qstr =
        "REPLACE INTO eit_cache "
        "       ( chanid,  eventid,  tableid,  version,  endtime) "
        "VALUES (:CHANID, :EVENTID, :TABLEID, :VERSION, :ENDTIME)";

    query.prepare(qstr);
    query.bindValue(":CHANID",   chanid);
    query.bindValue(":EVENTID",  eventid);
    query.bindValue(":TABLEID",  extract_table_id(sig));
    query.bindValue(":VERSION",  extract_version(sig));
    query.bindValue(":ENDTIME",  extract_endtime(sig));

    if (!query.exec())
        MythDB::DBError("Error updating eitcache", query);

    return;
}
示例#4
0
文件: linux.c 项目: bingzhang/pegasus
void* initMachine(void) {
    /* purpose: initialize the data structure.
     * returns: initialized MachineLinuxInfo structure.
     */
    unsigned long version;
    MachineLinuxInfo* p = (MachineLinuxInfo*) calloc(1, sizeof(MachineLinuxInfo));
    if (p == NULL) {
        printerr("calloc: %s\n", strerror(errno));
        return NULL;
    }

    /* name of this provider -- overwritten by importers */
    p->basic = initBasicMachine();
    p->basic->provider = "linux";

    gather_meminfo(&p->ram_total, &p->ram_free,
                   &p->ram_shared, &p->ram_buffer,
                   &p->swap_total, &p->swap_free);
    gather_loadavg(p->load);
    gather_proc_cpuinfo(p);
    gather_proc_uptime(&p->boottime, &p->idletime);

    version = extract_version(p->basic->uname.release);
    /* This used to have an upper limit of 3.2 from PM-571, but it was 
     * removed because the Linux kernel is changing version numbers too
     * fast to keep updating it.
     */
    if (version >= 2006000) {
        gather_linux_proc26(&p->procs, &p->tasks);
    } else if (version >= 2004000 && version <= 2004999) {
        gather_linux_proc24(&p->procs, &p->tasks);
    } else {
        printerr("Info: Kernel v%lu.%lu.%lu is not supported for proc stats gathering\n",
                 version / 1000000, (version % 1000000) / 1000, version % 1000);
    }

    return p;
}
int sample_main(int argc, char *argv[]) {
    VkResult res;
    struct sample_info info;
    uint32_t instance_layer_count;
    VkLayerProperties *vk_props = NULL;

    init_global_layer_properties(info);

    /* VULKAN_KEY_START */

    /*
     * It's possible, though very rare, that the number of
     * instance layers could change. For example, installing something
     * could include new layers that the loader would pick up
     * between the initial query for the count and the
     * request for VkLayerProperties. The loader indicates that
     * by returning a VK_INCOMPLETE status and will update the
     * the count parameter.
     * The count parameter will be updated with the number of
     * entries loaded into the data pointer - in case the number
     * of layers went down or is smaller than the size given.
     */
    do {
        res = vkEnumerateInstanceLayerProperties(&instance_layer_count, NULL);
        if (res)
            break;

        if (instance_layer_count == 0) {
            break;
        }

        vk_props = (VkLayerProperties *)realloc(
            vk_props, instance_layer_count * sizeof(VkLayerProperties));

        res =
            vkEnumerateInstanceLayerProperties(&instance_layer_count, vk_props);
    } while (res == VK_INCOMPLETE);

    std::cout << "Instance Layers:" << std::endl;
    for (uint32_t i = 0; i < instance_layer_count; i++) {
        VkLayerProperties *props = &vk_props[i];
        uint32_t major, minor, patch;
        std::cout << props->layerName << ":" << std::endl;
        extract_version(props->specVersion, major, minor, patch);
        std::cout << "\tVersion: " << props->implementationVersion << std::endl;
        std::cout << "\tAPI Version: "
                  << "(" << major << "." << minor << "." << patch << ")"
                  << std::endl;
        std::cout << "\tDescription: " << props->description << std::endl;
        std::cout << std::endl
                  << std::endl;
    }

    std::cout << std::endl;

    free(vk_props);

    /* VULKAN_KEY_END */

    return 0;
}