예제 #1
0
HEBI_DESTRUCTOR
static void
global_shutdown(void)
{
	struct hebi_context* ctx = hebi_context_get__();
	(void)hebi_realloc_scratch__(ctx, 0);
	ASSERT(!ctx->zstackused);

#ifdef USE_THREADS

	if (ctxkeyactive) {
		ctxkeyactive = 0;
		ctxkeyerr.he_domain = HEBI_ERRDOM_HEBI;
		ctxkeyerr.he_code = HEBI_EBADSTATE;
#if defined USE_C11_THREADS
		tss_delete(ctxkey);
#elif defined USE_POSIX_THREADS
		(void)pthread_key_delete(ctxkey);
#endif
	}

#endif

	hebi_alloc_table_shut__();
}
예제 #2
0
static int
do_test (void)
{
  /* Setting an invalid key should return an error.  */
  if (tss_set (key, TSS_VALUE) == thrd_success)
    FAIL_EXIT1 ("tss_set succeed where it should have failed");

  if (tss_create (&key, NULL) != thrd_success)
    FAIL_EXIT1 ("tss_create failed");

  thrd_t id;
  if (thrd_create (&id, tss_thrd, NULL) != thrd_success)
    FAIL_EXIT1 ("thrd_create failed");

  if (thrd_join (id, NULL) != thrd_success)
    FAIL_EXIT1 ("thrd failed");

  /* The value set in tss_thrd should not be visible here.  */
  void *value = tss_get (key);
  if (value != 0)
    FAIL_EXIT1 ("tss_get succeed where it should have failed");

  tss_delete (key);

  return 0;
}
예제 #3
0
파일: test.c 프로젝트: Walkerks/locks
static void test_tss (void)
{
  thrd_t threads[TEST_TSS_N_THREADS];
  int* value = (int*)malloc(sizeof(int));
  int i;

  *value = rand();

  tss_create(&(test_tss_data.key), test_tss_free);
  mtx_init(&(test_tss_data.mutex), mtx_plain);
  test_tss_data.values_freed = 0;

  assert(tss_get(test_tss_data.key) == NULL);
  tss_set(test_tss_data.key, value);
  assert(tss_get(test_tss_data.key) == value);

  for (i = 0; i < TEST_TSS_N_THREADS; i++)
  {
    thrd_create(&(threads[i]), test_tss_thread_func, NULL);
  }

  for (i = 0; i < TEST_TSS_N_THREADS; i++)
  {
    thrd_join(threads[i], NULL);
  }

  assert(test_tss_data.values_freed == TEST_TSS_N_THREADS);
  assert(tss_get(test_tss_data.key) == value);
  tss_delete(test_tss_data.key);
  assert(tss_get(test_tss_data.key) == NULL);
  assert(test_tss_data.values_freed == TEST_TSS_N_THREADS);

  free(value);
}
예제 #4
0
int main( void )
{
#ifndef REGTEST
    TESTCASE(tss_create(&key, NULL) == thrd_success);
    TESTCASE(tss_get(key) == NULL);
    TESTCASE(tss_set(key, &v) == thrd_success);
    TESTCASE(tss_get(key) == &v);
    tss_delete(key);
#endif
    return TEST_RESULTS;
}
예제 #5
0
파일: eglcurrent.c 프로젝트: xranby/mesa
static inline void _eglFiniTSD(void)
{
    mtx_lock(&_egl_TSDMutex);
    if (_egl_TSDInitialized) {
        _EGLThreadInfo *t = _eglGetTSD();

        _egl_TSDInitialized = EGL_FALSE;
        if (t && _egl_FreeTSD)
            _egl_FreeTSD((void *) t);
        tss_delete(_egl_TSD);
    }
    mtx_unlock(&_egl_TSDMutex);
}