<commit_before>/* thread.h
 *  Copyright (C) 2001-2003, Parrot Foundation.
 *  Overview:
 *     This is the api header for the windows thread primitives
 *  Data Structure and Algorithms:
 *  History:
 *  Notes:
 *  References:
 */

#ifndef PARROT_THR_WINDOWS_H_GUARD
#define PARROT_THR_WINDOWS_H_GUARD

#  undef FASTCALL
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
#  include <process.h>
#  include <limits.h>
#  undef CONST

typedef CRITICAL_SECTION Parrot_mutex;
typedef struct Windows_cond {
    HANDLE m_hSema;
    LONG m_lWaiters;
} Parrot_cond;
typedef HANDLE Parrot_thread;

#  define MUTEX_INIT(m) InitializeCriticalSectionAndSpinCount((PCRITICAL_SECTION)&(m), 4000)
#  define MUTEX_DESTROY(m) DeleteCriticalSection((PCRITICAL_SECTION)&(m))

#  define COND_INIT(c) \
     do { \
       (c).m_hSema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); \
       (c).m_lWaiters = 0; \
     } while (0)

#  define COND_DESTROY(c) CloseHandle((c).m_hSema)

#  define LOCK(m) TryEnterCriticalSection((PCRITICAL_SECTION)&(m))
#  define UNLOCK(m) LeaveCriticalSection((PCRITICAL_SECTION)&(m))

#  define COND_WAIT(c, m) \
     do { \
       ++(c).m_lWaiters; \
       UNLOCK(m); \
       WaitForSingleObject((c).m_hSema, INFINITE); \
       LOCK(m); \
       --(c).m_lWaiters; \
     } while (0)

#  define COND_TIMED_WAIT(c, m, t, rc) \
     do { \
       FLOATVAL now; \
       time_t sec; \
       LONG nsec; \
       DWORD diff; \
       now = Parrot_floatval_time(); \
       sec = (time_t)now; \
       nsec = (LONG)((now - sec)*1000.0f)*1000000L; \
       if ((t)->tv_sec > sec || ((t)->tv_sec == sec && (t)->tv_nsec > nsec)) \
       { \
         ++(c).m_lWaiters; \<commit_msg>revert part of 6ecb09f0ed, it's not the right way<commit_after>/* thread.h
 *  Copyright (C) 2001-2003, Parrot Foundation.
 *  Overview:
 *     This is the api header for the windows thread primitives
 *  Data Structure and Algorithms:
 *  History:
 *  Notes:
 *  References:
 */

#ifndef PARROT_THR_WINDOWS_H_GUARD
#define PARROT_THR_WINDOWS_H_GUARD

#  undef FASTCALL
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
#  include <process.h>
#  include <limits.h>
#  undef CONST

typedef CRITICAL_SECTION Parrot_mutex;
typedef struct Windows_cond {
    HANDLE m_hSema;
    LONG m_lWaiters;
} Parrot_cond;
typedef HANDLE Parrot_thread;

#  define MUTEX_INIT(m) InitializeCriticalSectionAndSpinCount((PCRITICAL_SECTION)&(m), 4000)
#  define MUTEX_DESTROY(m) DeleteCriticalSection((PCRITICAL_SECTION)&(m))

#  define COND_INIT(c) \
     do { \
       (c).m_hSema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); \
       (c).m_lWaiters = 0; \
     } while (0)

#  define COND_DESTROY(c) CloseHandle((c).m_hSema)

#  define LOCK(m) EnterCriticalSection((PCRITICAL_SECTION)&(m))
#  define UNLOCK(m) LeaveCriticalSection((PCRITICAL_SECTION)&(m))

#  define COND_WAIT(c, m) \
     do { \
       ++(c).m_lWaiters; \
       UNLOCK(m); \
       WaitForSingleObject((c).m_hSema, INFINITE); \
       LOCK(m); \
       --(c).m_lWaiters; \
     } while (0)

#  define COND_TIMED_WAIT(c, m, t, rc) \
     do { \
       FLOATVAL now; \
       time_t sec; \
       LONG nsec; \
       DWORD diff; \
       now = Parrot_floatval_time(); \
       sec = (time_t)now; \
       nsec = (LONG)((now - sec)*1000.0f)*1000000L; \
       if ((t)->tv_sec > sec || ((t)->tv_sec == sec && (t)->tv_nsec > nsec)) \
       { \
         ++(c).m_lWaiters; \
{'fraction_non_alphanumeric': 0.1402993836219548, 'fraction_numerical': 0.018784854710889344, 'mean_word_length': 2.9490150637311703, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '6484046', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1331, 'n_words': 256}