added gnu++11 support

Wed, 27 Feb 2013 13:30:21 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Feb 2013 13:30:21 +0100
changeset 95
ecfdc1c4a552
parent 94
57ea041df22f
child 96
fbbff331beba

added gnu++11 support

g++-debug.mk file | annotate | diff | comparison | revisions
g++.mk file | annotate | diff | comparison | revisions
test/buffer_tests.c file | annotate | diff | comparison | revisions
test/logging_tests.c file | annotate | diff | comparison | revisions
test/map_tests.c file | annotate | diff | comparison | revisions
ucx/buffer.c file | annotate | diff | comparison | revisions
ucx/logging.c file | annotate | diff | comparison | revisions
ucx/map.c file | annotate | diff | comparison | revisions
ucx/map.h file | annotate | diff | comparison | revisions
ucx/mempool.c file | annotate | diff | comparison | revisions
ucx/string.c file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/g++-debug.mk	Wed Feb 27 13:30:21 2013 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +#
     1.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 +#
     1.7 +# Copyright 2011 Olaf Wintermann. All rights reserved.
     1.8 +#
     1.9 +# Redistribution and use in source and binary forms, with or without
    1.10 +# modification, are permitted provided that the following conditions are met:
    1.11 +#
    1.12 +#   1. Redistributions of source code must retain the above copyright
    1.13 +#      notice, this list of conditions and the following disclaimer.
    1.14 +#
    1.15 +#   2. Redistributions in binary form must reproduce the above copyright
    1.16 +#      notice, this list of conditions and the following disclaimer in the
    1.17 +#      documentation and/or other materials provided with the distribution.
    1.18 +#
    1.19 +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.20 +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.21 +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.22 +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    1.23 +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.24 +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.25 +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.26 +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.27 +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.28 +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.29 +# POSSIBILITY OF SUCH DAMAGE.
    1.30 +#
    1.31 +
    1.32 +CC = g++
    1.33 +LD = g++
    1.34 +AR = ar
    1.35 +RM = rm
    1.36 +
    1.37 +CFLAGS  = -std=gnu++11 -g -O2 -fstrict-aliasing -Werror -Wall -pedantic -c
    1.38 +COFLAGS = -o
    1.39 +LDFLAGS = 
    1.40 +LOFLAGS = -o
    1.41 +ARFLAGS = -r
    1.42 +RMFLAGS = -f
    1.43 +
    1.44 +OBJ_EXT = o
    1.45 +LIB_EXT = a
    1.46 +APP_EXT =
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/g++.mk	Wed Feb 27 13:30:21 2013 +0100
     2.3 @@ -0,0 +1,44 @@
     2.4 +#
     2.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 +#
     2.7 +# Copyright 2011 Olaf Wintermann. All rights reserved.
     2.8 +#
     2.9 +# Redistribution and use in source and binary forms, with or without
    2.10 +# modification, are permitted provided that the following conditions are met:
    2.11 +#
    2.12 +#   1. Redistributions of source code must retain the above copyright
    2.13 +#      notice, this list of conditions and the following disclaimer.
    2.14 +#
    2.15 +#   2. Redistributions in binary form must reproduce the above copyright
    2.16 +#      notice, this list of conditions and the following disclaimer in the
    2.17 +#      documentation and/or other materials provided with the distribution.
    2.18 +#
    2.19 +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    2.20 +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    2.21 +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    2.22 +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    2.23 +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    2.24 +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    2.25 +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    2.26 +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    2.27 +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    2.28 +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2.29 +# POSSIBILITY OF SUCH DAMAGE.
    2.30 +#
    2.31 +
    2.32 +CC = g++
    2.33 +LD = g++
    2.34 +AR = ar
    2.35 +RM = rm
    2.36 +
    2.37 +CFLAGS  = -std=gnu++11 -O2 -fstrict-aliasing -c
    2.38 +COFLAGS = -o
    2.39 +LDFLAGS = 
    2.40 +LOFLAGS = -o
    2.41 +ARFLAGS = -r
    2.42 +RMFLAGS = -f
    2.43 +
    2.44 +OBJ_EXT = o
    2.45 +LIB_EXT = a
    2.46 +APP_EXT =
    2.47 +
     3.1 --- a/test/buffer_tests.c	Wed Feb 27 11:48:29 2013 +0100
     3.2 +++ b/test/buffer_tests.c	Wed Feb 27 13:30:21 2013 +0100
     3.3 @@ -120,7 +120,7 @@
     3.4      UCX_TEST_BEGIN
     3.5  
     3.6      char rb[16];
     3.7 -    for (int i = 0 ; i < 16 ; i++) {
     3.8 +    for (size_t i = 0 ; i < 16 ; i++) {
     3.9          UCX_TEST_ASSERT(b->pos == i, "pos wrong during read loop");
    3.10          UCX_TEST_ASSERT(!ucx_buffer_eof(b),
    3.11                  "EOF shall not be set during read loop");
     4.1 --- a/test/logging_tests.c	Wed Feb 27 11:48:29 2013 +0100
     4.2 +++ b/test/logging_tests.c	Wed Feb 27 13:30:21 2013 +0100
     4.3 @@ -16,7 +16,7 @@
     4.4      ucx_logger_trace(logger, "dont log this!");
     4.5      ucx_logger_error(logger, "error %d!", 42);
     4.6      fseek(stream, 0, SEEK_SET);
     4.7 -    int r = fread(buffer, 1, 100, stream);
     4.8 +    size_t r = fread(buffer, 1, 100, stream);
     4.9      
    4.10      size_t expected_length = 76;
    4.11      UCX_TEST_ASSERT(r == expected_length && strncmp(buffer,
     5.1 --- a/test/map_tests.c	Wed Feb 27 11:48:29 2013 +0100
     5.2 +++ b/test/map_tests.c	Wed Feb 27 13:30:21 2013 +0100
     5.3 @@ -184,7 +184,7 @@
     5.4      const char *string = (const char*) value;
     5.5      size_t n = strlen(string);
     5.6      char *encoded = (char*) malloc(n+1);
     5.7 -    for (int i = 0 ; i < n ; i++) {
     5.8 +    for (size_t i = 0 ; i < n ; i++) {
     5.9          encoded[i] = string[n-1-i];
    5.10      }
    5.11      encoded[n] = 0;
     6.1 --- a/ucx/buffer.c	Wed Feb 27 11:48:29 2013 +0100
     6.2 +++ b/ucx/buffer.c	Wed Feb 27 13:30:21 2013 +0100
     6.3 @@ -63,7 +63,7 @@
     6.4  }
     6.5  
     6.6  int ucx_buffer_seek(UcxBuffer *buffer, off_t offset, int whence) {
     6.7 -    off_t npos = 0;
     6.8 +    size_t npos = 0;
     6.9      switch (whence) {
    6.10      case SEEK_SET:
    6.11          npos = 0;
    6.12 @@ -78,7 +78,7 @@
    6.13  
    6.14      npos += offset;
    6.15      
    6.16 -    if (npos < 0 || npos > buffer->size) {
    6.17 +    if (npos > buffer->size) {
    6.18          return -1;
    6.19      } else {
    6.20          buffer->pos = npos;
     7.1 --- a/ucx/logging.c	Wed Feb 27 11:48:29 2013 +0100
     7.2 +++ b/ucx/logging.c	Wed Feb 27 13:30:21 2013 +0100
     7.3 @@ -9,20 +9,20 @@
     7.4      if (logger != NULL) {
     7.5          logger->stream = stream;
     7.6          logger->writer = (write_func)fwrite;
     7.7 -        logger->dateformat = "%F %T %z ";
     7.8 +        logger->dateformat = (char*) "%F %T %z ";
     7.9          logger->level = level;
    7.10          logger->mask = mask;
    7.11          logger->levels = ucx_map_new(8);
    7.12          
    7.13          unsigned int l;
    7.14          l = UCX_LOGGER_ERROR;
    7.15 -        ucx_map_int_put(logger->levels, l, "[ERROR]");
    7.16 +        ucx_map_int_put(logger->levels, l, (void*) "[ERROR]");
    7.17          l = UCX_LOGGER_WARN;
    7.18 -        ucx_map_int_put(logger->levels, l, "[WARNING]");
    7.19 +        ucx_map_int_put(logger->levels, l, (void*) "[WARNING]");
    7.20          l = UCX_LOGGER_INFO;
    7.21 -        ucx_map_int_put(logger->levels, l, "[INFO]");
    7.22 +        ucx_map_int_put(logger->levels, l, (void*) "[INFO]");
    7.23          l = UCX_LOGGER_TRACE;
    7.24 -        ucx_map_int_put(logger->levels, l, "[TRACE]");
    7.25 +        ucx_map_int_put(logger->levels, l, (void*) "[TRACE]");
    7.26      }
    7.27  
    7.28      return logger;
    7.29 @@ -70,6 +70,5 @@
    7.30          msg[k++] = '\n';
    7.31          
    7.32          logger->writer(msg, 1, k, logger->stream);
    7.33 -        fflush(logger->stream);
    7.34      }
    7.35  }
     8.1 --- a/ucx/map.c	Wed Feb 27 11:48:29 2013 +0100
     8.2 +++ b/ucx/map.c	Wed Feb 27 13:30:21 2013 +0100
     8.3 @@ -360,7 +360,7 @@
     8.4      UcxMapIterator iter = ucx_map_iterator(map);
     8.5      char *k, *v;
     8.6      sstr_t key, value;
     8.7 -    int written;
     8.8 +    size_t written;
     8.9  
    8.10      UCX_MAP_FOREACH(v, iter) {
    8.11          k = (char*) iter.cur->key.data;
     9.1 --- a/ucx/map.h	Wed Feb 27 11:48:29 2013 +0100
     9.2 +++ b/ucx/map.h	Wed Feb 27 13:30:21 2013 +0100
     9.3 @@ -51,7 +51,7 @@
     9.4  struct UcxMapIterator {
     9.5      UcxMap        *map;
     9.6      UcxMapElement *cur;
     9.7 -    int           index;
     9.8 +    size_t        index;
     9.9  };
    9.10  
    9.11  
    10.1 --- a/ucx/mempool.c	Wed Feb 27 11:48:29 2013 +0100
    10.2 +++ b/ucx/mempool.c	Wed Feb 27 13:30:21 2013 +0100
    10.3 @@ -5,6 +5,9 @@
    10.4  #include <stdlib.h>
    10.5  #include <string.h>
    10.6  #include <stdio.h>
    10.7 +#ifdef __cplusplus
    10.8 +#define __STDC_FORMAT_MACROS
    10.9 +#endif
   10.10  #include <inttypes.h>
   10.11  
   10.12  #include "mempool.h"
   10.13 @@ -79,13 +82,13 @@
   10.14      char *newm = (char*) realloc(mem, n + sizeof(ucx_destructor));
   10.15      if (newm == NULL) return NULL;
   10.16      if (mem != newm) {
   10.17 -        for(int i=0;i<pool->ndata;i++) {
   10.18 +        for(size_t i=0 ; i < pool->ndata ; i++) {
   10.19              if(pool->data[i] == mem) {
   10.20                  pool->data[i] = newm;
   10.21                  return newm + sizeof(ucx_destructor);
   10.22              }
   10.23          }
   10.24 -        fprintf(stderr, "FATAL: 0x%08"PRIxPTR" not in mpool 0x%08"PRIxPTR"\n",
   10.25 +        fprintf(stderr, "FATAL: 0x%08" PRIxPTR" not in mpool 0x%08" PRIxPTR"\n",
   10.26            (intptr_t)ptr, (intptr_t)pool);
   10.27          exit(1);
   10.28      } else {
   10.29 @@ -95,7 +98,7 @@
   10.30  
   10.31  void ucx_mempool_free(UcxMempool *pool) {
   10.32      ucx_memchunk *chunk;
   10.33 -    for(int i=0;i<pool->ndata;i++) {
   10.34 +    for(size_t i=0 ; i<pool->ndata ; i++) {
   10.35          chunk = (ucx_memchunk*) pool->data[i];
   10.36          if(chunk->destructor != NULL) {
   10.37              chunk->destructor(&chunk->c);
    11.1 --- a/ucx/string.c	Wed Feb 27 11:48:29 2013 +0100
    11.2 +++ b/ucx/string.c	Wed Feb 27 13:30:21 2013 +0100
    11.3 @@ -30,7 +30,7 @@
    11.4      size_t size = s.length;
    11.5      va_start(ap, s);
    11.6  
    11.7 -    for (int i=0;i<n-1;i++) {
    11.8 +    for (size_t i = 0 ; i < n-1 ; i++) {
    11.9          sstr_t str = va_arg(ap, sstr_t);
   11.10          size += str.length;
   11.11      }
   11.12 @@ -66,7 +66,7 @@
   11.13      memcpy(ptr, c1.ptr, cplen);
   11.14      len -= cplen;
   11.15      ptr += cplen;
   11.16 -    for (int i=0;i<n-1;i++) {
   11.17 +    for (size_t i = 0 ; i < n-1 ; i++) {
   11.18          sstr_t str = va_arg (ap, sstr_t);
   11.19          cplen = str.length > len ? len : str.length;
   11.20          if(cplen <= 0) {
   11.21 @@ -115,10 +115,10 @@
   11.22      }
   11.23      sstr_t sv = sstrdup(s);
   11.24  
   11.25 -    for (int i = 0 ; i < s.length ; i++) {
   11.26 +    for (size_t i = 0 ; i < s.length ; i++) {
   11.27          if (sv.ptr[i] == d.ptr[0]) {
   11.28              _Bool match = 1;
   11.29 -            for (int j = 1 ; j < d.length ; j++) {
   11.30 +            for (size_t j = 1 ; j < d.length ; j++) {
   11.31                  if (j+i < s.length) {
   11.32                      match &= (sv.ptr[i+j] == d.ptr[j]);
   11.33                  } else {
   11.34 @@ -128,7 +128,7 @@
   11.35              }
   11.36              if (match) {
   11.37                  (*n)++;
   11.38 -                for (int j = 0 ; j < d.length ; j++) {
   11.39 +                for (size_t j = 0 ; j < d.length ; j++) {
   11.40                      sv.ptr[i+j] = 0;
   11.41                  }
   11.42                  i += d.length;
   11.43 @@ -139,7 +139,7 @@
   11.44      result = (sstr_t*) malloc(sizeof(sstr_t) * (*n));
   11.45  
   11.46      char *pptr = sv.ptr;
   11.47 -    for (int i = 0 ; i < *n ; i++) {
   11.48 +    for (size_t i = 0 ; i < *n ; i++) {
   11.49          size_t l = strlen(pptr);
   11.50          char* ptr = (char*) malloc(l + 1);
   11.51          memcpy(ptr, pptr, l);

mercurial