src/hotspot/cpu/s390/vm_version_ext_s390.cpp
changeset 51034 9937ef7499dc
parent 50160 dc18db671651
child 53139 a3e7e08ee427
equal deleted inserted replaced
51033:003aa3e59090 51034:9937ef7499dc
    29 
    29 
    30 // VM_Version_Ext statics
    30 // VM_Version_Ext statics
    31 int   VM_Version_Ext::_no_of_threads = 0;
    31 int   VM_Version_Ext::_no_of_threads = 0;
    32 int   VM_Version_Ext::_no_of_cores = 0;
    32 int   VM_Version_Ext::_no_of_cores = 0;
    33 int   VM_Version_Ext::_no_of_sockets = 0;
    33 int   VM_Version_Ext::_no_of_sockets = 0;
       
    34 bool  VM_Version_Ext::_initialized = false;
    34 char  VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
    35 char  VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
    35 char  VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
    36 char  VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
    36 
    37 
    37 // get cpu information.
    38 // get cpu information.
    38 bool VM_Version_Ext::initialize_cpu_information(void) {
    39 void  VM_Version_Ext::initialize_cpu_information(void) {
    39   // Not yet implemented.
    40   // do nothing if cpu info has been initialized
    40   return false;
    41   if (_initialized) {
       
    42     return;
       
    43   }
       
    44 
       
    45   _no_of_cores  = os::processor_count();
       
    46   _no_of_threads = _no_of_cores;
       
    47   _no_of_sockets = _no_of_cores;
       
    48   snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE, "s390 %s", VM_Version::get_model_string());
       
    49   snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "zArch %s", features_string());
       
    50   _initialized = true;
    41 }
    51 }
    42 
    52 
    43 int VM_Version_Ext::number_of_threads(void) {
    53 int VM_Version_Ext::number_of_threads(void) {
    44   initialize_cpu_information();
    54   initialize_cpu_information();
    45   return _no_of_threads;
    55   return _no_of_threads;
    54   initialize_cpu_information();
    64   initialize_cpu_information();
    55   return _no_of_sockets;
    65   return _no_of_sockets;
    56 }
    66 }
    57 
    67 
    58 const char* VM_Version_Ext::cpu_name(void) {
    68 const char* VM_Version_Ext::cpu_name(void) {
    59   if (!initialize_cpu_information()) {
    69   initialize_cpu_information();
    60     return NULL;
       
    61   }
       
    62   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
    70   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
    63   if (NULL == tmp) {
    71   if (NULL == tmp) {
    64     return NULL;
    72     return NULL;
    65   }
    73   }
    66   strncpy(tmp, _cpu_name, CPU_TYPE_DESC_BUF_SIZE);
    74   strncpy(tmp, _cpu_name, CPU_TYPE_DESC_BUF_SIZE);
    67   return tmp;
    75   return tmp;
    68 }
    76 }
    69 
    77 
    70 const char* VM_Version_Ext::cpu_description(void) {
    78 const char* VM_Version_Ext::cpu_description(void) {
    71   if (!initialize_cpu_information()) {
    79   initialize_cpu_information();
    72     return NULL;
       
    73   }
       
    74   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
    80   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
    75   if (NULL == tmp) {
    81   if (NULL == tmp) {
    76     return NULL;
    82     return NULL;
    77   }
    83   }
    78   strncpy(tmp, _cpu_desc, CPU_DETAILED_DESC_BUF_SIZE);
    84   strncpy(tmp, _cpu_desc, CPU_DETAILED_DESC_BUF_SIZE);