I'm confused with mingw and implementation of the semaphores in posix pthreads.
Following code works without issues on linux, but when I compile it to exe, and run it's
waiting 2 signals (which I send over osc as this is liblo osc implementation) to release sem.
Practicaly I use osc_send to send the message to the program. This is the output on Linux/Windows..
Linux server side:
./nonblocking_server_example
path: <1>
Path: 1 0xbfa22b5c
path: <2>
Path: 2 0xbfa22b5c
Windows server side:
wine nonblocking_server_example.exe
path: <1>
Path: 1 007BFE3C
Path: 2 007BFE3C
path: <2>
client side Linux/Windows:
send_osc 3333 1
send_osc 3333 2

The strange thing is that win code doesn't change the way its working when I change the initial value to the semaphore (as shown in code after IFDEF).
Note: I'm doing everything on linux with help of wine.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <semaphore.h>

#include "lo/lo.h"

int done = 0;
sem_t lock;

void error(int num, const char *m, const char *path);
int generic_handler(const char *path, const char *types, lo_arg **argv,
		    int argc, void *data, void *user_data);
int quit_handler(const char *path, const char *types, lo_arg **argv, int argc,
		 void *data, void *user_data);

int main()
{
    char user_data[100];
    memset(&user_data, 0x00, sizeof(user_data));
    void sigint_handler(int sig);
    lo_server_thread st = lo_server_thread_new("3333", error);
    lo_server_thread_add_method(st, "/quit", "", quit_handler, NULL);
    lo_server_thread_add_method(st, NULL, NULL, generic_handler, user_data);
    lo_server_thread_start(st);
        if (signal(SIGINT, sigint_handler) == SIG_ERR) {
            perror("signal");
            exit(1);
        }
#ifdef WIN32
    sem_init(&lock, 0, 0);
#else
    sem_init(&lock, 0, 1);
#endif

    while (!done) {
    sem_wait(&lock);
    if (done)
        break;
    printf("Path: %s %p\n", user_data, &user_data);
    }
    lo_server_thread_free(st);
    return 0;
}

void error(int num, const char *msg, const char *path)
{
    printf("liblo server error %d in path %s: %s\n", num, path, msg);
    fflush(stdout);
}

int generic_handler(const char *path, const char *types, lo_arg **argv,
		    int argc, void *data, void *user_data)
{
    int i;
    strcpy (user_data, path);
    sem_post(&lock);
    printf("path: <%s>\n", path);
    for (i=0; i<argc; i++) {
	printf("arg %d '%c' ", i, types[i]);
	lo_arg_pp(types[i], argv[i]);
	printf("\n");
    if ( types[i] == 115 )
           printf ("String [s]: %s\n",(char *) argv[i]);
    else if ( types[i] == 105 )
           printf ("Int [i]: %d\n",(int) argv[i]->i);
    else if (types[i] == 102 )
            printf ("float [f]: %f\n",(float) argv[i]->f);
    else printf ("tip: %d\n", types[i]);
    }
    printf("\n");
    fflush(stdout);
    return 0;
}

int quit_handler(const char *path, const char *types, lo_arg **argv, int argc,
		 void *data, void *user_data)
{
    sem_post(&lock);
    done = 1;
    printf("quiting\n\n");
    fflush(stdout);
    return 0;
}

void sigint_handler(int sig)
{
sem_post(&lock);
    printf("Quiting!\n");
    done = 1;
}