Example #1
0
/*-------------------------------------------------------------------------
 * Function:	test_noconv
 *
 * Purpose:	Tests creation of datasets when no conversion is present.
 *
 * Return:	Success:	0
 *
 *		Failure:	number of errors
 *
 * Programmer:	Robb Matzke
 *              Monday, January  4, 1999
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static int
test_noconv(hid_t file)
{
    hid_t	cwg=-1, type=-1, space=-1, dset=-1;
    c_e1	val;
    static c_e1	data1[]={E1_RED,   E1_GREEN, E1_BLUE,  E1_GREEN, E1_WHITE,
			 E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE,  E1_RED,
			 E1_RED,   E1_BLUE,  E1_GREEN, E1_BLACK, E1_WHITE,
			 E1_RED,   E1_WHITE, E1_GREEN, E1_GREEN, E1_BLUE};
    c_e1	data2[NELMTS(data1)];
    hsize_t	ds_size[1]={NELMTS(data1)};
    size_t	i;

    TESTING("no-conversion datasets");
    if ((cwg=H5Gcreate(file, "test_noconv", 0))<0) goto error;

    if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error;
    if (H5Tenum_insert(type, "RED",   CPTR(val, E1_RED  ))<0) goto error;
    if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN))<0) goto error;
    if (H5Tenum_insert(type, "BLUE",  CPTR(val, E1_BLUE ))<0) goto error;
    if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE))<0) goto error;
    if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK))<0) goto error;

    if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error;
    if ((dset=H5Dcreate(cwg, "color_table", type, space, H5P_DEFAULT))<0)
	goto error;
    if (H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1)<0) goto error;
    if (H5Dread(dset, type, space, space, H5P_DEFAULT, data2)<0) goto error;

    for (i=0; i<ds_size[0]; i++) {
	if (data1[i]!=data2[i]) {
	    H5_FAILED();
	    printf("    data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
		   (unsigned long)i, (int)(data1[i]),
		   (unsigned long)i, (int)(data2[i]));
	    goto error;
	}
    }

    if (H5Dclose(dset)<0) goto error;
    if (H5Sclose(space)<0) goto error;
    if (H5Tclose(type)<0) goto error;
    if (H5Gclose(cwg)<0) goto error;
    PASSED();
    return 0;

 error:
    H5E_BEGIN_TRY {
	H5Dclose(dset);
	H5Sclose(space);
	H5Tclose(type);
	H5Gclose(cwg);
    } H5E_END_TRY;
    return 1;
}
Example #2
0
static obj_ptr _load(obj_ptr arg, obj_ptr env)
{
    if (NSTRINGP(arg))
        return MKERROR(MKSTRING("Expected a string argument in (load ...)"), arg);

    return _load_imp(CPTR(arg), env);
}
Example #3
0
void p_nearest(struct cache *ibuffer,	/* input buffer                  */
	       void *obufptr,	/* ptr in output buffer          */
	       int cell_type,	/* raster map type of obufptr    */
	       double *col_idx,	/* column index in input matrix  */
	       double *row_idx,	/* row index in input matrix     */
	       struct Cell_head *cellhd	/* cell header of input layer    */
    )
{
    int row, col;		/* row/col of nearest neighbor   */
    FCELL *cellp;

    /* cut indices to integer */
    row = (int)floor(*row_idx);
    col = (int)floor(*col_idx);

    /* check for out of bounds - if out of bounds set NULL value     */
    if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
	G_set_null_value(obufptr, 1, cell_type);
	return;
    }

    cellp = CPTR(ibuffer, row, col);

    if (G_is_f_null_value(cellp)) {
	G_set_null_value(obufptr, 1, cell_type);
	return;
    }

    G_set_raster_value_f(obufptr, *cellp, cell_type);
}
int searchCubeRotations(GList** Cubes){
	int i,unique;
	GList *current, *gl;
	int sorted_current[12], sorted_gl[12];
	
	// Phase 1 - set all duplicate flags to zero
	for(current = *Cubes; current != NULL; current = g_list_next(current) )
		CPTR(current)->duplicate = 0;
		
	// Phase 2 - Pairwise scan of list. Set duplicate flags as required
	for(current = *Cubes; current != NULL; current = g_list_next(current) ) {
		if(CPTR(current)->duplicate == 1) continue;
		
		// setup a sorted list of primes from scube
		for(i=0; i<12; i++) sorted_current[i] = CPTR(current)->Signature[i];
		qsort(sorted_current, 12, sizeof(int), compare_int);
		
		for(gl = g_list_next(current); gl != NULL; gl = g_list_next(gl)) {			
			if(CPTR(gl)->duplicate == 1) continue;	// ignore if already a duplicate.
			
			// setup a sorted list of primes from scube
			for(i=0; i<12; i++) sorted_gl[i] = CPTR(gl)->Signature[i];
			qsort(sorted_gl, 12, sizeof(int), compare_int);
		
			
			CPTR(gl)->duplicate = 1;	// assume is a duplicate
			for(i=0; i<12; i++) {
				if(sorted_current[i] != sorted_gl[i]) {
					// found a difference
					CPTR(gl)->duplicate = 0;
					// next cube
					break;
				}
			}// for i
		}// for gl
	}// for current

	// Phase 3 - Rescan Cubes. Report size of list and number of uniques(families?).
	unique = 0;
	for(current = *Cubes; current != NULL; current = g_list_next(current) )
		if( CPTR(current)->duplicate == 0) unique++;
		
	// printf("Cubes: List Size %d Uniques: %d\n\n", g_list_length(*Cubes), unique);
	
	// Phase 4 - return number of uniques	
	return unique;
}
Example #5
0
void p_cubic(struct cache *ibuffer,	/* input buffer                  */
	     void *obufptr,	/* ptr in output buffer          */
	     int cell_type,	/* raster map type of obufptr    */
	     double *row_idx,	/* row index (decimal)           */
	     double *col_idx,	/* column index (decimal)        */
	     struct Cell_head *cellhd	/* information of output map     */
    )
{
    int row;			/* row indices for interp        */
    int col;			/* column indices for interp     */
    int i, j;
    DCELL t, u;			/* intermediate slope            */
    DCELL result;		/* result of interpolation       */
    DCELL val[4];		/* buffer for temporary values   */
    DCELL cell[4][4];

    /* cut indices to integer */
    row = (int)floor(*row_idx - 0.5);
    col = (int)floor(*col_idx - 0.5);

    /* check for out of bounds of map - if out of bounds set NULL value     */
    if (row - 1 < 0 || row + 2 >= cellhd->rows ||
	col - 1 < 0 || col + 2 >= cellhd->cols) {
	G_set_null_value(obufptr, 1, cell_type);
	return;
    }

    for (i = 0; i < 4; i++)
	for (j = 0; j < 4; j++) {
	    const DCELL *cellp = CPTR(ibuffer, row - 1 + i, col - 1 + j);
	    if (G_is_d_null_value(cellp)) {
		G_set_null_value(obufptr, 1, cell_type);
		return;
	    }
	    cell[i][j] = *cellp;
	}

    /* do the interpolation  */
    t = *col_idx - 0.5 - col;
    u = *row_idx - 0.5 - row;

    for (i = 0; i < 4; i++) {
	val[i] = G_interp_cubic(t, cell[i][0], cell[i][1], cell[i][2], cell[i][3]);
    }

    result = G_interp_cubic(u, val[0], val[1], val[2], val[3]);

    G_set_raster_value_d(obufptr, result, cell_type);
}
Example #6
0
void p_bilinear(struct cache *ibuffer,	/* input buffer                  */
		void *obufptr,	/* ptr in output buffer          */
		int cell_type,	/* raster map type of obufptr    */
		double *col_idx,	/* column index          */
		double *row_idx,	/* row index                     */
		struct Cell_head *cellhd	/* information of output map     */
    )
{
    int row;			/* row indices for interp        */
    int col;			/* column indices for interp     */
    int i, j;
    FCELL t, u;			/* intermediate slope            */
    FCELL result;		/* result of interpolation       */
    FCELL c[2][2];

    /* cut indices to integer */
    row = (int)floor(*row_idx - 0.5);
    col = (int)floor(*col_idx - 0.5);

    /* check for out of bounds - if out of bounds set NULL value and return */
    if (row < 0 || row + 1 >= cellhd->rows || col < 0 || col + 1 >= cellhd->cols) {
	G_set_null_value(obufptr, 1, cell_type);
	return;
    }

    for (i = 0; i < 2; i++)
	for (j = 0; j < 2; j++) {
	    const FCELL *cellp = CPTR(ibuffer, row + i, col + j);
	    if (G_is_f_null_value(cellp)) {
		G_set_null_value(obufptr, 1, cell_type);
		return;
	    }
	    c[i][j] = *cellp;
	}

    /* do the interpolation  */
    t = *col_idx - 0.5 - col;
    u = *row_idx - 0.5 - row;

    result = G_interp_bilinear(t, u, c[0][0], c[0][1], c[1][0], c[1][1]);

    G_set_raster_value_f(obufptr, result, cell_type);
}
Example #7
0
void p_cubic_f(struct cache *ibuffer,	/* input buffer                  */
		void *obufptr,	/* ptr in output buffer          */
		int cell_type,	/* raster map type of obufptr    */
		double *row_idx,	/* row index                     */
		double *col_idx,	/* column index          */
	    struct Cell_head *cellhd	/* cell header of input layer    */
    )
{
    /* start nearest neighbor to do some basic tests */
    int row, col;		/* row/col of nearest neighbor   */
    DCELL *cellp, cell;

    /* cut indices to integer */
    row = (int)floor(*row_idx);
    col = (int)floor(*col_idx);

    /* check for out of bounds - if out of bounds set NULL value     */
    if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
        G_set_null_value(obufptr, 1, cell_type);
        return;
    }

    cellp = CPTR(ibuffer, row, col);
    /* if nearest is null, all the other interps will be null */
    if (G_is_d_null_value(cellp)) {
        G_set_null_value(obufptr, 1, cell_type);
        return;
    }
    cell = *cellp;
    
    p_cubic(ibuffer, obufptr, cell_type, row_idx, col_idx, cellhd);
    /* fallback to bilinear if cubic is null */
    if (G_is_d_null_value(obufptr)) {
        p_bilinear(ibuffer, obufptr, cell_type, row_idx, col_idx, cellhd);
        /* fallback to nearest if bilinear is null */
	if (G_is_d_null_value(obufptr))
	    G_set_raster_value_d(obufptr, cell, cell_type);
    }
}
Example #8
0
/*-------------------------------------------------------------------------
 * Function:	test_named
 *
 * Purpose:	Create an enumeration data type and store it in the file.
 *
 * Return:	Success:	0
 *
 *		Failure:	number of errors
 *
 * Programmer:	Robb Matzke
 *              Wednesday, December 23, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static int
test_named(hid_t file)
{
    hid_t	type=-1, cwg=-1;
    c_e1	val;
    signed char	val8;

    TESTING("named enumeration types");
    if ((cwg=H5Gcreate(file, "test_named", 0))<0) goto error;

    /* A native integer */
    if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error;
    if (H5Tenum_insert(type, "RED",   CPTR(val, E1_RED  ))<0) goto error;
    if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN))<0) goto error;
    if (H5Tenum_insert(type, "BLUE",  CPTR(val, E1_BLUE ))<0) goto error;
    if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE))<0) goto error;
    if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK))<0) goto error;
    if (H5Tcommit(cwg, "e1_a", type)<0) goto error;
    if (H5Tclose(type)<0) goto error;

    /* A smaller type */
    if ((type = H5Tcreate(H5T_ENUM, 1))<0) goto error;
    if (H5Tenum_insert(type, "RED",   CPTR(val8, E1_RED  ))<0) goto error;
    if (H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN))<0) goto error;
    if (H5Tenum_insert(type, "BLUE",  CPTR(val8, E1_BLUE ))<0) goto error;
    if (H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE))<0) goto error;
    if (H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK))<0) goto error;
    if (H5Tcommit(cwg, "e1_b", type)<0) goto error;
    if (H5Tclose(type)<0) goto error;

    /* A non-native type */
    if (H5T_ORDER_BE==H5Tget_order(H5T_NATIVE_INT)) {
	if ((type = H5Tenum_create(H5T_STD_U8LE))<0) goto error;
    } else {
	if ((type = H5Tenum_create(H5T_STD_U8BE))<0) goto error;
    }
    if (H5Tenum_insert(type, "RED",   CPTR(val8, E1_RED  ))<0) goto error;
    if (H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN))<0) goto error;
    if (H5Tenum_insert(type, "BLUE",  CPTR(val8, E1_BLUE ))<0) goto error;
    if (H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE))<0) goto error;
    if (H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK))<0) goto error;
    if (H5Tcommit(cwg, "e1_c", type)<0) goto error;
    if (H5Tclose(type)<0) goto error;

    if (H5Gclose(cwg)<0) goto error;
    PASSED();
    return 0;

 error:
    H5E_BEGIN_TRY {
	H5Tclose(type);
	H5Gclose(cwg);
    } H5E_END_TRY;
    return 1;
}
Example #9
0
/*-------------------------------------------------------------------------
 * Function:	test_tr2
 *
 * Purpose:	Tests conversions that use the O(log N) lookup function.
 *
 * Return:	Success:	0
 *
 *		Failure:	number of errors
 *
 * Programmer:	Robb Matzke
 *              Tuesday, January  5, 1999
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static int
test_tr2(hid_t file)
{
    hid_t	cwg=-1, m_type=-1, f_type=-1, space=-1, dset=-1;
    hsize_t	ds_size[1]={10};
    size_t	i;
    c_e1	val1;
    int		val2;
    static c_e1	data1[10]={E1_RED,   E1_GREEN, E1_BLUE,  E1_GREEN, E1_WHITE,
			   E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE,  E1_RED};
    c_e1	data2[10];

    TESTING("O(log N) converions");
    if ((cwg=H5Gcreate(file, "test_tr2", 0))<0) goto error;

    if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error;
    if (H5Tenum_insert(m_type, "RED",   CPTR(val1, E1_RED  ))<0) goto error;
    if (H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN))<0) goto error;
    if (H5Tenum_insert(m_type, "BLUE",  CPTR(val1, E1_BLUE ))<0) goto error;
    if (H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE))<0) goto error;
    if (H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK))<0) goto error;

    if ((f_type = H5Tcreate(H5T_ENUM, sizeof(int)))<0) goto error;
    if (H5Tenum_insert(f_type, "RED",   CPTR(val2, 1050))<0) goto error;
    if (H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040))<0) goto error;
    if (H5Tenum_insert(f_type, "BLUE",  CPTR(val2, 1030))<0) goto error;
    if (H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020))<0) goto error;
    if (H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010))<0) goto error;

    if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error;
    if ((dset=H5Dcreate(cwg, "color_table", f_type, space, H5P_DEFAULT))<0)
	goto error;
    if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1)<0) goto error;
    if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2)<0) goto error;

    for (i=0; i<ds_size[0]; i++) {
	if (data1[i]!=data2[i]) {
	    H5_FAILED();
	    printf("    data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
		   (unsigned long)i, (int)(data1[i]),
		   (unsigned long)i, (int)(data2[i]));
	    goto error;
	}
    }

    if (H5Dclose(dset)<0) goto error;
    if (H5Sclose(space)<0) goto error;
    if (H5Tclose(m_type)<0) goto error;
    if (H5Tclose(f_type)<0) goto error;
    if (H5Gclose(cwg)<0) goto error;
    PASSED();
    return 0;

 error:
    H5E_BEGIN_TRY {
	H5Dclose(dset);
	H5Sclose(space);
	H5Tclose(m_type);
	H5Tclose(f_type);
	H5Gclose(cwg);
    } H5E_END_TRY;
    return 1;
}
Example #10
0
int main(int argc, char **argv) {

    long Target = 75;
    long moving_target = Target;
    int i,rc;
    const int Nthreads = 32;

    pthread_t thread_id[Nthreads];
    GSList *gl[Nthreads];

    char fname[64];
    FILE *fout;
    int zeros[13]= {0,0,0,0,0,0,0,0,0,0,0,0,0};

    if(argc==2) {
        Target = strtol(argv[1],NULL,10);
    }
    printf("Target value is %ld\n",Target);

    for(i=0; i<Nthreads; i++) {
        rc = pthread_create( &thread_id[i], NULL, searchScubes, (void*)moving_target);
        if(rc != 0) printf("Error Thread create %d: rc = %d\n",i,rc);
        moving_target += 2;
    }

    for(i=0; i<Nthreads; i++) {
        rc = pthread_join( thread_id[i], (void**)&gl[i]);
        if(rc != 0) printf("Error Thread join %d: rc = %d\n",i,rc);
        moving_target = Target+(i*2);

        if(gl[i] != NULL) {
            // code to write each set of signatures to a unique file.
            // filename Scube_%03d.int13
            // for each signature write an array of 13 integers to disk
            // incorporate the code into the pthread_join section

            sprintf(fname,"./results/multi/Scube_%03d.int13",CPTR(gl[i])->Signature[12]);
            fout = fopen(fname,"w");
            if(fout != NULL) {
                fwrite(CPTR(gl[i])->Signature, sizeof(int), 13, fout);
                fclose(fout);
            }
        } else {	// No cubes found - write signature of 12 zeros and target
            zeros[12]=Target+(i*2);
            sprintf(fname,"./results/zero/Scube_%03ld.int13",Target+(i*2));
            fout = fopen(fname,"w");
            fwrite(zeros, sizeof(int), 13, fout);
            fclose(fout);
        }

    }

#if(0)
    // This section will print any cubes found.
    GList *cubes;
    for(i=0; i<Nthreads; i++) {
        cubes = gl[i];
        while(cubes != NULL) {
            if(CPTR(cubes)->duplicate == 0) {
                int x;
                printf("\tScube signature:\n");
                for(x=0; x<12; x++) printf("%02d ",CPTR(cubes)->Signature[x]);
                printf("\nTarget: %02d\n",CPTR(cubes)->Signature[12]);
                printCube(CPTR(cubes));
                printf("\n");
            }
            cubes = g_list_next(cubes);
        }
    }
#endif

    // Cleanup
    pthread_exit(NULL);

}
Example #11
0
int rectify(char *name, char *mapset, struct cache *ebuffer,
            double aver_z, char *result, char *interp_method)
{
    struct Cell_head cellhd;
    int ncols, nrows;
    int row, col;
    double row_idx, col_idx;
    int infd, outfd;
    RASTER_MAP_TYPE map_type;
    int cell_size;
    void *trast, *tptr;
    double n1, e1, z1;
    double nx, ex, nx1, ex1, zx1;
    struct cache *ibuffer;

    select_current_env();
    Rast_get_cellhd(name, mapset, &cellhd);

    /* open the file to be rectified
     * set window to cellhd first to be able to read file exactly
     */
    Rast_set_input_window(&cellhd);
    infd = Rast_open_old(name, mapset);
    map_type = Rast_get_map_type(infd);
    cell_size = Rast_cell_size(map_type);

    ibuffer = readcell(infd, seg_mb_img, 0);

    Rast_close(infd);		/* (pmx) 17 april 2000 */

    G_message(_("Rectify <%s@%s> (location <%s>)"),
	      name, mapset, G_location());
    select_target_env();
    G_set_window(&target_window);
    G_message(_("into  <%s@%s> (location <%s>) ..."),
	      result, G_mapset(), G_location());

    nrows = target_window.rows;
    ncols = target_window.cols;

    if (strcmp(interp_method, "nearest") != 0) {
	map_type = DCELL_TYPE;
	cell_size = Rast_cell_size(map_type);
    }

    /* open the result file into target window
     * this open must be first since we change the window later
     * raster maps open for writing are not affected by window changes
     * but those open for reading are
     */

    outfd = Rast_open_new(result, map_type);
    trast = Rast_allocate_output_buf(map_type);

    for (row = 0; row < nrows; row++) {
	n1 = target_window.north - (row + 0.5) * target_window.ns_res;

	G_percent(row, nrows, 2);

	Rast_set_null_value(trast, ncols, map_type);
	tptr = trast;
	for (col = 0; col < ncols; col++) {
	    DCELL *zp = CPTR(ebuffer, row, col);

	    e1 = target_window.west + (col + 0.5) * target_window.ew_res;
	    
	    /* if target cell has no elevation, set to aver_z */
	    if (Rast_is_d_null_value(zp)) {
		G_warning(_("No elevation available at row = %d, col = %d"), row, col);
		z1 = aver_z;
	    }
	    else
		z1 = *zp;

	    /* target coordinates e1, n1 to photo coordinates ex1, nx1 */
	    I_ortho_ref(e1, n1, z1, &ex1, &nx1, &zx1, &group.camera_ref,
			group.XC, group.YC, group.ZC, group.M);

	    G_debug(5, "\t\tAfter ortho ref (photo cords): ex = %f \t nx =  %f",
		    ex1, nx1);

	    /* photo coordinates ex1, nx1 to image coordinates ex, nx */
	    I_georef(ex1, nx1, &ex, &nx, group.E21, group.N21, 1);

	    G_debug(5, "\t\tAfter geo ref: ex = %f \t nx =  %f", ex, nx);

	    /* convert to row/column indices of source raster */
	    row_idx = (cellhd.north - nx) / cellhd.ns_res;
	    col_idx = (ex - cellhd.west) / cellhd.ew_res;

	    /* resample data point */
	    interpolate(ibuffer, tptr, map_type, &row_idx, &col_idx, &cellhd);

	    tptr = G_incr_void_ptr(tptr, cell_size);
	}
	Rast_put_row(outfd, trast, map_type);
    }
    G_percent(1, 1, 1);

    Rast_close(outfd);		/* (pmx) 17 april 2000 */
    G_free(trast);

    close(ibuffer->fd);
    release_cache(ibuffer);

    Rast_get_cellhd(result, G_mapset(), &cellhd);

    if (cellhd.proj == 0) {	/* x,y imagery */
	cellhd.proj = target_window.proj;
	cellhd.zone = target_window.zone;
    }

    if (target_window.proj != cellhd.proj) {
	cellhd.proj = target_window.proj;
	G_warning(_("Raster map <%s@%s>: projection don't match current settings"),
		  name, mapset);
    }

    if (target_window.zone != cellhd.zone) {
	cellhd.zone = target_window.zone;
	G_warning(_("Raster map <%s@%s>: zone don't match current settings"),
		  name, mapset);
    }

    select_current_env();

    return 1;
}
Example #12
0
[[gnu::always_inline]]
static uint64_t make_mask(size_t bits_set)
{
	return ~0ull >> (64 - bits_set);
}

[[gnu::always_inline]]
static bool x86_clobber_bit()
{
	bool b;
	return b;
}

[[gnu::always_inline]]
static uint64_t x86_read_reg(CPTR(x86_regs) regs, x86_reg reg)
{
	const x86_reg_info* reg_info = &x86_register_table[reg];
	const x86_reg_selector* selector = &reg_info->reg;
	const x86_qword_reg* r64 = &(regs->*selector->qword);
	if (reg_info->size == 8)
	{
		return r64->qword;
	}
	
	const x86_dword_reg* r32 = &(r64->*selector->dword);
	if (reg_info->size == 4)
	{
		return r32->dword;
	}