// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_

#include <intrin.h>

namespace dart {

inline int Utils::CountTrailingZeros(uword x) {
  uword result;
#if defined(ARCH_IS_32_BIT)
  _BitScanReverse(&result, x);
  return __builtin_ctzl(x);
#elif defined(ARCH_IS_64_BIT)
  _BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
  return static_cast<int>(result);
};

}  // namespace dart

#endif  // PLATFORM_UTILS_WIN_H_

// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_

#include <intrin.h>

namespace dart {

inline int Utils::CountTrailingZeros(uword x) {
  unsigned long result;  // NOLINT
#if defined(ARCH_IS_32_BIT)
  _BitScanReverse(&result, x);
#elif defined(ARCH_IS_64_BIT)
  _BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
  return static_cast<int>(result);
};

}  // namespace dart

#endif  // PLATFORM_UTILS_WIN_H_

Fix the build breakage on Windows caused by CountTrailingZeros.
Fix the build breakage on Windows caused by CountTrailingZeros.

Review URL: https://chromiumcodereview.appspot.com//10818020

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@9838 260f80e4-7a28-3924-810f-c04153c831b5
