• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CHKERR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CHKERR函数的典型用法代码示例。如果您正苦于以下问题:C++ CHKERR函数的具体用法?C++ CHKERR怎么用?C++ CHKERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CHKERR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_chunk_setup

void test_chunk_setup(cl_context context, cl_command_queue queue, size_t size, size_t offset, int isGPU)
{
	if(size == 0)
		return;
	cl_mem* d_a = isGPU ? &dg_a : &dc_a;
	cl_mem* d_b = isGPU ? &dg_b : &dc_b;
	cl_mem_flags a_flags = CL_MEM_READ_WRITE;
	cl_mem_flags b_flags = CL_MEM_READ_WRITE;
	void* a_mem = NULL;
	void* b_mem = NULL;

	if(!isGPU)
	{
		a_flags |= CL_MEM_USE_HOST_PTR;
		a_mem = h_a;
	}

	int err;
	*d_a = clCreateBuffer(context, a_flags, sizeof(*h_a) * size, a_mem, &err);
	CHKERR(err, "Failed to create chunk buffers!");
	*d_b = clCreateBuffer(context, b_flags, sizeof(*h_b) * size, b_mem, &err);
	CHKERR(err, "Failed to create chunk buffers!");

	err = clEnqueueWriteBuffer(queue, *d_a, CL_FALSE, 0, sizeof(*h_a) * size, h_a + offset, 0, NULL, NULL);
	CHKERR(err, "Failed to write chunk buffer A!");
}
开发者ID:BillTheBest,项目名称:load-balancer,代码行数:26,代码来源:Reduce.c


示例2: CCMIOReadOptstr

ErrorCode ReadCCMIO::get_str_option(const char *opt_str, EntityHandle seth, Tag &tag, 
                                    CCMIOID node, const char *other_tag_name)
{
  int len;
  CCMIOError error = kCCMIONoErr;
  std::vector<char> opt_string;
  if (kCCMIONoErr != CCMIOReadOptstr(NULL, node, opt_str, &len, NULL)) 
    return MB_SUCCESS;
    
  opt_string.resize(len);
  CCMIOReadOptstr(&error, node, opt_str, &len, &opt_string[0]);
  ErrorCode rval = MB_SUCCESS;
  if (!tag) {
    rval = mbImpl->tag_get_handle( other_tag_name ? other_tag_name : opt_str,
                                   NAME_TAG_SIZE, MB_TYPE_OPAQUE, tag,
                                   MB_TAG_SPARSE|MB_TAG_CREAT );
    CHKERR(rval, NULL);
  }

  if (opt_string.size() > NAME_TAG_SIZE) opt_string[NAME_TAG_SIZE-1] = '\0';
  else (opt_string.resize(NAME_TAG_SIZE, '\0'));

  rval = mbImpl->tag_set_data(tag, &seth, 1, &opt_string[0]);
  CHKERR(rval, NULL);

  return MB_SUCCESS;
}
开发者ID:chrismullins,项目名称:moab,代码行数:27,代码来源:ReadCCMIO.cpp


示例3: create_kernel

cl_kernel create_kernel(const char* filename, const char* kernel, const cl_context context, const cl_device_id device)
{
	cl_kernel kernel_compute;
	// Create a command queue
	cl_program program = createProgramFromSource(filename, context);

	// Build the program executable
	//int err = clBuildProgram(program, 1, &device, "-cl-opt-disable", NULL, NULL);
	int err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
	if (err == CL_BUILD_PROGRAM_FAILURE)
	{
		char *log;
		size_t logLen;
		err = clGetProgramBuildInfo(program, device_id_gpu, CL_PROGRAM_BUILD_LOG, 0, NULL, &logLen);
		log = (char *) malloc(sizeof(char)*logLen);
		err = clGetProgramBuildInfo(program, device_id_gpu, CL_PROGRAM_BUILD_LOG, logLen, (void *) log, NULL);
		fprintf(stdout, "CL Error %d: Failed to build program! Log:\n%s", err, log);
		free(log);
		exit(1);
	}
	CHKERR(err, "Failed to build program!");

	// Create the compute kernel in the program we wish to run
	kernel_compute = clCreateKernel(program, kernel, &err);
	CHKERR(err, "Failed to create a compute kernel!");
	
	return kernel_compute;
}
开发者ID:BillTheBest,项目名称:load-balancer,代码行数:28,代码来源:Reduce.c


示例4: Meta_SDcard_OP

void Meta_SDcard_OP(SDCARD_REQ *req, char *peer_buf, unsigned short peer_len)
{
    SDCARD_CNF cnf;
    int bufsz = 512;
    char fname[512];
    char buf[512];
	unsigned char cid[16];
	unsigned char csd[16];

    memset(&cnf, 0, sizeof(SDCARD_CNF));

    cnf.header.id = FT_SDCARD_CNF_ID;
    cnf.header.token = req->header.token;
    cnf.status = META_SUCCESS;

    sprintf(fname, "%s/cid", path);
    CHKERR(meta_sdcard_read_info(fname, buf, bufsz));
   	memcpy(cid,buf,16*sizeof(unsigned char));

    sprintf(fname, "%s/csd", path);
    CHKERR(meta_sdcard_read_info(fname, buf, bufsz));
    memcpy(csd,buf,16*sizeof(unsigned char));
	
    meta_sdcard_send_resp(&cnf);
    return;

error:
    cnf.status = META_FAILED;
    meta_sdcard_send_resp(&cnf);
    return;
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:31,代码来源:meta_sdcard.c


示例5: Sm_list_clear

int	Sm_list_clear(const char *fileName, int lineNbr, PsmPartition partition,
		PsmAddress list, SmListDeleteFn deleteFn, void *arg)
{
	CHKERR(partition);
	CHKERR(list);
	return wipeList(fileName, lineNbr, partition, list, deleteFn, arg, 0);
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:7,代码来源:smlist.c


示例6: op_func_group

herr_t op_func_group (hid_t loc_id, const char* objname, const H5L_info_t* /*info*/, void* /*ppar*/) {

  //struct param glopar;
  struct param* ppar;
  ppar = &glopar;

  int err;
  hid_t h5fi;
  hid_t h5fo;
  hid_t gid;
  H5G_stat_t statbuf;

  err = H5Gget_objinfo (loc_id, objname, 0, &statbuf); CHKERR(err);

  /* if object is group, open containers, create group, iterate over datasets, close */
  if (statbuf.type == H5G_GROUP) {
      h5fi = H5Fopen(((struct param *)ppar)->conti, H5F_ACC_RDONLY, H5P_DEFAULT); CHKRTN(h5fi < 0, FILEERR);
      h5fo = H5Fopen(((struct param *)ppar)->conto, H5F_ACC_RDWR, H5P_DEFAULT); CHKRTN(h5fo < 0, FILEERR);
      gid = H5Gcreate(h5fo, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHKRTN(gid < 0, ERR);
      strncpy(((struct param *)ppar)->grupi, objname, sizeof(((struct param *)ppar)->grupi) - 1);
      strncpy(((struct param *)ppar)->grupo, objname, sizeof(((struct param *)ppar)->grupo) - 1);
      err = H5Literate_by_name (h5fi, objname, H5_INDEX_NAME, H5_ITER_NATIVE, NULL, op_func_dset, (void *) ppar, NULL); CHKERR(err);
      err = H5Fclose(h5fo); CHKERR(err);
      err = H5Fclose(h5fi); CHKERR(err);
  }

  return EXIT_SUCCESS;
}
开发者ID:marandra,项目名称:image-conv-hfd5,代码行数:28,代码来源:bimconvfunct.c


示例7: test_chunk_kernel

void test_chunk_kernel(cl_context context, cl_command_queue queue, cl_device_id device, cl_kernel kernel, size_t size, size_t offset, int isGPU)
{
	if(size == 0)
		return;
	cl_mem* d_a = isGPU ? &dg_a : &dc_a;
	cl_mem* d_b = isGPU ? &dg_b : &dc_b;
	size_t chunk = isGPU ? 2 : size;

	cl_event* event = isGPU ? &event_gpu : &event_cpu;

	size_t local_size;
	clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &local_size, NULL);
	if(!isGPU)
		local_size = 1;

	int err = clSetKernelArg(kernel, 0, sizeof(cl_mem), d_a);
	err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), d_b);
	err |= clSetKernelArg(kernel, 2, sizeof(size_t), &size);
	err |= clSetKernelArg(kernel, 3, sizeof(size_t), &chunk);
	if(isGPU)
		err |= clSetKernelArg(kernel, 4, sizeof(reduce_t) * local_size * 2, NULL);
	CHKERR(err, "Errors setting kernel arguments");

	size_t groups = size / local_size / chunk + (size % (local_size*chunk) == 0 ? 0 : 1);
	size_t global_size = groups * local_size;
	err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global_size, &local_size, 0, NULL, event);
	CHKERR(err, "Failed to run kernel!");
	if(groups != 1)
	{
		cl_mem temp = *d_a;
		*d_a = *d_b;
		*d_b = temp;
		test_chunk_kernel(context, queue, device, kernel, groups, offset, isGPU);
	}
}
开发者ID:BillTheBest,项目名称:load-balancer,代码行数:35,代码来源:Reduce.c


示例8: ocdBuildProgramFromFile

cl_program ocdBuildProgramFromFile(cl_context context,cl_device_id device_id,const char* kernel_file_name)
{
	cl_int err;
	cl_program program;
	size_t kernelLength;
	char* kernelSource;
	FILE* kernel_fp;
	size_t items_read;

	#ifdef USE_AFPGA
		const char* kernel_file_mode = "rb";
	#else //CPU or GPU
		const char* kernel_file_mode = "r";
	#endif

	kernel_fp = fopen(kernel_file_name, kernel_file_mode);
	check(kernel_fp != NULL,"common_ocl.ocdBuildProgramFromFile() - Cannot open kernel file!");
	fseek(kernel_fp, 0, SEEK_END);
	kernelLength = (size_t) ftell(kernel_fp);
	kernelSource = malloc(sizeof(char)*kernelLength);
	check(kernelSource != NULL,"common_ocl.ocdBuildProgramFromFile() - Heap Overflow! Cannot allocate space for kernelSource.");
	rewind(kernel_fp);
	items_read = fread((void *) kernelSource, kernelLength, 1, kernel_fp);
	check(items_read == 1,"common_ocl.ocdBuildProgramFromFile() - Error reading from kernelFile");
	fclose(kernel_fp);

	/* Create the compute program from the source buffer */
	#ifdef USE_AFPGA //use Altera FPGA
		program = clCreateProgramWithBinary(context,1,&device_id,&kernelLength,(const unsigned char**)&kernelSource,NULL,&err);
	#else //CPU or GPU
		program = clCreateProgramWithSource(context, 1, (const char **) &kernelSource, &kernelLength, &err);
	#endif
	CHKERR(err, "common_ocl.ocdBuildProgramFromFile() - Failed to create a compute program!");

	/* Build the program executable */
	#ifdef USE_AFPGA //use Altera FPGA
		err = clBuildProgram(program,1,&device_id,"-DOPENCL -I.",NULL,NULL);
	#else
		err = clBuildProgram(program, 0, NULL, "-DOPENCL -I.", NULL, NULL);
	#endif
	if (err == CL_BUILD_PROGRAM_FAILURE)
	{
		char *buildLog;
		size_t logLen;
		err = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &logLen);
		buildLog = (char *) malloc(sizeof(char)*logLen);
		check(buildLog != NULL,"common_ocl.ocdBuildProgramFromFile() - Heap Overflow! Cannot allocate space for buildLog.");
		err = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, logLen, (void *) buildLog, NULL);
		fprintf(stderr, "CL Error %d: Failed to build program! Log:\n%s", err, buildLog);
		free(buildLog);
		exit(1);
	}
	CHKERR(err,"common_ocl.ocdBuildProgramFromFile() - Failed to build program!");

	free(kernelSource); /* Free kernel source */
	return program;
}
开发者ID:nz-ocl,项目名称:OpenDwarfs,代码行数:57,代码来源:common_ocl.c


示例9: map_vecs_Sprimme

TEMPLATE_PLEASE
int map_vecs_Sprimme(HSCALAR *V, int m, int nV, int ldV, HSCALAR *W, int n0,
      int n, int ldW, int *p, primme_context ctx) {

   int i;         /* Loop variable                                     */

   /* Compute the norm of the columns V(n0:n-1) */

   HREAL *Vnorms = NULL;
   CHKERR(Num_malloc_RHprimme(nV, &Vnorms, ctx));
   for (i = 0; i < nV; i++) {
      Vnorms[i] = sqrt(REAL_PART(
            Num_dot_SHprimme(m, &V[ldV * i], 1, &V[ldV * i], 1, ctx)));
   }
      
   /* Compute V'*W[n0:n-1] */

   HSCALAR *ip = NULL;
   CHKERR(Num_malloc_SHprimme(nV * (n - n0), &ip, ctx));
   Num_zero_matrix_SHprimme(ip, nV, n - n0, nV, ctx);
   CHKERR(Num_gemm_SHprimme("C", "N", nV, n - n0, m, 1.0, V, ldV, &W[ldW * n0],
         ldW, 0.0, ip, nV, ctx));

   for (i = n0; i < n; i++) {
      /* Find the j that maximizes ABS(V[j]'*W[i]/Vnorms[j]) and is not */
      /* in p(0:i-1)                                                    */

      int j, jmax=-1;
      HREAL ipmax = -1;
      for (j = 0; j < nV; j++) {
         HREAL ipij = ABS(ip[nV * (i - n0) + j]);
         if (ipij > ipmax * Vnorms[j]) {
            /* Check that j is not in p(0:i-1) */
            int k;
            for (k = 0; k < i && p[k] != j; k++)
               ;
            if (k < i) continue;

            /* Update ipmax and jmax */
            ipmax = fabs(ipij / Vnorms[j]);
            jmax = j;
         }
      }
      if (jmax < 0) {
         jmax = i;
      }

      /* Assign the map */

      p[i] = jmax;
   }
   
   CHKERR(Num_free_RHprimme(Vnorms, ctx));
   CHKERR(Num_free_SHprimme(ip, ctx));
    
   return 0;
}
开发者ID:primme,项目名称:primme,代码行数:57,代码来源:solve_projection.c


示例10: sm_list_prev

PsmAddress	sm_list_prev(PsmPartition partition, PsmAddress elt)
{
	SmListElt	*eltBuffer;

	CHKERR(partition);
	CHKERR(elt);
	eltBuffer = (SmListElt *) psp(partition, elt);
	CHKERR(eltBuffer);
	return eltBuffer->prev;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:10,代码来源:smlist.c


示例11: ltpei_parse_extension

int	ltpei_parse_extension(char **cursor, int *bytesRemaining, Lyst exts,
		unsigned int *extensionOffset)
{
	char			*initialCursor;
	LtpExtensionInbound	*extField;
	unsigned int		valueLength;

	CHKERR(cursor);
	CHKERR(*cursor);
	CHKERR(bytesRemaining);
	CHKERR(exts);
	if ((*bytesRemaining) < 1)
	{
		return 0;	/*	Corrupt.			*/
	}

	extField = MTAKE(sizeof(LtpExtensionInbound));
	if (extField == NULL)
	{
		return -1;	/*	Give up.			*/
	}

	initialCursor = *cursor;
	extField->offset = *extensionOffset;
	extField->tag = **cursor;
	(*cursor)++;
	(*bytesRemaining)--;
	extractSmallSdnv(&valueLength, cursor, bytesRemaining);
	if (valueLength == 0 || *bytesRemaining < valueLength)
	{
		return 0;	/*	Corrupt.			*/
	}

	extField->length = valueLength;
	extField->value = MTAKE(valueLength);
	if (extField->value == 0)
	{
		MRELEASE(extField);
		return -1;	/*	Give up.			*/
	}

	memcpy(extField->value, *cursor, valueLength);
	(*cursor) += valueLength;
	(*bytesRemaining) -= valueLength;
	if (lyst_insert_last(exts, extField) == NULL)
	{
		MRELEASE(extField->value);
		MRELEASE(extField);
		return -1;	/*	Give up.			*/
	}

	*extensionOffset += ((*cursor) - initialCursor);
	return 1;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:54,代码来源:ltpei.c


示例12: dtn2_updateRule

int	dtn2_updateRule(char *nodeNm, char *demux, FwdDirective *directive)
{
	Sdr		sdr = getIonsdr();
	char		nodeName[SDRSTRING_BUFSZ];
	Object		elt;
			OBJ_POINTER(Dtn2Plan, plan);
	Object		ruleAddr;
	Dtn2Rule	ruleBuf;

	CHKERR(nodeNm && demux && directive);
	if (*demux == '\0')
	{
		writeMemo("[?] Zero-length DTN2 rule demux.");
		return 0;
	}

	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] No plan defined for this node", nodeNm);
		return 0;
	}

	GET_OBJ_POINTER(sdr, Dtn2Plan, plan, sdr_list_data(sdr, elt));
	dtn2_findRule(nodeName, demux, plan, &ruleAddr, &elt);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Unknown rule", demux);
		return 0;
	}

	/*	All parameters validated, okay to update the rule.	*/

	sdr_stage(sdr, (char *) &ruleBuf, ruleAddr, sizeof(Dtn2Rule));
	dtn2_destroyDirective(&ruleBuf.directive);
	memcpy((char *) &ruleBuf.directive, (char *) directive,
			sizeof(FwdDirective));
	sdr_write(sdr, ruleAddr, (char *) &ruleBuf, sizeof(Dtn2Rule));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't update rule.", NULL);
		return -1;
	}

	return 1;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:54,代码来源:libdtn2fw.c


示例13: CCMIOSIZEC

ErrorCode ReadCCMIO::read_all_faces(CCMIOID topologyID, TupleList &vert_map, 
                                      TupleList &face_map
#ifndef TUPLE_LIST
                                      ,SenseList &sense_map
#endif
                                      , Range *new_faces) 
{
  CCMIOSize_t index = CCMIOSIZEC(0);
  CCMIOID faceID;
  ErrorCode rval;

    // get total # internal/bdy faces, size the face map accordingly
  int nint_faces = 0, nbdy_faces = 0;
  CCMIOSize_t nf;
  CCMIOError error = kCCMIONoErr;
  while (kCCMIONoErr == CCMIONextEntity(NULL, topologyID, kCCMIOBoundaryFaces, &index, 
                                        &faceID))
  {
    CCMIOEntitySize(&error, faceID, &nf, NULL);
    nbdy_faces = nbdy_faces + nf;
  }
  CCMIOGetEntity(&error, topologyID, kCCMIOInternalFaces, 0, &faceID);
  CCMIOEntitySize(&error, faceID, &nf, NULL);
  nint_faces = nint_faces + nf;
#ifdef TUPLE_LIST
  face_map.resize(2*nint_faces + nbdy_faces);
#endif
  
    // get multiple blocks of bdy faces
  index = CCMIOSIZEC(0);
  while (kCCMIONoErr == CCMIONextEntity(NULL, topologyID, kCCMIOBoundaryFaces, &index, 
                                        &faceID))
  {
    rval = read_faces(faceID, kCCMIOBoundaryFaces, vert_map, face_map
#ifndef TUPLE_LIST
                      , sense_map
#endif
                      , new_faces);
    CHKERR(rval, "Trouble reading boundary faces.");
  }
  
    // now get internal faces
  CCMIOGetEntity(&error, topologyID, kCCMIOInternalFaces, 0, &faceID);

  rval = read_faces(faceID, kCCMIOInternalFaces, vert_map,face_map
#ifndef TUPLE_LIST
                    , sense_map
#endif
                    , new_faces);
  CHKERR(rval, "Trouble reading internal faces.");

  return rval;
}
开发者ID:chrismullins,项目名称:moab,代码行数:53,代码来源:ReadCCMIO.cpp


示例14: dtn2_removeRule

int	dtn2_removeRule(char *nodeNm, char *demux)
{
	Sdr	sdr = getIonsdr();
	char	nodeName[SDRSTRING_BUFSZ];
	Object	elt;
		OBJ_POINTER(Dtn2Plan, plan);
	Object	ruleAddr;
		OBJ_POINTER(Dtn2Rule, rule);

	CHKERR(nodeNm && demux);
	if (*demux == '\0')
	{
		writeMemo("[?] Zero-length DTN2 rule demux.");
		return 0;
	}

	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] No plan defined for this node", nodeNm);
		return 0;
	}

	GET_OBJ_POINTER(sdr, Dtn2Plan, plan, sdr_list_data(sdr, elt));
	dtn2_findRule(nodeName, demux, plan, &ruleAddr, &elt);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Unknown rule", demux);
		return 0;
	}

	/*	All parameters validated, okay to remove the rule.	*/

	GET_OBJ_POINTER(sdr, Dtn2Rule, rule, ruleAddr);
	dtn2_destroyDirective(&(rule->directive));
	sdr_free(sdr, ruleAddr);
	sdr_list_delete(sdr, elt, NULL, NULL);
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't remove rule.", NULL);
		return -1;
	}

	return 1;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:53,代码来源:libdtn2fw.c


示例15: ltpei_add_xmit_trailer_extension

int	ltpei_add_xmit_trailer_extension(LtpXmitSeg *segment, char tag,
		int valueLength, char *value)
{
	Sdr 			sdr = getIonsdr();
	Sdnv			sdnv;
	LtpExtensionOutbound	extension;
	Object			addr;

	CHKERR(segment);
	CHKERR(ionLocked());
	encodeSdnv(&sdnv, valueLength);
	if (segment->pdu.trailerExtensions == 0)
	{
		if ((segment->pdu.trailerExtensions = sdr_list_create(sdr))
				== 0)
		{
			return -1;	/*	No space in SDR heap.	*/
		}
	}

	extension.tag = tag;
	extension.length = valueLength;
	if (valueLength == 0)
	{
		extension.value = 0;
	}
	else
	{
		CHKERR(value);
		extension.value = sdr_insert(sdr, value, valueLength);
		if (extension.value == 0)
		{
			return -1;	/*	No space in SDR heap.	*/
		}
	}

	if ((addr = sdr_insert(sdr, (char *) &extension,
			sizeof(LtpExtensionOutbound))) == 0)
	{
		return -1;		/*	No space in SDR heap.	*/
	}

	if (sdr_list_insert_last(sdr, segment->pdu.trailerExtensions, addr)
			== 0)
	{
		return -1;		/*	No space in SDR heap.	*/
	}

	segment->pdu.trailerExtensionsCount++;
	segment->pdu.trailerLength += (1 + sdnv.length + valueLength);
	return 0;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:52,代码来源:ltpei.c


示例16: dtn2_addPlan

int	dtn2_addPlan(char *nodeNm, FwdDirective *defaultDir)
{
	Sdr		sdr = getIonsdr();
	char		nodeName[SDRSTRING_BUFSZ];
	Object		nextPlan;
	Dtn2Plan	plan;
	Object		planObj;

	CHKERR(nodeNm && defaultDir);
	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	if (locatePlan(nodeName, &nextPlan) != 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Duplicate plan", nodeNm);
		return 0;
	}

	/*	Okay to add this plan to the database.			*/

	plan.nodeName = sdr_string_create(sdr, nodeName);
	memcpy((char *) &plan.defaultDirective, (char *) defaultDir,
			sizeof(FwdDirective));
	plan.rules = sdr_list_create(sdr);
	planObj = sdr_malloc(sdr, sizeof(Dtn2Plan));
	if (planObj)
	{
		if (nextPlan)
		{
			oK(sdr_list_insert_before(sdr, nextPlan, planObj));
		}
		else
		{
			oK(sdr_list_insert_last(sdr,
					(_dtn2Constants())->plans, planObj));
		}

		sdr_write(sdr, planObj, (char *) &plan, sizeof(Dtn2Plan));
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't add plan.", nodeNm);
		return -1;
	}

	return 1;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:52,代码来源:libdtn2fw.c


示例17: sdr_list_length

long	sdr_list_length(Sdr sdrv, Object list)
{
	SdrState	*sdr;
	SdrList		listBuffer;

	CHKERR(sdrv);
	CHKERR(list);
	sdr = sdrv->sdr;
	CHKERR(takeSdr(sdr) == 0);
	sdrFetch(listBuffer, list);
	releaseSdr(sdr);
	return listBuffer.length;
}
开发者ID:b,项目名称:ION,代码行数:13,代码来源:sdrlist.c


示例18: CCMIOGetEntity

ErrorCode ReadCCMIO::read_gids_and_types(CCMIOID /* problemID */,
                                           CCMIOID topologyID,
                                           std::vector<EntityHandle> &cells) 
{
    // get the cells entity and number of cells
  CCMIOSize_t dum_cells;
  int num_cells;
  CCMIOError error = kCCMIONoErr;
  CCMIOID cellsID, mapID;
  CCMIOGetEntity(&error, topologyID, kCCMIOCells, 0, &cellsID);
  CCMIOEntitySize(&error, cellsID, &dum_cells, NULL);
  num_cells = GETINT32(dum_cells);

    // check the number of cells against how many are in the cell array
  if (num_cells != (int)cells.size())
    CHKERR(MB_FAILURE, "Number of cells doesn't agree.");

    // read the gid map and set global ids
  std::vector<int> cell_gids(num_cells);
  CCMIOReadCells(&error, cellsID, &mapID, NULL,
                 CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
  CCMIOReadMap(&error, mapID, &cell_gids[0], 
               CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
  CHKCCMERR(error, "Couldn't read cells or cell id map.");

  ErrorCode rval = mbImpl->tag_set_data(mGlobalIdTag, &cells[0], 
                                          cells.size(), &cell_gids[0]);
  CHKERR(rval, "Couldn't set gids tag.");

    // now read cell material types; reuse cell_gids
  CCMIOReadCells(&error, cellsID, NULL, &cell_gids[0],
                 CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
  CHKCCMERR(error, "Trouble reading cell types.");

    // create the matsets
  std::map<int, Range> matset_ents;
  for (int i = 0; i < num_cells; i++)
    matset_ents[cell_gids[i]].insert(cells[i]);

  for (std::map<int, Range>::iterator mit = matset_ents.begin(); mit != matset_ents.end(); mit++) {
    EntityHandle matset;
    rval = mbImpl->create_meshset(MESHSET_SET, matset);
    CHKERR(rval, "Couldn't create material set.");
    newMatsets[mit->first] = matset;
    
    rval = mbImpl->add_entities(matset, mit->second);
    CHKERR(rval, "Couldn't add entities to material set.");
  }
  
  return MB_SUCCESS;
}
开发者ID:chrismullins,项目名称:moab,代码行数:51,代码来源:ReadCCMIO.cpp


示例19: face_map

ErrorCode ReadCCMIO::read_cells(CCMIOSize_t /* proc */, CCMIOID problemID,
                                CCMIOID /* verticesID */, CCMIOID topologyID,
                                  TupleList &vert_map, Range *new_ents) 
{

    // read the faces.
    // face_map fields: s:forward/reverse, i: cell id, ul: face handle, r: none
  ErrorCode rval;
#ifdef TUPLE_LIST
  TupleList face_map(1, 1, 1, 0, 0); 
#else
  TupleList face_map;
  SenseList sense_map;
#endif
  rval = read_all_faces(topologyID, vert_map, face_map
#ifndef TUPLE_LIST
                        , sense_map
#endif
                        , new_ents);
  CHKERR(rval, NULL);

    // read the cell topology types, if any exist in the file
  std::map<int,int> cell_topo_types;
  rval = read_topology_types(topologyID, cell_topo_types);
  CHKERR(rval, "Problem reading cell topo types.");
  
    // now construct the cells; sort the face map by cell ids first
#ifdef TUPLE_LIST  
  rval = face_map.sort(1);
  CHKERR(rval, "Couldn't sort face map by cell id.");
#endif
  std::vector<EntityHandle> new_cells;
  rval = construct_cells(face_map, 
#ifndef TUPLE_LIST
                         sense_map,
#endif
                         vert_map, cell_topo_types, new_cells);
  CHKERR(rval, NULL);
  if (new_ents) {
    Range::iterator rit = new_ents->end();
    std::vector<EntityHandle>::reverse_iterator vit;
    for (vit = new_cells.rbegin(); vit != new_cells.rend(); vit++)
      rit = new_ents->insert(rit, *vit);
  }
  
  rval = read_gids_and_types(problemID, topologyID, new_cells);
  CHKERR(rval, NULL);
  
  return MB_SUCCESS;
}
开发者ID:chrismullins,项目名称:moab,代码行数:50,代码来源:ReadCCMIO.cpp


示例20: reforwardStrandedBundles

static int	reforwardStrandedBundles()
{
	Sdr	sdr = getIonsdr();
	BpDB	*bpConstants = getBpConstants();
	Object	elt;
	Object	nextElt;

	CHKERR(sdr_begin_xn(sdr));
	for (elt = sdr_list_first(sdr, bpConstants->limboQueue); elt;
			elt = nextElt)
	{
		nextElt = sdr_list_next(sdr, elt);
		if (releaseFromLimbo(elt, 0) < 0)
		{
			putErrmsg("Failed releasing bundle from limbo.", NULL);
			sdr_cancel_xn(sdr);
			return -1;
		}
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("brss failed limbo release on client connect.", NULL);
		return -1;
	}

	return 0;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:28,代码来源:brsscla.c



注:本文中的CHKERR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CHKERRABORT函数代码示例发布时间:2022-05-30
下一篇:
C++ CHK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap