<commit_before>/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc.  All rights reserved."

#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."

/**
  \file elocks.c
  \brief Ephemeral locks

   The ydb big lock serializes access to the tokudb
   every call (including methods) into the tokudb library gets the lock 
   no internal function should invoke a method through an object */

#include <assert.h>
#include <pthread.h>
#include <sys/types.h>

#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
static pthread_mutex_t ydb_big_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#else
static pthread_mutex_t ydb_big_lock = PTHREAD_MUTEX_INITIALIZER;
#endif

void toku_ydb_lock(void) {
    int r = pthread_mutex_lock(&ydb_big_lock);   assert(r == 0);
}

void toku_ydb_unlock(void) {
    int r = pthread_mutex_unlock(&ydb_big_lock); assert(r == 0);
}

<commit_msg>Addresses #1032 Native windows locking replaces ydb_lock and ydb_unlock for CYGWIN only<commit_after>/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc.  All rights reserved."

#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."

/**
  \file elocks.c
  \brief Ephemeral locks

   The ydb big lock serializes access to the tokudb
   every call (including methods) into the tokudb library gets the lock 
   no internal function should invoke a method through an object */

#include <assert.h>
#include <pthread.h>
#include <sys/types.h>

#ifdef __CYGWIN__
#include <windows.h>
#include <winbase.h>
CRITICAL_SECTION ydb_big_lock;

void toku_ydb_lock(void) {
    static int initialized = 0;
    if (!initialized) {
        initialized=1;
        InitializeCriticalSection(&ydb_big_lock);
    }
    EnterCriticalSection(&ydb_big_lock);
}

void toku_ydb_unlock(void) {
    LeaveCriticalSection(&ydb_big_lock);
}

#else //Not Cygwin
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
static pthread_mutex_t ydb_big_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#else
static pthread_mutex_t ydb_big_lock = PTHREAD_MUTEX_INITIALIZER;
#endif

void toku_ydb_lock(void) {
    int r = pthread_mutex_lock(&ydb_big_lock);   assert(r == 0);
}

void toku_ydb_unlock(void) {
    int r = pthread_mutex_unlock(&ydb_big_lock); assert(r == 0);
}
#endif


{'fraction_non_alphanumeric': 0.08264462809917356, 'fraction_numerical': 0.015810276679841896, 'mean_word_length': 4.681632653061224, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7338534', 'n_tokens_mistral': 963, 'n_tokens_neox': 908, 'n_words': 297}