Use spinlock.h instead of continually definign this as static in a bunch of apps

This commit is contained in:
Kevin Lange 2014-05-18 19:34:49 -07:00
parent 0cdfcf766e
commit ce0dacb912
4 changed files with 5 additions and 41 deletions

View File

@ -23,6 +23,7 @@
#include "lib/yutani.h"
#include "lib/hashmap.h"
#include "lib/list.h"
#include "lib/spinlock.h"
#include "yutani_int.h"
@ -105,16 +106,6 @@ int32_t max(int32_t a, int32_t b) {
return (a > b) ? a : b;
}
static void spin_lock(int volatile * lock) {
while(__sync_lock_test_and_set(lock, 0x01)) {
syscall_yield();
}
}
static void spin_unlock(int volatile * lock) {
__sync_lock_release(lock);
}
static int next_buf_id(void) {
static int _next = 1;
return _next++;

View File

@ -9,21 +9,12 @@
#include <syscall.h>
#include "lib/graphics.h"
#include "lib/spinlock.h"
#define MAX_ARGS 1024
static wchar_t box_chars[] = L"▒␉␌␍␊°±␤␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥";
static void spin_lock(int volatile * lock) {
while(__sync_lock_test_and_set(lock, 0x01)) {
syscall_yield();
}
}
static void spin_unlock(int volatile * lock) {
__sync_lock_release(lock);
}
/* Returns the lower of two shorts */
static uint16_t min(uint16_t a, uint16_t b) {
return (a < b) ? a : b;

View File

@ -38,6 +38,7 @@
#include "lib/decorations.h"
#include "lib/pthread.h"
#include "lib/kbd.h"
#include "lib/spinlock.h"
#include "terminal-palette.h"
#include "terminal-font.h"
@ -124,16 +125,6 @@ static void set_term_font_size(float s) {
reinit(1);
}
static void spin_lock(int volatile * lock) {
while(__sync_lock_test_and_set(lock, 0x01)) {
syscall_yield();
}
}
static void spin_unlock(int volatile * lock) {
__sync_lock_release(lock);
}
/* Returns the lower of two shorts */
int32_t min(int32_t a, int32_t b) {
return (a < b) ? a : b;

View File

@ -12,6 +12,7 @@
#include <string.h>
#include <sys/wait.h>
#include "lib/pthread.h"
#include "lib/spinlock.h"
#define NUM_THREADS 5
#define VALUE 0x1000000
@ -20,17 +21,7 @@
volatile uint32_t result = 0;
int8_t use_locks = 0;
volatile uint8_t the_lock = 0;
void spin_lock(uint8_t volatile * lock) {
while(__sync_lock_test_and_set(lock, 0x01)) {
;; /* oh god */
}
}
void spin_unlock(uint8_t volatile * lock) {
__sync_lock_release(lock);
}
volatile int the_lock = 0;
void *print_pid(void * garbage) {
int i;