Example #1
0
BOOL TOOLHELPAPI NotifyRegister(
    HANDLE hTask,
    LPFNNOTIFYCALLBACK lpfn,
    WORD wFlags)
{
    NOTIFYSTRUCT *pInfo;
    NOTIFYSTRUCT *pTemp;

    /* Make sure TOOLHELP.DLL is installed */
    if (!wLibInstalled)
        return FALSE;

    /* If the notification hook has not yet been installed, install it */
    if (!wNotifyInstalled)
    {
        /* Make sure we can get a hook! */
        if (!NotifyInit())
            return FALSE;
        wNotifyInstalled = TRUE;
    }

    /* NULL hTask means current task */
    if (!hTask)
        hTask = GetCurrentTask();

    /* Register a death signal handler for this task (does nothing if one
     *  is already installed.
     */
    SignalRegister(hTask);

    /* Check to see if this task is already registered */
    for (pInfo = npNotifyHead ; pInfo ; pInfo = pInfo->pNext)
        if (pInfo->hTask == hTask)
            return FALSE;

    /* Allocate a new NOTIFYSTRUCT structure */
    pInfo = (NOTIFYSTRUCT *)LocalAlloc(LMEM_FIXED, sizeof (NOTIFYSTRUCT));
    if (!pInfo)
        return FALSE;

    /* Fill in the useful fields */
    pInfo->hTask = hTask;
    pInfo->wFlags = wFlags;
    pInfo->lpfn = lpfn;

    /* If this is the only handler, just insert it */
    if (!npNotifyHead)
    {
        pInfo->pNext = npNotifyHead;
        npNotifyHead = pInfo;
    }

    /* Otherwise, insert at the end of the list */
    else
    {
        for (pTemp = npNotifyHead ; pTemp->pNext ; pTemp = pTemp->pNext)
            ;
        pInfo->pNext = pTemp->pNext;
        pTemp->pNext = pInfo;
    }

    return TRUE;
}
Example #2
0
File: ddd.c Project: rolk/ug
DDD_Library::DDD_Library (int *argcp, char ***argvp)
#endif

{
#ifdef CPP_FRONTEND
  // check existence of another instance of DDD_Library
  if (_instance!=0)
  {
    DDD_PrintError('E', 1021,
                   "construction of two instances of DDD_Library is not allowed");
    HARD_EXIT;
  }
#endif

  int buffsize;

  /* init lineout-interface to stdout */
  DDD_UserLineOutFunction = NULL;

  /* if first arg is NULL, we assume that PPIF has been initialized elsewhere */
  if (argcp!=NULL)
  {
    /* init PPIF */
    if (InitPPIF(argcp, argvp) != PPIF_SUCCESS)
    {
      DDD_PrintError('E', 1005, "PPIF initialization failed");
      HARD_EXIT;
    }
  }


  /*
     printf("%4d: process_id=%d\n", me, getpid());
   */


  /* check max. number of procs (limited by GID construction) */
  if (procs>MAX_PROCS) {
    DDD_PrintError('E', 1010,
                   "too many processors, cannot construct global IDs in DDD_Init");
    HARD_EXIT;
  }

  /* compute size for general buffer */
  buffsize = (procs+1)*(sizeof(int)*BUFFER_SIZE_FACTOR);
  if (buffsize<MIN_BUFFER_SIZE)
  {
    buffsize = MIN_BUFFER_SIZE;
  }

  /* get bufferspace */
  iBuffer = (int *)AllocFix(buffsize);
  if (iBuffer==NULL) {
    DDD_PrintError('E', 1000, "not enough memory in DDD_Init");
    HARD_EXIT;
  }
  /* overlay with other buffers */
  cBuffer = (char *)iBuffer;

  /* init all DDD components */
  NotifyInit();
  LC_Init(LowComm_DefaultAlloc, LowComm_DefaultFree);
  ddd_StatInit();
  ddd_TypeMgrInit();
  ddd_ObjMgrInit();
  ddd_CplMgrInit();
  ddd_TopoInit();
  ddd_IdentInit();
  ddd_IFInit();
  ddd_XferInit();
  ddd_PrioInit();
  ddd_JoinInit();
  ddd_ConsInit();

  /* reset all global counters */
  ddd_nObjs  = 0;
  NCpl_Init;
  nCplItems  = 0;

  /* set options on default values */
  ddd_SetOption(OPT_WARNING_VARSIZE_OBJ,   OPT_ON);
  ddd_SetOption(OPT_WARNING_SMALLSIZE,     OPT_ON);
  ddd_SetOption(OPT_WARNING_PRIOCHANGE,    OPT_ON);
  ddd_SetOption(OPT_WARNING_DESTRUCT_HDR,  OPT_ON);
  ddd_SetOption(OPT_DEBUG_XFERMESGS,       OPT_OFF);
  ddd_SetOption(OPT_QUIET_CONSCHECK,       OPT_OFF);
  ddd_SetOption(OPT_IDENTIFY_MODE,         IDMODE_LISTS);
  ddd_SetOption(OPT_WARNING_REF_COLLISION, OPT_ON);
  ddd_SetOption(OPT_INFO_XFER,             XFER_SHOW_NONE);
  ddd_SetOption(OPT_INFO_JOIN,             JOIN_SHOW_NONE);
  ddd_SetOption(OPT_WARNING_OLDSTYLE,      OPT_ON);
  ddd_SetOption(OPT_INFO_IF_WITH_ATTR,     OPT_OFF);
  ddd_SetOption(OPT_XFER_PRUNE_DELETE,     OPT_OFF);
  ddd_SetOption(OPT_IF_REUSE_BUFFERS,      OPT_OFF);
  ddd_SetOption(OPT_IF_CREATE_EXPLICIT,    OPT_OFF);
  ddd_SetOption(OPT_CPLMGR_USE_FREELIST,   OPT_ON);

#ifdef CPP_FRONTEND
  // remember pointer to singleton
  _instance = this;
#endif
}