Пример #1
0
static void Long_term_analysis_filtering (
	int16_t		bc,	/* 					IN  */
	int16_t		Nc,	/* 					IN  */
	register int16_t	* dp,	/* previous d	[-120..-1]		IN  */
	register int16_t	* d,	/* d		[0..39]			IN  */
	register int16_t	* dpp,	/* estimate	[0..39]			OUT */
	register int16_t	* e	/* long term res. signal [0..39]	OUT */)
/*
 *  In this part, we have to decode the bc parameter to compute
 *  the samples of the estimate dpp [0..39].  The decoding of bc needs the
 *  use of table 4.3b.  The long term residual signal e [0..39]
 *  is then calculated to be fed to the RPE encoding section.
 */
{
	register int k ;

#	undef STEP
#	define STEP(BP)					\
	for (k = 0 ; k <= 39 ; k++)		\
	{	dpp [k] = GSM_MULT_R (BP, dp [k - Nc]) ;	\
		e [k]	= GSM_SUB (d [k], dpp [k]) ;	\
		}

	switch (bc)
	{	case 0:	STEP (3277) ; break ;
		case 1:	STEP (11469) ; break ;
		case 2: STEP (21299) ; break ;
		case 3: STEP (32767) ; break ;
		}
}
Пример #2
0
/* 4.2.8 */
static void decode_log_area_ratios(int16_t LARc[8], int16_t *LARpp)
{
    int16_t temp1;

    /* This procedure requires for efficient implementation
       two tables.
       INVA[1..8] = integer((32768*8)/real_A[1..8])
       MIC[1..8]  = minimum value of the LARc[1..8]
    */

    /* Compute the LARpp[1..8] */

#undef STEP
#define STEP(B,MIC,INVA)                            \
    temp1 = sat_add16(*LARc++, MIC) << 10;          \
    temp1 = sat_sub16(temp1, B << 1);               \
    temp1 = gsm_mult_r(INVA, temp1);                \
    *LARpp++ = sat_add16(temp1, temp1);

    STEP(    0,  -32,  13107);
    STEP(    0,  -32,  13107);
    STEP( 2048,  -16,  13107);
    STEP(-2560,  -16,  13107);

    STEP(   94,   -8,  19223);
    STEP(-1792,   -8,  17476);
    STEP( -341,   -4,  31454);
    STEP(-1144,   -4,  29708);

    /* NOTE: the addition of *MIC is used to restore the sign of *LARc. */
}
Пример #3
0
static void
generate_cesarovar(ModeInfo * mi, double pt1x, double pt1y,
		   double pt2x, double pt2y, int level, int sign)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	GC          gc = MI_GC(mi);
	turtlestruct *tp = &turtles[MI_SCREEN(mi)];
	complextype points[4];

	level--;

	tp->turtle.r = sqrt((double) ((pt2x - pt1x) * (pt2x - pt1x) +
				      (pt2y - pt1y) * (pt2y - pt1y))) / 2.0;
	points[0].x = pt1x;
	points[0].y = pt1y;
	points[2].x = pt2x;
	points[2].y = pt2y;
	tp->turtle.theta = POINT(pt1x, pt1y, pt2x, pt2y);
	tp->turtle.x = pt1x;
	tp->turtle.y = pt1y;
	STEP(tp->turtle.x, tp->turtle.y, tp->turtle.r, tp->turtle.theta);
	points[3].x = tp->turtle.x;
	points[3].y = tp->turtle.y;
	TURN(tp->turtle.theta, 90.0 * (double) sign);
	STEP(tp->turtle.x, tp->turtle.y, tp->turtle.r, tp->turtle.theta);
	points[1].x = tp->turtle.x;
	points[1].y = tp->turtle.y;
	sign = -1;
	if (level > 0) {
		int         j;

		for (j = 0; j < 2; j++) {
			pt1x = points[j].x;
			pt2x = points[j + 1].x;
			pt1y = points[j].y;
			pt2y = points[j + 1].y;
			generate_cesarovar(mi, pt1x, pt1y, pt2x, pt2y, level, sign);
		}
	} else {
		XDrawLine(display, window, gc,
			  (int) points[0].x + tp->start.x, (int) points[0].y + tp->start.y,
			  (int) points[2].x + tp->start.x, (int) points[2].y + tp->start.y);
		XDrawLine(display, window, gc,
			  (int) points[1].x + tp->start.x, (int) points[1].y + tp->start.y,
			  (int) points[3].x + tp->start.x, (int) points[3].y + tp->start.y);
	}
}
Пример #4
0
void detach(char *dbname)
{
    int ec;

    stmt_detach.sql = DETACH;
    ec = PREPARE(adb, stmt_detach);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_detach.sql, ec);
        exit(1);
    }

    ec = BINDSTR(stmt_detach, 1, dbname);
    if (ec != SQLITE_OK) {
        APPERR("bind", stmt_detach.sql, ec);
        exit(1);
    }

    ec = STEP(stmt_detach);
    if (ec = SQLITE_OK) {
        APPERR("step", stmt_detach.sql, ec);
        exit(1);
    }

    ec = FINALIZE(stmt_detach);
    if (ec = SQLITE_OK) {
        APPERR("finalize", stmt_detach.sql, ec);
        exit(1);
    }
}
Пример #5
0
void update_day_pass2(char *table_name)
{
    int ec, sp_id;
    char *ticker_symbol;

    printf("PASS2\n");

    stmt_q1.sql = Q1;
    ec = PREPARE(adb, stmt_q1);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_q1.sql, ec);
        exit(1);
    }

    do {

        ec = STEP(stmt_q1);
        if (ec == SQLITE_ROW) {

            sp_id = sqlite3_column_int(stmt_q1.stmtp, 0);
            ticker_symbol = (char *)sqlite3_column_text(stmt_q1.stmtp, 1);

            get_stock_prices(sp_id, table_name, ticker_symbol);

        }

    } while (ec == SQLITE_ROW);

    if (ec != SQLITE_DONE) {
        APPERR("step", stmt_q1.sql, ec);
        exit(1);
    }

}
logical DLInterpreter :: S ( )
{

  // was dsi
  return(STEP());

}
Пример #7
0
void update_day_pass3(char *table_name)
{
    int ec;

    printf("PASS3: %s\n", table_name);

    attach("analytic.db", "analytic");
    attach("timeSeries.db", "timeSeries");

    stmt_q4.sql = sql_buffer;
    sprintf(sql_buffer, Q4, "analytic", "timeSeries", table_name);
    ec = PREPARE(adb, stmt_q4);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_q4.sql, ec);
        exit(1);
    }

    ec = STEP(stmt_q4);
    if (ec = SQLITE_OK) {
        APPERR("step", stmt_q4.sql, ec);
        exit(1);
    }

    ec = FINALIZE(begin);
    if (ec = SQLITE_OK) {
        APPERR("finalize", stmt_q4.sql, ec);
        exit(1);
    }

    detach("analytic");
    detach("timeSeries");
}
Пример #8
0
//========================================================================================================================
void RcSeq_DeclareKeyboardOrStickOrCustom(uint8_t ChIdx, uint8_t Type, uint16_t PulseMinUs, uint16_t PulseMaxUs, KeyMap_t *KeyMap, uint8_t PosNb)
{
	RcChannel[ChIdx].Type = Type;
	RcChannel[ChIdx].PosNb = PosNb;
	RcChannel[ChIdx].PulseMinUs = PulseMinUs;
	RcChannel[ChIdx].PulseMaxUs = PulseMaxUs;
	RcChannel[ChIdx].StepUs = STEP(PulseMinUs, PulseMaxUs, PosNb, Type);
	RcChannel[ChIdx].KeyMap = KeyMap;
}
Пример #9
0
static uint16_t ip6PacketChecksum(const uint8_t sourceAndDestAddrs[32],
                                  const uint8_t packetHeaderAndContent[8],
                                  uint16_t length,
                                  uint32_t packetType_be)
{
    Assert_true(!((uintptr_t)sourceAndDestAddrs % 2));
    Assert_true(!((uintptr_t)packetHeaderAndContent % 2));

    // http://tools.ietf.org/html/rfc2460#page-27
    uint64_t sum = STEP(sourceAndDestAddrs, 32, 0);

    const uint32_t length_be = Endian_hostToBigEndian32(length);
    sum = STEP((uint8_t*) &length_be, 4, sum);
    sum = STEP((uint8_t*) &packetType_be, 4, sum);
    sum = STEP(packetHeaderAndContent, length, sum);

    return COMPLETE(sum);
}
Пример #10
0
/*
 * Get a char from the buffer
 * looping until there is something new to read
 */
int _kgetch (void) {
    int c = -1;

    if (buf_r != buf_w) {
	c = circlebuf[buf_r];
	buf_r = STEP(buf_r);
    }    
    return c;
}
Пример #11
0
/** \brief Breakpoint support.
 * \param id UNUSED could indicate a type/specific breakpoint for automated
 * handling.
 * \param msg UNUSED could be used to print information
 * \return How the breakpoint was handled HANDLED_USER for now.
 * TODO
 **/
enum handled_by elf_clientbreakpoint(int id, const char *msg){
  STEP();
  (void)id;
  (void)msg;
  //locked_print_string(msg, PRINTERR);
  //locked_print_int(id, PRINTERR);
  //....
  return HANDLED_USER;
}
Пример #12
0
static void
cycle(WORD R[])
{
    WORD	t;
    int		i;

    STEP(R,0);
    t = R[0];
    for (i = 1; i < N; ++i)
	R[i-1] = R[i];
    R[N-1] = t;
}
Пример #13
0
int insert_stock_price(int sp_id, double sp_price, char *sp_date)
{
    int ec;

    stmt_q3.sql = Q3;
    ec = PREPARE(adb, stmt_q3);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_q3.sql, ec);
        exit(1);
    }

    ec = BINDINT(stmt_q3, 1, sp_id);
    if (ec != SQLITE_OK) {
        APPERR("bind sp_id", stmt_q3.sql, ec);
        exit(1);
    }

    ec = BINDDBL(stmt_q3, 2, sp_price);
    if (ec != SQLITE_OK) {
        APPERR("bind sp_price", stmt_q3.sql, ec);
        exit(1);
    }

    ec = BINDSTR(stmt_q3, 3, sp_date);
    if (ec != SQLITE_OK) {
        APPERR("bind sp_date", stmt_q3.sql, ec);
        exit(1);
    }

    ec = STEP(stmt_q3);
    if (ec == SQLITE_DONE) {

        printf("insert of sp_id %d sp_price $%.2f sp_date %s succeeded\n",
                sp_id, sp_price, sp_date);

        ec = FINALIZE(stmt_q3);
        if (ec != SQLITE_OK) {
            APPERR("finalize", stmt_q3.sql, ec);
            exit(1);
        }
        return 1;

    } else if (ec == SQLITE_CONSTRAINT) {

        return 0;

    } else {

        APPERR("STEP", stmt_q3.sql, ec);
        exit(1);

    }
}
Пример #14
0
static void cycle(ulong32 *R)
{
    ulong32 t;
    int     i;

    STEP(R,0);
    t = R[0];
    for (i = 1; i < N; ++i) {
        R[i-1] = R[i];
    }
    R[N-1] = t;
}
Пример #15
0
/*
 * Get a char from the buffer
 * looping until there is something new to read
 */
int _kgetch (void) {
    int c = 0;

loop:
    if (buf_r != buf_w) {
	c = circlebuf[buf_r];
	buf_r = STEP(buf_r);
    }
    else
        goto loop;
    return c;
}
Пример #16
0
uint8_t SDHashClass::findSeg(SDHAddress seg0addr, SDHAddress *addr) {
	SDHAddress addr0 = *addr;
	SegmentInfo sinfo;
	uint8_t ret;

	do {
		ret = statSeg(*addr, &sinfo);
		if (ret == SDH_OK) {
			if (sinfo.segment0_addr == seg0addr) return SDH_OK;
		} else if (ret != SDH_ERR_WRONG_SEGMENT_TYPE) return ret;

		*addr+=STEP(addr0);
	} while (addr0 != *addr);

	return SDH_ERR_NO_SPACE;
}
Пример #17
0
static void Decoding_of_the_coded_Log_Area_Ratios(gsmword *LARc, gsmword *LARpp)
{
	gsmword	temp1;
	long	ltmp;

#undef	STEP
#define	STEP( B, MIC, INVA )	\
		temp1    = (gsmword)(SASL( *LARc++ + MIC , 10));	\
		temp1    -= SASL( B, 1 );		\
		temp1    = (gsmword)GSM_MULT_R( INVA, temp1 );		\
		*LARpp++ = (gsmword)GSM_ADD( temp1, temp1 );

	STEP(      0,  -32,  13107 );
	STEP(      0,  -32,  13107 );
	STEP(   2048,  -16,  13107 );
	STEP(  -2560,  -16,  13107 );

	STEP(     94,   -8,  19223 );
	STEP(  -1792,   -8,  17476 );
	STEP(   -341,   -4,  31454 );
	STEP(  -1144,   -4,  29708 );
}
Пример #18
0
void update_day_pass1(char *table_name)
{
    char *ticker_symbol;
    int ec, symbols = 0, inserts = 0;


    stmt_distinctticker.sql = sql_buffer;
    sprintf(sql_buffer, SQL_DISTINCTTICKER, table_name);
    ec = PREPARE(tdb, stmt_distinctticker);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_distinctticker.sql, ec);
        exit(1);
    }

    do {

        ec = STEP(stmt_distinctticker);
        if (ec == SQLITE_ROW) {

            ticker_symbol = (char *)sqlite3_column_text(stmt_distinctticker.stmtp, 0);

            symbols++;
            if (insertTicker(ticker_symbol))
                inserts++;
        }

    } while (ec == SQLITE_ROW);

    printf("PASS1 %s %d %d\n", table_name, symbols, inserts);

    if (ec != SQLITE_DONE) {
        APPERR("step", stmt_distinctticker.sql, ec);
        exit(1);
    }

    ec = FINALIZE(stmt_distinctticker);
    if (ec != SQLITE_OK) {
        APPERR("finalize", stmt_distinctticker.sql, ec);
        exit(1);
    }
}
Пример #19
0
uint8_t SDHashClass::statFile(SDHFilehandle fh, FileInfo *finfo, SDHAddress *addrPtr) {
	SDHAddress addr = _foldHash(fh);
	SDHAddress addr0 = addr;

	uint8_t ret;
	FileInfo info;
	do {
		if (addrPtr) *addrPtr = addr;
		ret = statSeg0(addr, &info);
		if (ret == SDH_OK) {
			if (info.hash == fh) {
				if (finfo) *finfo = info;
				return SDH_OK;
			}
		} else if (ret == SDH_ERR_FILE_NOT_FOUND) return ret;

		addr+=STEP(addr0);
	} while (addr != addr0);
	
	return SDH_ERR_NO_SPACE;
}
Пример #20
0
int insertTicker(char *ticker_symbol)
{
    int ec;

    if (!strcmp(ticker_symbol, "UnderlyingSymbol"))
        return 0;

    stmt_insertticker.sql = SQL_INSERTTICKER;
    ec = PREPARE(adb, stmt_insertticker);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_insertticker.sql, ec);
        exit(1);
    }

    ec = BINDSTR(stmt_insertticker, 1, ticker_symbol);
    if (ec != SQLITE_OK) {
        APPERR("bind", stmt_insertticker.sql, ec);
        exit(1);
    }

    ec = STEP(stmt_insertticker);
    if (ec == SQLITE_DONE) {
        ec = FINALIZE(stmt_insertticker);
        printf("insert of symbol %s succeeded\n", ticker_symbol);
        if (ec != SQLITE_OK) {
            APPERR("finalize", stmt_insertticker.sql, ec);
            exit(1);
        }
        return 1;
    } else if (ec == SQLITE_CONSTRAINT) {
        return 0;
    } else {
        APPERR("STEP", stmt_insertticker.sql, ec);
        exit(1);
    }


}
Пример #21
0
void end_transaction(void)
{
    int ec;

    end.sql = END;
    ec = PREPARE(adb, end);
    if (ec != SQLITE_OK) {
        APPERR("prepare", end.sql, ec);
        exit(1);
    }

    ec = STEP(end);
    if (ec = SQLITE_OK) {
        APPERR("step", end.sql, ec);
        exit(1);
    }

    ec = FINALIZE(end);
    if (ec = SQLITE_OK) {
        APPERR("finalize", end.sql, ec);
        exit(1);
    }
}
Пример #22
0
void begin_transaction(void)
{
    int ec;

    begin.sql = BEGIN;
    ec = PREPARE(adb, begin);
    if (ec != SQLITE_OK) {
        APPERR("prepare", begin.sql, ec);
        exit(1);
    }

    ec = STEP(begin);
    if (ec = SQLITE_OK) {
        APPERR("step", begin.sql, ec);
        exit(1);
    }


    ec = FINALIZE(begin);
    if (ec = SQLITE_OK) {
        APPERR("finalize", begin.sql, ec);
        exit(1);
    }
}
Пример #23
0
void get_stock_prices(int sp_id, char *table_name, char *symbol)
{
    int ec;
    double stock_price;
    char *data_date;

    stmt_q2.sql = sql_buffer;
    sprintf(sql_buffer, Q2, table_name, symbol);
    ec = PREPARE(tdb, stmt_q2);
    if (ec != SQLITE_OK) {
        APPERR("get_stock_prices:prepare", stmt_q2.sql, ec);
        exit(1);
    }

    do {

        ec = STEP(stmt_q2);
        if (ec == SQLITE_ROW) {
            stock_price = sqlite3_column_double(stmt_q2.stmtp, 0);
            data_date = (char *)sqlite3_column_text(stmt_q2.stmtp, 1);
            insert_stock_price(sp_id, stock_price, data_date);
        }

    } while (ec == SQLITE_ROW);

    if (ec != SQLITE_DONE) {
        APPERR("step", stmt_q2.sql, ec);
        exit(1);
    }

    ec = FINALIZE(stmt_q2);
    if (ec != SQLITE_OK) {
        APPERR("finalize", stmt_q2.sql, ec);
        exit(1);
    }
}
Пример #24
0
static void Calculation_of_the_LTP_parameters (
	register int16_t	* d,		/* [0..39]	IN	*/
	register int16_t	* dp,		/* [-120..-1]	IN	*/
	int16_t		* bc_out,	/* 		OUT	*/
	int16_t		* Nc_out	/* 		OUT	*/)
{
	register int	k, lambda ;
	int16_t		Nc, bc ;
	int16_t		wt [40] ;

	int32_t	L_max, L_power ;
	int16_t		R, S, dmax, scal ;
	register int16_t	temp ;

	/*  Search of the optimum scaling of d [0..39].
	 */
	dmax = 0 ;

	for (k = 0 ; k <= 39 ; k++)
	{	temp = d [k] ;
		temp = GSM_ABS (temp) ;
		if (temp > dmax) dmax = temp ;
		}

	temp = 0 ;
	if (dmax == 0)
		scal = 0 ;
	else
	{	assert (dmax > 0) ;
		temp = gsm_norm ((int32_t) dmax << 16) ;
		}

	if (temp > 6) scal = 0 ;
	else scal = 6 - temp ;

	assert (scal >= 0) ;

	/*  Initialization of a working array wt
	 */

	for (k = 0 ; k <= 39 ; k++) wt [k] = SASR_W (d [k], scal) ;

	/* Search for the maximum cross-correlation and coding of the LTP lag */
	L_max = 0 ;
	Nc = 40 ;	/* index for the maximum cross-correlation */

	for (lambda = 40 ; lambda <= 120 ; lambda++)
	{

# undef STEP
#		define STEP(k) 	(int32_t) wt [k] * dp [k - lambda]

		register int32_t L_result ;

		L_result = STEP (0) ; L_result += STEP (1) ;
		L_result += STEP (2) ; L_result += STEP (3) ;
		L_result += STEP (4) ; L_result += STEP (5) ;
		L_result += STEP (6) ; L_result += STEP (7) ;
		L_result += STEP (8) ; L_result += STEP (9) ;
		L_result += STEP (10) ; L_result += STEP (11) ;
		L_result += STEP (12) ; L_result += STEP (13) ;
		L_result += STEP (14) ; L_result += STEP (15) ;
		L_result += STEP (16) ; L_result += STEP (17) ;
		L_result += STEP (18) ; L_result += STEP (19) ;
		L_result += STEP (20) ; L_result += STEP (21) ;
		L_result += STEP (22) ; L_result += STEP (23) ;
		L_result += STEP (24) ; L_result += STEP (25) ;
		L_result += STEP (26) ; L_result += STEP (27) ;
		L_result += STEP (28) ; L_result += STEP (29) ;
		L_result += STEP (30) ; L_result += STEP (31) ;
		L_result += STEP (32) ; L_result += STEP (33) ;
		L_result += STEP (34) ; L_result += STEP (35) ;
		L_result += STEP (36) ; L_result += STEP (37) ;
		L_result += STEP (38) ; L_result += STEP (39) ;

		if (L_result > L_max)
		{	Nc = lambda ;
			L_max = L_result ;
			}
		}

	*Nc_out = Nc ;

	L_max <<= 1 ;

	/*  Rescaling of L_max
	 */
	assert (scal <= 100 && scal >= -100) ;
	L_max = L_max >> (6 - scal) ;	/* sub (6, scal) */

	assert (Nc <= 120 && Nc >= 40) ;

	/*   Compute the power of the reconstructed short term residual
	 *   signal dp [..]
	 */
	L_power = 0 ;
	for (k = 0 ; k <= 39 ; k++)
	{	register int32_t L_temp ;

		L_temp = SASR_W (dp [k - Nc], 3) ;
		L_power += L_temp * L_temp ;
		}
	L_power <<= 1 ;	/* from L_MULT */

	/*  Normalization of L_max and L_power
	 */

	if (L_max <= 0)
	{	*bc_out = 0 ;
		return ;
		}
	if (L_max >= L_power)
	{	*bc_out = 3 ;
		return ;
		}

	temp = gsm_norm (L_power) ;

	R = SASR_L (L_max << temp, 16) ;
	S = SASR_L (L_power << temp, 16) ;

	/*  Coding of the LTP gain
	 */

	/*  Table 4.3a must be used to obtain the level DLB [i] for the
	 *  quantization of the LTP gain b to get the coded version bc.
	 */
	for (bc = 0 ; bc <= 2 ; bc++) if (R <= gsm_mult (S, gsm_DLB [bc])) break ;
	*bc_out = bc ;
}
Пример #25
0
static void Weighting_filter (
	register word	* e,		/* signal [-5..0.39.44]	IN  */
	word		* x		/* signal [0..39]	OUT */
)
/*
 *  The coefficients of the weighting filter are stored in a table
 *  (see table 4.4).  The following scaling is used:
 *
 *	H[0..10] = integer( real_H[ 0..10] * 8192 ); 
 */
{
	/* word			wt[ 50 ]; */

	register longword	L_result;
	register int		k /* , i */ ;

	/*  Initialization of a temporary working array wt[0...49]
	 */

	/* for (k =  0; k <=  4; k++) wt[k] = 0;
	 * for (k =  5; k <= 44; k++) wt[k] = *e++;
	 * for (k = 45; k <= 49; k++) wt[k] = 0;
	 *
	 *  (e[-5..-1] and e[40..44] are allocated by the caller,
	 *  are initially zero and are not written anywhere.)
	 */
	e -= 5;

	/*  Compute the signal x[0..39]
	 */ 
	for (k = 0; k <= 39; k++) {

		L_result = 8192 >> 1;

		/* for (i = 0; i <= 10; i++) {
		 *	L_temp   = GSM_L_MULT( wt[k+i], gsm_H[i] );
		 *	L_result = GSM_L_ADD( L_result, L_temp );
		 * }
		 */

#undef	STEP
#define	STEP( i, H )	(e[ k + i ] * (longword)H)

		/*  Every one of these multiplications is done twice --
		 *  but I don't see an elegant way to optimize this. 
		 *  Do you?
		 */

#ifdef	STUPID_COMPILER
		L_result += STEP(	0, 	-134 ) ;
		L_result += STEP(	1, 	-374 )  ;
	               /* + STEP(	2, 	0    )  */
		L_result += STEP(	3, 	2054 ) ;
		L_result += STEP(	4, 	5741 ) ;
		L_result += STEP(	5, 	8192 ) ;
		L_result += STEP(	6, 	5741 ) ;
		L_result += STEP(	7, 	2054 ) ;
	 	       /* + STEP(	8, 	0    )  */
		L_result += STEP(	9, 	-374 ) ;
		L_result += STEP(	10, 	-134 ) ;
#else
		L_result +=
		  STEP(	0, 	-134 ) 
		+ STEP(	1, 	-374 ) 
	     /* + STEP(	2, 	0    )  */
		+ STEP(	3, 	2054 ) 
		+ STEP(	4, 	5741 ) 
		+ STEP(	5, 	8192 ) 
		+ STEP(	6, 	5741 ) 
		+ STEP(	7, 	2054 ) 
	     /* + STEP(	8, 	0    )  */
		+ STEP(	9, 	-374 ) 
		+ STEP(10, 	-134 )
		;
#endif

		/* L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x2) *)
		 * L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x4) *)
		 *
		 * x[k] = SASR( L_result, 16 );
		 */

		/* 2 adds vs. >>16 => 14, minus one shift to compensate for
		 * those we lost when replacing L_MULT by '*'.
		 */

		L_result = SASR( L_result, 13 );
		x[k] =  (  L_result < MIN_WORD ? MIN_WORD
			: (L_result > MAX_WORD ? MAX_WORD : L_result ));
	}
}
Пример #26
0
static void RPE_grid_selection (
	word		* x,		/* [0..39]		IN  */ 
	word		* xM,		/* [0..12]		OUT */
	word		* Mc_out	/*			OUT */
)
/*
 *  The signal x[0..39] is used to select the RPE grid which is
 *  represented by Mc.
 */
{
	/* register word	temp1;	*/
	register int		/* m, */  i;
	register longword	L_result, L_temp;
	longword		EM;	/* xxx should be L_EM? */
	word			Mc;

	longword		L_common_0_3;

	EM = 0;
	Mc = 0;

	/* for (m = 0; m <= 3; m++) {
	 *	L_result = 0;
	 *
	 *
	 *	for (i = 0; i <= 12; i++) {
	 *
	 *		temp1    = SASR( x[m + 3*i], 2 );
	 *
	 *		assert(temp1 != MIN_WORD);
	 *
	 *		L_temp   = GSM_L_MULT( temp1, temp1 );
	 *		L_result = GSM_L_ADD( L_temp, L_result );
	 *	}
	 * 
	 *	if (L_result > EM) {
	 *		Mc = m;
	 *		EM = L_result;
	 *	}
	 * }
	 */

#undef	STEP
#define	STEP( m, i )		L_temp = SASR( x[m + 3 * i], 2 );	\
				L_result += L_temp * L_temp;

	/* common part of 0 and 3 */

	L_result = 0;
	STEP( 0, 1 ); STEP( 0, 2 ); STEP( 0, 3 ); STEP( 0, 4 );
	STEP( 0, 5 ); STEP( 0, 6 ); STEP( 0, 7 ); STEP( 0, 8 );
	STEP( 0, 9 ); STEP( 0, 10); STEP( 0, 11); STEP( 0, 12);
	L_common_0_3 = L_result;

	/* i = 0 */

	STEP( 0, 0 );
	L_result <<= 1;	/* implicit in L_MULT */
	EM = L_result;

	/* i = 1 */

	L_result = 0;
	STEP( 1, 0 );
	STEP( 1, 1 ); STEP( 1, 2 ); STEP( 1, 3 ); STEP( 1, 4 );
	STEP( 1, 5 ); STEP( 1, 6 ); STEP( 1, 7 ); STEP( 1, 8 );
	STEP( 1, 9 ); STEP( 1, 10); STEP( 1, 11); STEP( 1, 12);
	L_result <<= 1;
	if (L_result > EM) {
		Mc = 1;
	 	EM = L_result;
	}

	/* i = 2 */

	L_result = 0;
	STEP( 2, 0 );
	STEP( 2, 1 ); STEP( 2, 2 ); STEP( 2, 3 ); STEP( 2, 4 );
	STEP( 2, 5 ); STEP( 2, 6 ); STEP( 2, 7 ); STEP( 2, 8 );
	STEP( 2, 9 ); STEP( 2, 10); STEP( 2, 11); STEP( 2, 12);
	L_result <<= 1;
	if (L_result > EM) {
		Mc = 2;
	 	EM = L_result;
	}

	/* i = 3 */

	L_result = L_common_0_3;
	STEP( 3, 12 );
	L_result <<= 1;
	if (L_result > EM) {
		Mc = 3;
	 	EM = L_result;
	}

	/**/

	/*  Down-sampling by a factor 3 to get the selected xM[0..12]
	 *  RPE sequence.
	 */
	for (i = 0; i <= 12; i ++) xM[i] = x[Mc + 3*i];
	*Mc_out = Mc;
}
Пример #27
0
/*
 * Solves the puzzle and prints results.
 * Returns 1 on success and 0 on nonexistence of a solution.
 */
static int solve(int *start, int *end)
{
    Grid *root, *goal, *cur, *child, *iter, **result;
    Pqueue *pq;
    Set *visited;
    int goal_grid_code, child_code;
    int i, ch;
    int path_length;

    root = (Grid *) malloc(sizeof(Grid));
    memcpy(root->g, start, sizeof(int) * 9);
    root->parent = NULL;
    root->hole = 1;
    root->depth = 0;

    goal = (Grid *) malloc(sizeof(Grid));
    memcpy(goal->g, end, sizeof(int) * 9);
    goal_grid_code = grid_code(goal);
    get_correct_positions(goal);

    path_length = 0;
    i = 0;
    pq = pqueue_new();
    visited = set_new(4);
    pqueue_insert(pq, root);
    set_insert(visited, grid_code(root));


    while (!empty(pq)) {
        cur = pqueue_extract_min(pq);
        if (verbose) {
            fprintf(output, "%d.\n", ++i);
            fprintf(output, "Depth: %d\n", cur->depth);
            fprintf(output, "Grid:\n");
            grid_print(output, cur);
            fprintf(output, "f: %2d\n", weight(cur));
            fprintf(output, "\n");
        }
        if (grid_code(cur) == goal_grid_code)
            break;

        ch = 0;

#define ADD_CHILD() {                                                         \
    child_code = grid_code(child);                                            \
    if (!set_contains(visited, child_code)) {                                 \
        set_insert(visited, child_code);                                      \
        pqueue_insert(pq, child);                                             \
        cur->child[ch++] = child;                                             \
    } else                                                                    \
        free(child);                                                          \
}

        /* Hole not on the left wall. */
        if (cur->hole % 3 > 0) {
            child = make_child(cur);
            grid_move_hole(child, child->hole - 1);
            ADD_CHILD();
        }
        /* Hole not on the right wall. */
        if (cur->hole % 3 < 2) {
            child = make_child(cur);
            grid_move_hole(child, child->hole + 1);
            ADD_CHILD();
        }
        /* Hole not on the top wall. */
        if (cur->hole / 3 > 0) {
            child = make_child(cur);
            grid_move_hole(child, child->hole - 3);
            ADD_CHILD();
        }
        /* Hole not on the bottom wall. */
        if (cur->hole / 3 < 2) {
            child = make_child(cur);
            grid_move_hole(child, child->hole + 3);
            ADD_CHILD();
        }
#undef ADD_CHILD

        /* End of children character. */
        cur->child[ch] = NULL;

        if (verbose) {
            fprintf(output, "Children:\n");
            grid_children(output, cur);
            fprintf(output, "------------------------\n");
            fprintf(output, "\n");
            STEP();
        }
    }

    if (grid_code(cur) != goal_grid_code)
        return 0;

    /* Collect result path. */
    for (iter = cur; iter != NULL; iter = iter->parent)
        path_length ++;

    result = (Grid**) malloc(sizeof(Grid*) * path_length);

    i = path_length - 1;
    for (iter = cur; iter != NULL; iter = iter->parent)
        result[i--] = iter;

    if (verbose)
        fprintf(output, "Solution sequence:\n");

    for (i = 0; i < path_length; i++) {
        grid_print(output, result[i]);
        STEP();
        fprintf(output, "\n");
    }


    /* Clean up. */
    grid_dispose(root);
    set_dispose(visited);
    pqueue_dispose(pq);
    free(result);
    free(goal);

    return 1;
}
Пример #28
0
void VMError::report(outputStream* st) {
# define BEGIN if (_current_step == 0) { _current_step = 1;
# define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
# define END }

  // don't allocate large buffer on stack
  static char buf[O_BUFLEN];

  BEGIN

  STEP(10, "(printing fatal error message)")

    st->print_cr("#");
    if (should_report_bug(_id)) {
      st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
    } else {
      st->print_cr("# There is insufficient memory for the Java "
                   "Runtime Environment to continue.");
    }

  STEP(15, "(printing type of error)")

     switch(_id) {
       case oom_error:
         if (_size) {
           st->print("# Native memory allocation (malloc) failed to allocate ");
           jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
           st->print(buf);
           st->print(" bytes");
           if (_message != NULL) {
             st->print(" for ");
             st->print(_message);
           }
           st->cr();
         } else {
           if (_message != NULL)
             st->print("# ");
             st->print_cr(_message);
         }
         // In error file give some solutions
         if (_verbose) {
           st->print_cr("# Possible reasons:");
           st->print_cr("#   The system is out of physical RAM or swap space");
           st->print_cr("#   In 32 bit mode, the process size limit was hit");
           st->print_cr("# Possible solutions:");
           st->print_cr("#   Reduce memory load on the system");
           st->print_cr("#   Increase physical memory or swap space");
           st->print_cr("#   Check if swap backing store is full");
           st->print_cr("#   Use 64 bit Java on a 64 bit OS");
           st->print_cr("#   Decrease Java heap size (-Xmx/-Xms)");
           st->print_cr("#   Decrease number of Java threads");
           st->print_cr("#   Decrease Java thread stack sizes (-Xss)");
           st->print_cr("#   Set larger code cache with -XX:ReservedCodeCacheSize=");
           st->print_cr("# This output file may be truncated or incomplete.");
         } else {
           return;  // that's enough for the screen
         }
         break;
       case internal_error:
       default:
         break;
     }

  STEP(20, "(printing exception/signal name)")

     st->print_cr("#");
     st->print("#  ");
     // Is it an OS exception/signal?
     if (os::exception_name(_id, buf, sizeof(buf))) {
       st->print("%s", buf);
       st->print(" (0x%x)", _id);                // signal number
       st->print(" at pc=" PTR_FORMAT, _pc);
     } else {
       if (should_report_bug(_id)) {
         st->print("Internal Error");
       } else {
         st->print("Out of Memory Error");
       }
       if (_filename != NULL && _lineno > 0) {
#ifdef PRODUCT
         // In product mode chop off pathname?
         char separator = os::file_separator()[0];
         const char *p = strrchr(_filename, separator);
         const char *file = p ? p+1 : _filename;
#else
         const char *file = _filename;
#endif
         size_t len = strlen(file);
         size_t buflen = sizeof(buf);

         strncpy(buf, file, buflen);
         if (len + 10 < buflen) {
           sprintf(buf + len, ":%d", _lineno);
         }
         st->print(" (%s)", buf);
       } else {
         st->print(" (0x%x)", _id);
       }
     }

  STEP(30, "(printing current thread and pid)")

     // process id, thread id
     st->print(", pid=%d", os::current_process_id());
     st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
     st->cr();

  STEP(40, "(printing error message)")

     if (should_report_bug(_id)) {  // already printed the message.
       // error message
       if (_detail_msg) {
         st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
       } else if (_message) {
         st->print_cr("#  Error: %s", _message);
       }
    }

  STEP(50, "(printing Java version string)")

     // VM version
     st->print_cr("#");
     JDK_Version::current().to_string(buf, sizeof(buf));
     st->print_cr("# JRE version: %s", buf);
     st->print_cr("# Java VM: %s (%s %s %s %s)",
                   Abstract_VM_Version::vm_name(),
                   Abstract_VM_Version::vm_release(),
                   Abstract_VM_Version::vm_info_string(),
                   Abstract_VM_Version::vm_platform_string(),
                   UseCompressedOops ? "compressed oops" : ""
                 );

  STEP(60, "(printing problematic frame)")

     // Print current frame if we have a context (i.e. it's a crash)
     if (_context) {
       st->print_cr("# Problematic frame:");
       st->print("# ");
       frame fr = os::fetch_frame_from_context(_context);
       fr.print_on_error(st, buf, sizeof(buf));
       st->cr();
       st->print_cr("#");
     }
  STEP(63, "(printing core file information)")
    st->print("# ");
    if (coredump_status) {
      st->print("Core dump written. Default location: %s", coredump_message);
    } else {
      st->print("Failed to write core dump. %s", coredump_message);
    }
    st->print_cr("");
    st->print_cr("#");

  STEP(65, "(printing bug submit message)")

     if (should_report_bug(_id) && _verbose) {
       print_bug_submit_message(st, _thread);
     }

  STEP(70, "(printing thread)" )

     if (_verbose) {
       st->cr();
       st->print_cr("---------------  T H R E A D  ---------------");
       st->cr();
     }

  STEP(80, "(printing current thread)" )

     // current thread
     if (_verbose) {
       if (_thread) {
         st->print("Current thread (" PTR_FORMAT "):  ", _thread);
         _thread->print_on_error(st, buf, sizeof(buf));
         st->cr();
       } else {
         st->print_cr("Current thread is native thread");
       }
       st->cr();
     }

  STEP(90, "(printing siginfo)" )

     // signal no, signal code, address that caused the fault
     if (_verbose && _siginfo) {
       os::print_siginfo(st, _siginfo);
       st->cr();
     }

  STEP(100, "(printing registers, top of stack, instructions near pc)")

     // registers, top of stack, instructions near pc
     if (_verbose && _context) {
       os::print_context(st, _context);
       st->cr();
     }

  STEP(105, "(printing register info)")

     // decode register contents if possible
     if (_verbose && _context && Universe::is_fully_initialized()) {
       os::print_register_info(st, _context);
       st->cr();
     }

  STEP(110, "(printing stack bounds)" )

     if (_verbose) {
       st->print("Stack: ");

       address stack_top;
       size_t stack_size;

       if (_thread) {
          stack_top = _thread->stack_base();
          stack_size = _thread->stack_size();
       } else {
          stack_top = os::current_stack_base();
          stack_size = os::current_stack_size();
       }

       address stack_bottom = stack_top - stack_size;
       st->print("[" PTR_FORMAT "," PTR_FORMAT "]", stack_bottom, stack_top);

       frame fr = _context ? os::fetch_frame_from_context(_context)
                           : os::current_frame();

       if (fr.sp()) {
         st->print(",  sp=" PTR_FORMAT, fr.sp());
         size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024);
         st->print(",  free space=" SIZE_FORMAT "k", free_stack_size);
       }

       st->cr();
     }

  STEP(120, "(printing native stack)" )

     if (_verbose) {
       frame fr = _context ? os::fetch_frame_from_context(_context)
                           : os::current_frame();

       // see if it's a valid frame
       if (fr.pc()) {
          st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");


          int count = 0;
          while (count++ < StackPrintLimit) {
             fr.print_on_error(st, buf, sizeof(buf));
             st->cr();
             if (os::is_first_C_frame(&fr)) break;
             fr = os::get_sender_for_C_frame(&fr);
          }

          if (count > StackPrintLimit) {
             st->print_cr("...<more frames>...");
          }

          st->cr();
       }
     }

  STEP(130, "(printing Java stack)" )

     if (_verbose && _thread && _thread->is_Java_thread()) {
       print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
     }

  STEP(135, "(printing target Java thread stack)" )

     // printing Java thread stack trace if it is involved in GC crash
     if (_verbose && _thread && (_thread->is_Named_thread())) {
       JavaThread*  jt = ((NamedThread *)_thread)->processed_thread();
       if (jt != NULL) {
         st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id());
         print_stack_trace(st, jt, buf, sizeof(buf), true);
       }
     }

  STEP(140, "(printing VM operation)" )

     if (_verbose && _thread && _thread->is_VM_thread()) {
        VMThread* t = (VMThread*)_thread;
        VM_Operation* op = t->vm_operation();
        if (op) {
          op->print_on_error(st);
          st->cr();
          st->cr();
        }
     }

  STEP(150, "(printing current compile task)" )

     if (_verbose && _thread && _thread->is_Compiler_thread()) {
        CompilerThread* t = (CompilerThread*)_thread;
        if (t->task()) {
           st->cr();
           st->print_cr("Current CompileTask:");
           t->task()->print_line_on_error(st, buf, sizeof(buf));
           st->cr();
        }
     }

  STEP(160, "(printing process)" )

     if (_verbose) {
       st->cr();
       st->print_cr("---------------  P R O C E S S  ---------------");
       st->cr();
     }

  STEP(170, "(printing all threads)" )

     // all threads
     if (_verbose && _thread) {
       Threads::print_on_error(st, _thread, buf, sizeof(buf));
       st->cr();
     }

  STEP(175, "(printing VM state)" )

     if (_verbose) {
       // Safepoint state
       st->print("VM state:");

       if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing");
       else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint");
       else st->print("not at safepoint");

       // Also see if error occurred during initialization or shutdown
       if (!Universe::is_fully_initialized()) {
         st->print(" (not fully initialized)");
       } else if (VM_Exit::vm_exited()) {
         st->print(" (shutting down)");
       } else {
         st->print(" (normal execution)");
       }
       st->cr();
       st->cr();
     }

  STEP(180, "(printing owned locks on error)" )

     // mutexes/monitors that currently have an owner
     if (_verbose) {
       print_owned_locks_on_error(st);
       st->cr();
     }

  STEP(190, "(printing heap information)" )

     if (_verbose && Universe::is_fully_initialized()) {
       // Print heap information before vm abort. As we'd like as much
       // information as possible in the report we ask for the
       // extended (i.e., more detailed) version.
       Universe::print_on(st, true /* extended */);
       st->cr();

       Universe::heap()->barrier_set()->print_on(st);
       st->cr();

       st->print_cr("Polling page: " INTPTR_FORMAT, os::get_polling_page());
       st->cr();
     }

  STEP(195, "(printing code cache information)" )

     if (_verbose && Universe::is_fully_initialized()) {
       // print code cache information before vm abort
       CodeCache::print_bounds(st);
       st->cr();
     }

  STEP(200, "(printing ring buffers)" )

     if (_verbose) {
       Events::print_all(st);
       st->cr();
     }

  STEP(205, "(printing dynamic libraries)" )

     if (_verbose) {
       // dynamic libraries, or memory map
       os::print_dll_info(st);
       st->cr();
     }

  STEP(210, "(printing VM options)" )

     if (_verbose) {
       // VM options
       Arguments::print_on(st);
       st->cr();
     }

  STEP(220, "(printing environment variables)" )

     if (_verbose) {
       os::print_environment_variables(st, env_list, buf, sizeof(buf));
       st->cr();
     }

  STEP(225, "(printing signal handlers)" )

     if (_verbose) {
       os::print_signal_handlers(st, buf, sizeof(buf));
       st->cr();
     }

  STEP(230, "" )

     if (_verbose) {
       st->cr();
       st->print_cr("---------------  S Y S T E M  ---------------");
       st->cr();
     }

  STEP(240, "(printing OS information)" )

     if (_verbose) {
       os::print_os_info(st);
       st->cr();
     }

  STEP(250, "(printing CPU info)" )
     if (_verbose) {
       os::print_cpu_info(st);
       st->cr();
     }

  STEP(260, "(printing memory info)" )

     if (_verbose) {
       os::print_memory_info(st);
       st->cr();
     }

  STEP(270, "(printing internal vm info)" )

     if (_verbose) {
       st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
       st->cr();
     }

  STEP(280, "(printing date and time)" )

     if (_verbose) {
       os::print_date_and_time(st);
       st->cr();
     }

  END

# undef BEGIN
# undef STEP
# undef END
}
Пример #29
0
unsigned int
__udivsi3 (unsigned int a, unsigned int b)
{
  unsigned int d, t, s0, s1, s2, r0, r1;
  fu u0, u1, u2,  u1b, u2b;

  if (b > a)
    return 0;
  if ((int) b < 0)
    return 1;

  /* Assuming B is nonzero, compute S0 such that 0 <= S0,
     (B << S0+1) does not overflow,
     A < 4.01 * (B << S0), with S0 choosen as small as possible
     without taking to much time calculating.  */
#ifdef CONVERT_UNSIGNED
  u0.f = a;
  u1.f = b;
#else /* !CONVERT_UNSIGNED */
  u0.f = (int) a;
  u1.f = (int) b;
#ifdef CONCISE
  if (a < 0)
    u0.i = (a >> 8) - 0x00800000 + 0x3f800000 + (31 << 23);
#else /* To use flag seting / cmove, this can be written as:  */
 {
  unsigned c = 0xff800000 - 0x4f000000;
  t = (int)a >> 8;
  if (t >= c)
    u0.i = (t - c);
 }
#endif
#endif /* !CONVERT_UNSIGNED */
  s0 = u0.i + 1 /* Compensate for rounding errors.  */
	    - 0x00800000 /* adjust by one */ ;
  s0 = s0 - u1.i;
  s0 = (int)s0 >= 0 ? s0 : 0;
  s0 >>= 23;

  b <<= s0;
  r1 = 0;

  r0 = 1 << s0;
  a = ((t=a) - b);
  if (a <= t)
    {
      r1 += r0;
      a = ((t=a) - b);
      if (a <= t)
	do {
	  r1 += r0;
	  a = ((t=a) - b);
	} while (a <= t);
    }
  a += b;
  d = b - 1;

#define STEP(n) case n: a += a; t = a - d; if (t <= a) a = t;
  switch (s0)
    {
    STEP (31)
    STEP (30)
    STEP (29)
    STEP (28)
    STEP (27)
    STEP (26)
    STEP (25)
    STEP (24)
    STEP (23)
    STEP (22)
    STEP (21)
    STEP (20)
    STEP (19)
    STEP (18)
    STEP (17)
    STEP (16)
    STEP (15)
    STEP (14)
    STEP (13)
    STEP (12)
    STEP (11)
    STEP (10)
    STEP (9)
    STEP (8)
    STEP (7)
    STEP (6)
    STEP (5)
    STEP (4)
    STEP (3)
    STEP (2)
    STEP (1)
    case 0: ;
    }
  r0 = r1 | (r0-1 & a);
  return r0;
}
Пример #30
0
void update(int pass)
{
    char *tsmd_name;
    int tsmd_rowcnt, tsmd_processed, tsmd_rowid, ec;

    stmt_timeseriesmetadata.sql = SQL_TIMESERIESMETADATA;

    ec = PREPARE(adb, stmt_timeseriesmetadata);
    if (ec != SQLITE_OK) {
        APPERR("prepare", stmt_timeseriesmetadata.sql, ec);
        exit(1);
    }

    do {

        ec = STEP(stmt_timeseriesmetadata);
        if (ec == SQLITE_ROW) {
            /*
             *     0          1            2               3
             * rowid, tsmd_name, tsmd_rowcnt, tsmd_processed
             */
            tsmd_rowid = sqlite3_column_int(stmt_timeseriesmetadata.stmtp, 0);
            tsmd_name = (char *)sqlite3_column_text(stmt_timeseriesmetadata.stmtp, 1);
            tsmd_rowcnt = sqlite3_column_int(stmt_timeseriesmetadata.stmtp, 2);
            tsmd_processed = sqlite3_column_int(stmt_timeseriesmetadata.stmtp, 3);

            printf("Processing rowid %d name %s rowcnt %d processed %d\n",
                    tsmd_rowid, tsmd_name, tsmd_rowcnt, tsmd_processed);


            switch(pass) {

                case 1:
                    update_day_pass1(tsmd_name);
                    break;
                case 2:
                    begin_transaction();
                        update_day_pass2(tsmd_name);
                    end_transaction();
                    break;
                case 3:
                    update_day_pass3(tsmd_name);
                    break;
                default:
                    printf("invalude pass number %d\n", pass);
                    exit(1);
            }
        }

    } while (ec == SQLITE_ROW);

    if (ec != SQLITE_DONE) {
        APPERR("step", stmt_timeseriesmetadata.sql, ec);
        exit(1);
    }

    ec = FINALIZE(stmt_timeseriesmetadata);
    if (ec != SQLITE_OK) {
        APPERR("finalize", stmt_timeseriesmetadata.sql, ec);
        exit(1);
    }

}