Sha256: 6ce758507ab5b6b865b4b96b60bf43a899cfeda35770e01ae0d58a508794d5e1

Contents?: true

Size: 935 Bytes

Versions: 74

Compression:

Stored size: 935 Bytes

Contents

/*
 * Copyright (c) 2007 Wayne Meissner. All rights reserved.
 *
 * For licensing, see LICENSE.SPECS
 */

#ifdef _WIN32
#include <windows.h>
#define sleep(x) Sleep(x)
#endif

#ifndef _WIN32
#include <unistd.h>
#include <pthread.h>
#endif

int testAdd(int a, int b)
{
    return a + b;
};

int testFunctionAdd(int a, int b, int (*f)(int, int))
{
    return f(a, b);
};

void testBlocking(int seconds) {
    sleep(seconds);
};

struct async_data {
    void (*fn)(int);
    int value;
};

static void* asyncThreadCall(void *data)
{
    struct async_data* d = (struct async_data *) data;
    if (d != NULL && d->fn != NULL) {
        (*d->fn)(d->value);
    }

    return NULL;
}

void testAsyncCallback(void (*fn)(int), int value)
{
#ifndef _WIN32
    pthread_t t;
    struct async_data d;
    d.fn = fn;
    d.value = value;
    pthread_create(&t, NULL, asyncThreadCall, &d);
    pthread_join(t, NULL);
#else
    (*fn)(value);
#endif
} 

Version data entries

74 entries across 71 versions & 16 rubygems

Version Path
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
tdiary-5.0.1 vendor/bundle/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
vagrant-cloudstack-1.2.0 vendor/bundle/gems/ffi-1.9.10-x86-mingw32/spec/ffi/fixtures/FunctionTest.c
geminfo-0.1.0 path/gems/ffi-1.9.10-x86-mingw32/spec/ffi/fixtures/FunctionTest.c
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/ffi-1.9.10/spec/ffi/fixtures/FunctionTest.c
ffi-1.9.10-x64-mingw32 spec/ffi/fixtures/FunctionTest.c
ffi-1.9.10-x86-mingw32 spec/ffi/fixtures/FunctionTest.c
ffi-1.9.10 spec/ffi/fixtures/FunctionTest.c
ffi-1.9.9-x86-mingw32 spec/ffi/fixtures/FunctionTest.c
ffi-1.9.9-x64-mingw32 spec/ffi/fixtures/FunctionTest.c