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

C++ INT32_C函数代码示例

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

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



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

示例1: testShiftLeft_int32

 void testShiftLeft_int32()
 {
    int32_t a[] = {-2147483647-1, -2147483647, 2147483647};
    CPPUNIT_ASSERT_EQUAL(INT32_C(0), (int32_t)(a[0]<<1));
    CPPUNIT_ASSERT_EQUAL(INT32_C(2), (int32_t)(a[1]<<1));
    CPPUNIT_ASSERT_EQUAL(INT32_C(-2), (int32_t)(a[2]<<1));
 }
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:7,代码来源:MpDspUtilsTest.cpp


示例2: local_openswapped

inline static void
local_openswapped(io_logging_t log,
                  io_art_t f,
                  io_file_swap_t swapped)
{
	if (f->mode == IO_FILE_READ) {
		switch(swapped) {
			case IO_FILE_ISNOT_SWAPPED:
				io_logging_msg(log, INT32_C(3),
				               "Assuming unswapped file");
				break;
			case IO_FILE_IS_SWAPPED:
				io_logging_msg(log, INT32_C(3),
				               "Assuming swapped file");
				break;
			case IO_FILE_UNKOWN_SWAPPING:
			default:
				io_logging_msg(log, INT32_C(3),
				               "Will try to find out swap status");
		}
	}

	/* Now set the swapping */
	f->swapped = swapped;

	return;
}
开发者ID:PascalSteger,项目名称:darcoda,代码行数:27,代码来源:io_art.c


示例3: main

int main(void)
{
  char buf[64];
  int8_t i8;
  uint8_t u8;
  int16_t i16;
  uint16_t u16;
#if defined(__SMALLER_C_32__) || !defined(__SMALLER_C__)
  int32_t i32;
  uint32_t u32;
#endif
  intmax_t imax;
  uintmax_t umax;
  TEST_PRINT(buf, PRId8, INT8_C(-128), "-128");
  TEST_PRINT(buf, PRIi8, INT8_C(-128), "-128");
  TEST_PRINT(buf, PRIo8, UINT8_C(255), "377");
  TEST_PRINT(buf, PRIu8, UINT8_C(255), "255");
  TEST_PRINT(buf, PRIx8, UINT8_C(255), "ff");
  TEST_PRINT(buf, PRIX8, UINT8_C(255), "FF");
  TEST_PRINT(buf, PRId16, INT16_C(-32767), "-32767");
  TEST_PRINT(buf, PRIi16, INT16_C(-32767), "-32767");
  TEST_PRINT(buf, PRIo16, UINT16_C(65535), "177777");
  TEST_PRINT(buf, PRIu16, UINT16_C(65535), "65535");
  TEST_PRINT(buf, PRIx16, UINT16_C(65535), "ffff");
  TEST_PRINT(buf, PRIX16, UINT16_C(65535), "FFFF");
  TEST_PRINT(buf, PRIdMAX, INTMAX_C(-32767), "-32767");
  TEST_PRINT(buf, PRIuMAX, UINTMAX_C(65535), "65535");
#if defined(__SMALLER_C_32__) || !defined(__SMALLER_C__)
  TEST_PRINT(buf, PRId32, INT32_C(-2147483647), "-2147483647");
  TEST_PRINT(buf, PRIi32, INT32_C(-2147483647), "-2147483647");
  TEST_PRINT(buf, PRIo32, UINT32_C(4294967295), "37777777777");
  TEST_PRINT(buf, PRIu32, UINT32_C(4294967295), "4294967295");
  TEST_PRINT(buf, PRIx32, UINT32_C(4294967295), "ffffffff");
  TEST_PRINT(buf, PRIX32, UINT32_C(4294967295), "FFFFFFFF");
  TEST_PRINT(buf, PRIdMAX, INTMAX_C(-2147483647), "-2147483647");
  TEST_PRINT(buf, PRIuMAX, UINTMAX_C(4294967295), "4294967295");
#endif
  TEST_SCAN("-128", SCNd8, i8, INT8_C(-128));
  TEST_SCAN("-128", SCNi8, i8, INT8_C(-128));
  TEST_SCAN("377", SCNo8, u8, UINT8_C(255));
  TEST_SCAN("255", SCNu8, u8, UINT8_C(255));
  TEST_SCAN("Ff", SCNx8, u8, UINT8_C(255));
  TEST_SCAN("-32767", SCNd16, i16, INT16_C(-32767));
  TEST_SCAN("-32767", SCNi16, i16, INT16_C(-32767));
  TEST_SCAN("177777", SCNo16, u16, UINT16_C(65535));
  TEST_SCAN("65535", SCNu16, u16, UINT16_C(65535));
  TEST_SCAN("FffF", SCNx16, u16, UINT16_C(65535));
  TEST_SCAN("-32767", SCNdMAX, imax, INTMAX_C(-32767));
  TEST_SCAN("65535", SCNuMAX, umax, UINTMAX_C(65535));
#if defined(__SMALLER_C_32__) || !defined(__SMALLER_C__)
  TEST_SCAN("-2147483647", SCNd32, i32, INT32_C(-2147483647));
  TEST_SCAN("-2147483647", SCNi32, i32, INT32_C(-2147483647));
  TEST_SCAN("37777777777", SCNo32, u32, UINT32_C(4294967295));
  TEST_SCAN("4294967295", SCNu32, u32, UINT32_C(4294967295));
  TEST_SCAN("ffFFffFF", SCNx32, u32, UINT32_C(4294967295));
  TEST_SCAN("-2147483647", SCNdMAX, imax, INTMAX_C(-2147483647));
  TEST_SCAN("4294967295", SCNuMAX, umax, UINTMAX_C(4294967295));
#endif
  return 0;
}
开发者ID:alexfru,项目名称:SmallerC,代码行数:60,代码来源:intn.c


示例4: while

/*NATIVE_ARRAY[IFTHEN_EXP]*/void r1298remove_first(T1298 C,T2 a1){
T2 _i=0;
while(1){
/*until*/if((_i)==(/*`upper'*/a1)) break;
/*RF7:put*/(C)[_i]=(/*RF8:item*/(C)[/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/]/*:RF8*/);
/*:RF7*/_i=/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/;
}
}/*--*/
开发者ID:Imhotup,项目名称:Liberty,代码行数:8,代码来源:compile_to_c4.c


示例5: io_art_init

extern void
io_art_init(io_logging_t log,
               io_art_t f)
{
  if (f == NULL)
    return;
  
  if (f->header != NULL) {
    io_logging_warn(log, INT32_C(1),
                    "Already have the header information! Rereading.");
    io_art_header_del(log, &(f->header));
  }
  
  if (f->mode != IO_FILE_READ) {
    io_logging_warn(log, INT32_C(1),
                    "%s is not opened for reading. "
                    "Will do nothing.",
                    f->fname);
    return;
  }
  
  io_logging_msg(log, INT32_C(5),
                 "Starting to initialize file object from %s",
                 f->fname);
  f->header = io_art_header_get(log, f);
  io_logging_msg(log, INT32_C(5),
                 "Done with initializing file object from %s",
                 f->fname);
  
  f->multimass = 1;
  f->no_part = f->header->N_particles;
  f->no_part_with_mass = f->no_part;
  
#ifdef DEBUG_ART
  fprintf(stderr,"aexpn    = %f\n",f->header->aexpn);
  fprintf(stderr,"aexp0    = %f\n",f->header->aexp0);
  fprintf(stderr,"amplt    = %f\n",f->header->amplt);
  fprintf(stderr,"astep    = %f\n",f->header->astep);
  fprintf(stderr,"istep    = %d\n",f->header->istep);
  fprintf(stderr,"partw    = %f\n",f->header->partw);
  fprintf(stderr,"nrowc    = %d\n",f->header->nrowc);
  fprintf(stderr,"ngridc   = %d\n",f->header->ngridc);
  fprintf(stderr,"nspecies = %d\n",f->header->nspecies);
  fprintf(stderr,"nseed    = %d\n",f->header->nseed);
  fprintf(stderr,"Om0      = %f\n",f->header->Om0);
  fprintf(stderr,"Oml0     = %f\n",f->header->Oml0);
  fprintf(stderr,"hubble   = %f\n",f->header->hubble);
  fprintf(stderr,"wp5      = %f\n",f->header->wp5);
  fprintf(stderr,"Ocurv    = %f\n",f->header->Ocurv);
  fprintf(stderr,"munit    = %f\n",f->header->munit);
  fprintf(stderr,"boxsize  = %f\n",f->header->boxsize);
  fprintf(stderr,"N_particles    = %d\n",f->header->N_particles);
  fprintf(stderr,"N_pages        = %d\n",f->header->N_pages);
  fprintf(stderr,"N_in_last      = %d\n",f->header->N_in_last);
#endif
  
  return;
}
开发者ID:PascalSteger,项目名称:darcoda,代码行数:58,代码来源:io_art.c


示例6: io_file_get_numpart

extern uint64_t
io_file_get_numpart(io_logging_t log,
                    io_file_t    f,
                    uint64_t     *pskip,
                    uint64_t     *pread)
{
	uint64_t pskip_parallel, pread_parallel;
	uint64_t numpart = UINT64_C(0);
	long     tmp     = 0L;

	/* Sanity check */
	if ((f == NULL) || (f->ftype == IO_FILE_EMPTY))
		return UINT64_C(0);

	/*
	 * Get the number of particles available in the file, to do yet
	 * another sanity check
	 */
	io_file_get(log, f, IO_FILE_GET_NOPART_IN_FILE, (void *)(&tmp));
	numpart = (uint64_t)tmp;

	/* See if we are reading more than available */
	if (*pskip > numpart) {
		io_logging_warn(log, INT32_C(
		                    1),
		                "Trying to skip %" PRIu64 " particles, but there"
		                                          "are only %" PRIu64
		                " particles in the file. "
		                "Adjusting skipping to %"
		                PRIu64,
		                *pskip, numpart, numpart);
		*pskip = numpart;
	}
	if (*pskip + *pread > numpart) {
		io_logging_warn(log, INT32_C(
		                    1),
		                "There are %" PRIu64 " particles in the file, "
		                                     "but the choice of pread and pskip would need "
		                                     "%" PRIu64 ", adjusting to %"
		                PRIu64,
		                numpart, *pskip + *pread, numpart - *pskip);
		*pread = numpart - *pskip;
	}

	/* Now figure out how many particles actually will be read by
	 * that choice of pskip and pread
	 */
#ifdef WITH_MPI
	local_recalcreadskip(f, f->size_mycomm, *pskip, *pread, &pskip_parallel, &pread_parallel);
#else
	pskip_parallel = *pskip;
	pread_parallel = *pread;
#endif

	/* And return the number of particles which will be read */
	return pread_parallel;
} /* io_file_get_numpart */
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:57,代码来源:io_file.c


示例7: fivmr_AH_double_to_int

int32_t fivmr_AH_double_to_int(double a) {
    if (a!=a) {
        return 0;
    } else if (a==1./0.) {
        return INT32_C(2147483647);
    } else if (a==-1./0.) {
        return INT32_C(-2147483647)-1;
    } else {
        return (int32_t)a;
    }
}
开发者ID:smflorentino,项目名称:cse605,代码行数:11,代码来源:fivmr_arith_helpers.c


示例8: io_amiga_log

extern void
io_amiga_log(io_logging_t log, io_amiga_t f)
{
	io_logging_msg(log, INT32_C(5),
	               "Fileobject information:");
	io_logging_msg(log, INT32_C(5),
	               "  Filetype:          %s",
	               io_file_typestr(f->ftype));
	io_logging_msg(log, INT32_C(5),
	               "  Filename:          %s",
	               f->fname);
	io_logging_msg(log, INT32_C(5),
	               "  Mode:              %" PRIi8,
	               f->mode);
	io_logging_msg(log, INT32_C(5),
	               "  Swapping:          %" PRIi8,
	               f->swapped);
	io_logging_msg(log, INT32_C(5),
	               "  File sizeof(long): %" PRIi8,
	               f->file_sizeof_long);
	io_logging_msg(log, INT32_C(5),
	               "  minweight:         %g",
	               f->minweight);
	io_logging_msg(log, INT32_C(5),
	               "  maxweight:         %g",
	               f->maxweight);
	io_amiga_header_log(log, f->header);

	return;
}
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:30,代码来源:io_amiga.c


示例9: local_openfsol

inline static void
local_openfsol(io_logging_t log, io_amiga_t f)
{
	/* In write mode, that is easy */
	if (f->mode == IO_FILE_WRITE) {
		f->file_sizeof_long = (int32_t)sizeof(uint64_t);
		return;
	}

	/* We are reading from a file, so checking for the swapping */
	if (f->swapped == IO_FILE_UNKOWN_SWAPPING) {
		/* But we only do that if the swapping is unkown */
		io_util_readint32(f->file, &(f->file_sizeof_long),
		                  IO_FILE_ISNOT_SWAPPED);
		if (f->file_sizeof_long > 8) {
			/* Wupps, byteswapped value found */
			io_logging_msg(log, INT32_C(2),
			               "Byteswapped file, will do the swapping.");
			io_util_sexchange((void *)(&(f->file_sizeof_long)), 4);
			if (f->swapped == IO_FILE_UNKOWN_SWAPPING)
				f->swapped = IO_FILE_IS_SWAPPED;
			/* Verify that the value is now making sense */
			if (f->file_sizeof_long > 8) {
				/* Still not making sense, corrupt file? */
				io_logging_warn(log, INT32_C(0),
				                "The file does not make sense. Maybe "
				                "it is corrupt or not an AMIGA binary "
				                "file?");
				/* Anyhow, continue */
			}
		} else {
			io_logging_msg(log, INT32_C(2),
			               "File is not byteswapped, everything fine.");
			f->swapped = IO_FILE_ISNOT_SWAPPED;
		}
	} else {
		/* Okay, we believe the swapping value and read the int */
		io_util_readint32(f->file, &(f->file_sizeof_long), f->swapped);
		/* But be nice and check for sanity */
		if (f->file_sizeof_long > 8) {
			io_logging_warn(log, INT32_C(0),
			                "Trying to read with the predefined "
			                "byteswapping state, but the value for "
			                "sizeof(long) is weird. Are you sure "
			                "the swapping is correct?");
		}
	}

	return;
}
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:50,代码来源:io_amiga.c


示例10: lqfs_initialize

static int
lqfs_initialize(qfsvfs_t *qfsvfsp, daddr_t bno, int ord, size_t nb,
    struct fiolog *flp)
{
	ml_odunit_t	*ud, *ud2;
	buf_t		*bp;
	timeval_lqfs_common_t tv;
	int error = 0;

	/* LINTED: warning: logical expression always true: op "||" */
	ASSERT(sizeof (ml_odunit_t) < DEV_BSIZE);
	ASSERT(nb >= ldl_minlogsize);

	bp = QFS_GETBLK(qfsvfsp, qfsvfsp->mi.m_fs[ord].dev, bno,
	    dbtob(LS_SECTORS));
	bzero(bp->b_un.b_addr, bp->b_bcount);

	ud = (void *)bp->b_un.b_addr;
	ud->od_version = LQFS_VERSION_LATEST;
	ud->od_maxtransfer = MIN(VFS_IOTRANSZ(qfsvfsp), ldl_maxtransfer);
	if (ud->od_maxtransfer < ldl_mintransfer) {
		ud->od_maxtransfer = ldl_mintransfer;
	}
	ud->od_devbsize = DEV_BSIZE;

	ud->od_requestsize = flp->nbytes_actual;
	ud->od_statesize = dbtob(LS_SECTORS);
	ud->od_logsize = nb - ud->od_statesize;

	ud->od_statebno = INT32_C(0);

	uniqtime(&tv);
	if (tv.tv_usec == last_loghead_ident) {
		tv.tv_usec++;
	}
	last_loghead_ident = tv.tv_usec;
	ud->od_head_ident = tv.tv_usec;
	ud->od_tail_ident = ud->od_head_ident;
	ud->od_chksum = ud->od_head_ident + ud->od_tail_ident;

	ud->od_bol_lof = dbtob(ud->od_statebno) + ud->od_statesize;
	ud->od_eol_lof = ud->od_bol_lof + ud->od_logsize;
	ud->od_head_lof = ud->od_bol_lof;
	ud->od_tail_lof = ud->od_bol_lof;

	ASSERT(lqfs_initialize_debug(ud));

	ml_odunit_validate(ud);

	ud2 = (void *)(bp->b_un.b_addr + DEV_BSIZE);
	bcopy(ud, ud2, sizeof (*ud));

	if ((error = SAM_BWRITE2(qfsvfsp, bp)) != 0) {
		brelse(bp);
		return (error);
	}
	brelse(bp);

	return (0);
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:60,代码来源:lqfs.c


示例11: oscap_bfind_i

int32_t oscap_bfind_i(void *ptr, size_t nmemb, size_t size, void *key, int cmpfn(void *, void *), size_t *save)
{
	size_t w, s;
	int cmp;
	uint8_t *p;

	w = nmemb;
	s = 0;
	p = (uint8_t *) ptr;

	while (w > 0) {
		cmp = cmpfn(key, p + (size * (s + w / 2)));
		if (cmp > 0) {
			s += w / 2 + 1;
			w = w - w / 2 - 1;
		} else if (cmp < 0) {
			w = w / 2;
		} else {
			assert((s + w / 2) <= INT32_MAX);
			return ((int32_t) (s + w / 2));
		}
	}

        if (save != NULL)
                *save = s;

	return INT32_C(-1);
}
开发者ID:jan-cerny,项目名称:openscap,代码行数:28,代码来源:bfind.c


示例12: rtems_malloc_boundary_at_malloc

static void rtems_malloc_boundary_at_malloc(
  void     *pointer,
  size_t    size
)
{
  void *return_this;
  struct mallocNode *mp = (struct mallocNode *)pointer;
  intptr_t *fp, *nfp;
  int i;

  _RTEMS_Lock_allocator();
    mp->memory = mp + 1;
    return_this = mp->memory;
    mp->size = size - (sizeof(struct mallocNode) + SENTINELSIZE);
    fp = (intptr_t *)&size - 2;
    for (i = 0 ; i < CALLCHAINSIZE ; i++) {
      mp->callChain[i] = fp[1];
      nfp = (intptr_t *)(fp[0]);
      if((nfp <= fp) || (nfp > (intptr_t *)(INT32_C(0x1000000) /* 1 << 24 */)))
       break;
      fp = nfp;
    }
    while (i < CALLCHAINSIZE)
      mp->callChain[i++] = 0;
    memcpy((char *)mp->memory + mp->size, SENTINEL, SENTINELSIZE);
    mp->forw = mallocNodeHead.forw;
    mp->back = &mallocNodeHead;
    mallocNodeHead.forw->back = mp;
    mallocNodeHead.forw = mp;
  _RTEMS_Unlock_allocator();
}
开发者ID:FullMentalPanic,项目名称:RTEMS_NEW_TOOL_CHAIN,代码行数:31,代码来源:malloc_boundary.c


示例13: io_tipsy_header_log

extern void
io_tipsy_header_log(io_logging_t log, io_tipsy_header_t header)
{
  io_logging_msg(log, INT32_C(5),
                 "   time:                         %e",
                 header->time);
  io_logging_msg(log, INT32_C(5),
                 "  nbodies:                       %" PRIi32,
                 header->nbodies);
  io_logging_msg(log, INT32_C(5),
                 "  ndim:                          %" PRIi32,
                 header->ndim);
  io_logging_msg(log, INT32_C(5),
                 "  nsph:                          %" PRIi32,
                 header->nsph);
  io_logging_msg(log, INT32_C(5),
                 "  ndark:                         %" PRIi32,
                 header->ndark);
  io_logging_msg(log, INT32_C(5),
                 "  nstar:                         %" PRIi32,
                 header->nstar);  
  io_logging_msg(log, INT32_C(5),
                 "  pad:                           %" PRIi32,
                 header->pad);  
  return;
}
开发者ID:PascalSteger,项目名称:darcoda,代码行数:26,代码来源:io_tipsy_header.c


示例14: io_art_resetscale

extern void
io_art_resetscale(io_logging_t log,
                     io_art_t f,
                     double posscale,
                     double weightscale) {
	if (f == NULL)
		return;

	io_logging_msg(log, INT32_C(8),
	               "Old posscale: %g   New posscale: %g",
	               f->posscale, posscale);
	io_logging_msg(log, INT32_C(8),
	               "Old weightscale: %g   New weightscale: %g",
	               f->weightscale, weightscale);
	f->posscale = posscale;
	f->weightscale = weightscale;

	return;
}
开发者ID:PascalSteger,项目名称:darcoda,代码行数:19,代码来源:io_art.c


示例15: io_amiga_writepart_ord

extern uint64_t
io_amiga_writepart_ord(io_logging_t log,
                       io_amiga_t f,
                       uint64_t pskip,
                       uint64_t pwrite,
                       void *nxt_part,
                       io_file_strg_struct_t strg)
{
	uint64_t no_part = 0;
	ptrdiff_t stride;

	if (local_write_common(log, f, strg.weight.val,
	                       pskip, strg.bytes_float) == 0)
		return UINT64_C(0);

	/* Start putting the particles to the file */
	do {
		/* Write the current particle */
		fwrite(strg.posx.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momx.val, strg.bytes_float, 1, f->file);
		fwrite(strg.posy.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momy.val, strg.bytes_float, 1, f->file);
		fwrite(strg.posz.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momz.val, strg.bytes_float, 1, f->file);
		if (strg.weight.val != NULL)
			fwrite(strg.weight.val, strg.bytes_float, 1, f->file);
		no_part++;

		/* Advance to the next particle */
		stride = (char *)*((char **)nxt_part) - (char *)nxt_part;
		nxt_part = (void *)((char *)nxt_part + stride);
		INCR(strg.posx.val, stride);
		INCR(strg.momx.val, stride);
		INCR(strg.posy.val, stride);
		INCR(strg.momy.val, stride);
		INCR(strg.posz.val, stride);
		INCR(strg.momz.val, stride);
		if (strg.weight.val != NULL)
			INCR(strg.weight.val, stride);
	} while (    (*((char **)nxt_part) != NULL)
	          && (no_part < pwrite) );

	io_logging_msg(log, INT32_C(3),
	               "Wrote %" PRIu64 " particles to file",
	               no_part);

	/* Update the header */
	f->header->no_part = (long)(pskip + no_part);
	f->header->multi_mass = (strg.weight.val == NULL ? 0 : 1);
	f->header->double_precision = (strg.bytes_float > 4 ? 1 : 0);

	/* Done */
	return no_part;
}
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:54,代码来源:io_amiga.c


示例16: io_ascii_init

extern void
io_ascii_init(io_logging_t log,
              io_ascii_t f)
{
	if (f->mode == IO_FILE_READ) {
		io_logging_msg(log, INT32_C(5),
		               "Starting to initialize file object from %s",
		               f->fname);
		f->header = io_ascii_header_get(log, f);
		io_logging_msg(log, INT32_C(5),
		               "Done with initializing file object from %s",
		               f->fname);
	} else {
		io_logging_warn(log, INT32_C(1),
		                "%s is not opened for reading. "
		                "Will do nothing.",
		                f->fname);
	}

	return;
}
开发者ID:PascalSteger,项目名称:darcoda,代码行数:21,代码来源:io_ascii.c


示例17: io_amiga_set

extern bool
io_amiga_set(io_logging_t log,
             io_amiga_t f,
             io_file_get_t what,
             void *res)
{
	if (f == NULL)
		return false;

	if (f->header == NULL) {
		io_logging_warn(log, INT32_C(3),
		                "File does not have a header yet, "
		                "creating one.");
		f->header = io_amiga_header_new(log);
		if (f->header == NULL)
			return false;
	}

	switch (what) {
		case IO_FILE_GET_BOXSIZE:
			f->header->boxsize = *((double *)res);
			break;
		case IO_FILE_GET_PMASS:
			f->header->pmass = *((double *)res);
			break;
		case IO_FILE_GET_Z:
			f->header->a_current = 1./(*((double *)res) + 1.);
			f->header->a_initial = 0.1/(*((double *)res) + 1.);
			break;
		case IO_FILE_GET_A:
			f->header->a_current = *((double *)res);
			f->header->a_initial = *((double *)res)/10.0;
			break;
		case IO_FILE_GET_OMEGA0:
			f->header->omega0 = *((double *)res);
			break;
		case IO_FILE_GET_OMEGAL:
			f->header->lambda0 = *((double *)res);
			break;
		case IO_FILE_GET_H:
			io_logging_fatal(log,
			                 "The Hubble parameter is not available "
			                 "for AMIGA files.");
			return false;
		default:
			io_logging_fatal(log, "Requesting something unkown in %s.",
			                 __func__);
			return false;
	}

	return true;
}
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:52,代码来源:io_amiga.c


示例18: io_amiga_writepart

extern uint64_t
io_amiga_writepart(io_logging_t log,
                   io_amiga_t f,
                   uint64_t pskip,
                   uint64_t pwrite,
                   io_file_strg_struct_t strg)
{
	uint64_t no_part = 0;

	if (local_write_common(log, f, strg.weight.val,
	                       pskip, strg.bytes_float) == 0)
		return UINT64_C(0);

	/* Start putting the particles to the file */
	for (no_part=0; no_part<pwrite; no_part++) {
		/* Write the current particle */
		fwrite(strg.posx.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momx.val, strg.bytes_float, 1, f->file);
		fwrite(strg.posy.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momy.val, strg.bytes_float, 1, f->file);
		fwrite(strg.posz.val, strg.bytes_float, 1, f->file);
		fwrite(strg.momz.val, strg.bytes_float, 1, f->file);
		if (strg.weight.val != NULL)
			fwrite(strg.weight.val, strg.bytes_float, 1, f->file);

		/* Advance to next particle */
		INCR(strg.posx.val, strg.posx.stride);
		INCR(strg.momx.val, strg.momx.stride);
		INCR(strg.posy.val, strg.posy.stride);
		INCR(strg.momy.val, strg.momy.stride);
		INCR(strg.posz.val, strg.posz.stride);
		INCR(strg.momz.val, strg.momz.stride);
		if (strg.weight.val != NULL)
			INCR(strg.weight.val, strg.weight.stride);
	}

	/* Update the header */
	f->header->no_part = pskip + no_part;
	f->header->multi_mass = (strg.weight.val == NULL ? 0 : 1);
	f->header->double_precision = (strg.bytes_float > 4 ? 1 : 0);

	/* Update logfile */
	io_logging_msg(log, INT32_C(3),
	               "Wrote %" PRIu64 " particles to file",
	               no_part);

	/* Done */
	return no_part;
}
开发者ID:EdoardoCarlesi,项目名称:MergerTreeMPI,代码行数:49,代码来源:io_amiga.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ INT32_TO_NPVARIANT函数代码示例发布时间:2022-05-30
下一篇:
C++ INT2PTR函数代码示例发布时间: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