From 8d580338464db9ac7947abca9a7af2c60446f347 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 28 Feb 2016 23:18:13 +0100 Subject: [PATCH] Convert regress to C. --- regress/.gitignore | 2 +- regress/Makefile | 8 ++++---- regress/{regress.c++ => regress.c} | 8 +++++--- regress/{test-fmemopen.c++ => test-fmemopen.c} | 2 +- regress/{test-pthread-argv.c++ => test-pthread-argv.c} | 10 +++++++--- .../{test-pthread-basic.c++ => test-pthread-basic.c} | 2 +- ...-pthread-main-join.c++ => test-pthread-main-join.c} | 2 +- regress/{test-pthread-once.c++ => test-pthread-once.c} | 8 +++++--- regress/{test-pthread-self.c++ => test-pthread-self.c} | 2 +- regress/{test-pthread-tls.c++ => test-pthread-tls.c} | 6 ++++-- regress/{test-signal-raise.c++ => test-signal-raise.c} | 2 +- 11 files changed, 31 insertions(+), 21 deletions(-) rename regress/{regress.c++ => regress.c} (98%) rename regress/{test-fmemopen.c++ => test-fmemopen.c} (98%) rename regress/{test-pthread-argv.c++ => test-pthread-argv.c} (93%) rename regress/{test-pthread-basic.c++ => test-pthread-basic.c} (98%) rename regress/{test-pthread-main-join.c++ => test-pthread-main-join.c} (97%) rename regress/{test-pthread-once.c++ => test-pthread-once.c} (93%) rename regress/{test-pthread-self.c++ => test-pthread-self.c} (98%) rename regress/{test-pthread-tls.c++ => test-pthread-tls.c} (95%) rename regress/{test-signal-raise.c++ => test-signal-raise.c} (98%) diff --git a/regress/.gitignore b/regress/.gitignore index 3504b478..cffd0bca 100644 --- a/regress/.gitignore +++ b/regress/.gitignore @@ -1,3 +1,3 @@ regress test-* -!test-*.c++ +!test-*.c diff --git a/regress/Makefile b/regress/Makefile index 6699365d..c73dfd98 100644 --- a/regress/Makefile +++ b/regress/Makefile @@ -5,11 +5,11 @@ include ../build-aux/version.mak include ../build-aux/dirs.mak OPTLEVEL?=$(DEFAULT_OPTLEVEL) -CXXFLAGS?=$(OPTLEVEL) +CFLAGS?=$(OPTLEVEL) TESTDIR?=$(LIBEXECDIR)/test CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\" -DTESTDIR=\"$(TESTDIR)\" -CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti +CFLAGS:=$(CFLAGS) -Wall -Wextra BINARIES:=\ regress \ @@ -36,8 +36,8 @@ ifneq ($(TESTS),) install $(TESTS) $(DESTDIR)$(TESTDIR) endif -%: %.c++ - $(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@ +%: %.c + $(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ clean: rm -f $(BINARIES) $(TESTS) *.o diff --git a/regress/regress.c++ b/regress/regress.c similarity index 98% rename from regress/regress.c++ rename to regress/regress.c index 4baf6c07..799e7d57 100644 --- a/regress/regress.c++ +++ b/regress/regress.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - regress.c++ + regress.c Automatically invokes system tests. *******************************************************************************/ @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ bool is_usable_terminal(int fd) 10 <= ws.ws_col; } -void tenth_last_column() +void tenth_last_column(void) { struct wincurpos wcp; struct winsize ws; @@ -153,7 +154,8 @@ int main(int argc, char* argv[]) break; if ( arg[1] != '-' ) { - while ( char c = *++arg ) switch ( c ) + char c; + while ( (c = *++arg) ) switch ( c ) { case 'b': buffered = true; break; case 'q': verbosity--; break; diff --git a/regress/test-fmemopen.c++ b/regress/test-fmemopen.c similarity index 98% rename from regress/test-fmemopen.c++ rename to regress/test-fmemopen.c index 3bba4cbc..d03404fe 100644 --- a/regress/test-fmemopen.c++ +++ b/regress/test-fmemopen.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-fmemopen.c++ + test-fmemopen.c Tests basic fmemopen() usage. *******************************************************************************/ diff --git a/regress/test-pthread-argv.c++ b/regress/test-pthread-argv.c similarity index 93% rename from regress/test-pthread-argv.c++ rename to regress/test-pthread-argv.c index a4139ed1..c900d5b7 100644 --- a/regress/test-pthread-argv.c++ +++ b/regress/test-pthread-argv.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-argv.c++ + test-pthread-argv.c Tests if the argument vector and environment dies with the main thread. *******************************************************************************/ @@ -31,8 +31,10 @@ char** global_argv; char** global_envp; size_t answer = 0; -void* thread_routine(void*) +void* thread_routine(void* ctx) { + (void) ctx; + int errnum; if ( (errnum = pthread_join(main_thread, NULL)) ) @@ -49,8 +51,10 @@ void* thread_routine(void*) exit(0); } -int main(int /*argc*/, char* argv[], char* envp[]) +int main(int argc, char* argv[], char* envp[]) { + (void) argc; + int errnum; for ( int i = 0; argv[i]; i++ ) diff --git a/regress/test-pthread-basic.c++ b/regress/test-pthread-basic.c similarity index 98% rename from regress/test-pthread-basic.c++ rename to regress/test-pthread-basic.c index e8df0685..0696e7df 100644 --- a/regress/test-pthread-basic.c++ +++ b/regress/test-pthread-basic.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-basic.c++ + test-pthread-basic.c Tests whether basic pthread support works. *******************************************************************************/ diff --git a/regress/test-pthread-main-join.c++ b/regress/test-pthread-main-join.c similarity index 97% rename from regress/test-pthread-main-join.c++ rename to regress/test-pthread-main-join.c index 96b01dc0..125edf71 100644 --- a/regress/test-pthread-main-join.c++ +++ b/regress/test-pthread-main-join.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-main-join.c++ + test-pthread-main-join.c Tests whether the main thread can be joined. *******************************************************************************/ diff --git a/regress/test-pthread-once.c++ b/regress/test-pthread-once.c similarity index 93% rename from regress/test-pthread-once.c++ rename to regress/test-pthread-once.c index ccaf926e..8d51f29b 100644 --- a/regress/test-pthread-once.c++ +++ b/regress/test-pthread-once.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-once.c++ + test-pthread-once.c Tests whether basic pthread_once() support works. *******************************************************************************/ @@ -27,13 +27,15 @@ static int init_counter = 0; static pthread_once_t init_counter_once = PTHREAD_ONCE_INIT; -void init_counter_increase() +void init_counter_increase(void) { init_counter++; } -void* thread_routine(void*) +void* thread_routine(void* ctx) { + (void) ctx; + pthread_once(&init_counter_once, init_counter_increase); return NULL; diff --git a/regress/test-pthread-self.c++ b/regress/test-pthread-self.c similarity index 98% rename from regress/test-pthread-self.c++ rename to regress/test-pthread-self.c index de16ba6e..2dce98ef 100644 --- a/regress/test-pthread-self.c++ +++ b/regress/test-pthread-self.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-self.c++ + test-pthread-self.c Tests whether basic pthread_self() support works. *******************************************************************************/ diff --git a/regress/test-pthread-tls.c++ b/regress/test-pthread-tls.c similarity index 95% rename from regress/test-pthread-tls.c++ rename to regress/test-pthread-tls.c index 14ead1cb..4d2325b5 100644 --- a/regress/test-pthread-tls.c++ +++ b/regress/test-pthread-tls.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-pthread-tls.c++ + test-pthread-tls.c Tests whether basic tls support works. *******************************************************************************/ @@ -26,8 +26,10 @@ __thread int tls_variable = 42; -void* thread_routine(void*) +void* thread_routine(void* ctx) { + (void) ctx; + test_assert(tls_variable == 42); tls_variable = 9001; diff --git a/regress/test-signal-raise.c++ b/regress/test-signal-raise.c similarity index 98% rename from regress/test-signal-raise.c++ rename to regress/test-signal-raise.c index 31a2097f..6ff533db 100644 --- a/regress/test-signal-raise.c++ +++ b/regress/test-signal-raise.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - test-signal-raise.c++ + test-signal-raise.c Tests whether basic raise() support works. *******************************************************************************/