Example #1
0
CUresult CuDeviceMem::ToDevice(size_t sourceOffset, CuDeviceMem* target,
	size_t targetOffset, size_t size) {

	if(Context() != target->Context()) return CUDA_ERROR_INVALID_CONTEXT;
	if(targetOffset + size > target->Size()) return CUDA_ERROR_INVALID_VALUE;
	
	return ToDevice(sourceOffset, target->Handle() + targetOffset, size);
}
Example #2
0
File: parse.c Project: aosm/X11apps
int
ParseInput(DviWidget dw)
{
	int		n, k;
	int		c;
	char		Buffer[BUFSIZ];
	int		NextPage;
	int		prevFont;
	int		otherc;
	unsigned char	tc;

	/*
	 * make sure some state exists
	 */

	if (!dw->dvi.state)
	    push_env (dw);
	for (;;) {
		switch (DviGetC(dw, &c)) {
		case '\n':	
			break;
		case ' ':	/* when input is text */
		case 0:		/* occasional noise creeps in */
			break;
		case '{':	/* push down current environment */
			push_env(dw);
			break;
		case '}':
			pop_env(dw);
			break;
		/*
		 * two motion digits plus a character
		 */
		case '0': case '1': case '2': case '3': case '4':
		case '5': case '6': case '7': case '8': case '9':
			HorizontalMove(dw, (c-'0')*10 +
					   DviGetC(dw,&otherc)-'0');
			/* fall through */
		case 'c':	/* single ascii character */
			(void) DviGetC(dw,&c);
		    	if (c == ' ')
			    break;
			tc = c;
			PutCharacters (dw, &tc, 1);
			break;
		case 'C':
			GetWord(dw, Buffer, BUFSIZ);
			{
	    	    	    DviCharNameMap	*map;
			    int			i;
			    unsigned char	*ligature;
    	    	    
			    c = -1;
	    	    	    map = QueryFontMap (dw, dw->dvi.state->font_number);
	    	    	    if (map)
			    {
		    	    	c = DviCharIndex (map, Buffer);
				if (c == -1)
				{
				    ligature = DviCharIsLigature (map, Buffer);
				    if (ligature) {
					i = strlen ((char *) ligature);
					PutCharacters (dw, ligature, i);
					break;
   				    }
				}
			    }
			    prevFont = -1;
	    	    	    if (c == -1) {
			    	for (i = 1; (map = QueryFontMap (dw, i)); i++)
				    if (map->special)
				    	if ((c = DviCharIndex (map, Buffer)) != -1) {
					    prevFont = dw->dvi.state->font_number;
					    dw->dvi.state->font_number = i;
					    break;
				    	}
			    }
			    if (c != -1)
			    {
				tc = c;
				PutCharacters (dw, &tc, 1);
			    }
			    if (prevFont != -1)
				dw->dvi.state->font_number = prevFont;
			}
			break;
		case 'D':	/* draw function */
			GetLine(dw, Buffer, BUFSIZ);
			ParseDrawFunction(dw, Buffer);
			break;
		case 's':	/* ignore fractional sizes */
			n = GetNumber(dw);
			if (!dw->dvi.size_scale)
			{
			    static int	guesses[] = { 1, 4, 100, 1000, 1 };
			    int		i;

			    for (i = 0; i < 4; i++)
				if (8 <= n/guesses[i] && n/guesses[i] <= 24)
				{
				    break;
				}
    			    dw->dvi.size_scale = guesses[i];
			}
			dw->dvi.state->font_size = n;
			dw->dvi.state->line_width = n * (dw->dvi.device_resolution / 
							 (720 * dw->dvi.size_scale));
			break;
		case 'f':
			n = GetNumber(dw);
			dw->dvi.state->font_number = n;
			break;
		case 'H':	/* absolute horizontal motion */
			k = GetNumber(dw);
			HorizontalGoto(dw, k);
			break;
		case 'h':	/* relative horizontal motion */
			k = GetNumber(dw);
			HorizontalMove(dw, k);
			break;
		case 'w':	/* word space */
			break;
		case 'V':
			n = GetNumber(dw);
			VerticalGoto(dw, n);
			break;
		case 'v':
			n = GetNumber(dw);
			VerticalMove(dw, n);
			break;
		case 'P':	/* new spread */
			break;
		case 'p':	/* new page */
			(void) GetNumber(dw);
			NextPage = dw->dvi.current_page + 1;
			RememberPagePosition(dw, NextPage);
			FlushCharCache (dw);
			return(NextPage);
		case 'n':	/* end of line */
			GetNumber(dw);
			GetNumber(dw);
			HorizontalGoto(dw, 0);
			break;
		case '#':	/* comment */
		case 'F':	/* file info */
			GetLine(dw, NULL, 0);
			break;
		case 't':	/* text */
			GetLine(dw, Buffer, BUFSIZ);
			PutCharacters (dw, (unsigned char *)Buffer,
				       strlen (Buffer));
			dw->dvi.state->x = ToDevice (dw, dw->dvi.cache.x);
			break;
		case 'x':	/* device control */
			ParseDeviceControl(dw);
			break;
		case EOF:
			dw->dvi.last_page = dw->dvi.current_page;
			FlushCharCache (dw);
			return dw->dvi.current_page;
		default:
			GetLine (dw, Buffer, BUFSIZ);
			fprintf (stderr, "Unknown command %s\n", Buffer);
			break;
		}
	}
}
Example #3
0
CUresult CuDeviceMem::ToDevice(CuDeviceMem* target) {
	if(Context() != target->Context()) return CUDA_ERROR_INVALID_CONTEXT;
	if(Size() != target->Size()) return CUDA_ERROR_INVALID_VALUE;
	return ToDevice(target->Handle());
}