move mutex init into a constructor function

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@363 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
mheily 2011-01-13 02:32:15 +00:00
parent 5688cce8ad
commit 975066c934
4 changed files with 45 additions and 2 deletions

View File

@ -38,6 +38,7 @@
#include <sys/types.h>
#include <stdint.h>
#define LIBKQUEUE 1
int _libkqueue_init(void) __attribute__ ((constructor));
#endif
struct timespec;

View File

@ -30,7 +30,14 @@ int KQUEUE_DEBUG = 0;
static RB_HEAD(kqt, kqueue) kqtree = RB_INITIALIZER(&kqtree);
static pthread_rwlock_t kqtree_mtx = PTHREAD_RWLOCK_INITIALIZER;
static pthread_rwlock_t kqtree_mtx;
int __attribute__ ((constructor))
_libkqueue_init(void)
{
pthread_rwlock_init(&kqtree_mtx, NULL);
return (0);
}
static int
kqueue_cmp(struct kqueue *a, struct kqueue *b)

View File

@ -149,7 +149,6 @@ struct knote {
TAILQ_ENTRY(knote) event_ent; /* Used by filter->kf_event */
RB_ENTRY(knote) kntree_ent; /* Used by filter->kntree */
};
LIST_HEAD(knotelist, knote);
#define KNOTE_ENABLE(ent) do { \
(ent)->kev.flags &= ~EV_DISABLE; \

36
src/windows/kqueue.c Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2011 Mark Heily <mark@heily.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "private.h"
BOOL WINAPI DllMain(
HINSTANCE self,
DWORD reason,
LPVOID unused)
{
switch (reason) {
case DLL_PROCESS_ATTACH:
/* TODO: initialize mutexes */
break;
case DLL_PROCESS_DETACH:
/* TODO: cleanup */
break;
}
return (TRUE);
}