Project

General

Profile

Actions

Bug #115

closed

Mac OSX

Added by François Félix Ingrand almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-

Description

Voici 2 patches… le premier me semble sans danger et élimine un warning de clang, le second est pour palier a l’absence de spinlock sur OSX (trouvé sur le web).

ashitaka:genom3-pocolibs felix$ git diff
diff --git a/common/typecopy.h b/common/typecopy.h
index ca0e93c..fce6db4 100644
--- a/common/typecopy.h
++ b/common/typecopy.h
@ -253,6 +253,7 @ genom_tcopy_<"[$t mangle]">(<"[$t argument reference dst]">,
<"[$e pass value src->[$e name]]">);
if (s) return s;
<' }'>
return 0; /* fix Wreturn-type /
<' } else {'>
(void)dst; (void)src; /
fix -Wunused-parameter */
<' }'>
diff --git a/server/control_task.h b/server/control_task.h
index 8ee261f..c756e76 100644
--
a/server/control_task.h
+++ b/server/control_task.h
@ -42,6 +42,49 @ lang c
#include "<"$comp">_remotelib.h"
#include "<"$comp">_activity.h"

#ifdef APPLE
+typedef int pthread_spinlock_t;

static inline
+int pthread_spin_init(pthread_spinlock_t *lock, int pshared) {
asm volatile ("" ::: "memory");
+ *lock = 0;
+ return 0;
}

static inline
+int pthread_spin_destroy(pthread_spinlock_t *lock) {
return 0;
}

static inline
+int pthread_spin_lock(pthread_spinlock_t *lock) {
while (1) {
+ int i;
+ for (i=0; i < 10000; i++) {
+ if (sync_bool_compare_and_swap(lock, 0, 1)) {
+ return 0;
+ }
+ }
+ sched_yield();
+ }
}

static __inline

+int pthread_spin_trylock(pthread_spinlock_t *lock) {
if (sync_bool_compare_and_swap(lock, 0, 1)) {
+ return 0;
+ }
+ return EBUSY;
}

static __inline

+int pthread_spin_unlock(pthread_spinlock_t *lock) {
asm volatile ("" ::: "memory");
+ *lock = 0;
+ return 0;
}
#endif

/* --- an enum of all the codels defined ----------------------------------------------------- */

ashitaka:genom3-pocolibs felix$


Felix


Files

signature.asc (801 Bytes) signature.asc François Félix Ingrand, 2017-06-01 17:19
Actions

Also available in: Atom PDF