예제 #1
0
 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));
 }
예제 #2
0
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;
}
예제 #3
0
파일: intn.c 프로젝트: alexfru/SmallerC
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;
}
예제 #4
0
/*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*/;
}
}/*--*/
예제 #5
0
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;
}
예제 #6
0
/*NATIVE_ARRAY[IFTHEN]*/void r1293remove(T1293 C,T2 a1,T2 a2){
T2 _i=0;
_i=/*`index'*/a1;
while(1){
/*until*/if((_i)==(/*`upper'*/a2)) 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*/;
}
}/*--*/
예제 #7
0
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 */
예제 #8
0
/*NATIVE_ARRAY[HASHED_SET_NODE[FEATURE_STAMP]]*/void r1383clear_all(T1383 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #9
0
/*NATIVE_ARRAY[AVL_DICTIONARY_NODE[INTEGER_32,INTEGER_32]]*/void r1403clear_all(T1403 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #10
0
/*NATIVE_ARRAY[E_OLD]*/void r1382clear_all(T1382 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #11
0
/*NATIVE_ARRAY[HASHED_DICTIONARY_NODE[PLUGIN,STRING]]*/void r1376clear_all(T1376 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #12
0
/*NATIVE_ARRAY[HASHED_DICTIONARY_NODE[RECYCLING_POOL[AVL_TREE_NODE_ANY],FIXED_STRING]]*/void r1314clear_all(T1314 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #13
0
/*NATIVE_ARRAY[HASHED_DICTIONARY_NODE[CLIENT_LIST,FEATURE_NAME]]*/void r1301clear_all(T1301 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #14
0
/*NATIVE_ARRAY[LINKED_LIST[TUPLE[CHARACTER,INTEGER_32]]]*/void r1402clear_all(T1402 C,T2 a1){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`upper'*/a1;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(INT32_C(0))/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #15
0
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;
    }
}
예제 #16
0
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;
}
예제 #17
0
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;
}
예제 #18
0
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);
}
예제 #19
0
파일: bfind.c 프로젝트: jan-cerny/openscap
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);
}
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();
}
예제 #21
0
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;
}
예제 #22
0
/*NATIVE_ARRAY[FORMAL_GENERIC_ARG]*/void r1284set_slice_with(T1284 C,T0*a1,T2 a2,T2 a3){
T2 _i=0;
_i=/*`lower'*/a2;
while(1){
/*until*/if(/*RF8:>*/((int32_t)(_i))>(/*`upper'*/a3)/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(/*`v'*/a1);
/*:RF7*/_i=/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #23
0
/*NATIVE_ARRAY[RUN_FEATURE_2]*/void r1310set_slice_with(T1310 C,T0*a1,T2 a2,T2 a3){
T2 _i=0;
_i=/*`lower'*/a2;
while(1){
/*until*/if(/*RF8:>*/((int32_t)(_i))>(/*`upper'*/a3)/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(/*`v'*/a1);
/*:RF7*/_i=/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #24
0
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;
}
예제 #25
0
/*NATIVE_ARRAY[E_OLD]*/void r1382clear(T1382 C,T2 a1,T2 a2){
T0*_v=(void*)0;
T2 _i=0;
_i=/*`lower'*/a1;
while(1){
/*until*/if(/*RF8:>*/((int32_t)(_i))>(/*`upper'*/a2)/*:RF8*/) break;
/*RF7:put*/(C)[_i]=(_v);
/*:RF7*/_i=/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/;
}
}/*--*/
예제 #26
0
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;
}
예제 #27
0
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;
}
예제 #28
0
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;
}
예제 #29
0
/*NATIVE_ARRAY[FAST_ARRAY[CODE_CONTEXT]]*/void r1440move(T1440 C,T2 a1,T2 a2,T2 a3){
T2 _i=0;
if((/*`offset'*/a3)==(INT8_C(0))){
}
else{
if(/*RF8:<*/((int32_t)(/*`offset'*/a3))<(INT32_C(0))/*:RF8*/){
_i=/*`lower'*/a1;
while(1){
/*until*/if(/*RF8:>*/((int32_t)(_i))>(/*`upper'*/a2)/*:RF8*/) break;
/*RF7:put*/(C)[/*RF8:+*/((int32_t)(_i))+(/*`offset'*/a3)/*:RF8*/]=(/*RF8:item*/(C)[_i]/*:RF8*/);
/*:RF7*/_i=/*RF8:+*/((int32_t)(_i))+(INT32_C(1))/*:RF8*/;
}
}
else{
_i=/*`upper'*/a2;
while(1){
/*until*/if(/*RF8:<*/((int32_t)(_i))<(/*`lower'*/a1)/*:RF8*/) break;
/*RF7:put*/(C)[/*RF8:+*/((int32_t)(_i))+(/*`offset'*/a3)/*:RF8*/]=(/*RF8:item*/(C)[_i]/*:RF8*/);
/*:RF7*/_i=/*RF8:-*/((int32_t)(_i))-(INT32_C(1))/*:RF8*/;
}
}
}
}/*--*/
예제 #30
0
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;
}