コード例 #1
0
ファイル: arch_code.c プロジェクト: Pachot/mlworks
static void first_and_last_instructions(word**first, word **last,
					mlval codepointer)
{
  mlval codeobject  = FOLLOWBACK(codepointer);
  mlval ancillaries = CCVANCILLARY(codeobject);
  mlval profiles = FIELD(ancillaries,ANC_PROFILES);
  size_t length = NFIELDS(profiles);
  unsigned int codenumber = CCODENUMBER(codepointer);
  
  *first = (word*) (codepointer-POINTER+8);
  *last = NULL;

  if (length == codenumber+1) {
    mlval header = *(mlval*)(codeobject-POINTER);
    *last = ((word*) (codeobject-POINTER))+LENGTH(header)-1;
  } else {
    word *p = *first;
    size_t offset = (codepointer-codeobject+8);
    for(; p+=2, offset += 8; ) {
      word w = *p;
      if (SECONDARY(w) == BACKPTR && LENGTH(w) == offset) {
	*last = p-1;
	break;
      }
    }
    if (*last == NULL)
      error ("no backptr found!\n");
  }
}
コード例 #2
0
ファイル: libml.c プロジェクト: Pachot/mlworks
static enum MLkind decode_hdr(unsigned hdr)
{
  switch (SECONDARY(hdr)) {

     case RECORD    :   return( Tuple_MLK      );
     case STRING    :   return( String_MLK     );
     case ARRAY     :   return( Array_MLK      );
     case BYTEARRAY :   return( ByteArray_MLK  );
     case CODE      :   return( Closure_MLK    );

     case BACKPTR   :   /* FALLTHROUGH */
     case WEAKARRAY :   return( Other_MLK      );

     default        :   return( Invalid_MLK    );
  };
}
コード例 #3
0
ファイル: pool_connection_pool.c プロジェクト: anchowee/pqc
static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p)
{
	/* create master connection */
	MASTER_CONNECTION(p) = malloc(sizeof(POOL_CONNECTION_POOL_SLOT));
	if (MASTER_CONNECTION(p) == NULL)
	{
		pool_error("pool_create_cp: malloc() failed");
		return NULL;
	}
	create_cp(MASTER_CONNECTION(p), 0);

	/* initialize Paramter Status save structure */
	if (pool_init_params(&MASTER(p)->params))
	{
		return NULL;
	}
	p->num = 1;	/* number of slots */

	/* create secondary connection */
	if (DUAL_MODE)
	{
		SECONDARY_CONNECTION(p) = malloc(sizeof(POOL_CONNECTION_POOL_SLOT));
		if (SECONDARY_CONNECTION(p) == NULL)
		{
			pool_error("pool_create_cp: malloc() failed");
			return NULL;
		}
		create_cp(SECONDARY_CONNECTION(p), 1);

		/* initialize Paramter Status save structure */
		if (pool_init_params(&SECONDARY(p)->params))
		{
			return NULL;
		}

		p->num++;	/* number of slots */
	}

	return p;
}