summaryrefslogtreecommitdiff
path: root/usr/rsc/gmp/gcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/rsc/gmp/gcc.c')
-rw-r--r--usr/rsc/gmp/gcc.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/usr/rsc/gmp/gcc.c b/usr/rsc/gmp/gcc.c
new file mode 100644
index 000000000..2e1c884e2
--- /dev/null
+++ b/usr/rsc/gmp/gcc.c
@@ -0,0 +1,54 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include <stdint.h>
+#include <gmp.h>
+#include <string.h>
+
+typedef int32_t int32;
+typedef uint64_t uint64;
+
+typedef struct Int Int;
+struct Int
+{
+ mpz_t *mp;
+};
+
+void
+gmp_newInt(void *v)
+{
+ struct {
+ uint64 x;
+ Int *z;
+ } *a = v;
+
+ a->z->mp = malloc(sizeof *a->z->mp);
+ mpz_init_set_ui(*a->z->mp, a->x);
+}
+
+void
+gmp_addInt(void *v)
+{
+ struct {
+ Int *z;
+ Int *x;
+ Int *y;
+ Int *ret;
+ } *a = v;
+
+ a->ret = a->z;
+ mpz_add(*a->z->mp, *a->x->mp, *a->y->mp);
+}
+
+void
+gmp_stringInt(void *v)
+{
+ struct {
+ Int *z;
+ char *p;
+ } *a = v;
+
+ a->p = mpz_get_str(NULL, 10, *a->z->mp);
+}
+