Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement enif_tsd_* stubs #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CC ?= gcc
CFLAGS ?= -MMD -std=gnu99 -Wall -Wextra -ggdb -fms-extensions -rdynamic -Wno-missing-field-initializers
CFLAGS := $(CFLAGS) -I$(ERTS_INCLUDE_DIR) $(DEFINES)
PARSE_CFLAGS := $(CFLAGS) -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare
LDFLAGS ?= -ldl
LDFLAGS ?= -ldl -pthread
RAGEL ?= ragel
RAGELFLAGS ?= -G2
PROVEFLAGS ?=
Expand Down
25 changes: 25 additions & 0 deletions nif_stubs.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <assert.h>
#include <ctype.h>
#include <pthread.h>
#include <stdarg.h>
#include <string.h>

Expand Down Expand Up @@ -1033,6 +1034,30 @@ int enif_get_string(ErlNifEnv *UNUSED, term t, char *buf, unsigned size,
}


int enif_tsd_key_create(char *UNUSED, ErlNifTSDKey *key)
{
return pthread_key_create((pthread_key_t *)key, NULL);
}


void enif_tsd_key_destroy(ErlNifTSDKey key)
{
assert(0 == pthread_key_delete(key));
}


void enif_tsd_set(ErlNifTSDKey key, void *data)
{
assert(0 == pthread_setspecific(key, data));
}


void *enif_tsd_get(ErlNifTSDKey key)
{
return pthread_getspecific(key);
}


/*
* FUNCTIONS WHOSE IMPLEMENTATION IS PATHOLOGICAL
*/
Expand Down