Skip to content

Commit 88b58d4

Browse files
authored
Merge pull request #96 from MycroftAI/travis_gcc6
Fix build failures with glibc 2.20 (i.e Ubuntu 16.10)
2 parents eb4613e + eb4d658 commit 88b58d4

File tree

7 files changed

+52
-16
lines changed

7 files changed

+52
-16
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ matrix:
1313
os: linux
1414
compiler: gcc
1515
sudo: false
16+
- env: TASK="gcc6" # gcc-6
17+
os: linux
18+
compiler: gcc-6
19+
sudo: false
1620
- env: TASK="arm-linux-gnueabihf-gcc" # arm build
1721
os: linux
1822
compiler: gcc
@@ -57,6 +61,10 @@ addons:
5761
- mingw32-runtime
5862
- wine
5963
- xvfb
64+
- gcc-6
65+
- g++-6
66+
sources:
67+
- sourceline: 'ppa:ubuntu-toolchain-r/test'
6068
coverity_scan:
6169
project:
6270
name: "MycroftAI/mimic"

run_testsuite.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ case "${WHAT_TO_RUN}" in
152152
# for ubuntu precise in travis, that does not provide pkg-config:
153153
pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu"
154154
pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata"
155+
export CFLAGS="$CFLAGS --std=c99"
156+
./configure --enable-shared || exit 1
157+
make || exit 1
158+
make check || exit 1
159+
;;
160+
gcc6)
161+
./autogen.sh
162+
# for ubuntu precise in travis, that does not provide pkg-config:
163+
pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu"
164+
pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata"
165+
export CC="/usr/bin/gcc-6"
166+
export CXX="/usr/bin/g++-6"
155167
./configure --enable-shared || exit 1
156168
make || exit 1
157169
make check || exit 1

src/audio/au_alsa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#ifdef CST_AUDIO_ALSA
4545

46-
#define _BSD_SOURCE /* alsa alloca stuff and nanosleep */
46+
#define _POSIX_C_SOURCE 200112L
4747

4848
#include <stdlib.h>
4949
#include <unistd.h>
@@ -56,6 +56,9 @@
5656
#include "cst_wave.h"
5757
#include "cst_audio.h"
5858

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

6164
int audio_flush_alsa(cst_audiodev *ad);

src/utils/cst_mmap_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#if (MMAP_TYPE == MMAP_TYPE_POSIX)
4242

43-
# define _POSIX_C_SOURCE 200809L
43+
# define _POSIX_C_SOURCE 200112L
4444

4545
#include <sys/types.h>
4646
#include <sys/mman.h>

src/utils/cst_socket.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ int cst_socket_close(int socket)
6262
return -1;
6363
}
6464
#else
65+
#define _POSIX_C_SOURCE 200112L
6566
#include <stdio.h>
6667
#include <stdlib.h>
6768
#ifndef _MSC_VER
@@ -81,6 +82,11 @@ int cst_socket_close(int socket)
8182
#include "cst_socket.h"
8283
#include "cst_error.h"
8384

85+
/* OSX el capitan does not define INADDR_NONE in all cases */
86+
#ifndef INADDR_NONE
87+
#define INADDR_NONE ((in_addr_t) -1)
88+
#endif
89+
8490
int cst_socket_open(const char *host, int port)
8591
{
8692
/* Return an FD to a remote server */
@@ -105,7 +111,7 @@ int cst_socket_open(const char *host, int port)
105111
cst_errmsg("cst_socket: gethostbyname failed\n");
106112
return -1;
107113
}
108-
memmove(&serv_addr.sin_addr, serverhost->h_addr,
114+
memmove(&serv_addr.sin_addr, serverhost->h_addr_list[0],
109115
serverhost->h_length);
110116
}
111117
serv_addr.sin_family = AF_INET;

src/utils/cst_url.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
/* Only support http: if sockets are available */
4242
/* */
4343
/*************************************************************************/
44+
45+
#define _POSIX_C_SOURCE 200112L
46+
4447
#include <math.h>
4548
#include "cst_file.h"
4649
#include "cst_string.h"

unittests/cutest.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,12 @@
8787
**********************/
8888

8989
/* The unit test files should not rely on anything below. */
90-
9190
#include <stdarg.h>
9291
#include <stdio.h>
9392
#include <stdlib.h>
9493
#include <string.h>
9594

96-
#if defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)
95+
#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)) && !defined(__STRICT_ANSI__)
9796
#define CUTEST_UNIX__ 1
9897
#include <errno.h>
9998
#include <unistd.h>
@@ -102,12 +101,16 @@
102101
#include <signal.h>
103102
#endif
104103

105-
#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)
104+
#if (defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)) && !defined(__STRICT_ANSI__)
106105
#define CUTEST_WIN__ 1
107106
#include <windows.h>
108107
#include <io.h>
109108
#endif
110109

110+
#if defined(__STRICT_ANSI__)
111+
#define CUTEST_ANSI__ 1
112+
#endif
113+
111114
#ifdef __cplusplus
112115
#include <exception>
113116
#endif
@@ -162,16 +165,16 @@ test_print_in_color__(int color, const char* fmt, ...)
162165
{
163166
const char* col_str;
164167
switch(color) {
165-
case CUTEST_COLOR_GREEN__: col_str = "\e[0;32m"; break;
166-
case CUTEST_COLOR_RED__: col_str = "\e[0;31m"; break;
167-
case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\e[1;32m"; break;
168-
case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\e[1;30m"; break;
169-
case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\e[1m"; break;
170-
default: col_str = "\e[0m"; break;
168+
case CUTEST_COLOR_GREEN__: col_str = "\033[0;32m"; break;
169+
case CUTEST_COLOR_RED__: col_str = "\033[0;31m"; break;
170+
case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\033[1;32m"; break;
171+
case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\033[1;30m"; break;
172+
case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\033[1m"; break;
173+
default: col_str = "\033[0m"; break;
171174
}
172175
printf("%s", col_str);
173176
n = printf("%s", buffer);
174-
printf("\e[0m");
177+
printf("\033[0m");
175178
return n;
176179
}
177180
#elif defined CUTEST_WIN__
@@ -352,9 +355,10 @@ test_do_run__(const struct test__* test)
352355
return (test_current_failures__ == 0) ? 0 : -1;
353356
}
354357

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

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

461-
#else
466+
#else /* CUTEST_ANSI__ */
462467

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

651656

652657
#endif /* #ifndef CUTEST_H__ */
653-

0 commit comments

Comments
 (0)