<commit_before>#include <stdlib.h>
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "typeinfo.h"
#include "dwarf_eh.h"
#include "cxxabi.h"

using namespace ABI_NAMESPACE;

extern "C" void __cxa_free_exception(void *thrown_exception);
extern "C" void __cxa_free_dependent_exception(void *thrown_exception);
extern "C" void* __dynamic_cast(const void *sub,
                                const __class_type_info *src,
                                const __class_type_info *dst,
                                ptrdiff_t src2dst_offset);

/**
 * The type of a handler that has been found.
 */
typedef enum
{
	/** No handler. */
	handler_none,
	/**
	 * A cleanup - the exception will propagate through this frame, but code
	 * must be run when this happens.
	 */
	handler_cleanup,
	/**
	 * A catch statement.  The exception will not propagate past this frame
	 * (without an explicit rethrow).
	 */
	handler_catch
} handler_type;

/**
 * Per-thread info required by the runtime.  We store a single structure
 * pointer in thread-local storage, because this tends to be a scarce resource
 * and it's impolite to steal all of it and not leave any for the rest of the
 * program.
 *
 * Instances of this structure are allocated lazily - at most one per thread -
 * and are destroyed on thread termination.
 */
struct __cxa_thread_info
{
	/** The termination handler for this thread. */
	terminate_handler terminateHandler;
	/** The unexpected exception handler for this thread. */
	unexpected_handler unexpectedHandler;
	/**
	 * The number of emergency buffers held by this thread.  This is 0 in
	 * normal operation - the emergency buffers are only used when malloc()
	 * fails to return memory for allocating an exception.  Threads are not
	 * permitted to hold more than 4 emergency buffers (as per recommendation
	 * in ABI spec [3.3.1]).
	 */
	int emergencyBuffersHeld;
	/**
	 * The public part of this structure, accessible from outside of this
	 * module.
	 */
	__cxa_eh_globals globals;
};
/**
 * Dependent exception.  This 
 */
struct __cxa_dependent_exception
{
#if __LP64__
	void *primaryException;
#endif
	std::type_info *exceptionType;
	void (*exceptionDestructor) (void *); 
	unexpected_handler unexpectedHandler;
	terminate_handler terminateHandler;
	__cxa_exception *nextException;
	int handlerCount;
	int handlerSwitchValue;
	const char *actionRecord;
	const char *languageSpecificData;
	void *catchTemp;
	void *adjustedPtr;
#if !__LP64__
	void *primaryException;
#endif
	_Unwind_Exception unwindHeader;
};


namespace std
{
	void unexpected();
	class exception
	{
		public:
			virtual ~exception() throw();
			virtual const char* what() const throw();
	};

}

extern "C" std::type_info *__cxa_current_exception_type();

extern "C" char* __cxa_demangle(const char* mangled_name,
                                char* buf,
                                size_t* n,
                                int* status);

/**
 * Class of exceptions to distinguish between this and other exception types.
 *
 * The first four characters are the vendor ID.  Currently, we use GNUC,
 * because we aim for ABI-compatibility with the GNU implementation, and
 * various checks may test for equality of the class, which is incorrect.
 */
static const uint64_t exception_class =
	EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0');
/**
 * Class used for dependent exceptions.  
 */
static const uint64_t dependent_exception_class =
	EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01');
/**
 * The low four bytes of the exception class, indicating that we conform to the
 * Itanium C++ ABI.  This is currently unused, but should be used in the future
 * if we change our exception class, to allow this library and libsupc++ to be
 * linked to the same executable and both to interoperate.
 */
static const uint32_t abi_exception_class = 
	GENERIC_EXCEPTION_CLASS('C', '+', '+', '\0');

static bool isCXXException(uint64_t cls)
{
	return (cls == exception_class) || (cls == dependent_exception_class);
}

static bool isDependentException(uint64_t cls)
{<commit_msg>am 534b85dd: Fix exception.cc to not include its own (incompatible) prototype of a function that\'s now in the header.<commit_after>#include <stdlib.h>
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "typeinfo.h"
#include "dwarf_eh.h"
#include "cxxabi.h"

using namespace ABI_NAMESPACE;

extern "C" void __cxa_free_exception(void *thrown_exception);
extern "C" void __cxa_free_dependent_exception(void *thrown_exception);
extern "C" void* __dynamic_cast(const void *sub,
                                const __class_type_info *src,
                                const __class_type_info *dst,
                                ptrdiff_t src2dst_offset);

/**
 * The type of a handler that has been found.
 */
typedef enum
{
	/** No handler. */
	handler_none,
	/**
	 * A cleanup - the exception will propagate through this frame, but code
	 * must be run when this happens.
	 */
	handler_cleanup,
	/**
	 * A catch statement.  The exception will not propagate past this frame
	 * (without an explicit rethrow).
	 */
	handler_catch
} handler_type;

/**
 * Per-thread info required by the runtime.  We store a single structure
 * pointer in thread-local storage, because this tends to be a scarce resource
 * and it's impolite to steal all of it and not leave any for the rest of the
 * program.
 *
 * Instances of this structure are allocated lazily - at most one per thread -
 * and are destroyed on thread termination.
 */
struct __cxa_thread_info
{
	/** The termination handler for this thread. */
	terminate_handler terminateHandler;
	/** The unexpected exception handler for this thread. */
	unexpected_handler unexpectedHandler;
	/**
	 * The number of emergency buffers held by this thread.  This is 0 in
	 * normal operation - the emergency buffers are only used when malloc()
	 * fails to return memory for allocating an exception.  Threads are not
	 * permitted to hold more than 4 emergency buffers (as per recommendation
	 * in ABI spec [3.3.1]).
	 */
	int emergencyBuffersHeld;
	/**
	 * The public part of this structure, accessible from outside of this
	 * module.
	 */
	__cxa_eh_globals globals;
};
/**
 * Dependent exception.  This 
 */
struct __cxa_dependent_exception
{
#if __LP64__
	void *primaryException;
#endif
	std::type_info *exceptionType;
	void (*exceptionDestructor) (void *); 
	unexpected_handler unexpectedHandler;
	terminate_handler terminateHandler;
	__cxa_exception *nextException;
	int handlerCount;
	int handlerSwitchValue;
	const char *actionRecord;
	const char *languageSpecificData;
	void *catchTemp;
	void *adjustedPtr;
#if !__LP64__
	void *primaryException;
#endif
	_Unwind_Exception unwindHeader;
};


namespace std
{
	void unexpected();
	class exception
	{
		public:
			virtual ~exception() throw();
			virtual const char* what() const throw();
	};

}

extern "C" std::type_info *__cxa_current_exception_type();

/**
 * Class of exceptions to distinguish between this and other exception types.
 *
 * The first four characters are the vendor ID.  Currently, we use GNUC,
 * because we aim for ABI-compatibility with the GNU implementation, and
 * various checks may test for equality of the class, which is incorrect.
 */
static const uint64_t exception_class =
	EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0');
/**
 * Class used for dependent exceptions.  
 */
static const uint64_t dependent_exception_class =
	EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01');
/**
 * The low four bytes of the exception class, indicating that we conform to the
 * Itanium C++ ABI.  This is currently unused, but should be used in the future
 * if we change our exception class, to allow this library and libsupc++ to be
 * linked to the same executable and both to interoperate.
 */
static const uint32_t abi_exception_class = 
	GENERIC_EXCEPTION_CLASS('C', '+', '+', '\0');

static bool isCXXException(uint64_t cls)
{
	return (cls == exception_class) || (cls == dependent_exception_class);
}

static bool isDependentException(uint64_t cls)
{
{'fraction_non_alphanumeric': 0.09663142365379887, 'fraction_numerical': 0.006515859355790509, 'mean_word_length': 3.66189111747851, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6671253', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2357, 'n_words': 904}