Ejemplo n.º 1
0
/**
 ** Changement de taille d'une zone 
 **/
void *
smMemRealloc(void *pBlock, size_t newSize)
{
    SM_MALLOC_CHUNK *c;
    void *newBlock;

    /* get a pointer to the old block header */
    c = (SM_MALLOC_CHUNK *)pBlock - 1;
    if (c->next != MALLOC_MAGIC) {
       LOGDBG(("comLib:smMemLib: realloc(something not returned by malloc)\n"));
       return NULL;
    }

    /* alloc new block */
    newBlock = smMemMalloc(newSize);
    if (newBlock == NULL) {
	return NULL;
    }
    if (pBlock != NULL) {
	if (newSize > c->length)
            memcpy(newBlock, pBlock, c->length);
        else
            memcpy(newBlock, pBlock, newSize);
	smMemFree(pBlock);
    }
    return newBlock;
}
Ejemplo n.º 2
0
void 
h2rngDelete(H2RNG_ID rngId)
{
    if (rngId == NULL) {
	return;
    }
    /* Reseter le flag d'initialisation */
    rngId->flgInit = 0;
    
    /* Liberer le pool de memoire */
    smMemFree ((char *) rngId);
}
Ejemplo n.º 3
0
STATUS
h2devClean(const char *name)
{
   int i, match = 0;
   unsigned char *pool;

   if (h2devAttach() == ERROR) {
      return ERROR;
   }
   /* Look for devices */
   for (i = 0; i < H2_DEV_MAX; i++) {
      if (H2DEV_TYPE(i) != H2_DEV_TYPE_NONE && 
	  fnmatch(name, H2DEV_NAME(i), 0) == 0) {
	 logMsg("Freeing %s\n", H2DEV_NAME(i));
	 match++;
	 switch (H2DEV_TYPE(i)) {
	      case H2_DEV_TYPE_MBOX:
		 mboxDelete(i);
		 break;
	      case H2_DEV_TYPE_POSTER:
		pool = smObjGlobalToLocal(H2DEV_POSTER_POOL(i));
		if (pool != NULL) 
		    smMemFree(pool);
		h2semDelete(H2DEV_POSTER_SEM_ID(i));
		h2devFree(i);
		break;
	      case H2_DEV_TYPE_TASK:
		h2semDelete(H2DEV_TASK_SEM_ID(i));
		h2devFree(i);
		break;
	      case H2_DEV_TYPE_SEM:
	      case H2_DEV_TYPE_NONE:
		break;
	      default:
		/* error */
		logMsg("comLib: unknown device type %d\n", H2DEV_TYPE(i));
		return ERROR;
		break;
	    } /* switch */
	} 
    } /* for */

    if (match == 0) {
	logMsg("No matching device\n");
	return ERROR;
    }
    return OK;
}
Ejemplo n.º 4
0
MSG_Q_ID msgQSmCreate 
    (
    int	maxMsgs,	/* max messages that can be queued */
    int	maxMsgLength,	/* max bytes in a message */
    int	options		/* message queue options */
    )
    {
    SM_MSG_Q_ID	smMsgQId;
    void *	pSmMsgPool;	/* pointer to memory for messages */
    int         nodeSize = SM_MSG_NODE_SIZE (maxMsgLength);
    int         temp;           /* temp storage */

    if (INT_RESTRICT () != OK)	/* restrict ISR from calling */
        {
	return (NULL);
        }

    /* 
     * allocate shared memory message queue descriptor from 
     * dedicated shared memory pool.
     */

    smMsgQId = (SM_MSG_Q_ID) smMemPartAlloc ((SM_PART_ID) smMsgQPartId,
                                             sizeof (SM_MSG_Q));
    if (smMsgQId == NULL)
        {
	return (NULL);
        }

    /* 
     * allocate shared memory message queue data buffers from 
     * shared memory system pool.
     */

    pSmMsgPool = smMemMalloc (nodeSize * maxMsgs);
    if (pSmMsgPool == NULL)
    	{ 
	smMemPartFree ((SM_PART_ID) smMsgQPartId, (char *) smMsgQId);
	return (NULL);
	}

    /* Initialize shared memory message queue structure */

    if (msgQSmInit (smMsgQId, maxMsgs, maxMsgLength, options, pSmMsgPool) !=OK)
	{
	smMemPartFree ((SM_PART_ID) smMsgQPartId, (char *) smMsgQId);
	smMemFree ((char *) pSmMsgPool);
	return (NULL);
	}

    /* update shared infos data */

    CACHE_PIPE_FLUSH ();                        /* CACHE FLUSH   [SPR 68334] */
    temp = pSmObjHdr->curNumMsgQ;               /* PCI bridge bug [SPR 68844]*/

    pSmObjHdr->curNumMsgQ = htonl (ntohl (pSmObjHdr->curNumMsgQ) + 1);

    CACHE_PIPE_FLUSH ();                        /* CACHE FLUSH   [SPR 68334] */
    temp = pSmObjHdr->curNumMsgQ;               /* BRIDGE FLUSH  [SPR 68334] */

    return ((MSG_Q_ID) (SM_OBJ_ADRS_TO_ID (smMsgQId)));
    }