1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12204 from cladmi/pr/pthread/enable_avr

pthread_cond.h: use 'sys/types.h' value of 'clockid_t' for avr. Enables pthread on AVR.
This commit is contained in:
Juan I Carrano 2019-09-12 16:41:59 +02:00 committed by GitHub
commit e9ca2114ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 70 additions and 69 deletions

View File

@ -25,14 +25,18 @@
# include "msp430_types.h"
#endif
#if defined(__WITH_AVRLIBC__)
/* avr-libc 'time.h' does not include 'sys/types.h' but we need 'clockid_t' */
# include <sys/types.h>
#endif
#ifdef __MACH__
/* needed for AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER */
#include <AvailabilityMacros.h>
#endif
#if defined(__WITH_AVRLIBC__) || (defined(__MACH__) && !defined(AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER))
#if !defined(AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER)
typedef int clockid_t;
#endif
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -1,12 +1,5 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
USEMODULE += posix_headers
USEMODULE += pthread

View File

@ -1,12 +1,10 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno i-nucleo-lrwan1 jiminy-mega256rfr2 \
mega-xplained stm32l0538-disco waspmote-pro
# AVR platform: unknown type name: clockid_t
# exclude boards with insufficient memory
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY = \
i-nucleo-lrwan1 \
nucleo-f031k6 \
stm32l0538-disco \
#
# Modules to include.
USEMODULE += pthread

View File

@ -1,12 +1,5 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
USEMODULE += pthread
include $(RIOTBASE)/Makefile.include

View File

@ -1,12 +1,5 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
USEMODULE += posix_headers

View File

@ -26,7 +26,6 @@ static mutex_t mutex = MUTEX_INIT;
static pthread_cond_t cv;
static volatile int is_finished;
static volatile long count;
static volatile long expected_value;
static char stack[THREAD_STACKSIZE_MAIN];
/**
@ -50,12 +49,17 @@ static void *second_thread(void *arg)
return NULL;
}
#ifdef BOARD_NATIVE
#define ITERATION_STEPS 100000
#else
#define ITERATION_STEPS 10000
#endif
int main(void)
{
puts("START");
count = 0;
is_finished = 0;
expected_value = 1000ul * 1000ul;
pthread_cond_init(&cv, NULL);
kernel_pid_t pid = thread_create(stack,sizeof(stack), THREAD_PRIORITY_MAIN - 1,
@ -67,11 +71,11 @@ int main(void)
thread_wakeup(pid);
count++;
if ((count % 100000) == 0) {
if ((count % ITERATION_STEPS) == 0) {
printf("Still alive alternated [count: %ldk] times.\n", count / 1000);
}
if (count == expected_value) {
if (count == (10ul * ITERATION_STEPS)) {
puts("condition fulfilled.");
is_finished = 1;
mutex_unlock(&mutex);

View File

@ -1,13 +1,25 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno hifive1 hifive1b i-nucleo-lrwan1 \
jiminy-mega256rfr2 mega-xplained stm32l0538-disco waspmote-pro
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-nano \
arduino-uno \
nucleo-f031k6 \
hifive1 \
hifive1b \
i-nucleo-lrwan1 \
stm32l0538-disco \
#
# AVR platform: unknown type name: clockid_t
# hifive1: not enough memory for thread stacks
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
# The test reboots on 'arduino-mega2560' because it mallocs too much memory.
# So I disabled all the other avr boards. Re-enable after success test.
BOARD_INSUFFICIENT_MEMORY += \
arduino-leonardo \
arduino-mega2560 \
jiminy-mega256rfr2 \
mega-xplained \
waspmote-pro \
#
USEMODULE += posix_headers
USEMODULE += pthread

View File

@ -1,13 +1,11 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
BOARD_INSUFFICIENT_MEMORY = \
arduino-duemilanove \
arduino-nano \
arduino-uno \
nucleo-f031k6 \
#
USEMODULE += posix_headers
USEMODULE += pthread

View File

@ -1,21 +1,28 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
USEMODULE += pthread
USEMODULE += xtimer
USEMODULE += random
BOARD_INSUFFICIENT_MEMORY += chronos i-nucleo-lrwan1 \
msb-430 msb-430h nucleo-f031k6 \
nucleo-f042k6 nucleo-l031k6 nucleo-f030r8 \
nucleo-f303k8 nucleo-f334r8 nucleo-l053r8 \
stm32f0discovery stm32l0538-disco
BOARD_INSUFFICIENT_MEMORY = \
arduino-duemilanove \
arduino-leonardo \
arduino-nano \
arduino-uno \
chronos \
i-nucleo-lrwan1 \
msb-430 \
msb-430h \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l031k6 \
nucleo-l053r8 \
stm32f0discovery \
stm32l0538-disco \
#
# HACK Blacklist native as `murdock` fails on utf-8 characters for native tests
TEST_ON_CI_BLACKLIST += native

View File

@ -1,13 +1,12 @@
include ../Makefile.tests_common
BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo arduino-mega2560 \
arduino-nano arduino-uno jiminy-mega256rfr2 mega-xplained \
waspmote-pro
# arduino mega2560 uno duemilanove : unknown type name: clockid_t
# jiminy-mega256rfr2: unknown type name: clockid_t
# mega-xplained: unknown type name: clockid_t
USEMODULE += posix_headers
USEMODULE += pthread
BOARD_INSUFFICIENT_MEMORY = \
arduino-duemilanove \
arduino-nano \
arduino-uno \
#
include $(RIOTBASE)/Makefile.include