seperate the declaration of the data type spinlock and the implementation of a spinlock
This commit is contained in:
parent
3aaa2406de
commit
ae52943045
2 changed files with 42 additions and 7 deletions
|
@ -21,6 +21,7 @@
|
|||
#define __SPINLOCK_H__
|
||||
|
||||
#include <metalsvm/stddef.h>
|
||||
#include <metalsvm/spinlock_types.h>
|
||||
#include <metalsvm/tasks_types.h>
|
||||
#include <asm/irqflags.h>
|
||||
#include <asm/atomic.h>
|
||||
|
@ -29,13 +30,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct spinlock {
|
||||
atomic_int32_t queue, dequeue;
|
||||
tid_t owner;
|
||||
} spinlock_t;
|
||||
|
||||
#define SPINLOCK_INIT { ATOMIC_INIT(0), ATOMIC_INIT(1), MAX_TASKS }
|
||||
|
||||
inline static int spinlock_init(spinlock_t* s) {
|
||||
if (BUILTIN_EXPECT(!s, 0))
|
||||
return -1;
|
||||
|
|
41
include/metalsvm/spinlock_types.h
Normal file
41
include/metalsvm/spinlock_types.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2011 Stefan Lankes, Chair for Operating Systems,
|
||||
* RWTH Aachen University
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of MetalSVM.
|
||||
*/
|
||||
|
||||
#ifndef __SPINLOCK_TYPES_H__
|
||||
#define __SPINLOCK_TYPES_H__
|
||||
|
||||
#include <metalsvm/stddef.h>
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct spinlock {
|
||||
atomic_int32_t queue, dequeue;
|
||||
tid_t owner;
|
||||
} spinlock_t;
|
||||
|
||||
#define SPINLOCK_INIT { ATOMIC_INIT(0), ATOMIC_INIT(1), MAX_TASKS }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue