LCOV - code coverage report
Current view: directory - src/trusted/platform_qualify/osx - nacl_os_qualify.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 17 6 35.3 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include <string.h>
       8                 : #include <sys/utsname.h>
       9                 : 
      10                 : #include "native_client/src/shared/platform/nacl_log.h"
      11                 : #include "native_client/src/trusted/platform_qualify/kernel_version.h"
      12                 : #include "native_client/src/trusted/platform_qualify/nacl_os_qualify.h"
      13                 : 
      14                 : 
      15                 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
      16                 : 
      17                 : /*
      18                 :  * The 64-bit Mac kernel bug was fixed in kernel version 10.8.0, which
      19                 :  * is in Mac OS X 10.6.8.
      20                 :  */
      21                 : static const char *kMinimumKernelVersion = "10.8";
      22                 : 
      23               0 : static int KernelVersionIsBuggy(const char *version) {
      24                 :   int res;
      25               0 :   if (!NaClCompareKernelVersions(version, kMinimumKernelVersion, &res)) {
      26               0 :     NaClLog(LOG_ERROR, "KernelVersionIsBuggy: "
      27                 :             "Couldn't parse kernel version: %s\n", version);
      28               0 :     return 1;
      29                 :   }
      30               0 :   return res < 0;
      31                 : }
      32                 : 
      33                 : #endif
      34                 : 
      35                 : /*
      36                 :  * Returns 1 if the operating system can run Native Client modules.
      37                 :  */
      38              12 : int NaClOsIsSupported() {
      39                 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
      40                 :   struct utsname info;
      41              12 :   if (uname(&info) != 0) {
      42               0 :     NaClLog(LOG_ERROR, "NaClOsIsSupported: uname() failed\n");
      43               0 :     return 0;
      44                 :   }
      45              12 :   if (strcmp(info.machine, "x86_64") == 0 &&
      46                 :       KernelVersionIsBuggy(info.release)) {
      47               0 :     NaClLog(LOG_ERROR,
      48                 :             "NaClOsIsSupported: "
      49                 :             "This system is running an old 64-bit Mac OS X kernel.  "
      50                 :             "This kernel version is buggy and can crash when running "
      51                 :             "Native Client's x86-32 sandbox.  "
      52                 :             "The fix is to upgrade to Mac OS X 10.6.8 or later, or, as a "
      53                 :             "workaround, to switch to using a 32-bit kernel, which will "
      54                 :             "be capable of running Native Client.  For more information, see "
      55                 :             "http://code.google.com/p/nativeclient/issues/detail?id=1712\n");
      56               0 :     return 0;
      57                 :   }
      58                 : #endif
      59              12 :   return 1;
      60                 : }
      61                 : 
      62                 : 
      63                 : /*
      64                 :  * Returns 1 if the operating system is a 64-bit version of
      65                 :  * Windows.  For now, all of these versions are not supported.
      66                 :  */
      67               1 : int NaClOsIs64BitWindows() {
      68               1 :   return 0;
      69                 : }
      70                 : 
      71                 : /*
      72                 :  * Returns 1 if the operating system is a version that restores the
      73                 :  * local descriptor table of processes.  This determines which 64-bit
      74                 :  * solution is required to execute Native Client modules.
      75                 :  */
      76               0 : int NaClOsRestoresLdt() {
      77               0 :   return 1;
      78                 : }

Generated by: LCOV version 1.7