Add Makefile for OpenBSD
This commit is contained in:
parent
0b5a11ce8c
commit
42bc366e01
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ cmake*
|
||||
build
|
||||
compile_commands.json
|
||||
site
|
||||
libflint.so
|
||||
|
29
Makefile
Normal file
29
Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
.PHONY : clean
|
||||
|
||||
CFLAGS = -std=c99 -Iinclude -pedantic -Wall -Wextra
|
||||
LDFLAGS = -fPIC -shared
|
||||
|
||||
TARGET = libflint.so
|
||||
SRC != ls src/*.c
|
||||
OBJ = $(SRC:./src/$.c=./obj/%.o)
|
||||
|
||||
PREFIX = $(DESTDIR)/usr/local
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
cc $(CFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJ)
|
||||
|
||||
./obj/%.o: ./src/%.c
|
||||
cc $(CFLAGS) -c $< -o $@
|
||||
|
||||
install: $(TARGET)
|
||||
cp $(TARGET) $(LIBDIR)
|
||||
|
||||
uninstall:
|
||||
rm -f $(LIBDIR)/$(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
|
@ -75,4 +75,5 @@ Point *bresenham(int x0, int y0, int x1, int y1, size_t *sz) {
|
||||
|
||||
Point *bresenham_p(Point p1, Point p2, size_t *sz) {
|
||||
return bresenham(p1.x, p1.y, p2.x, p2.y, sz);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
src/vector.c
14
src/vector.c
@ -31,7 +31,13 @@ int vec_init_with_capacity(Vector *vec, void (*destroy)(void *data), size_t capa
|
||||
|
||||
static int vec_grow(Vector *const vec) {
|
||||
vec->capacity *= 2;
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
vec->elements = reallocarray(vec->elements, vec->capacity, sizeof(void *));
|
||||
#else
|
||||
vec->elements = reallocf(vec->elements, sizeof(void *) * vec->capacity);
|
||||
#endif
|
||||
|
||||
if (vec->elements == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -106,7 +112,13 @@ int vec_shrink(Vector *vec) {
|
||||
}
|
||||
|
||||
vec->capacity = vec_len(vec);
|
||||
vec->elements = reallocf(vec, sizeof(void*) * vec_cap(vec));
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
vec->elements = reallocarray(vec->elements, vec->capacity, sizeof(void *));
|
||||
#else
|
||||
vec->elements = reallocf(vec->elements, sizeof(void *) * vec->capacity);
|
||||
#endif
|
||||
|
||||
if (vec->elements == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user