<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
*  License, v. 2.0. If a copy of the MPL was not distributed with this 
*  file, You can obtain one at http://mozilla.org/MPL/2.0/.*/

#ifndef UA_UTIL_H_
#define UA_UTIL_H_

#include "ua_config.h"

/* Assert */
#include <assert.h>
#define UA_assert(ignore) assert(ignore)

/* BSD Queue Macros */
#include "queue.h"

/* container_of */
#define container_of(ptr, type, member) \
    (type *)((uintptr_t)ptr - offsetof(type,member))

/* Thread Local Storage */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
# define UA_THREAD_LOCAL _Thread_local /* C11 */
#elif defined(__GNUC__)
# define UA_THREAD_LOCAL __thread /* GNU extension */
#elif defined(_MSC_VER)
# define UA_THREAD_LOCAL __declspec(thread) /* MSVC extension */
#else
# define UA_THREAD_LOCAL
# warning The compiler does not allow thread-local variables. \
  The library can be built, but will not be thread-safe.
#endif

/* Atomic Operations
 * -----------------
 * Atomic operations that synchronize across processor cores (for
 * multithreading). Only the inline-functions defined next are used. Replace
 * with architecture-specific operations if necessary. */
#ifndef UA_ENABLE_MULTITHREADING
# define UA_atomic_sync()
#else
# ifdef _MSC_VER /* Visual Studio */<commit_msg>don't define thread-local variable when multithreading is disabled; required for OpenBSD<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
*  License, v. 2.0. If a copy of the MPL was not distributed with this 
*  file, You can obtain one at http://mozilla.org/MPL/2.0/.*/

#ifndef UA_UTIL_H_
#define UA_UTIL_H_

#include "ua_config.h"

/* Assert */
#include <assert.h>
#define UA_assert(ignore) assert(ignore)

/* BSD Queue Macros */
#include "queue.h"

/* container_of */
#define container_of(ptr, type, member) \
    (type *)((uintptr_t)ptr - offsetof(type,member))

/* Thread Local Storage */
#ifdef UA_ENABLE_MULTITHREADING
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#  define UA_THREAD_LOCAL _Thread_local /* C11 */
# elif defined(__GNUC__)
#  define UA_THREAD_LOCAL __thread /* GNU extension */
# elif defined(_MSC_VER)
#  define UA_THREAD_LOCAL __declspec(thread) /* MSVC extension */
# else
#  error The compiler does not support thread-local variables.
# endif
#else
# define UA_THREAD_LOCAL
#endif

/* Atomic Operations
 * -----------------
 * Atomic operations that synchronize across processor cores (for
 * multithreading). Only the inline-functions defined next are used. Replace
 * with architecture-specific operations if necessary. */
#ifndef UA_ENABLE_MULTITHREADING
# define UA_atomic_sync()
#else
# ifdef _MSC_VER /* Visual Studio */
{'fraction_non_alphanumeric': 0.1151603498542274, 'fraction_numerical': 0.008746355685131196, 'mean_word_length': 4.208728652751423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6133125', 'n_tokens_mistral': 896, 'n_tokens_neox': 856, 'n_words': 284}