2013-03-06 10:29:49 +01:00
|
|
|
/**
|
|
|
|
* Native CPU atomic.h implementation
|
|
|
|
*
|
2014-05-15 18:07:02 +02:00
|
|
|
* Copyright (C) 2013 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
2013-03-06 10:29:49 +01:00
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* 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.
|
2013-03-06 10:29:49 +01:00
|
|
|
*
|
|
|
|
* @ingroup arch
|
|
|
|
* @{
|
|
|
|
* @file
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "atomic.h"
|
|
|
|
#include "irq.h"
|
|
|
|
#include "debug.h"
|
2013-03-06 01:08:15 +01:00
|
|
|
|
2013-06-21 03:52:57 +02:00
|
|
|
unsigned int atomic_set_return(unsigned int *val, unsigned int set)
|
2013-03-06 01:08:15 +01:00
|
|
|
{
|
|
|
|
unsigned int old_val;
|
|
|
|
unsigned int old_state;
|
|
|
|
|
|
|
|
DEBUG("atomic_set_return\n");
|
|
|
|
|
|
|
|
old_state = disableIRQ();
|
|
|
|
|
|
|
|
old_val = *val;
|
|
|
|
*val = set;
|
|
|
|
|
|
|
|
restoreIRQ(old_state);
|
|
|
|
|
|
|
|
return old_val;
|
|
|
|
}
|