Example #1
0
/**
 * Copies from device memory to device memory. dstDevice and srcDevice are the 
 * base pointers of the destination and source, respectively. ByteCount 
 * specifies the number of bytes to copy. Note that this function is 
 * asynchronous.
 *
 * Parameters:
 * dstDevice - Destination device pointer
 * srcDevice - Source device pointer
 * ByteCount - Size of memory copy in bytes
 *
 * Returns:
 * CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, 
 * CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE 
 */
CUresult cuMemcpyDtoD_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, unsigned int ByteCount)
{
	CUresult res;
	struct CUctx_st *ctx;
	Ghandle handle;
	uint64_t dst_addr = dstDevice;
	uint64_t src_addr = srcDevice;
	uint32_t size = ByteCount;

	if (!gdev_initialized)
		return CUDA_ERROR_NOT_INITIALIZED;

	res = cuCtxGetCurrent(&ctx);
	if (res != CUDA_SUCCESS)
		return res;

	if (!dst_addr || !src_addr || !size)
		return CUDA_ERROR_INVALID_VALUE;

	handle = ctx->gdev_handle;

	if (gmemcpy(handle, dst_addr, src_addr, size))
		return CUDA_ERROR_UNKNOWN;

	return CUDA_SUCCESS;
}
Example #2
0
/**
 * @function GUI_AddKey
 * @brief ... add a key. Not safe outside the keyboard macro; that's why the file is not in the <widget> folder
 * @param const rect_st *rec: key dimension
 * @param const uint8_t *glyph: glyph array (size KBD_MAP_COUNT). One glyph per map
 * @return g_obj_st: NULL if error, pointer to the generic object otherwise
 */
g_obj_st /*@null@*/ *GUI_AddKey(const rect_st *rec, const uint8_t *glyph) {

  g_obj_st *g_obj = NULL, *res = NULL;
  key_st *key = NULL;

  /*check parameters*/
  if(rec != NULL && glyph != NULL && pMapId != NULL) {

    /*allocate a generic object*/
    g_obj = GUI_AddGenericObject();
    if(g_obj != NULL) {

      /*allocate a key*/
      key = salloc(sizeof(key_st));
      if(key != NULL) {

        /*key settings*/
        gmemcpy(key->glyph, glyph, KBD_MAP_COUNT * sizeof(key->glyph[0]));

        /*linkage between generic obj & key*/
        g_obj->rec = *rec;
        g_obj->draw = KeyDraw;
        g_obj->task = NULL;
        g_obj->obj = key;
        res = g_obj;
      }
    }
  }

  return res;
}
Example #3
0
//----------------------------------------------------------------------------
// duplicate string
//----------------------------------------------------------------------------
tChar* xstrndup(tCChar* pStr, tUint32 cbStr)
{
	tChar	 *pstr = 0;

	if (pStr && cbStr && (pstr = (tChar*) malloc(cbStr + 1))) {
		gmemcpy(pstr, pStr, cbStr);
    *(pstr + cbStr) = '\0';
    } // if

	return pstr;
  } // xstrndup