Exemple #1
0
void initProfiling (void)
{
    // initialise our arena
    prof_arena = newArena();

    /* for the benefit of allocate()... */
    {
        nat n;
        for (n=0; n < n_capabilities; n++) {
            capabilities[n]->r.rCCCS = CCS_SYSTEM;
        }
    }

#ifdef THREADED_RTS
    initMutex(&ccs_mutex);
#endif

    /* Set up the log file, and dump the header and cost centre
     * information into it.
     */
    initProfilingLogFile();

    /* Register all the cost centres / stacks in the program
     * CC_MAIN gets link = 0, all others have non-zero link.
     */
    REGISTER_CC(CC_MAIN);
    REGISTER_CC(CC_SYSTEM);
    REGISTER_CC(CC_GC);
    REGISTER_CC(CC_OVERHEAD);
    REGISTER_CC(CC_DONT_CARE);
    REGISTER_CC(CC_PINNED);
    REGISTER_CC(CC_IDLE);

    REGISTER_CCS(CCS_SYSTEM);
    REGISTER_CCS(CCS_GC);
    REGISTER_CCS(CCS_OVERHEAD);
    REGISTER_CCS(CCS_DONT_CARE);
    REGISTER_CCS(CCS_PINNED);
    REGISTER_CCS(CCS_IDLE);
    REGISTER_CCS(CCS_MAIN);

    /* find all the registered cost centre stacks, and make them
     * children of CCS_MAIN.
     */
    ASSERT(CCS_LIST == CCS_MAIN);
    CCS_LIST = CCS_LIST->prevStack;
    CCS_MAIN->prevStack = NULL;
    CCS_MAIN->root = CCS_MAIN;
    ccsSetSelected(CCS_MAIN);

    initProfiling2();

    if (RtsFlags.CcFlags.doCostCentres) {
        initTimeProfiling();
    }

    if (RtsFlags.ProfFlags.doHeapProfile) {
        initHeapProfiling();
    }
}
Exemple #2
0
void
initUserSignals(void)
{
    sigemptyset(&userSignals);
#ifdef THREADED_RTS
    initMutex(&sig_mutex);
#endif
}
Exemple #3
0
void initTracing (void)
{
#ifdef THREADED_RTS
    initMutex(&trace_utx);
#endif

#ifdef DEBUG
#define DEBUG_FLAG(name, class) \
    class = RtsFlags.DebugFlags.name ? 1 : 0;

    DEBUG_FLAG(scheduler,    DEBUG_sched);

    DEBUG_FLAG(interpreter,  DEBUG_interp);
    DEBUG_FLAG(weak,         DEBUG_weak);
    DEBUG_FLAG(gccafs,       DEBUG_gccafs);
    DEBUG_FLAG(gc,           DEBUG_gc);
    DEBUG_FLAG(block_alloc,  DEBUG_block_alloc);
    DEBUG_FLAG(sanity,       DEBUG_sanity);
    DEBUG_FLAG(stable,       DEBUG_stable);
    DEBUG_FLAG(stm,          DEBUG_stm);
    DEBUG_FLAG(prof,         DEBUG_prof);
    DEBUG_FLAG(linker,       DEBUG_linker);
    DEBUG_FLAG(squeeze,      DEBUG_squeeze);
    DEBUG_FLAG(hpc,          DEBUG_hpc);
    DEBUG_FLAG(sparks,       DEBUG_sparks);
#endif

    // -Ds turns on scheduler tracing too
    TRACE_sched =
        RtsFlags.TraceFlags.scheduler ||
        RtsFlags.DebugFlags.scheduler;

    // -Dg turns on gc tracing too
    TRACE_gc =
        RtsFlags.TraceFlags.gc ||
        RtsFlags.DebugFlags.gc;

    TRACE_spark_sampled =
        RtsFlags.TraceFlags.sparks_sampled;

    // -Dr turns on full spark tracing
    TRACE_spark_full =
        RtsFlags.TraceFlags.sparks_full ||
        RtsFlags.DebugFlags.sparks;

    TRACE_user =
        RtsFlags.TraceFlags.user;

    eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG;

    /* Note: we can have any of the TRACE_* flags turned on even when
       eventlog_enabled is off. In the DEBUG way we may be tracing to stderr.
     */

    if (eventlog_enabled) {
        initEventLogging();
    }
}
Exemple #4
0
	TPThread(ThreadPool* threadPool, int threadWaitSecond = 0):
	threadWaitSecond_(threadWaitSecond), 
	currTask_(NULL), 
	threadPool_(threadPool)
	{
		state_ = THREAD_STATE_SLEEP;
		initCond();
		initMutex();
	}
Exemple #5
0
int CALLBACK WinMain(
   HINSTANCE hInstance,
   HINSTANCE hPrevInstance, 
   LPSTR lpCmdLine, 
   int nCmdShow)
{
   MSG msg;
   BOOL bRet;
   HMODULE dllMod;
   HHOOK hookHandle;
   SOCKET serverSocket; 
   HANDLE serverThreadHandle;

   UNREFERENCED_PARAMETER(hPrevInstance);
   UNREFERENCED_PARAMETER(lpCmdLine);
   UNREFERENCED_PARAMETER(nCmdShow);

   /* initialize, all of these functions and procedures 
   * must complete successfully in order for the main loop to begin */
   if( 
      !initMutex() ||

      !registerWindowClass( hInstance ) ||

      !createWindow( hInstance ) ||

      ((dllMod = LoadLibrary( TEXT(GHOST_DLL)) ) == NULL ) ||

      !(initializeLibrary() ) ||

      !(initKeyFile() )  ||

      !(initWinSock(&serverSocket) ) ||

      !(initServerThread(&serverSocket, &serverThreadHandle) ) ||

      ((hookHandle = SetWindowsHookEx(
      WH_KEYBOARD_LL, 
      hookProcedure, 
      dllMod, 0) ) == NULL))
   {
      return EXIT_FAILURE;
   }

   /* main message loop */
   while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }

   /* clean up and exit */
   UnhookWindowsHookEx( hookHandle );
   FreeLibrary( dllMod );

   return EXIT_SUCCESS;
}
void VectorBlurOperation::initExecution()
{
	initMutex();
	this->m_inputImageProgram = getInputSocketReader(0);
	this->m_inputZProgram = getInputSocketReader(1);
	this->m_inputSpeedProgram = getInputSocketReader(2);
	this->m_cachedInstance = NULL;
	QualityStepHelper::initExecution(COM_QH_INCREASE);
	
}
Exemple #7
0
void
initThreadLabelTable(void)
{
#if defined(THREADED_RTS)
  initMutex(&threadLabels_mutex);
#endif /* THREADED_RTS */

  if (threadLabels == NULL) {
    threadLabels = allocHashTable();
  }
}
Exemple #8
0
void
initGlobalStore(void)
{
    uint32_t i;
    for (i=0; i < MaxStoreKey; i++) {
        store[i] = 0;
    }
#ifdef THREADED_RTS
    initMutex(&globalStoreLock);
#endif
}
Exemple #9
0
queue_t* queue_init(int size, int nmemb)
{
    queue_t* queue = malloc(sizeof(queue_t));
    queue->data = (char*)malloc(size * nmemb);
    queue->size = size;
    queue->nmemb = nmemb;
    queue->readpos = 0;
    queue->writepos = 0;
    queue->number = 0;
    initMutex(&queue->mutex);
    return queue;
}
Exemple #10
0
void initTracing (void)
{
#ifdef THREADED_RTS
    initMutex(&trace_utx);
#endif

    DEBUG_FLAG(scheduler,    DEBUG_sched);
    DEBUG_FLAG(interpreter,  DEBUG_interp);
    DEBUG_FLAG(weak,         DEBUG_weak);
    DEBUG_FLAG(gccafs,       DEBUG_gccafs);
    DEBUG_FLAG(gc,           DEBUG_gc);
    DEBUG_FLAG(block_alloc,  DEBUG_block_alloc);
    DEBUG_FLAG(sanity,       DEBUG_sanity);
    DEBUG_FLAG(stable,       DEBUG_stable);
    DEBUG_FLAG(stm,          DEBUG_stm);
    DEBUG_FLAG(prof,         DEBUG_prof);
    DEBUG_FLAG(gran,         DEBUG_gran);
    DEBUG_FLAG(par,          DEBUG_par);
    DEBUG_FLAG(linker,       DEBUG_linker);
    DEBUG_FLAG(squeeze,      DEBUG_squeeze);
    DEBUG_FLAG(hpc,          DEBUG_hpc);

    PAR_FLAG(verbose,        PAR_DEBUG_verbose);
    PAR_FLAG(bq,             PAR_DEBUG_bq);
    PAR_FLAG(schedule,       PAR_DEBUG_schedule);
    PAR_FLAG(free,           PAR_DEBUG_free);
    PAR_FLAG(resume,         PAR_DEBUG_resume);
    PAR_FLAG(weight,         PAR_DEBUG_weight);
    PAR_FLAG(fetch,          PAR_DEBUG_fetch);
    PAR_FLAG(fish,           PAR_DEBUG_fish);
    PAR_FLAG(tables,         PAR_DEBUG_tables);
    PAR_FLAG(packet,         PAR_DEBUG_packet);
    PAR_FLAG(pack,           PAR_DEBUG_pack);
    PAR_FLAG(paranoia,       PAR_DEBUG_paranoia);

    GRAN_FLAG(event_trace,   GRAN_DEBUG_event_trace);
    GRAN_FLAG(event_stats,   GRAN_DEBUG_event_stats);
    GRAN_FLAG(bq,            GRAN_DEBUG_bq);
    GRAN_FLAG(pack,          GRAN_DEBUG_pack);
    GRAN_FLAG(checkSparkQ,   GRAN_DEBUG_checkSparkQ);
    GRAN_FLAG(thunkStealing, GRAN_DEBUG_thunkStealing);
    GRAN_FLAG(randomSteal,   GRAN_DEBUG_randomSteal);
    GRAN_FLAG(findWork,      GRAN_DEBUG_findWork);
    GRAN_FLAG(unused,        GRAN_DEBUG_unused);
    GRAN_FLAG(pri,           GRAN_DEBUG_pri);
    GRAN_FLAG(checkLight,    GRAN_DEBUG_checkLight);
    GRAN_FLAG(sortedQ,       GRAN_DEBUG_sortedQ);
    GRAN_FLAG(blockOnFetch,  GRAN_DEBUG_blockOnFetch);
    GRAN_FLAG(packBuffer,    GRAN_DEBUG_packBuffer);
    GRAN_FLAG(blockedOnFetch_sanity, GRAN_DEBUG_BOF_sanity);

    TRACE_FLAG(sched, TRACE_sched);
}
Exemple #11
0
void initTracing (void)
{
    const EventLogWriter *eventlog_writer = getEventLogWriter();

#if defined(THREADED_RTS)
    initMutex(&trace_utx);
#endif

    // -Ds turns on scheduler tracing too
    TRACE_sched =
        RtsFlags.TraceFlags.scheduler ||
        RtsFlags.DebugFlags.scheduler;

    // -Dg turns on gc tracing too
    TRACE_gc =
        RtsFlags.TraceFlags.gc ||
        RtsFlags.DebugFlags.gc ||
        RtsFlags.DebugFlags.scheduler;
    if (TRACE_gc && RtsFlags.GcFlags.giveStats == NO_GC_STATS) {
        RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;
    }

    TRACE_spark_sampled =
        RtsFlags.TraceFlags.sparks_sampled;

    // -Dr turns on full spark tracing
    TRACE_spark_full =
        RtsFlags.TraceFlags.sparks_full ||
        RtsFlags.DebugFlags.sparks;

    TRACE_user =
        RtsFlags.TraceFlags.user;

    // We trace cap events if we're tracing anything else
    TRACE_cap =
        TRACE_sched ||
        TRACE_gc ||
        TRACE_spark_sampled ||
        TRACE_spark_full ||
        TRACE_user;

    eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG &&
                        eventlog_writer != NULL;

    /* Note: we can have any of the TRACE_* flags turned on even when
       eventlog_enabled is off. In the DEBUG way we may be tracing to stderr.
     */

    if (eventlog_enabled) {
        initEventLogging(eventlog_writer);
    }
}
Exemple #12
0
int main(int argc, char** argv)
{
    pid_t pid;
    int pipeline[2];
    char pipeReadBuffer[GCC_OUTPUT_BUFFER_SIZE] = {0};   
    
    
    // Traitement des taches du parent
    execute_folder_operations(get_folder_path(argc, argv));
    cFilesList = get_c_files(cFilesList);
    check_folder_has_cFiles(cFilesList);
    create_pipeline(pipeline);
    pid = create_child();
    
    
    if (pid > 0) { // PARENT - Ajustements propre a ce processus
        free_array_of_array(cFilesList);        // Free, cFilesList maintenant inutile pour ce processus
        signal(SIGINT, set_run_status);         // Gestion de la fin du prog par le processus parent
        
        while (RUN) {                           // Lance la lecture sur pipe avec enfant
            read(pipeline[0], pipeReadBuffer, sizeof(pipeReadBuffer));
            
            if (strlen(pipeReadBuffer) != 0)
                //printf("DEBUG-> Parent received:\n%s", pipeReadBuffer);
                printf("%s", pipeReadBuffer);
                
            strcpy(pipeReadBuffer, "");         // Vide buffer
        }
        
        kill(pid, SIGUSR1);                     // Kill Child Process
        wait(NULL);
        
    } else {       // ENFANT - Lance les operations de traitements
        sigignore(SIGINT);                      // Le parent s'occupe de tuer l'enfant        
        signal(SIGUSR1, child_clean_atexit);    // Ecoute directive de terminaison envoyee par le parent
        initMutex();                            // Initialisation du ou des mutex(es)
        
        while (1) {
            JobsList = update_JobsList(JobsList, cFilesList); // Ajout d'une "job" pour tous les nouveaux fichiers

            if (JobsList != NULL)
                update_threads(JobsList, pipeline); // Creation d'un thread pour les nouvelles "Jobs" dans le tableau
            
            sleep(FOLDER_POLLING_DELAY);            // Inutile de verifier le dossier trop rapidement...
            
            cFilesList = free_array_of_array(cFilesList); // Nettoyage
            cFilesList = get_c_files(cFilesList);   // Update la liste et boucle...
        }
    }
    
    return (EXIT_SUCCESS);
}
void GaussianYBlurOperation::initExecution()
{
	BlurBaseOperation::initExecution();

	initMutex();

	if (this->m_sizeavailable) {
		float rad = max_ff(m_size * m_data->sizey, 0.0f);
		m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
		
		this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
	}
}
Exemple #14
0
void
initStablePtrTable(void)
{
    if (SPT_size > 0) return;
    SPT_size = INIT_SPT_SIZE;
    stable_ptr_table = stgMallocBytes(SPT_size * sizeof(spEntry),
                                      "initStablePtrTable");
    initSpEntryFreeList(stable_ptr_table,INIT_SPT_SIZE,NULL);

#if defined(THREADED_RTS)
    initMutex(&stable_ptr_mutex);
#endif
}
Socket::Socket(SOCKET sock,SOCKADDR_IN csin,ETypeConnection connection)
{
    this->sock=sock;
    this->connection=connection;
    this->protocole=TP_TCP;
    this->infoConnection=csin;

    this->isConnect=true;

    initBuffer();

    initMutex(mutex1);
}
			PosixConditionSemaphore() : sigcnt(0)
			{
				initCond();
				try
				{
					initMutex();
				}
				catch(...)
				{
					pthread_cond_destroy(&cond);
					throw;
				}
			}
                        TerminatableSynchronousReorderSet(uint64_t const rnext = 0)
                        : numwait(0), Q(), terminated(false), next(rnext)
                        {
				initCond();
				try
				{
					initMutex();
				}
				catch(...)
				{
					pthread_cond_destroy(&cond);
					throw;
				}                        
                        }
Exemple #18
0
static void
initCapability( Capability *cap, nat i )
{
    nat g;

    cap->no = i;
    cap->in_haskell        = rtsFalse;

    cap->run_queue_hd      = END_TSO_QUEUE;
    cap->run_queue_tl      = END_TSO_QUEUE;

#if defined(THREADED_RTS)
    initMutex(&cap->lock);
    cap->running_task      = NULL; // indicates cap is free
    cap->spare_workers     = NULL;
    cap->n_spare_workers   = 0;
    cap->suspended_ccalls  = NULL;
    cap->returning_tasks_hd = NULL;
    cap->returning_tasks_tl = NULL;
    cap->inbox              = (Message*)END_TSO_QUEUE;
    cap->sparks_created     = 0;
    cap->sparks_dud         = 0;
    cap->sparks_converted   = 0;
    cap->sparks_gcd         = 0;
    cap->sparks_fizzled     = 0;
#endif

    cap->f.stgEagerBlackholeInfo = (W_)&__stg_EAGER_BLACKHOLE_info;
    cap->f.stgGCEnter1     = (StgFunPtr)__stg_gc_enter_1;
    cap->f.stgGCFun        = (StgFunPtr)__stg_gc_fun;

    cap->mut_lists  = stgMallocBytes(sizeof(bdescr *) *
				     RtsFlags.GcFlags.generations,
				     "initCapability");
    cap->saved_mut_lists = stgMallocBytes(sizeof(bdescr *) *
                                          RtsFlags.GcFlags.generations,
                                          "initCapability");

    for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
	cap->mut_lists[g] = NULL;
    }

    cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE;
    cap->free_invariant_check_queues = END_INVARIANT_CHECK_QUEUE;
    cap->free_trec_chunks = END_STM_CHUNK_LIST;
    cap->free_trec_headers = NO_TREC;
    cap->transaction_tokens = 0;
    cap->context_switch = 0;
    cap->pinned_object_block = NULL;
}
Exemple #19
0
void hs_spt_insert_stableptr(StgWord64 key[2], StgStablePtr *entry) {
  // hs_spt_insert is called from constructor functions, so
  // the SPT needs to be initialized here.
  if (spt == NULL) {
    spt = allocHashTable_(hashFingerprint, compareFingerprint);
#if defined(THREADED_RTS)
    initMutex(&spt_lock);
#endif
  }

  ACQUIRE_LOCK(&spt_lock);
  insertHashTable(spt, (StgWord)key, entry);
  RELEASE_LOCK(&spt_lock);
}
void GaussianXBlurOperation::initExecution()
{
	BlurBaseOperation::initExecution();

	initMutex();

	if (this->m_sizeavailable) {
		float rad = this->m_size * this->m_data->sizex;
		CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);

		this->m_rad = rad;
		this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
	}
}
Exemple #21
0
void
ioManagerStart (void)
{
    initMutex(&event_buf_mutex);
    next_event = 0;

    // Make sure the IO manager thread is running
    Capability *cap;
    if (io_manager_event == INVALID_HANDLE_VALUE) {
        cap = rts_lock();
        rts_evalIO(&cap, ensureIOManagerIsRunning_closure, NULL);
        rts_unlock(cap);
    }
}
void GaussianAlphaXBlurOperation::initExecution()
{
	/* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */

	initMutex();

	if (this->m_sizeavailable) {
		float rad = max_ff(m_size * m_data.sizex, 0.0f);
		m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
		
		m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
		m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
	}
}
void GaussianAlphaYBlurOperation::initExecution()
{
	/* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */

	initMutex();

	if (this->m_sizeavailable) {
		float rad = this->m_size * this->m_data->sizey;
		CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);

		this->m_rad = rad;
		this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
		this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff);
	}
}
void BokehBlurOperation::initExecution()
{
  initMutex();
  this->m_inputProgram = getInputSocketReader(0);
  this->m_inputBokehProgram = getInputSocketReader(1);
  this->m_inputBoundingBoxReader = getInputSocketReader(2);

  int width = this->m_inputBokehProgram->getWidth();
  int height = this->m_inputBokehProgram->getHeight();

  float dimension = min(width, height);

  this->m_bokehMidX = width / 2.0f;
  this->m_bokehMidY = height / 2.0f;
  this->m_bokehDimension = dimension / 2.0f;
  QualityStepHelper::initExecution(COM_QH_INCREASE);
}
void GaussianYBlurOperation::initExecution()
{
	BlurBaseOperation::initExecution();

	initMutex();

	if (this->m_sizeavailable) {
		float rad = max_ff(m_size * m_data.sizey, 0.0f);
		m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);

		this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
		this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
		                                                               m_filtersize);
#endif
	}
}
Exemple #26
0
Fichier : Task.c Projet : A1kmm/ghc
void
initTaskManager (void)
{
    if (!tasksInitialized) {
        taskCount = 0;
        workerCount = 0;
        currentWorkerCount = 0;
        peakWorkerCount = 0;
        tasksInitialized = 1;
#if defined(THREADED_RTS)
#if !defined(MYTASK_USE_TLV)
	newThreadLocalKey(&currentTaskKey);
#endif
        initMutex(&all_tasks_mutex);
#endif
    }
}
Exemple #27
0
static Task*
newTask (rtsBool worker)
{
    Task *task;

#define ROUND_TO_CACHE_LINE(x) ((((x)+63) / 64) * 64)
    task = stgMallocBytes(ROUND_TO_CACHE_LINE(sizeof(Task)), "newTask");
    
    task->cap           = NULL;
    task->worker        = worker;
    task->stopped       = rtsFalse;
    task->running_finalizers = rtsFalse;
    task->n_spare_incalls = 0;
    task->spare_incalls = NULL;
    task->incall        = NULL;
    
#if defined(THREADED_RTS)
    initCondition(&task->cond);
    initMutex(&task->lock);
    task->wakeup = rtsFalse;
#endif

    task->next = NULL;

    ACQUIRE_LOCK(&all_tasks_mutex);

    task->all_prev = NULL;
    task->all_next = all_tasks;
    if (all_tasks != NULL) {
        all_tasks->all_prev = task;
    }
    all_tasks = task;

    taskCount++;
    if (worker) {
        workerCount++;
        currentWorkerCount++;
        if (currentWorkerCount > peakWorkerCount) {
            peakWorkerCount = currentWorkerCount;
        }
    }
    RELEASE_LOCK(&all_tasks_mutex);

    return task;
}
void GaussianXBlurOperation::initExecution()
{
	BlurBaseOperation::initExecution();

	initMutex();

	if (this->m_sizeavailable) {
		float rad = max_ff(m_size * m_data.sizex, 0.0f);
		m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);

		/* TODO(sergey): De-duplicate with the case below and Y blur. */
		this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
		this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
		                                                               m_filtersize);
#endif
	}
}
Exemple #29
0
void
initProfiling1 (void)
{
    // initialise our arena
    prof_arena = newArena();

    /* for the benefit of allocate()... */
    {
        nat n;
        for (n=0; n < n_capabilities; n++) {
            capabilities[n].r.rCCCS = CCS_SYSTEM;
        }
    }

#ifdef THREADED_RTS
    initMutex(&ccs_mutex);
#endif
}
Exemple #30
0
void hs_spt_insert(StgWord64 key[2],void *spe_closure) {
  // hs_spt_insert is called from constructor functions, so
  // the SPT needs to be initialized here.
  if (spt == NULL) {
    spt = allocHashTable_( (HashFunction *)hashFingerprint
                         , (CompareFunction *)compareFingerprint
                         );
#ifdef THREADED_RTS
    initMutex(&spt_lock);
#endif
  }

  StgStablePtr * entry = stgMallocBytes( sizeof(StgStablePtr)
                                       , "hs_spt_insert: entry"
                                       );
  *entry = getStablePtr(spe_closure);
  ACQUIRE_LOCK(&spt_lock);
  insertHashTable(spt, (StgWord)key, entry);
  RELEASE_LOCK(&spt_lock);
}