<commit_before>/*=============================================================================

    This file is part of FLINT.

    FLINT is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    FLINT 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with FLINT; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

=============================================================================*/
/******************************************************************************

    Copyright (C) 2013 <NAME>

******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>

#ifndef GMP_COMPAT_H
#define GMP_COMPAT_H

#if defined(__MINGW64__) && !defined(__MPIR_VERSION)

#define FLINT_MOCK_MPZ_UI(xxx, yyy) \
   __mpz_struct (xxx)[1] = {{ 1, 0, NULL }}; \
   if ((yyy) > 0) { \
      (xxx)->_mp_size = 1; \
      (xxx)->_mp_d = (mp_ptr) &(yyy); \
   }

#define FLINT_MOCK_MPZ_SI(xxx, yyy) \
   __mpz_struct (xxx)[1] = {{ 1, 0, NULL }}; \
   if ((yyy) != 0) { \
      (xxx)->_mp_d = (mp_ptr) &(yyy); \
       if ((yyy) > 0) (xxx)->_mp_size = 1; \
       else (xxx)->_mp_size = -1, (yyy) = -(yyy); \
   }

#define flint_mpz_get_si(xxx) \
   ((xxx)->_mp_size == 0 ? (slong) WORD(0) : \
   ((xxx)->_mp_size > 0 ? (slong) (xxx)->_mp_d[0] : (slong) -(xxx)->_mp_d[0]))

#define flint_mpz_get_ui(xxx) \
   ((xxx)->_mp_size == 0 ? WORD(0) : (xxx)->_mp_d[0])

static __inline__
void flint_mpz_set_si(mpz_ptr r, slong s)
{
   if (s == 0)
      r->_mp_size = 0;
   else {
      if (r->_mp_alloc == 0) {
         r->_mp_d = flint_malloc(sizeof(mp_limb_t));
         r->_mp_alloc = 1;
      }

      if (s < 0) {
         r->_mp_size = -1;
         r->_mp_d[0] = -s;
      } else {
         r->_mp_size = 1;
         r->_mp_d[0] = s;
      }
   }
}

static __inline__
void flint_mpz_set_ui(mpz_ptr r, ulong u)
{
   if (u == 0)
      r->_mp_size = 0;
   else {
      if (r->_mp_alloc == 0) {
         r->_mp_d = flint_malloc(sizeof(mp_limb_t));
         r->_mp_alloc = 1;
      }

      r->_mp_size = 1;
      r->_mp_d[0] = u;
   }
}

static __inline__
void flint_mpz_init_set_si(mpz_ptr r, slong s)
{
   if (s == 0) {
      r->_mp_d = NULL;
      r->_mp_size = 0;
      r->_mp_alloc = 0;
   } else {
      r->_mp_d = flint_malloc(sizeof(mp_limb_t));
      r->_mp_alloc = 1;
      
      if (s < 0) {
         r->_mp_size = -1;
         r->_mp_d[0] = -s;
      } else {
         r->_mp_size = 1;
         r->_mp_d[0] = s;
      }
   }
}

static __inline__
void flint_mpz_init_set_ui(mpz_ptr r, ulong u)
{
   if (u == 0) {
      r->_mp_d = NULL;
      r->_mp_size = 0;
      r->_mp_alloc = 0;
   } else {
      r->_mp_d = flint_malloc(sizeof(mp_limb_t));
      r->_mp_alloc = 1;

      r->_mp_size = 1;
      r->_mp_d[0] = u;
   }
}

static __inline__
void flint_mpz_add_ui(mpz_ptr a, mpz_srcptr b, ulong c)
{<commit_msg>GMP expects an allocation even for 0.<commit_after>/*=============================================================================

    This file is part of FLINT.

    FLINT is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    FLINT 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with FLINT; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

=============================================================================*/
/******************************************************************************

    Copyright (C) 2013 <NAME>

******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>

#ifndef GMP_COMPAT_H
#define GMP_COMPAT_H

#if defined(__MINGW64__) && !defined(__MPIR_VERSION)

#define FLINT_MOCK_MPZ_UI(xxx, yyy) \
   __mpz_struct (xxx)[1] = {{ 1, 0, NULL }}; \
   if ((yyy) > 0) { \
      (xxx)->_mp_size = 1; \
      (xxx)->_mp_d = (mp_ptr) &(yyy); \
   }

#define FLINT_MOCK_MPZ_SI(xxx, yyy) \
   __mpz_struct (xxx)[1] = {{ 1, 0, NULL }}; \
   if ((yyy) != 0) { \
      (xxx)->_mp_d = (mp_ptr) &(yyy); \
       if ((yyy) > 0) (xxx)->_mp_size = 1; \
       else (xxx)->_mp_size = -1, (yyy) = -(yyy); \
   }

#define flint_mpz_get_si(xxx) \
   ((xxx)->_mp_size == 0 ? (slong) WORD(0) : \
   ((xxx)->_mp_size > 0 ? (slong) (xxx)->_mp_d[0] : (slong) -(xxx)->_mp_d[0]))

#define flint_mpz_get_ui(xxx) \
   ((xxx)->_mp_size == 0 ? WORD(0) : (xxx)->_mp_d[0])

static __inline__
void flint_mpz_set_si(mpz_ptr r, slong s)
{
   if (s < 0) {
      r->_mp_size = -1;
      r->_mp_d[0] = -s;
   } else {
      r->_mp_size = s != 0;
      r->_mp_d[0] = s;
   }
}

static __inline__
void flint_mpz_set_ui(mpz_ptr r, ulong u)
{
   r->_mp_d[0] = u; 
   r->_mp_size = u != 0;
}

static __inline__
void flint_mpz_init_set_si(mpz_ptr r, slong s)
{
   r->_mp_d = flint_malloc(sizeof(mp_limb_t));
   r->_mp_alloc = 1;

   if (s < 0) {
      r->_mp_size = -1;
      r->_mp_d[0] = -s;
   } else {
      r->_mp_size = s != 0;
      r->_mp_d[0] = s;
   }
}

static __inline__
void flint_mpz_init_set_ui(mpz_ptr r, ulong u)
{
   r->_mp_d = flint_malloc(sizeof(mp_limb_t));
   r->_mp_alloc = 1;

   r->_mp_d[0] = u; 
   r->_mp_size = u != 0;
}

static __inline__
void flint_mpz_add_ui(mpz_ptr a, mpz_srcptr b, ulong c)
{
{'fraction_non_alphanumeric': 0.23403225806451614, 'fraction_numerical': 0.019838709677419356, 'mean_word_length': 2.875625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 85, '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': '4754868', 'n_tokens_mistral': 2432, 'n_tokens_neox': 2302, 'n_words': 594}