Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikwidlund committed Jan 30, 2021
1 parent ec7aba7 commit 77756bd
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
@@ -1,9 +1,9 @@
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
AM_CFLAGS = -std=gnu11 -g -O3 -march=native -flto -I$(srcdir)/src -fPIC
AM_CFLAGS = -std=gnu11 -I$(srcdir)/src -fPIC
AM_LDFLAGS = -static

DIST_SUBDIRS = docs examples
DIST_SUBDIRS = docs example

EXTRA_DIST = \
CHANGES \
Expand Down Expand Up @@ -50,7 +50,7 @@ mainheader_HEADERS = src/dynamic.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libdynamic.pc

MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in docs/Makefile.in benchmark/Makefile.in examples/Makefile.in libdynamic-?.?.?.tar.gz
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in docs/Makefile.in example/Makefile.in libdynamic-?.?.?.tar.gz
maintainer-clean-local:; rm -rf autotools m4 libdynamic-?.?.?

### unit tests ###
Expand Down
6 changes: 2 additions & 4 deletions configure.ac
Expand Up @@ -3,14 +3,12 @@ AC_CONFIG_AUX_DIR(autotools)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign no-define])

: ${CFLAGS="-Wall -Wextra -Wpedantic"}
: ${CXXFLAGS="-Wall -Wextra -Wpedantic"}
: ${CFLAGS="-Wall -Wextra -Wpedantic -g -O3 -march=native -flto"}

AM_PROG_AR
LT_INIT
AM_PROG_CC_C_O
AC_PROG_CXX

AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile libdynamic.pc])
AC_CONFIG_FILES([Makefile docs/Makefile example/Makefile libdynamic.pc])
AC_OUTPUT
13 changes: 13 additions & 0 deletions example/Makefile.am
@@ -0,0 +1,13 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
AM_CFLAGS = -std=gnu11 -std=gnu11
LDADD = -L.. -ldynamic

bin_PROGRAMS = \
maps \
mapi \
list \
async

async_LDFLAGS = -pthread

MAINTAINERCLEANFILES = Makefile.in
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 0 additions & 23 deletions examples/Makefile.am

This file was deleted.

19 changes: 2 additions & 17 deletions src/dynamic/buffer.c
Expand Up @@ -18,12 +18,6 @@ static size_t buffer_roundup(size_t size)
return size;
}

static inline void buffer_assert(int value)
{
if (!value)
abort();
}

/* constructor/destructor */

void buffer_construct(buffer *b)
Expand All @@ -50,14 +44,10 @@ size_t buffer_capacity(buffer *b)

void buffer_reserve(buffer *b, size_t capacity)
{
void *data;

if (capacity > b->capacity)
{
capacity = buffer_roundup(capacity);
data = realloc(b->data, capacity);
buffer_assert(data != NULL);
b->data = data;
b->data = realloc(b->data, capacity);
b->capacity = capacity;
}
}
Expand All @@ -71,14 +61,9 @@ void buffer_resize(buffer *b, size_t size)

void buffer_compact(buffer *b)
{
void *data;

if (b->capacity > b->size)
{
data = realloc(b->data, b->size);
if (b->size)
buffer_assert(data != NULL);
b->data = data;
b->data = realloc(b->data, b->size);
b->capacity = b->size;
}
}
Expand Down
16 changes: 1 addition & 15 deletions test/buffer.c
Expand Up @@ -49,24 +49,10 @@ void core(__attribute__((unused)) void **state)
buffer_destruct(&b);
}

void alloc(__attribute__((unused)) void **state)
{
buffer b;

buffer_construct(&b);
debug_out_of_memory = 1;
debug_abort = 1;
expect_assert_failure(buffer_reserve(&b, 100));
debug_abort = 0;
debug_out_of_memory = 0;
buffer_destruct(&b);
}

int main()
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(core),
cmocka_unit_test(alloc),
cmocka_unit_test(core)
};

return cmocka_run_group_tests(tests, NULL, NULL);
Expand Down

0 comments on commit 77756bd

Please sign in to comment.