e3a493
--- src/gmpints.c.orig	2016-03-19 16:35:29.000000000 -0600
e3a493
+++ src/gmpints.c	2016-04-02 07:38:28.517903402 -0600
e3a493
@@ -377,6 +377,41 @@ Obj ObjInt_UInt( UInt i )
Jerry James f93ce6
   }
Jerry James f93ce6
 }
Jerry James 78c817
 
Jerry James f93ce6
+Obj ObjInt_LongLong( long long i )
Jerry James f93ce6
+{
Jerry James f93ce6
+  Obj gmp;
Jerry James f93ce6
+  unsigned long long ull;
Jerry James f93ce6
+  size_t j;
Jerry James f93ce6
+
Jerry James f93ce6
+  if ( (-(1LL<
Jerry James f93ce6
+    return INTOBJ_INT((Int) i);
Jerry James f93ce6
+
Jerry James f93ce6
+  if ( i >= 0LL ) {
Jerry James f93ce6
+    gmp = NewBag( T_INTPOS, sizeof(i) );
Jerry James f93ce6
+    ull = (unsigned long long) i;
Jerry James f93ce6
+  }
Jerry James f93ce6
+  else {
Jerry James f93ce6
+    gmp = NewBag( T_INTNEG, sizeof(i) );
Jerry James f93ce6
+    ull = (unsigned long long) -i;
Jerry James f93ce6
+  }
Jerry James f93ce6
+  for ( j = 0U; j < sizeof(i) / sizeof(TypLimb); j++ )
Jerry James f93ce6
+    ((TypLimb *)ADDR_OBJ( gmp ))[j] = ull >> (j * sizeof(TypLimb));
Jerry James f93ce6
+  return GMP_NORMALIZE( gmp );
Jerry James f93ce6
+}
Jerry James f93ce6
+
Jerry James f93ce6
+Obj ObjInt_ULongLong( unsigned long long i )
Jerry James f93ce6
+{
Jerry James f93ce6
+  Obj gmp;
Jerry James f93ce6
+  size_t j;
Jerry James f93ce6
+
Jerry James f93ce6
+  if ( i < 1ULL<
Jerry James f93ce6
+    return INTOBJ_INT((Int) i);
Jerry James f93ce6
+  gmp = NewBag( T_INTPOS, sizeof(i) );
Jerry James f93ce6
+  for ( j = 0U; j < sizeof(i) / sizeof(TypLimb); j++ )
Jerry James f93ce6
+    ((TypLimb *)ADDR_OBJ( gmp ))[j] = i >> (j * sizeof(TypLimb));
Jerry James f93ce6
+  return GMP_NORMALIZE( gmp );
Jerry James f93ce6
+}
Jerry James f93ce6
+
Jerry James f93ce6
 
Jerry James f93ce6
 /****************************************************************************
Jerry James f93ce6
 **
e3a493
--- src/gmpints.h.orig	2016-03-19 16:35:29.000000000 -0600
e3a493
+++ src/gmpints.h	2016-04-02 07:38:28.518903322 -0600
e3a493
@@ -87,6 +87,21 @@ typedef mp_size_t   TypGMPSize;
Jerry James f93ce6
 Obj ObjInt_Int(Int i);
Jerry James f93ce6
 Obj ObjInt_UInt(UInt i);
Jerry James 78c817
 
Jerry James f93ce6
+
Jerry James 78c817
+/**************************************************************************
Jerry James 78c817
+** The following two functions convert a C long long or unsigned long long
Jerry James f93ce6
+** respectively into* a GAP integer, either an immediate, small integer if
Jerry James 78c817
+** possible or otherwise a new GAP bag with TNUM T_INTPOS or T_INTNEG.
Jerry James 78c817
+**
Jerry James 78c817
+*F ObjInt_LongLong(long long i)
Jerry James 78c817
+*F ObjInt_ULongLong(unsigned long long i)
Jerry James 78c817
+**
Jerry James 78c817
+****************************************************************************/
Jerry James 78c817
+
Jerry James 78c817
+Obj ObjInt_LongLong(long long i);
Jerry James 78c817
+Obj ObjInt_ULongLong(unsigned long long i);
Jerry James 78c817
+
Jerry James 78c817
+
Jerry James 78c817
 /****************************************************************************
Jerry James 78c817
 **
Jerry James f93ce6
 */
e3a493
--- src/integer.c.orig	2016-03-19 16:35:29.000000000 -0600
e3a493
+++ src/integer.c	2016-04-02 07:38:28.520903161 -0600
e3a493
@@ -216,6 +216,58 @@ Obj ObjInt_UInt(UInt i)
Jerry James 78c817
 }
Jerry James 78c817
 
Jerry James 78c817
 
Jerry James 78c817
+/**************************************************************************
Jerry James 78c817
+** The following two functions convert a C long long or unsigned long long
Jerry James 78c817
+** respectively into a GAP integer, either an immediate, small integer if
Jerry James 78c817
+** possible or otherwise a new GAP bag with TNUM T_INTPOS or T_INTNEG.
Jerry James 78c817
+**
Jerry James 78c817
+*F ObjInt_LongLong(long long i)
Jerry James 78c817
+*F ObjInt_ULongLong(unsigned long long i)
Jerry James 78c817
+**
Jerry James 78c817
+****************************************************************************/
Jerry James 78c817
+
Jerry James 78c817
+#define NDIGITS_RAW (sizeof (long long) / sizeof (TypDigit))
Jerry James 78c817
+#define NDIGITS (NDIGITS_RAW >= 4U ? NDIGITS_RAW : 4U)
Jerry James 78c817
+
Jerry James 78c817
+Obj ObjInt_LongLong(long long i)
Jerry James 78c817
+{
Jerry James 78c817
+    Obj n;
Jerry James 78c817
+    long long bound = 1LL << NR_SMALL_INT_BITS;
Jerry James 78c817
+    if (i >= bound) {
Jerry James 78c817
+        /* We have to make a big integer */
Jerry James 78c817
+        size_t j;
Jerry James 78c817
+        n = NewBag(T_INTPOS, NDIGITS);
Jerry James 78c817
+        for ( j = 0U; j < NDIGITS; j++ )
Jerry James 78c817
+            ADDR_INT(n)[j] = (TypDigit) (i >> (j * NR_DIGIT_BITS));
Jerry James 78c817
+        return n;
Jerry James 78c817
+    } else if (-i > bound) {
Jerry James 78c817
+        size_t j;
Jerry James 78c817
+        n = NewBag(T_INTNEG, NDIGITS);
Jerry James 78c817
+        for ( j = 0U; j < NDIGITS; j++ )
Jerry James 78c817
+            ADDR_INT(n)[j] = (TypDigit) ((-i) >> (j * NR_DIGIT_BITS));
Jerry James 78c817
+        return n;
Jerry James 78c817
+    } else {
Jerry James 78c817
+        return INTOBJ_INT((Int) i);
Jerry James 78c817
+    }
Jerry James 78c817
+}
Jerry James 78c817
+
Jerry James 78c817
+Obj ObjInt_ULongLong(unsigned long long i)
Jerry James 78c817
+{
Jerry James 78c817
+    Obj n;
Jerry James 78c817
+    unsigned long long bound = 1ULL << NR_SMALL_INT_BITS;
Jerry James 78c817
+    if (i >= bound) {
Jerry James 78c817
+        /* We have to make a big integer */
Jerry James 78c817
+        size_t j;
Jerry James 78c817
+        n = NewBag(T_INTPOS, NDIGITS);
Jerry James 78c817
+        for ( j = 0U; j < NDIGITS; j++ )
Jerry James 78c817
+            ADDR_INT(n)[j] = (TypDigit) (i >> (j * NR_DIGIT_BITS));
Jerry James 78c817
+        return n;
Jerry James 78c817
+    } else {
Jerry James 78c817
+        return INTOBJ_INT((Int) i);
Jerry James 78c817
+    }
Jerry James 78c817
+}
Jerry James 78c817
+
Jerry James 78c817
+
Jerry James 78c817
 
Jerry James 78c817
 /****************************************************************************
Jerry James 78c817
 **
e3a493
--- src/integer.h.orig	2016-03-19 16:35:29.000000000 -0600
e3a493
+++ src/integer.h	2016-04-02 07:38:28.521903081 -0600
Jerry James f93ce6
@@ -59,6 +59,20 @@ Obj ObjInt_Int(Int i);
Jerry James 78c817
 Obj ObjInt_UInt(UInt i);
Jerry James 78c817
 
Jerry James f93ce6
 
Jerry James 78c817
+/**************************************************************************
Jerry James 78c817
+** The following two functions convert a C long long or unsigned long long
Jerry James f93ce6
+** respectively into a GAP integer, either an immediate, small integer if
Jerry James 78c817
+** possible or otherwise a new GAP bag with TNUM T_INTPOS or T_INTNEG.
Jerry James 78c817
+**
Jerry James 78c817
+*F ObjInt_LongLong(long long i)
Jerry James 78c817
+*F ObjInt_ULongLong(unsigned long long i)
Jerry James 78c817
+**
Jerry James 78c817
+****************************************************************************/
Jerry James 78c817
+
Jerry James 78c817
+Obj ObjInt_LongLong(long long i);
Jerry James 78c817
+Obj ObjInt_ULongLong(unsigned long long i);
Jerry James 78c817
+
Jerry James 78c817
+
Jerry James 78c817
 /****************************************************************************
Jerry James 78c817
 **
Jerry James f93ce6
 *F  PrintInt( <int> ) . . . . . . . . . . . . . . . print an integer constant