<commit_before>//////////////////////////////////////////////////////////////////////
//
//                             Pixie
//
// Copyright  1999 - 2003, <NAME>
//
// Contact: <EMAIL>
//
//	This library is free software; you can redistribute it and/or
//	modify it under the terms of the GNU Lesser General Public
//	License as published by the Free Software Foundation; either
//	version 2.1 of the License, or (at your option) any later version.
//
//	This library is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//	Lesser General Public License for more details.
//
//	You should have received a copy of the GNU Lesser General Public
//	License along with this library; if not, write to the Free Software
//	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//
//  File				:	atomic.h
//  Classes				:	-
//  Description			:
//
////////////////////////////////////////////////////////////////////////
#ifndef ATOMIC_H
#define ATOMIC_H


////////////////////////////////////////////////////////////////////////
// Atomic increment/decrement functions



// Windows (32 bit)
#if defined(_WIN32)

inline int atomicIncrement(volatile int *pointer) {
    unsigned char retVal;
    __asm {
        mov ECX,pointer
        lock inc DWORD ptr[ECX]
        setne retVal
    }
    return retVal;
}

inline int atomicDecrement(volatile int *pointer) {
    unsigned char retVal;
    __asm {
        mov ECX,pointer
        lock dec DWORD ptr[ECX]
        setne retVal
    }
    return retVal;
}

// Windows 64 bits
#elif defined(__WIN64)

inline int atomicIncrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "incl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return static_cast<int>(ret);
}

inline int atomicDecrement(volatile int *ptr)
{
    unsigned char ret;
    asm volatile("lock\n"
                 "decl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return static_cast<int>(ret);
}



// GCC (i386)
#elif defined(__i386__) && defined(__GNUC__)

inline int atomicIncrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "incl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return ret;
}

inline int atomicDecrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "decl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return ret;
}

// GCC (MIPS)
#elif defined(__GNUC__)

inline int atomicIncrement(volatile int *ptr) {
    register int ret;
    register int one = 1;
    asm volatile("lwarx  %0, 0, %2\n"
                 "add    %0, %3, %0\n"
                 "stwcx. %0, 0, %2\n"
                 "bne-   $-12\n"
                 : "=&r" (ret), "=m" (*ptr)
                 : "r" (ptr), "r" (one)
                 : "cc", "memory");
    return ret;
}

inline int atomicDecrement(volatile int *ptr) {
    register int ret;
    register int one = -1;
    asm volatile("lwarx  %0, 0, %2\n"
                 "add    %0, %3, %0\n"
                 "stwcx. %0, 0, %2\n"
                 "bne-   $-12\n"
                 : "=&r" (ret), "=m" (*ptr)
                 : "r" (ptr), "r" (one)
                 : "cc", "memory");
    return ret;
}


#else


#define	ATOMIC_UNSUPPORTED

// Have a cross platform solution here
inline int atomicIncrement(volatile int *ptr) {
	int	value;
	osLock(CRenderer::atomicMutex);
	value	=	++(*ptr);
	osUnlock(CRenderer::atomicMutex);
	return value;
}

inline int atomicDecrement(volatile int *ptr) {
	int	value;
	osLock(CRenderer::atomicMutex);
	value	=	--(*ptr);
	osUnlock(CRenderer::atomicMutex);
	return value;
}

#endif

#endif
<commit_msg>Minior change to atomic.h for better compatibility<commit_after>//////////////////////////////////////////////////////////////////////
//
//                             Pixie
//
// Copyright  1999 - 2003, <NAME>
//
// Contact: <EMAIL>
//
//	This library is free software; you can redistribute it and/or
//	modify it under the terms of the GNU Lesser General Public
//	License as published by the Free Software Foundation; either
//	version 2.1 of the License, or (at your option) any later version.
//
//	This library is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//	Lesser General Public License for more details.
//
//	You should have received a copy of the GNU Lesser General Public
//	License along with this library; if not, write to the Free Software
//	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//
//  File				:	atomic.h
//  Classes				:	-
//  Description			:
//
////////////////////////////////////////////////////////////////////////
#ifndef ATOMIC_H
#define ATOMIC_H


////////////////////////////////////////////////////////////////////////
// Atomic increment/decrement functions




///////////////////////////////////////////////////////////////
// Intel compiler
#if defined(INTEL_COMPILER)

inline int atomicIncrement(volatile int *pointer) {
	return InterlochedIncrement(pointer);
}

inline int	atomicDecrement(volatile int *pointer) {
	return InterlockedDecremenet(pointer);
}

///////////////////////////////////////////////////////////////
// Apple
#elif defined(__APPLE__)

#include <libkern/OSAtomic.h>

inline int atomicIncrement(int *ptr) {
	return OSAtomicIncrement32(ptr);
}

inline int atomicDecrement(int *ptr) {
	return OSAtomicDecrement32(ptr);
}

///////////////////////////////////////////////////////////////
// Windows (32 bit)
#elif defined(_WIN32)

inline int atomicIncrement(volatile int *pointer) {
    unsigned char retVal;
    __asm {
        mov ECX,pointer
        lock inc DWORD ptr[ECX]
        setne retVal
    }
    return retVal;
}

inline int atomicDecrement(volatile int *pointer) {
    unsigned char retVal;
    __asm {
        mov ECX,pointer
        lock dec DWORD ptr[ECX]
        setne retVal
    }
    return retVal;
}

///////////////////////////////////////////////////////////////
// Windows 64 bits
#elif defined(__WIN64)

inline int atomicIncrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "incl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return static_cast<int>(ret);
}

inline int atomicDecrement(volatile int *ptr)
{
    unsigned char ret;
    asm volatile("lock\n"
                 "decl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return static_cast<int>(ret);
}


///////////////////////////////////////////////////////////////
// GCC (i386)
#elif defined(__i386__) && defined(__GNUC__)

inline int atomicIncrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "incl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return ret;
}

inline int atomicDecrement(volatile int *ptr) {
    unsigned char ret;
    asm volatile("lock\n"
                 "decl %0\n"
                 "setne %1"
                 : "=m" (*ptr), "=qm" (ret)
                 : "m" (*ptr)
                 : "memory");
    return ret;
}

///////////////////////////////////////////////////////////////
// GCC (MIPS)
#elif defined(__GNUC__)

inline int atomicIncrement(volatile int *ptr) {
    register int ret;
    register int one = 1;
    asm volatile("lwarx  %0, 0, %2\n"
                 "add    %0, %3, %0\n"
                 "stwcx. %0, 0, %2\n"
                 "bne-   $-12\n"
                 : "=&r" (ret), "=m" (*ptr)
                 : "r" (ptr), "r" (one)
                 : "cc", "memory");
    return ret;
}

inline int atomicDecrement(volatile int *ptr) {
    register int ret;
    register int one = -1;
    asm volatile("lwarx  %0, 0, %2\n"
                 "add    %0, %3, %0\n"
                 "stwcx. %0, 0, %2\n"
                 "bne-   $-12\n"
                 : "=&r" (ret), "=m" (*ptr)
                 : "r" (ptr), "r" (one)
                 : "cc", "memory");
    return ret;
}

///////////////////////////////////////////////////////////////
// Generic
#else


#define	ATOMIC_UNSUPPORTED

// Have a cross platform solution here
inline int atomicIncrement(volatile int *ptr) {
	int	value;
	osLock(CRenderer::atomicMutex);
	value	=	++(*ptr);
	osUnlock(CRenderer::atomicMutex);
	return value;
}

inline int atomicDecrement(volatile int *ptr) {
	int	value;
	osLock(CRenderer::atomicMutex);
	value	=	--(*ptr);
	osUnlock(CRenderer::atomicMutex);
	return value;
}

#endif

#endif

{'fraction_non_alphanumeric': 0.2353867142407388, 'fraction_numerical': 0.014482107251547907, 'mean_word_length': 1.3842882161621215, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '5168019', 'n_tokens_mistral': 2880, 'n_tokens_neox': 2738, 'n_words': 840}