Skip to content

Commit

Permalink
Merge pull request #96 from MycroftAI/travis_gcc6
Browse files Browse the repository at this point in the history
Fix build failures with glibc 2.20 (i.e Ubuntu 16.10)
  • Loading branch information
forslund authored Feb 24, 2017
2 parents eb4613e + eb4d658 commit 88b58d4
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ matrix:
os: linux
compiler: gcc
sudo: false
- env: TASK="gcc6" # gcc-6
os: linux
compiler: gcc-6
sudo: false
- env: TASK="arm-linux-gnueabihf-gcc" # arm build
os: linux
compiler: gcc
Expand Down Expand Up @@ -57,6 +61,10 @@ addons:
- mingw32-runtime
- wine
- xvfb
- gcc-6
- g++-6
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
coverity_scan:
project:
name: "MycroftAI/mimic"
Expand Down
12 changes: 12 additions & 0 deletions run_testsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ case "${WHAT_TO_RUN}" in
# for ubuntu precise in travis, that does not provide pkg-config:
pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu"
pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata"
export CFLAGS="$CFLAGS --std=c99"
./configure --enable-shared || exit 1
make || exit 1
make check || exit 1
;;
gcc6)
./autogen.sh
# for ubuntu precise in travis, that does not provide pkg-config:
pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu"
pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata"
export CC="/usr/bin/gcc-6"
export CXX="/usr/bin/g++-6"
./configure --enable-shared || exit 1
make || exit 1
make check || exit 1
Expand Down
5 changes: 4 additions & 1 deletion src/audio/au_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#ifdef CST_AUDIO_ALSA

#define _BSD_SOURCE /* alsa alloca stuff and nanosleep */
#define _POSIX_C_SOURCE 200112L

#include <stdlib.h>
#include <unistd.h>
Expand All @@ -56,6 +56,9 @@
#include "cst_wave.h"
#include "cst_audio.h"

/* alloca.h is not C99 compliant nor POSIX compliant, but alsa needs it and does not include it */
/* See similar patch: https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2008-July/058080.html */
#include <alloca.h>
#include <alsa/asoundlib.h>

int audio_flush_alsa(cst_audiodev *ad);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cst_mmap_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#if (MMAP_TYPE == MMAP_TYPE_POSIX)

# define _POSIX_C_SOURCE 200809L
# define _POSIX_C_SOURCE 200112L

#include <sys/types.h>
#include <sys/mman.h>
Expand Down
8 changes: 7 additions & 1 deletion src/utils/cst_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ int cst_socket_close(int socket)
return -1;
}
#else
#define _POSIX_C_SOURCE 200112L
#include <stdio.h>
#include <stdlib.h>
#ifndef _MSC_VER
Expand All @@ -81,6 +82,11 @@ int cst_socket_close(int socket)
#include "cst_socket.h"
#include "cst_error.h"

/* OSX el capitan does not define INADDR_NONE in all cases */
#ifndef INADDR_NONE
#define INADDR_NONE ((in_addr_t) -1)
#endif

int cst_socket_open(const char *host, int port)
{
/* Return an FD to a remote server */
Expand All @@ -105,7 +111,7 @@ int cst_socket_open(const char *host, int port)
cst_errmsg("cst_socket: gethostbyname failed\n");
return -1;
}
memmove(&serv_addr.sin_addr, serverhost->h_addr,
memmove(&serv_addr.sin_addr, serverhost->h_addr_list[0],
serverhost->h_length);
}
serv_addr.sin_family = AF_INET;
Expand Down
3 changes: 3 additions & 0 deletions src/utils/cst_url.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
/* Only support http: if sockets are available */
/* */
/*************************************************************************/

#define _POSIX_C_SOURCE 200112L

#include <math.h>
#include "cst_file.h"
#include "cst_string.h"
Expand Down
30 changes: 17 additions & 13 deletions unittests/cutest.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@
**********************/

/* The unit test files should not rely on anything below. */

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)
#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)) && !defined(__STRICT_ANSI__)
#define CUTEST_UNIX__ 1
#include <errno.h>
#include <unistd.h>
Expand All @@ -102,12 +101,16 @@
#include <signal.h>
#endif

#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)
#if (defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)) && !defined(__STRICT_ANSI__)
#define CUTEST_WIN__ 1
#include <windows.h>
#include <io.h>
#endif

#if defined(__STRICT_ANSI__)
#define CUTEST_ANSI__ 1
#endif

#ifdef __cplusplus
#include <exception>
#endif
Expand Down Expand Up @@ -162,16 +165,16 @@ test_print_in_color__(int color, const char* fmt, ...)
{
const char* col_str;
switch(color) {
case CUTEST_COLOR_GREEN__: col_str = "\e[0;32m"; break;
case CUTEST_COLOR_RED__: col_str = "\e[0;31m"; break;
case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\e[1;32m"; break;
case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\e[1;30m"; break;
case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\e[1m"; break;
default: col_str = "\e[0m"; break;
case CUTEST_COLOR_GREEN__: col_str = "\033[0;32m"; break;
case CUTEST_COLOR_RED__: col_str = "\033[0;31m"; break;
case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\033[1;32m"; break;
case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\033[1;30m"; break;
case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\033[1m"; break;
default: col_str = "\033[0m"; break;
}
printf("%s", col_str);
n = printf("%s", buffer);
printf("\e[0m");
printf("\033[0m");
return n;
}
#elif defined CUTEST_WIN__
Expand Down Expand Up @@ -352,9 +355,10 @@ test_do_run__(const struct test__* test)
return (test_current_failures__ == 0) ? 0 : -1;
}

#if !defined(CUTEST_ANSI__)
/* Called if anything goes bad in cutest, or if the unit test ends in other
* way then by normal returning from its function (e.g. exception or some
* abnormal child process termination). */
* abnormal child process termination). On CUTEST_ANSI__ this is not used so we don't define it*/
static void
test_error__(const char* fmt, ...)
{
Expand All @@ -377,6 +381,7 @@ test_error__(const char* fmt, ...)
printf("\n");
}
}
#endif

/* Trigger the unit test. If possible (and not suppressed) it starts a child
* process who calls test_do_run__(), otherwise it calls test_do_run__()
Expand Down Expand Up @@ -458,7 +463,7 @@ test_run__(const struct test__* test)
failed = 1;
}

#else
#else /* CUTEST_ANSI__ */

/* A platform where we don't know how to run child process. */
failed = (test_do_run__(test) != 0);
Expand Down Expand Up @@ -650,4 +655,3 @@ main(int argc, char** argv)


#endif /* #ifndef CUTEST_H__ */

0 comments on commit 88b58d4

Please sign in to comment.