projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added rsisamd.h
[idzebra-moved-to-github.git]
/
util
/
zebra-lock.c
diff --git
a/util/zebra-lock.c
b/util/zebra-lock.c
index
47b2424
..
dfd8cea
100644
(file)
--- a/
util/zebra-lock.c
+++ b/
util/zebra-lock.c
@@
-1,37
+1,69
@@
#include <assert.h>
#include <assert.h>
+#include <stdio.h>
#include <zebra-lock.h>
#include <zebra-lock.h>
+
int zebra_mutex_init (Zebra_mutex *p)
{
int zebra_mutex_init (Zebra_mutex *p)
{
+ if (p->state == 1)
+ {
+ fprintf (stderr, "zebra_mutex_init. state=%d\n", p->state);
+ }
+ p->state = 1;
#if HAVE_PTHREAD_H
pthread_mutex_init (&p->mutex, 0);
#endif
#if HAVE_PTHREAD_H
pthread_mutex_init (&p->mutex, 0);
#endif
+#ifdef WIN32
+ InitializeCriticalSection (&p->mutex);
+#endif
return 0;
}
int zebra_mutex_destroy (Zebra_mutex *p)
{
return 0;
}
int zebra_mutex_destroy (Zebra_mutex *p)
{
+ --(p->state);
+ if (p->state != 0)
+ {
+ fprintf (stderr, "zebra_mutex_destroy. state = %d\n", p->state);
+ }
#if HAVE_PTHREAD_H
pthread_mutex_destroy (&p->mutex);
#endif
#if HAVE_PTHREAD_H
pthread_mutex_destroy (&p->mutex);
#endif
+#ifdef WIN32
+ DeleteCriticalSection (&p->mutex);
+#endif
return 0;
}
int zebra_mutex_lock (Zebra_mutex *p)
{
return 0;
}
int zebra_mutex_lock (Zebra_mutex *p)
{
+ if (p->state != 1)
+ {
+ fprintf (stderr, "zebra_mutex_lock. state = %d\n", p->state);
+ }
#if HAVE_PTHREAD_H
pthread_mutex_lock (&p->mutex);
#endif
#if HAVE_PTHREAD_H
pthread_mutex_lock (&p->mutex);
#endif
+#ifdef WIN32
+ EnterCriticalSection (&p->mutex);
+#endif
return 0;
}
int zebra_mutex_unlock (Zebra_mutex *p)
{
return 0;
}
int zebra_mutex_unlock (Zebra_mutex *p)
{
+ if (p->state != 1)
+ {
+ fprintf (stderr, "zebra_mutex_unlock. state = %d\n", p->state);
+ }
#if HAVE_PTHREAD_H
pthread_mutex_unlock (&p->mutex);
#endif
#if HAVE_PTHREAD_H
pthread_mutex_unlock (&p->mutex);
#endif
+#ifdef WIN32
+ LeaveCriticalSection (&p->mutex);
+#endif
return 0;
}
return 0;
}