root/opal/win32/opal_utsname.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. uname

   1 /*
   2  Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3                          University Research and Technology
   4                          Corporation.  All rights reserved.
   5  Copyright (c) 2004-2014 The University of Tennessee and The University
   6                          of Tennessee Research Foundation.  All rights
   7                          reserved.
   8  Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9                          University of Stuttgart.  All rights reserved.
  10  Copyright (c) 2004-2005 The Regents of the University of California.
  11                          All rights reserved.
  12  $COPYRIGHT$
  13 
  14  Additional copyrights may follow
  15 
  16  $HEADER$
  17  */
  18 
  19 #include "opal_config.h"
  20 #include "opal/win32/opal_utsname.h"
  21 #include "opal/util/string_copy.h"
  22 
  23 /*
  24     This has to fill in the following information
  25 
  26     1. sysname: name of the operating system --
  27     2. nodename: GetComputerName
  28     3. release: GetVersionEx
  29     4. version: GetVersionEx
  30     5. machine: GetSystemInfo
  31 */
  32 
  33 int uname( struct utsname *un )
  34 {
  35     TCHAR env_variable[] = "OS=%OS%";
  36     DWORD info_buf_count;
  37     OSVERSIONINFO version_info;
  38     SYSTEM_INFO sys_info;
  39     TCHAR info_buf[OPAL_UTSNAME_LEN];
  40 
  41     info_buf_count = ExpandEnvironmentStrings( env_variable, info_buf, OPAL_UTSNAME_LEN);
  42     if (0 == info_buf_count) {
  43         snprintf( un->sysname, OPAL_UTSNAME_LEN, "Unknown" );
  44     } else {
  45         /* remove the "OS=" from the beginning of the string */
  46         opal_string_copy( un->sysname, info_buf + 3, OPAL_UTSNAME_LEN );
  47     }
  48     info_buf_count = OPAL_UTSNAME_LEN;
  49     if (!GetComputerName( un->nodename, &info_buf_count)) {
  50         snprintf(un->nodename, OPAL_UTSNAME_LEN, "undefined");
  51     }
  52 
  53     version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  54     if (!GetVersionEx(&version_info)) {
  55         snprintf(un->release, OPAL_UTSNAME_LEN, "undefined");
  56         snprintf(un->version, OPAL_UTSNAME_LEN, "undefined");
  57     } else {
  58         /* fill in both release and version information */
  59         snprintf( un->release, OPAL_UTSNAME_LEN, "%d.%d.%d",
  60                   version_info.dwMajorVersion,
  61                   version_info.dwMinorVersion,
  62                   version_info.dwBuildNumber);
  63         snprintf( un->version, OPAL_UTSNAME_LEN, "%s", version_info.szCSDVersion );
  64     }
  65 
  66     /* get machine information */
  67     GetSystemInfo(&sys_info);
  68     switch( sys_info.wProcessorArchitecture ) {
  69         case PROCESSOR_ARCHITECTURE_UNKNOWN:
  70             snprintf( un->machine, OPAL_UTSNAME_LEN, "Unknown %d", sys_info.wProcessorLevel );
  71             break;
  72         case PROCESSOR_ARCHITECTURE_INTEL:
  73             snprintf( un->machine, OPAL_UTSNAME_LEN, "Intel %d", sys_info.wProcessorLevel );
  74             break;
  75         case PROCESSOR_ARCHITECTURE_IA64:
  76             snprintf( un->machine, OPAL_UTSNAME_LEN, "IA64 %d", sys_info.wProcessorLevel );
  77             break;
  78         case PROCESSOR_ARCHITECTURE_AMD64:
  79             snprintf( un->machine, OPAL_UTSNAME_LEN, "AMD %d", sys_info.wProcessorLevel );
  80             break;
  81         default:
  82             snprintf( un->machine, OPAL_UTSNAME_LEN, "UFO hardware %d", sys_info.wProcessorLevel );
  83             break;
  84     }
  85 
  86     return 0;
  87 }

/* [<][>][^][v][top][bottom][index][help] */