<commit_before>/* @(#)dtkCpuid.cpp ---
 *
 * Author: <NAME>
 * Copyright (C) 2012 - <NAME>, Inria.
 * Created: 2012/04/25 13:18:27
 * Version: $Id$
 * Last-Updated: mer. avril 25 15:46:20 2012 (+0200)
 *           By: <NAME>
 *     Update #: 46
 */

/* Commentary:
 *
 */

/* Change log:
 *
 */

#include <dtkCore/dtkGlobal.h>

#include "dtkCpuid.h"

#ifdef _WIN32
#include <limits.h>
typedef unsigned __int32  uint32_t;

#else
#include <stdint.h>
#endif


class dtkCpuidPrivate
{
public:
  uint32_t regs[4];
};

dtkCpuid::dtkCpuid(void) : d (new dtkCpuidPrivate)
{

}

dtkCpuid::~dtkCpuid(void)
{
    delete d;
}

/* public: */
/*   const uint32_t &EAX() const {return regs[0];}; */
/*   const uint32_t &EBX() const {return regs[1];}; */
/*   const uint32_t &ECX() const {return regs[2];}; */
/*   const uint32_t &EDX() const {return regs[3];}; */

void dtkCpuid::load(unsigned i) {
#ifdef _WIN32
    __cpuid((int *)d->regs, (int)i);

#else
    asm volatile
      ("cpuid" : "=a" (d->regs[0]), "=b" (d->regs[1]), "=c" (d->regs[2]), "=d" (d->regs[3])
       : "a" (i), "c" (0));
    // ECX is set to zero for CPUID function 4
#endif
}

QString dtkCpuid::vendor(void)
{
    this->load(0); // Get CPU vendor

    QString vendor;<commit_msg>Fix building core's CPUID on M$ Windows.<commit_after>/* @(#)dtkCpuid.cpp ---
 *
 * Author: <NAME>
 * Copyright (C) 2012 - <NAME>, Inria.
 * Created: 2012/04/25 13:18:27
 * Version: $Id$
 * Last-Updated: mer. avril 25 15:46:20 2012 (+0200)
 *           By: <NAME>
 *     Update #: 46
 */

/* Commentary:
 *
 */

/* Change log:
 *
 */

#include <dtkCore/dtkGlobal.h>

#include "dtkCpuid.h"

#if defined(Q_OS_WIN)
#include <limits.h>
#if defined(MSVC)
typedef unsigned __int32  uint32_t;
#endif
#else
#include <stdint.h>
#endif


class dtkCpuidPrivate
{
public:
  uint32_t regs[4];
};

dtkCpuid::dtkCpuid(void) : d (new dtkCpuidPrivate)
{

}

dtkCpuid::~dtkCpuid(void)
{
    delete d;
}

/* public: */
/*   const uint32_t &EAX() const {return regs[0];}; */
/*   const uint32_t &EBX() const {return regs[1];}; */
/*   const uint32_t &ECX() const {return regs[2];}; */
/*   const uint32_t &EDX() const {return regs[3];}; */

void dtkCpuid::load(unsigned i) {
#if defined(Q_OS_WIN) && defined(MSVC)
    __cpuid((int *)d->regs, (int)i);
#else
    asm volatile
      ("cpuid" : "=a" (d->regs[0]), "=b" (d->regs[1]), "=c" (d->regs[2]), "=d" (d->regs[3])
       : "a" (i), "c" (0));
    // ECX is set to zero for CPUID function 4
#endif
}

QString dtkCpuid::vendor(void)
{
    this->load(0); // Get CPU vendor

    QString vendor;
{'fraction_non_alphanumeric': 0.20750293083235638, 'fraction_numerical': 0.05001953888237593, 'mean_word_length': 3.2454394693200666, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4859194', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1105, 'n_words': 255}