1
0
mirror of https://github.com/golang/go synced 2024-10-04 14:31:21 -06:00
go/usr/rsc/gmp/gcc.c

55 lines
739 B
C
Raw Normal View History

// 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);
}