Browse Source

Use openlibm

Jeremy Soller 7 years ago
parent
commit
bf987098dc
10 changed files with 29 additions and 5 deletions
  1. 0 0
      include/limits.h
  2. 1 0
      include/math.h
  3. 5 0
      test.sh
  4. 1 0
      tests/.gitignore
  5. 13 1
      tests/Makefile
  6. 1 1
      tests/alloc.c
  7. 1 1
      tests/args.c
  8. 1 1
      tests/create.c
  9. 5 0
      tests/math.c
  10. 1 1
      tests/write.c

+ 0 - 0
include/limits.h


+ 1 - 0
include/math.h

@@ -0,0 +1 @@
+#include <openlibm.h>

+ 5 - 0
test.sh

@@ -2,6 +2,11 @@ set -ex
 
 cargo build
 cargo build --manifest-path crt0/Cargo.toml
+
+cd openlibm
+make
+cd ..
+
 cd tests
 make clean
 make run

+ 1 - 0
tests/.gitignore

@@ -2,4 +2,5 @@
 /args
 /create
 /create.out
+/math
 /write

+ 13 - 1
tests/Makefile

@@ -2,6 +2,7 @@ BINS=\
 	alloc \
 	args \
 	create \
+	math \
 	write
 
 all: $(BINS)
@@ -13,4 +14,15 @@ run: $(BINS)
 	for bin in $(BINS); do echo "\\033[1m$${bin}\\033[0m"; ./$${bin} test args; done
 
 %: %.c
-	gcc -nostdinc -nostdlib -I ../include -I ../target/include ../target/debug/libcrt0.a $< ../target/debug/libc.a -o $@
+	gcc \
+		-nostdinc \
+		-nostdlib \
+		-I ../include \
+		-I ../target/include \
+		-I ../openlibm/include \
+		-I ../openlibm/src \
+		../target/debug/libcrt0.a \
+		$< \
+		../target/debug/libc.a \
+		../openlibm/libopenlibm.a \
+		-o $@

+ 1 - 1
tests/alloc.c

@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-int main(int argc, char **argv) {
+int main(int argc, char ** argv) {
     write(STDERR_FILENO, "malloc\n", 7);
     char * ptr = (char *)malloc(256);
     write(STDERR_FILENO, "set\n", 4);

+ 1 - 1
tests/args.c

@@ -1,7 +1,7 @@
 #include <string.h>
 #include <unistd.h>
 
-int main(int argc, char **argv) {
+int main(int argc, char ** argv) {
     int i;
     for(i = 0; i < argc; i++) {
         write(STDOUT_FILENO, argv[i], strlen(argv[i]));

+ 1 - 1
tests/create.c

@@ -1,7 +1,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-int main(int argc, char **argv) {
+int main(int argc, char ** argv) {
     int fd = creat("create.out", 0755);
     if (fd >= 0) {
         write(fd, "Hello World!\n", 13);

+ 5 - 0
tests/math.c

@@ -0,0 +1,5 @@
+#include <math.h>
+
+int main(int argc, char ** argv) {
+    float c = cos(3.14);
+}

+ 1 - 1
tests/write.c

@@ -1,6 +1,6 @@
 #include <unistd.h>
 
-int main(int argc, char **argv) {
+int main(int argc, char ** argv) {
     write(STDOUT_FILENO, "Hello World!\n", 13);
     return 0;
 }