diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77bd409c38b9ce095ab102b47204a889e124ec15..d83bea67c4d7639ee71cab65e65958a90608c9b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,8 @@ make:generic: except: - /^wip.*/ - /^WIP.*/ + variables: + CFLAGS: "-std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-but-set-parameter" script: - ./autogen.sh - mkdir build @@ -37,6 +39,7 @@ make:generic: artifacts: when: on_failure paths: + - config.log - tests/*.log make:knl: diff --git a/configure.ac b/configure.ac index 4bafead0335bceef778393a2d4dd487b66e19aa4..2ed0176fe2a65262462859f515ea871c28c718fe 100644 --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AC_CHECK_LIB(dl, dlopen) # add pthread support. # doc in m4/ax_pthread.m4. Defines automake PTHREAD_CFLAGS and PTHREAD_LIBS -AX_PTHREAD +AX_PTHREAD([],[AC_MSG_ERROR([Cannot find how to compile with pthreads.])]) CC="$PTHREAD_CC" # NUMA support @@ -100,11 +100,6 @@ AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_FILES([Makefile src/Makefile - src/area/Makefile - src/dma/Makefile - src/tiling/Makefile - src/scratch/Makefile - src/utils/Makefile include/Makefile tests/Makefile doc/Makefile diff --git a/include/aml.h b/include/aml.h index 0f0b6f45cdaf882426a2b2751162cf9cf58dc89a..69a64ac27ef9ebc0581b0e74ac8571a5d7581af8 100644 --- a/include/aml.h +++ b/include/aml.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include diff --git a/include/aml/dma/linux-par.h b/include/aml/dma/linux-par.h index 5f42f64e1968ee835e2c33fc8196cb86b00151a9..2f74051f403c737fca4eb7a99204e713e4716c98 100644 --- a/include/aml/dma/linux-par.h +++ b/include/aml/dma/linux-par.h @@ -33,7 +33,7 @@ struct aml_dma_linux_par_thread_data { * A logical identifier of the thread in charge for * the request progress. **/ - int tid; + size_t tid; /** The actual thread in charge for the request progress**/ pthread_t thread; /** The dma containing sequential operations **/ @@ -70,7 +70,7 @@ struct aml_dma_linux_par_data { struct aml_dma_linux_par_ops { void *(*do_thread)(void *thread_data); int (*do_copy)(struct aml_dma_linux_par_data *data, - struct aml_dma_request_linux_par *request, int tid); + struct aml_dma_request_linux_par *request, size_t tid); }; /** diff --git a/include/aml/utils/error.h b/include/aml/utils/error.h index c152aa758a4b6da7d777636df8fcea0c177e387e..cce03a5d27bc838f3d9b7366189f20dba1f21b7c 100644 --- a/include/aml/utils/error.h +++ b/include/aml/utils/error.h @@ -30,10 +30,10 @@ extern int aml_errno; /** * Get a string description of an aml error. - * @param errno: the aml error number. + * @param err: the aml error number. * Returns a static string describing the error. **/ -const char *aml_strerror(const int errno); +const char *aml_strerror(const int err); /** * Print error on standard error output. diff --git a/src/Makefile.am b/src/Makefile.am index 737dea2103075d2237dc290fc9628fcc5a9d5132..63944aab455530d819c2f010b114281046ced842 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,24 +1,38 @@ -lib_LTLIBRARIES = libaml.la - -libaml_la_SOURCES = aml.c - -libaml_la_CFLAGS = -I$(top_srcdir)/include - -libaml_la_LDFLAGS=$(PTHREAD_CFLAGS) -libaml_la_LIBADD= - -SUBDIRS=utils -libaml_la_LIBADD+=$(top_srcdir)/src/utils/libamlutils.la - -SUBDIRS+=area -libaml_la_LIBADD+=$(top_srcdir)/src/area/libamlarea.la - -SUBDIRS+=dma -libaml_la_LIBADD+=$(top_srcdir)/src/dma/libamldma.la - -SUBDIRS+=tiling -libaml_la_LIBADD+=$(top_srcdir)/src/tiling/libamltiling.la - -SUBDIRS+=scratch -libaml_la_LIBADD+=$(top_srcdir)/src/scratch/libamlscratch.la +AM_CFLAGS = -I$(top_srcdir)/include $(PTHREAD_CFLAGS) +AM_LDFLAGS = $(PTHREAD_LIBS) + + +AREA_SOURCES = \ + area/area.c \ + area/linux.c + +DMA_SOURCES = \ + dma/dma.c \ + dma/dma_linux_par.c \ + dma/dma_linux_seq.c + +SCRATCH_SOURCES = \ + scratch/scratch.c \ + scratch/scratch_par.c \ + scratch/scratch_seq.c + +TILING_SOURCES = \ + tiling/tiling.c \ + tiling/tiling_1d.c \ + tiling/tiling_2d.c + +UTILS_SOURCES = \ + utils/bitmap.c \ + utils/error.c \ + utils/vector.c + +LIB_SOURCES = \ + $(AREA_SOURCES) \ + $(DMA_SOURCES) \ + $(SCRATCH_SOURCES) \ + $(TILING_SOURCES) \ + $(UTILS_SOURCES) \ + aml.c +lib_LTLIBRARIES = libaml.la +libaml_la_SOURCES = $(LIB_SOURCES) diff --git a/src/aml.c b/src/aml.c index 86b5522caa32c208a0e3b6f9fc1aee277494514f..c108e8e64c18dc94a2c642e8aa2261ddf2f65af8 100644 --- a/src/aml.c +++ b/src/aml.c @@ -21,6 +21,8 @@ int aml_errno; int aml_init(int *argc, char **argv[]) { + // disable warnings + (void)argc; (void)argv; return 0; } diff --git a/src/area/Makefile.am b/src/area/Makefile.am deleted file mode 100644 index 232b592dfcd8d56d58b707ba72082c2f7e88b729..0000000000000000000000000000000000000000 --- a/src/area/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -AM_CFLAGS=-I$(top_srcdir)/include - -AM_CPPFLAGS=$(AM_CFLAGS) - -noinst_LTLIBRARIES = libamlarea.la - -libamlarea_la_LDFLAGS = -lnuma - -libamlarea_la_CFLAGS = $(AM_CFLAGS) - -libamlarea_la_SOURCES = \ - area.c \ - linux.c diff --git a/src/area/linux.c b/src/area/linux.c index 035b58fc50e48f4c9cad61a4371924ae4f827a1f..9a78634225ff9068d494a718e459f9d7abb43ca8 100644 --- a/src/area/linux.c +++ b/src/area/linux.c @@ -47,6 +47,8 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data, { int err, mode, i; struct bitmask *nodeset; + // unused parameter + (void)size; nodeset = numa_allocate_nodemask(); if (nodeset == NULL) @@ -209,7 +211,6 @@ int aml_area_linux_init(struct aml_area *area, const int mmap_flags, const int binding_flags) { struct aml_area_linux_data *data; - int err; if (area == NULL) return -AML_EINVAL; diff --git a/src/dma/Makefile.am b/src/dma/Makefile.am deleted file mode 100644 index 093f3b48223c9ee39e6287db9341fac1f57e2e57..0000000000000000000000000000000000000000 --- a/src/dma/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -AM_CFLAGS=-I$(top_srcdir)/include - -AM_CPPFLAGS=$(AM_CFLAGS) - -noinst_LTLIBRARIES=libamldma.la - -libamldma_la_SOURCES=\ - dma.c \ - dma_linux_par.c \ - dma_linux_seq.c - -libamldma_la_CFLAGS=$(AM_CFLAGS) -libamldma_la_LDFLAGS=$(AM_CFLAGS) - diff --git a/src/dma/dma_linux_par.c b/src/dma/dma_linux_par.c index ce5122d95838dc862748aa6834626a6c67f18d4d..342c14aeba88535e7d775d8f0283e805a35a4a79 100644 --- a/src/dma/dma_linux_par.c +++ b/src/dma/dma_linux_par.c @@ -66,7 +66,7 @@ void *aml_dma_linux_par_do_thread(void *arg) } int aml_dma_linux_par_do_copy(struct aml_dma_linux_par_data *dma, - struct aml_dma_request_linux_par *req, int tid) + struct aml_dma_request_linux_par *req, size_t tid) { assert(dma != NULL); assert(req != NULL); @@ -125,7 +125,7 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d, } pthread_mutex_unlock(&dma->data.lock); - for (int i = 0; i < dma->data.nbthreads; i++) { + for (size_t i = 0; i < dma->data.nbthreads; i++) { struct aml_dma_linux_par_thread_data *rd = &req->thread_data[i]; rd->req = req; @@ -149,7 +149,7 @@ int aml_dma_linux_par_destroy_request(struct aml_dma_data *d, (struct aml_dma_request_linux_par *)r; /* we cancel and join, instead of killing, for a cleaner result */ - for (int i = 0; i < dma->data.nbthreads; i++) { + for (size_t i = 0; i < dma->data.nbthreads; i++) { pthread_cancel(req->thread_data[i].thread); pthread_join(req->thread_data[i].thread, NULL); } @@ -172,7 +172,7 @@ int aml_dma_linux_par_wait_request(struct aml_dma_data *d, struct aml_dma_request_linux_par *req = (struct aml_dma_request_linux_par *)r; - for (int i = 0; i < dma->data.nbthreads; i++) + for (size_t i = 0; i < dma->data.nbthreads; i++) pthread_join(req->thread_data[i].thread, NULL); /* destroy a completed request */ @@ -244,7 +244,7 @@ int aml_dma_linux_par_init(struct aml_dma *d, size_t nbreqs, sizeof(struct aml_dma_request_linux_par), offsetof(struct aml_dma_request_linux_par, type), AML_DMA_REQUEST_TYPE_INVALID); - for (int i = 0; i < nbreqs; i++) { + for (size_t i = 0; i < nbreqs; i++) { struct aml_dma_request_linux_par *req = aml_vector_get(&dma->data.requests, i); @@ -262,7 +262,7 @@ void aml_dma_linux_par_fini(struct aml_dma *d) if (d == NULL || d->data == NULL) return; dma = (struct aml_dma_linux_par *)d->data; - for (int i = 0; i < aml_vector_size(&dma->data.requests); i++) { + for (size_t i = 0; i < aml_vector_size(&dma->data.requests); i++) { struct aml_dma_request_linux_par *req = aml_vector_get(&dma->data.requests, i); diff --git a/src/scratch/Makefile.am b/src/scratch/Makefile.am deleted file mode 100644 index 011806417f1ad7220e6f6d5364cc7250d41f0d29..0000000000000000000000000000000000000000 --- a/src/scratch/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -AM_CFLAGS=-I$(top_srcdir)/include -AM_CPPFLAGS=$(AM_CFLAGS) - -noinst_LTLIBRARIES=libamlscratch.la - -libamlscratch_la_SOURCES=\ -scratch.c \ -scratch_seq.c \ -scratch_par.c - -libamlscratch_la_CFLAGS=$(AM_CFLAGS) - diff --git a/src/scratch/scratch_par.c b/src/scratch/scratch_par.c index 779be86554def1388e8a3e8c977e82e74edd1591..283ef951e3efb5b4bc2e2f2c585b630d44523c03 100644 --- a/src/scratch/scratch_par.c +++ b/src/scratch/scratch_par.c @@ -58,6 +58,7 @@ void *aml_scratch_par_do_thread(void *arg) aml_dma_copy(scratch->data.dma, scratch->data.tiling, req->dstptr, req->dstid, scratch->data.tiling, req->srcptr, req->srcid); + return NULL; } struct aml_scratch_par_ops aml_scratch_par_inner_ops = { diff --git a/src/tiling/Makefile.am b/src/tiling/Makefile.am deleted file mode 100644 index e6cbc25134e7e8fd2f6b90ae7c0b854e6fdc7523..0000000000000000000000000000000000000000 --- a/src/tiling/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -AM_CFLAGS=-I$(top_srcdir)/include -AM_CPPFLAGS=$(AM_CFLAGS) - -noinst_LTLIBRARIES=libamltiling.la - -libamltiling_la_SOURCES=\ -tiling.c \ -tiling_1d.c \ -tiling_2d.c diff --git a/src/tiling/tiling_1d.c b/src/tiling/tiling_1d.c index 2729f12b567d664c9c7f085af8e88edcf649314b..3fe78ad1aa422e1dd90b9179cd52647e053dbce1 100644 --- a/src/tiling/tiling_1d.c +++ b/src/tiling/tiling_1d.c @@ -62,8 +62,7 @@ struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops = { int aml_tiling_1d_tileid(const struct aml_tiling_data *t, va_list ap) { - const struct aml_tiling_1d_data *data = - (const struct aml_tiling_1d_data *)t; + (void)t; size_t x = va_arg(ap, size_t); return x; } @@ -99,7 +98,7 @@ int aml_tiling_1d_ndims(const struct aml_tiling_data *t, va_list ap) size_t *x = va_arg(ap, size_t *); *x = data->totalsize/data->blocksize; if (data->totalsize % data->blocksize != 0) - *x++; + *x += 1; return 0; } @@ -107,6 +106,7 @@ int aml_tiling_1d_init_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator *it, int flags) { assert(it->data != NULL); + (void)flags; struct aml_tiling_iterator_1d_data *data = (struct aml_tiling_iterator_1d_data *)it->data; @@ -136,12 +136,15 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t, int aml_tiling_1d_fini_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator *it) { + (void)t; + (void)it; return 0; } int aml_tiling_1d_destroy_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator **it) { + (void)t; free(*it); return 0; } @@ -197,7 +200,6 @@ int aml_tiling_1d_create(struct aml_tiling **t, int aml_tiling_1d_init(struct aml_tiling *t, size_t tilesize, size_t totalsize) { - int err; struct aml_tiling_1d_data *data; if (t == NULL || t->data == NULL) @@ -215,6 +217,7 @@ int aml_tiling_1d_init(struct aml_tiling *t, void aml_tiling_1d_fini(struct aml_tiling *t) { /* nothing to do */ + (void)t; } diff --git a/src/tiling/tiling_2d.c b/src/tiling/tiling_2d.c index 7bba98f73a83c1126af06d202840b762b89f8196..2de8a2f144cf39af9c76f93bf99629f2cb971adc 100644 --- a/src/tiling/tiling_2d.c +++ b/src/tiling/tiling_2d.c @@ -92,7 +92,7 @@ size_t aml_tiling_2d_tilesize(const struct aml_tiling_data *t, int tileid) const struct aml_tiling_2d_data *data = (const struct aml_tiling_2d_data *)t; - if (tileid < 0 || tileid >= data->ndims[0]*data->ndims[1]) + if (tileid < 0 || tileid >= (int)(data->ndims[0]*data->ndims[1])) return 0; else return data->blocksize; @@ -105,7 +105,7 @@ void *aml_tiling_2d_tilestart(const struct aml_tiling_data *t, (const struct aml_tiling_2d_data *)t; intptr_t p = (intptr_t)ptr; - if (tileid < 0 || tileid >= data->ndims[0]*data->ndims[1]) + if (tileid < 0 || tileid >= (int)(data->ndims[0]*data->ndims[1])) return NULL; else return (void *)(p + tileid*data->blocksize); @@ -128,6 +128,7 @@ int aml_tiling_2d_init_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator *it, int flags) { assert(it->data != NULL); + (void)flags; struct aml_tiling_iterator_2d_data *data = (struct aml_tiling_iterator_2d_data *)it->data; it->ops = &aml_tiling_iterator_2d_ops; @@ -156,12 +157,15 @@ int aml_tiling_2d_create_iterator(struct aml_tiling_data *t, int aml_tiling_2d_fini_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator *it) { + (void)t; + (void)it; return 0; } int aml_tiling_2d_destroy_iterator(struct aml_tiling_data *t, struct aml_tiling_iterator **it) { + (void)t; free(*it); return 0; } @@ -238,8 +242,8 @@ int aml_tiling_2d_init(struct aml_tiling *t, int type, size_t tilesize, size_t totalsize, size_t rowsize, size_t colsize) { - int err; struct aml_tiling_2d_data *data; + (void)type; if (t == NULL || t->data == NULL) return -AML_EINVAL; @@ -258,6 +262,7 @@ int aml_tiling_2d_init(struct aml_tiling *t, int type, void aml_tiling_2d_fini(struct aml_tiling *t) { /* nothing to do */ + (void)t; } diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am deleted file mode 100644 index e27a9f63f67727615709492940a2ba2934ffb964..0000000000000000000000000000000000000000 --- a/src/utils/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -AM_CFLAGS=-I$(top_srcdir)/include -AM_CPPFLAGS=$(AM_CFLAGS) - -noinst_LTLIBRARIES=libamlutils.la - -libamlutils_la_SOURCES=\ - vector.c \ - bitmap.c \ - error.c - -libamlutils_la_CFLAGS=$(AM_CFLAGS) -libamlutils_la_LDFLAGS= - diff --git a/src/utils/bitmap.c b/src/utils/bitmap.c index f9f9c8346aada1d5b5dd801361546cfb03525600..a6d38d121b0efd813e0e03400adbe9e8d98412e6 100644 --- a/src/utils/bitmap.c +++ b/src/utils/bitmap.c @@ -7,9 +7,8 @@ * * SPDX-License-Identifier: BSD-3-Clause *******************************************************************************/ - +#include "config.h" #include "aml.h" -#include #define AML_BITMAP_EMPTY (0UL) #define AML_BITMAP_FULL (~0UL) diff --git a/src/utils/error.c b/src/utils/error.c index 4d9a7d15ef5364989d7eee8a67f6be073ef9acaf..4f8c752bbdf44062f41c3fda9023d69fc54c6b00 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -20,11 +20,11 @@ static const char * const aml_error_strings[] = { [AML_ENOTSUP] = "Operation not supported", }; -const char *aml_strerror(const int errno) +const char *aml_strerror(const int err) { - if (errno < 0 || errno < AML_ERROR_MAX) + if (err < 0 || err < AML_ERROR_MAX) return "Unknown error"; - return aml_error_strings[errno]; + return aml_error_strings[err]; } void aml_perror(const char *msg) diff --git a/src/utils/vector.c b/src/utils/vector.c index 3d9c90f5d8a06415e8a9c443db08a63c5601489b..ea111203ffd17ac5436681c7fd0d9d8aaf901e33 100644 --- a/src/utils/vector.c +++ b/src/utils/vector.c @@ -29,7 +29,7 @@ int aml_vector_resize(struct aml_vector *vec, size_t newsize) vec->ptr = realloc(vec->ptr, newsize * vec->sz); assert(vec->ptr != NULL); - for (int i = vec->nbelems; i < newsize; i++) { + for (size_t i = vec->nbelems; i < newsize; i++) { int *k = AML_VECTOR_KEY_P(vec, i); *k = vec->na; } @@ -47,8 +47,13 @@ size_t aml_vector_size(const struct aml_vector *vec) void *aml_vector_get(struct aml_vector *vec, int id) { assert(vec != NULL); - if (id != vec->na && id < vec->nbelems) - return AML_VECTOR_ELT_P(vec, id); + if (id == vec->na || id < 0) + return NULL; + + size_t idx = (size_t)id; + + if (idx < vec->nbelems) + return AML_VECTOR_ELT_P(vec, idx); else return NULL; } @@ -57,7 +62,7 @@ void *aml_vector_get(struct aml_vector *vec, int id) int aml_vector_find(const struct aml_vector *vec, int key) { assert(vec != NULL); - for (int i = 0; i < vec->nbelems; i++) { + for (size_t i = 0; i < vec->nbelems; i++) { int *k = AML_VECTOR_KEY_P(vec, i); if (*k == key) @@ -135,7 +140,7 @@ int aml_vector_init(struct aml_vector *vec, size_t reserve, size_t size, vec->na = na; vec->nbelems = reserve; vec->ptr = ptr; - for (int i = 0; i < vec->nbelems; i++) { + for (size_t i = 0; i < vec->nbelems; i++) { int *k = AML_VECTOR_KEY_P(vec, i); *k = na; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 6ce626884330331186b80ce96fadd73783ae04d9..2409170da41dbaad5abfa2f1f1c9fc6905f2fd48 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,7 @@ AM_COLOR_TESTS = yes -# add OpenMP to flags for test programs -AM_CFLAGS = -I$(top_srcdir)/include -AM_LDFLAGS = ../src/libaml.la +AM_CFLAGS = -I$(top_srcdir)/include $(PTHREAD_CFLAGS) +AM_LDFLAGS = ../src/libaml.la $(PTHREAD_LIBS) # valgrind support if TEST_VALGRIND diff --git a/tests/area/test_area.c b/tests/area/test_area.c index e02ddfdcedf26f1717fc49ccad0b80d19ac544fb..359a7fcb097adf19549d2631eaec990787f7ff69 100644 --- a/tests/area/test_area.c +++ b/tests/area/test_area.c @@ -17,7 +17,6 @@ void test_map(const struct aml_area *area){ assert(area->ops->munmap != NULL); void *ptr; - int err; size_t s; const size_t sizes[4] = {1, 32, 4096, 1<<20}; diff --git a/tests/area/test_linux.c b/tests/area/test_linux.c index 1ef6522a2b5efcb19dd060bcddbb8c35cac63a76..9bf5191ac6e73e98dfdff8f900e0f14d2933b7dc 100644 --- a/tests/area/test_linux.c +++ b/tests/area/test_linux.c @@ -7,54 +7,65 @@ * * SPDX-License-Identifier: BSD-3-Clause *******************************************************************************/ +#include "config.h" #include "aml.h" #include "aml/area/linux.h" #include #include -const size_t sizes[3] = {1, 1<<12, 1<<20}; +const size_t sizes[3] = { 1, 1 << 12, 1 << 20 }; + const int binding_flags[3] = { AML_AREA_LINUX_BINDING_FLAG_BIND, AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE, AML_AREA_LINUX_BINDING_FLAG_PREFERRED }; + const int mmap_flags[2] = { AML_AREA_LINUX_MMAP_FLAG_PRIVATE, AML_AREA_LINUX_MMAP_FLAG_SHARED }; -void test_binding(struct aml_bitmap *bitmap){ +void test_binding(struct aml_bitmap *bitmap) +{ void *ptr; - int err; - size_t s; - int bf, mf, i, nnodes, binding_flag, mmap_flag; + int binding_flag, mmap_flag; struct aml_area *area; - for(bf=0; bfops->mmap((struct aml_area_data*)area->data, - NULL, - sizes[s]); + ptr = area->ops->mmap( + (struct aml_area_data *)area->data, + NULL, sizes[s]); assert(ptr != NULL); memset(ptr, 0, sizes[s]); - assert(aml_area_linux_check_binding((struct aml_area_linux_data*)area->data, ptr, sizes[s]) > 0); - assert(area->ops->munmap((struct aml_area_data*)area->data, ptr, sizes[s]) == AML_SUCCESS); + assert(aml_area_linux_check_binding( + (struct aml_area_linux_data *)area->data, + ptr, sizes[s]) > 0); + assert(area->ops->munmap( + (struct aml_area_data *)area->data, + ptr, sizes[s]) == AML_SUCCESS); aml_area_linux_destroy(&area); } } - + } - + } -void test_bind(){ +void test_bind(void) +{ struct bitmask *nodeset; - int i, num_nodes; + int i, num_nodes; struct aml_bitmap bitmap; struct aml_area *area; @@ -62,24 +73,25 @@ void test_bind(){ num_nodes = numa_bitmask_weight(nodeset); aml_bitmap_fill(&bitmap); - if(aml_bitmap_last(&bitmap) > num_nodes){ - assert(aml_area_linux_create(&area, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, - &bitmap, - AML_AREA_LINUX_BINDING_FLAG_PREFERRED) == -AML_EDOM); + if (aml_bitmap_last(&bitmap) > num_nodes) { + assert(aml_area_linux_create + (&area, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, &bitmap, + AML_AREA_LINUX_BINDING_FLAG_PREFERRED) == -AML_EDOM); assert(area == NULL); } test_binding(NULL); aml_bitmap_zero(&bitmap); - for(i = 0; i -static const unsigned long is[8] = { - 0, - AML_BITMAP_NBITS / 4, - 3 * AML_BITMAP_NBITS / 4, - AML_BITMAP_NBITS - 1, - AML_BITMAP_NBITS, - AML_BITMAP_NBITS + AML_BITMAP_NBITS / 4, - AML_BITMAP_NBITS + 3 * AML_BITMAP_NBITS / 4, - AML_BITMAP_NBITS + AML_BITMAP_NBITS - 1 -}; - -static const int nis = sizeof(is) / sizeof(*is); - void test_bitmap_fill(){ unsigned long i; struct aml_bitmap b; aml_bitmap_fill(&b); - for(i = 0; i < nis; i++) - assert(aml_bitmap_isset(&b, is[i])); + for(i = 0; i < AML_BITMAP_MAX; i++) + assert(aml_bitmap_isset(&b, i)); assert(aml_bitmap_nset(&b) == AML_BITMAP_MAX); } @@ -37,8 +24,8 @@ void test_bitmap_zero(){ unsigned long i; struct aml_bitmap b; aml_bitmap_zero(&b); - for(i = 0; i < nis; i++) - assert(!aml_bitmap_isset(&b, is[i])); + for(i = 0; i < AML_BITMAP_MAX; i++) + assert(!aml_bitmap_isset(&b, i)); assert(aml_bitmap_nset(&b) == 0); } @@ -47,108 +34,37 @@ void test_bitmap_set(){ struct aml_bitmap b; aml_bitmap_zero(&b); - for(i = 0; i < nis; i++){ - aml_bitmap_set(&b, is[i]); - assert(aml_bitmap_isset(&b, is[i])); + for(i = 0; i < AML_BITMAP_MAX; i++){ + aml_bitmap_set(&b, i); + assert(aml_bitmap_isset(&b, i)); - for(j = 0; j < is[i]; j++) + for(j = 0; j < i; j++) assert(!aml_bitmap_isset(&b, j)); - for(j = is[i]+1; j < AML_BITMAP_MAX; j++) + for(j = i+1; j < AML_BITMAP_MAX; j++) assert(!aml_bitmap_isset(&b, j)); - - assert(aml_bitmap_nset(&b) == 1); - aml_bitmap_clear(&b, is[i]); - assert(!aml_bitmap_isset(&b, is[i])); - } -} -void test_bitmap_string_conversion(const char * bitmap_str){ - struct aml_bitmap b, c; - char * cstr; - - assert(aml_bitmap_from_string(&b, bitmap_str) == 0); - - if(bitmap_str == NULL || - !strcasecmp(bitmap_str, "none") || - !strcasecmp(bitmap_str, "zero") || - !strcasecmp(bitmap_str, "empty")){ - assert(aml_bitmap_iszero(&b)); - } - else if(!strcasecmp(bitmap_str, "all") || - !strcasecmp(bitmap_str, "full") || - !strcasecmp(bitmap_str, "fill")){ - assert(aml_bitmap_isfull(&b)); - } - - cstr = aml_bitmap_to_string(&b); - assert(cstr != NULL); - assert(aml_bitmap_from_string(&c, cstr) == 0); - assert(aml_bitmap_isequal(&b,&c)); - free(cstr); -} - -void test_bitmap_string(){ - const size_t int_len = 16; - char *bstr, *next; - int i; - const size_t max_len = int_len * (1+nis); - size_t len = 0; - struct aml_bitmap b; - - assert(aml_bitmap_from_string(&b, "unapropriate string") == -1); - - test_bitmap_string_conversion("all"); - test_bitmap_string_conversion("full"); - test_bitmap_string_conversion("fill"); - test_bitmap_string_conversion("zero"); - test_bitmap_string_conversion("empty"); - test_bitmap_string_conversion("none"); - test_bitmap_string_conversion(NULL); - - bstr = malloc(int_len); - for(i = 0; i -int main(int argc, char *argv[]) +int main(void) { struct aml_vector v; diff --git a/tests/utils/test_version.c b/tests/utils/test_version.c index 248cf8b1b2d310c9907ebafc11ab6a1faf769003..94a604be2e6fa207318fe48678a05bdf75f77156 100644 --- a/tests/utils/test_version.c +++ b/tests/utils/test_version.c @@ -11,7 +11,7 @@ #include "aml.h" #include -int main(int argc, char *argv[]) +int main(void) { assert(aml_version_major == AML_VERSION_MAJOR); assert(aml_version_minor == AML_VERSION_MINOR);