Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/port/port_win.cc
Show All 26 Lines | |||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
// | // | ||||
#include "port/port_win.h" | #include "port/port_win.h" | ||||
#include <windows.h> | #include <windows.h> | ||||
#include <cassert> | #include <cassert> | ||||
#include <intrin.h> | |||||
namespace leveldb { | namespace leveldb { | ||||
namespace port { | namespace port { | ||||
Mutex::Mutex() : | Mutex::Mutex() : | ||||
cs_(NULL) { | cs_(NULL) { | ||||
assert(!cs_); | assert(!cs_); | ||||
cs_ = static_cast<void *>(new CRITICAL_SECTION()); | cs_ = static_cast<void *>(new CRITICAL_SECTION()); | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
void* AtomicPointer::NoBarrier_Load() const { | void* AtomicPointer::NoBarrier_Load() const { | ||||
return rep_; | return rep_; | ||||
} | } | ||||
void AtomicPointer::NoBarrier_Store(void* v) { | void AtomicPointer::NoBarrier_Store(void* v) { | ||||
rep_ = v; | rep_ = v; | ||||
} | } | ||||
bool HasAcceleratedCRC32C() { | |||||
#if defined(__x86_64__) || defined(__i386__) | |||||
int cpu_info[4]; | |||||
__cpuid(cpu_info, 1); | |||||
return (cpu_info[2] & (1 << 20)) != 0; | |||||
#else | |||||
return false; | |||||
#endif | |||||
} | |||||
} | } | ||||
} | } |