Visualizza post

Questa sezione ti permette di visualizzare tutti i post inviati da questo utente. N.B: puoi vedere solo i post relativi alle aree dove hai l'accesso.


Post - eloaders

Pagine: 1 2 [3]
31
Programmazione / Re:Libcpuid14 Extern
« il: 03 Novembre 2016, 08:52:13 »
Already we are closer to what he wants. However, this causes crash interpreter.
Is this code you tested and works?

32
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 20:01:51 »
In C it looks like this:

Codice: [Seleziona]
#include <stdio.h>
#include <libcpuid.h>
int main(void)
{
if (!cpuid_present()) {                                                // check for CPUID presence
printf("Sorry, your CPU doesn't support CPUID!\n");
return -1;
}
struct cpu_raw_data_t raw;
struct cpu_id_t data;                                                  // contains recognized CPU features data
if (cpuid_get_raw_data(&raw) < 0) {                                    // obtain the raw CPUID data
printf("Sorry, cannot get the CPUID raw data.\n");
printf("Error: %s\n", cpuid_error());                          // cpuid_error() gives the last error description
return -2;
}
if (cpu_identify(&raw, &data) < 0) {                                   // identify the CPU, using the given raw data.
printf("Sorrry, CPU identification failed.\n");
printf("Error: %s\n", cpuid_error());
return -3;
}
struct cpu_mark_t mark;
cpu_tsc_mark(&mark);
cpu_tsc_unmark(&mark);
printf("{\n");
printf(" \"VENDOR_STR\": \"%s\",\n", data.vendor_str);               //
printf(" \"CPU_CODENAME\": \"%s\",\n", data.cpu_codename);       //
printf(" \"BRAND_STR\": \"%s\",\n", data.brand_str);       //
printf(" \"NUM_CORES\": \"%d\",\n", data.num_cores);       //
printf(" \"NUM_LOGICAL_CPUS\": \"%d\",\n", data.num_logical_cpus);     //
printf(" \"TOTAL_LOGICAL_CPUS\": \"%d\",\n", data.total_logical_cpus); //
printf(" \"FAMILY\": \"%d\",\n", data.family);                         //
printf(" \"MODEL\": \"%d\",\n", data.model);                           //
printf(" \"STEPPING\": \"%d\",\n", data.stepping);                     //
printf(" \"EXT_FAMILY\": \"%d\",\n", data.ext_family);                 //
printf(" \"EXT_MODEL\": \"%d\",\n", data.ext_model);                   //
printf(" \"CPU_CLOCK\": \"%d MHz\",\n", cpu_clock());                      //
printf(" \"CPU_CLOCK_BY_OS\": \"%d MHz\",\n", cpu_clock_by_os());          //
printf(" \"CPU_CLOCK_BY_IC\": \"%d MHz\",\n", cpu_clock_by_ic(25, 16));    //
printf(" \"CPU_CLOCK_MEASURE\": \"%d MHz\",\n", cpu_clock_measure(400, 1));//
printf(" \"MARK_TSC\": \"%llu\",\n", mark.tsc);       //
printf(" \"MARK_SYS_CLOCK\": \"%llu\",\n", mark.sys_clock);            //

It seems that in order to initiate the data is sufficient to initiate:  cpu_identify() and cpuid_get_raw_data()
How to move to the code gambas?

33
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 19:47:05 »
I am the author of I-Nex. A code is needed me to get rid of external programs. But I not quite know how to do it. I do not know how to use libcpuid to make it work. The module now looks like this:

Codice: [Seleziona]
' Gambas module file

Library "libcpuid:14"

Public Struct cpu_id_t
  vendor_str[16] As Byte
  brand_str[64] As Byte
  vendor As Integer
  flags[128] As Byte
  family As Integer
  model As Integer
  stepping As Integer
  ext_family As Integer
  ext_model As Integer
  num_cores As Integer
  num_logical_cpus As Integer
  total_logical_cpus As Integer
  l1_data_cache As Integer
  l1_instruction_cache As Integer
  l2_cache As Integer
  l3_cache As Integer
  l4_cache As Integer
  l1_assoc As Integer
  l2_assoc As Integer
  l3_assoc As Integer
  l4_assoc As Integer
  l1_cacheline As Integer
  l2_cacheline As Integer
  l3_cacheline As Integer
  l4_cacheline As Integer
  cpu_codename[64] As Byte
  sse_size As Integer
  detection_hints[16] As Byte
End Struct

Private cpu_id_t As New Cpu_id_t
'Private Extern cpu_id_t(info As Cpu_id_t) As Integer
Public Sub Main()
 Dim si As New Cpu_id_t
 Print si.l1_assoc
 Print si.sse_size
 Print si.vendor
End

34
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 19:39:02 »
Each value returns me 0. What could be the problem?

35
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 19:26:04 »
Thank you very much.

36
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 19:22:42 »
You can help me write it correctly?

37
Programmazione / Re:Libcpuid14 Extern
« il: 02 Novembre 2016, 19:16:23 »
That's why the code below work?

Codice: [Seleziona]
' Gambas module file

Library "libc:6"

Public Struct sysinfo
  uptime As Long
  loads[3] As Long
  totalram As Long
  freeram As Long
  sharedram As Long
  bufferram As Long
  totalswap As Long
  freeswap As Long
  procs As Short
  pad As Short
  totalhigh As Long
  freehigh As Long
  mem_unit As Integer
End Struct
 
' int sysinfo (struct sysinfo *__info)
' Returns information on overall system statistics.
Private Extern sysinfo(info As Sysinfo) As Integer
Public Logs As New Logger

Public Sub Main()
 
 Dim si As New Sysinfo
 Dim err As Integer
   
  err = sysinfo(si)
  If err < 0 Then
   Logs("Libc6 Sysinfo Error", Logger.Error)
  Else
   Finfosys.TextBox58.Text = "Uptime: " & Date(0, 0, 0, 0, 0, 0, CInt(si.uptime * 1000))
  Endif
End

38
Programmazione / Libcpuid14 Extern
« il: 02 Novembre 2016, 18:51:04 »
Hello. I do not know Italian. Therefore, I try to write in English. My natural language is Polish.
So sorry for the mistakes that occur.

I have a problem with the library libcpuid. I do not have enough of an idea to do what I want. I therefore ask you to help solve the problem.

Example code:
Codice: [Seleziona]
' Gambas module file

Library "libcpuid:14"

Public Struct cpu_id_t
vendor_str[64] As String
brand_str[64] As String
vendor As String
flags[256] As Byte
family As Integer
model As Integer
stepping As Integer
ext_family As Integer
ext_model As Integer
num_cores As Integer
num_logical_cpus As Integer
total_logical_cpus As Integer
l1_data_cache As Integer
l1_instruction_cache As Integer
l2_cache As Integer
l3_cache As Integer
l4_cache As Integer
l1_assoc As Integer
l2_assoc As Integer
l3_assoc As Integer
l4_assoc As Integer
l1_cacheline As Integer
l2_cacheline As Integer
l3_cacheline As Integer
l4_cacheline As Integer
cpu_codename[64] As String
sse_size As Integer
detection_hints[128] As Byte
End Struct

Private cpu_id_t As New Cpu_id_t
'Private Extern cpu_id_t(info As Cpu_id_t) As Integer
Public Sub Main()
 Dim si As New Cpu_id_t
 Print si.l1_assoc
 
End

Doxygen doc: http://libcpuid.sourceforge.net/doxy/index.html
Sources: https://github.com/anrieff/libcpuid

i hope that your help will help me to continue to learn to use libraries in C.

Pagine: 1 2 [3]