mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-31 09:21:19 +01:00
core: Remove atomic_set_return()
This commit is contained in:
parent
6821350835
commit
41ef11c215
@ -26,19 +26,6 @@
|
||||
#include "cpu.h"
|
||||
#include "atomic.h"
|
||||
|
||||
#if (ARCH_HAS_ATOMIC_SET_RETURN == 0)
|
||||
|
||||
unsigned int atomic_set_return(unsigned int *val, unsigned int set)
|
||||
{
|
||||
unsigned int mask = disableIRQ();
|
||||
unsigned int old_val = *val;
|
||||
*val = set;
|
||||
restoreIRQ(mask);
|
||||
return old_val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Set ARCH_HAS_ATOMIC_COMPARE_AND_SWAP within cpu.h to override this function */
|
||||
#if (ARCH_HAS_ATOMIC_COMPARE_AND_SWAP == 0)
|
||||
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup core_arch
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Architecture dependent interface for an atomic set operation
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef ATOMIC_ARCH_H
|
||||
#define ATOMIC_ARCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Define mappings between arch and internal interfaces
|
||||
*
|
||||
* This mapping is done for compatibility of existing platforms,
|
||||
* new platforms should always use the *_arch_* interfaces.
|
||||
* @{
|
||||
*/
|
||||
#ifdef COREIF_NG
|
||||
#define atomic_set_return atomic_arch_set_return
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Set a value atomically without interruption from interrupts etc.
|
||||
*
|
||||
* @param[out] to_set variable to set
|
||||
* @param[in] value value to set to_set to
|
||||
*
|
||||
* @return the value that was set
|
||||
*/
|
||||
unsigned int atomic_arch_set_return(unsigned int *to_set, unsigned int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ATOMIC_ARCH_H */
|
||||
/** @} */
|
||||
@ -21,8 +21,6 @@
|
||||
#ifndef ATOMIC_H_
|
||||
#define ATOMIC_H_
|
||||
|
||||
#include "arch/atomic_arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -34,18 +32,6 @@ typedef struct atomic_int {
|
||||
volatile int value;
|
||||
} atomic_int_t;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets a new and returns the old value of a variable atomically
|
||||
*
|
||||
* @param[in] val The variable to be set
|
||||
* @param[in] set The value to be written
|
||||
*
|
||||
* @return The old value of *val*
|
||||
*/
|
||||
unsigned int atomic_set_return(unsigned int *val, unsigned int set);
|
||||
|
||||
/**
|
||||
* @brief Initializer for atomic variables
|
||||
*
|
||||
|
||||
@ -15,55 +15,6 @@
|
||||
|
||||
#include "tests-core.h"
|
||||
|
||||
static void test_atomic_set_return_null_null(void)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_set_return(&res, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, res);
|
||||
}
|
||||
|
||||
static void test_atomic_set_return_one_null(void)
|
||||
{
|
||||
unsigned int res = 1;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(1, atomic_set_return(&res, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, res);
|
||||
}
|
||||
|
||||
static void test_atomic_set_return_null_one(void)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_set_return(&res, 1));
|
||||
TEST_ASSERT_EQUAL_INT(1, res);
|
||||
}
|
||||
|
||||
static void test_atomic_set_return_limit_null(void)
|
||||
{
|
||||
unsigned int res = UINT_MAX;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(UINT_MAX, atomic_set_return(&res, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, res);
|
||||
}
|
||||
|
||||
static void test_atomic_set_return_null_limit(void)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_set_return(&res, UINT_MAX));
|
||||
TEST_ASSERT_EQUAL_INT(UINT_MAX, res);
|
||||
}
|
||||
|
||||
static void test_atomic_set_return_null_random(void)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
unsigned int r = 45; /* XXX: decided by fair dice-roll ;-) */
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_set_return(&res, r));
|
||||
TEST_ASSERT_EQUAL_INT(r, res);
|
||||
}
|
||||
|
||||
/* Test atomic_set_to_one on a variable set to 0 */
|
||||
static void test_atomic_set_to_one_zero(void)
|
||||
{
|
||||
@ -257,12 +208,6 @@ static void test_atomic_value(void)
|
||||
Test *tests_core_atomic_tests(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_atomic_set_return_null_null),
|
||||
new_TestFixture(test_atomic_set_return_one_null),
|
||||
new_TestFixture(test_atomic_set_return_null_one),
|
||||
new_TestFixture(test_atomic_set_return_limit_null),
|
||||
new_TestFixture(test_atomic_set_return_null_limit),
|
||||
new_TestFixture(test_atomic_set_return_null_random),
|
||||
new_TestFixture(test_atomic_set_to_one_one),
|
||||
new_TestFixture(test_atomic_set_to_one_zero),
|
||||
new_TestFixture(test_atomic_set_to_one_twice),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user