Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add in bigSol.c file for glue code.

  • Loading branch information...
commit 06368a7fa941d2abfb4b178c012d7591d3e0b869 1 parent 5c30ee3
@colomon authored
View
2  build-BigDigit/Makefile.am
@@ -1,3 +1,3 @@
lib_LTLIBRARIES = libbd.la
-libbd_la_SOURCES = bigd.c bigdRand.c bigdigits.c bigdigitsRand.c
+libbd_la_SOURCES = bigd.c bigdRand.c bigdigits.c bigdigitsRand.c bigSol.c
dist_doc_DATA = README
View
5 build-BigDigit/Makefile.in
@@ -75,7 +75,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libbd_la_LIBADD =
am_libbd_la_OBJECTS = bigd.lo bigdRand.lo bigdigits.lo \
- bigdigitsRand.lo
+ bigdigitsRand.lo bigSol.lo
libbd_la_OBJECTS = $(am_libbd_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -217,7 +217,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
lib_LTLIBRARIES = libbd.la
-libbd_la_SOURCES = bigd.c bigdRand.c bigdigits.c bigdigitsRand.c
+libbd_la_SOURCES = bigd.c bigdRand.c bigdigits.c bigdigitsRand.c bigSol.c
dist_doc_DATA = README
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -315,6 +315,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigSol.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigdRand.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigdigits.Plo@am__quote@
View
16 build-BigDigit/bigSol.c
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+
+void *
+bdSolMalloc(int size) {
+ return malloc(size);
+}
+
+void
+bdSolFree(void *p) {
+ free(p);
+}
+
+char *
+bdSolStrCast(void *s) {
+ return (char *) s;
+}
View
16 lib/Math/BigInt.pm
@@ -15,9 +15,9 @@ sub bdIsEqual(OpaquePointer $a, OpaquePointer $b) returns Int is native("libbd")
sub bdCompare(OpaquePointer $a, OpaquePointer $b) returns Int is native("libbd") { ... }
sub bdIsZero(OpaquePointer $a) returns Int is native("libbd") { ... }
-sub malloc(Int $n) returns OpaquePointer is native("libSystem") { ... }
-sub free(OpaquePointer $p) is native("libSystem") { ... }
-sub strcat(OpaquePointer $s, Str $t) returns Str is native("libSystem") { ... }
+sub bdSolMalloc(Int $n) returns OpaquePointer is native("libbd") { ... }
+sub bdSolFree(OpaquePointer $p) is native("libbd") { ... }
+sub bdSolStrCast(OpaquePointer $s) returns Str is native("libbd") { ... }
class Math::BigInt does Real {
has $.bd;
@@ -35,15 +35,15 @@ class Math::BigInt does Real {
}
method Str() {
- my $space = malloc(1000);
+ my $space = bdSolMalloc(1000);
my $size = bdConvToDecimal($.bd, $space, 0);
if $size > 999 {
- free($space);
- $space = malloc($size + 1);
+ bdSolFree($space);
+ $space = bdSolMalloc($size + 1);
}
bdConvToDecimal($.bd, $space, $size + 1);
- my $result = strcat($space, "");
- free($space);
+ my $result = bdSolStrCast($space);
+ bdSolFree($space);
$result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.