set up gmp and bdwgc
This commit is contained in:
parent
75f49ac9cb
commit
a30700ff0d
8
Makefile
8
Makefile
|
@ -1,14 +1,14 @@
|
|||
.POSIX:
|
||||
.PHONY: all debug run clean
|
||||
DEPS=src/main.o src/util.o
|
||||
LIBS=-lgc -lgmp
|
||||
DEPS=src/main.o src/util.o src/gmp_setup.o
|
||||
LIBS=-static -l:libgmp.a -l:libgc.a -l:libpthread.a
|
||||
DBGFLAGS=-Og -g
|
||||
DBGBIN=secd_debug
|
||||
|
||||
all: secd
|
||||
|
||||
secd: $(DEPS)
|
||||
$(CC) $(LIBS) $(CFLAGS) $(DEPS) -o secd
|
||||
$(CC) $(CFLAGS) $(DEPS) $(LIBS) -o secd
|
||||
|
||||
$(DBGBIN): $(DEPS)
|
||||
$(CC) $(LIBS) $(DBGFLAGS) -DENABLE_DBG_H -o secd_debug
|
||||
|
@ -23,4 +23,4 @@ clean:
|
|||
|
||||
.SUFFIXES: .c .o
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
|
||||
|
|
17
src/gmp_setup.c
Normal file
17
src/gmp_setup.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gc.h>
|
||||
#include <gmp.h>
|
||||
|
||||
void gmp_free(void* p, size_t s) {
|
||||
GC_FREE(p); // TODO: see if this performs better than a NOP
|
||||
}
|
||||
|
||||
void* gmp_realloc(void* p, size_t o, size_t n) {
|
||||
return GC_REALLOC(p, n);
|
||||
}
|
||||
|
||||
void gmp_init(void) {
|
||||
mp_set_memory_functions(GC_malloc, gmp_realloc, gmp_free);
|
||||
}
|
6
src/gmp_setup.h
Normal file
6
src/gmp_setup.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _GMP_SETUP_H
|
||||
#define _GMP_SETUP_H
|
||||
|
||||
void gmp_init(void);
|
||||
|
||||
#endif
|
|
@ -1,15 +1,19 @@
|
|||
#include <gc.h>
|
||||
#include <gmp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <gc.h>
|
||||
|
||||
#include "dbg.h"
|
||||
#include "util.h"
|
||||
#include "gmp_setup.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
GC_INIT();
|
||||
|
||||
gmp_init();
|
||||
|
||||
if (argc < 2) {
|
||||
die("Not enough args");
|
||||
}
|
||||
|
@ -20,4 +24,5 @@ int main(int argc, char** argv) {
|
|||
buf = readFile(argv[1], &size);
|
||||
|
||||
fwrite(buf, 1, size, stdout);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user