Exemplo n.º 1
0
EscapeSequenceSyntax::EscapeSequenceSyntax()
{
	number_ = DEFINE("number", REPEAT(1, 4, RANGE('0', '9')));
	title_ = DEFINE("title", REPEAT(1, RANGE(32, 255)));
	
	controlSequence_ =
		DEFINE("controlSequence",
			GLUE(
				CHAR(27),
				CHOICE(
					GLUE(
						// csi sequences
						CHAR('['),
						REPEAT(0, 1, RANGE("?>")),
						REPEAT(0, 15,
							GLUE(
								REF("number"),
								REPEAT(0, 1, CHAR(';'))
							)
						),
						RANGE(32, 255)
					),
					GLUE(
						// osc sequences
						CHAR(']'),
						REF("number"),
						CHAR(';'),
						REF("title"),
						CHAR(7)
					),
					GLUE(
						// two or three byte escape sequences
						REPEAT(0, 1,
							// character set selection, etc.
							RANGE("()%")
						),
						// other
						RANGE(33, 127)
					)
				)
			)
		);
	
	ENTRY("controlSequence");
	LINK();
}
Exemplo n.º 2
0
isc_result_t
dns_time64_fromtext(const char *source, isc_int64_t *target) {
	int year, month, day, hour, minute, second;
	isc_int64_t value;
	int secs;
	int i;

#define RANGE(min, max, value) \
	do { \
		if (value < (min) || value > (max)) \
			return (ISC_R_RANGE); \
	} while (0)

	if (strlen(source) != 14U)
		return (DNS_R_SYNTAX);
	if (sscanf(source, "%4d%2d%2d%2d%2d%2d",
		   &year, &month, &day, &hour, &minute, &second) != 6)
		return (DNS_R_SYNTAX);

	RANGE(1970, 9999, year);
	RANGE(1, 12, month);
	RANGE(1, days[month - 1] +
		 ((month == 2 && is_leap(year)) ? 1 : 0), day);
	RANGE(0, 23, hour);
	RANGE(0, 59, minute);
	RANGE(0, 60, second);		/* 60 == leap second. */

	/*
	 * Calulate seconds since epoch.
	 */
	value = second + (60 * minute) + (3600 * hour) + ((day - 1) * 86400);
	for (i = 0; i < (month - 1); i++)
		value += days[i] * 86400;
	if (is_leap(year) && month > 2)
		value += 86400;
	for (i = 1970; i < year; i++) {
		secs = (is_leap(i) ? 366 : 365) * 86400;
		value += secs;
	}

	*target = value;
	return (ISC_R_SUCCESS);
}
Exemplo n.º 3
0
RSL_LITE_PACK ( int * Fcomm0, char * buf , int * shw0 , 
           int * sendbegm0 , int * sendwm0 , int * sendbegp0 , int * sendwp0 ,
           int * recvbegm0 , int * recvwm0 , int * recvbegp0 , int * recvwp0 ,
           int * typesize0 , int * xy0 , int * pu0 , int * imemord , int * xstag0, /* not used */
           int *me0, int * np0 , int * np_x0 , int * np_y0 , 
           int * ids0 , int * ide0 , int * jds0 , int * jde0 , int * kds0 , int * kde0 ,
           int * ims0 , int * ime0 , int * jms0 , int * jme0 , int * kms0 , int * kme0 ,
           int * ips0 , int * ipe0 , int * jps0 , int * jpe0 , int * kps0 , int * kpe0 )
{
  int me, np, np_x, np_y ;
  int sendbegm , sendwm, sendbegp , sendwp ;
  int recvbegm , recvwm, recvbegp , recvwp ;
  int shw , typesize ;
  int ids , ide , jds , jde , kds , kde ;
  int ims , ime , jms , jme , kms , kme ;
  int ips , ipe , jps , jpe , kps , kpe ;
  int xy ;   /* y = 0 , x = 1 */
  int pu ;   /* pack = 0 , unpack = 1 */
  register int i, j, k, t ;
#ifdef crayx1
  register int i2,i3,i4,i_offset;
#endif
  char *p ;
  int da_buf ;
  int yp, ym, xp, xm ;
  int nbytes, ierr ;
  register int *pi, *qi ;

#ifndef STUBMPI
  MPI_Comm comm, *comm0, dummy_comm ;
  int js, je, ks, ke, is, ie, wcount ;

  comm0 = &dummy_comm ;
  *comm0 = MPI_Comm_f2c( *Fcomm0 ) ;

  shw = *shw0 ;          /* logical half-width of stencil */
  sendbegm = *sendbegm0 ;  /* send index of sten copy (edge = 1), lower/left */
  sendwm   = *sendwm0   ;  /* send width of sten copy counting towards edge, lower/left */
  sendbegp = *sendbegp0 ;  /* send index of sten copy (edge = 1), upper/right */
  sendwp   = *sendwp0   ;  /* send width of sten copy counting towards edge, upper/right */
  recvbegm = *recvbegm0 ;  /* recv index of sten copy (edge = 1), lower/left */
  recvwm   = *recvwm0   ;  /* recv width of sten copy counting towards edge, lower/left */
  recvbegp = *recvbegp0 ;  /* recv index of sten copy (edge = 1), upper/right */
  recvwp   = *recvwp0   ;  /* recv width of sten copy counting towards edge, upper/right */
  me = *me0 ; np = *np0 ; np_x = *np_x0 ; np_y = *np_y0 ;
  typesize = *typesize0 ;
  ids = *ids0-1 ; ide = *ide0-1 ; jds = *jds0-1 ; jde = *jde0-1 ; kds = *kds0-1 ; kde = *kde0-1 ;
  ims = *ims0-1 ; ime = *ime0-1 ; jms = *jms0-1 ; jme = *jme0-1 ; kms = *kms0-1 ; kme = *kme0-1 ;
  ips = *ips0-1 ; ipe = *ipe0-1 ; jps = *jps0-1 ; jpe = *jpe0-1 ; kps = *kps0-1 ; kpe = *kpe0-1 ;
  xy = *xy0 ;
  pu = *pu0 ;

/* need to adapt for other memory orders */

#define RANGE(S1,E1,S2,E2,S3,E3,S4,E4) (((E1)-(S1)+1)*((E2)-(S2)+1)*((E3)-(S3)+1)*((E4)-(S4)+1))
#define IMAX(A) (((A)>ids)?(A):ids)
#define IMIN(A) (((A)<ide)?(A):ide)
#define JMAX(A) (((A)>jds)?(A):jds)
#define JMIN(A) (((A)<jde)?(A):jde)

  da_buf = ( pu == 0 ) ? RSL_SENDBUF : RSL_RECVBUF ;

  if ( ips <= ipe && jps <= jpe ) {

  if ( np_y > 1 && xy == 0 ) {
    MPI_Cart_shift( *comm0 , 0, 1, &ym, &yp ) ;
    if ( yp != MPI_PROC_NULL && jpe <= jde  && jde != jpe ) {
      p = buffer_for_proc( yp , 0 , da_buf ) ;
      if ( pu == 0 ) {
        if ( sendwp > 0 ) {
          je = jpe - sendbegp + 1 ; js = je - sendwp + 1 ;
          ks = kps           ; ke = kpe ;
          is = IMAX(ips-shw) ; ie = IMIN(ipe+shw) ;
          nbytes = buffer_size_for_proc( yp, da_buf ) ;
	  if ( yp_curs + RANGE( js, je, kps, kpe, ips-shw, ipe+shw, 1, typesize ) > nbytes ) {
#ifndef MS_SUA
	    fprintf(stderr,"memory overwrite in rsl_lite_pack, Y pack up, %d > %d\n",
	        yp_curs + RANGE( js, je, kps, kpe, ips-shw, ipe+shw, 1, typesize ), nbytes ) ;
#endif
	    MPI_Abort(MPI_COMM_WORLD, 99) ;
          }
          if ( typesize == 8 ) {
            F_PACK_LINT ( buf, p+yp_curs, imemord, &js, &je, &ks, &ke, &is, &ie, 
                                                &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            yp_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_PACK_INT ( buf, p+yp_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            yp_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
          }
        }
      } else {
        if ( recvwp > 0 ) {
          js = jpe+recvbegp         ; je = js + recvwp - 1 ;
          ks = kps           ; ke = kpe ;
          is = IMAX(ips-shw) ; ie = IMIN(ipe+shw) ;
          if ( typesize == 8 ) {
            F_UNPACK_LINT ( p+yp_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            yp_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_UNPACK_INT ( p+yp_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            yp_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
	  }
	}
      }
    }
    if ( ym != MPI_PROC_NULL && jps >= jds  && jps != jds ) {
      p = buffer_for_proc( ym , 0 , da_buf ) ;
      if ( pu == 0 ) {
        if ( sendwm > 0 ) {
          js = jps+sendbegm-1 ; je = js + sendwm -1 ;
          ks = kps           ; ke = kpe ;
          is = IMAX(ips-shw) ; ie = IMIN(ipe+shw) ;
          nbytes = buffer_size_for_proc( ym, da_buf ) ;
	  if ( ym_curs + RANGE( js, je, kps, kpe, ips-shw, ipe+shw, 1, typesize ) > nbytes ) {
#ifndef  MS_SUA
	    fprintf(stderr,"memory overwrite in rsl_lite_pack, Y pack dn, %d > %d\n",
	        ym_curs + RANGE( js, je, kps, kpe, ips-shw, ipe+shw, 1, typesize ), nbytes ) ;
#endif
	    MPI_Abort(MPI_COMM_WORLD, 99) ;
          }
          if ( typesize == 8 ) {
            F_PACK_LINT ( buf, p+ym_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            ym_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_PACK_INT ( buf, p+ym_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            ym_curs += wcount*typesize ;
  	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
	  }
	}
      } else {
        if ( recvwm > 0 ) {
          je = jps-recvbegm ; js = je - recvwm + 1 ;
          ks = kps           ; ke = kpe ;
          is = IMAX(ips-shw) ; ie = IMIN(ipe+shw) ;
          if ( typesize == 8 ) {
            F_UNPACK_LINT ( p+ym_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                  &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            ym_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_UNPACK_INT ( p+ym_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                 &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            ym_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
          }
        }
      }
    }
  }

  if ( np_x > 1 && xy == 1 ) {
    MPI_Cart_shift( *comm0, 1, 1, &xm, &xp ) ;
    if ( xp != MPI_PROC_NULL  && ipe <= ide && ide != ipe ) {
      p = buffer_for_proc( xp , 0 , da_buf ) ;
      if ( pu == 0 ) {
        if ( sendwp > 0 ) {
          js = JMAX(jps-shw) ; je = JMIN(jpe+shw) ;
          ks = kps           ; ke = kpe ;
          ie = ipe - sendbegp + 1 ; is = ie - sendwp + 1 ;
          nbytes = buffer_size_for_proc( xp, da_buf ) ;
          if ( xp_curs + RANGE( js, je, kps, kpe, ipe-shw+1, ipe, 1, typesize ) > nbytes ) {
#ifndef MS_SUA
	    fprintf(stderr,"memory overwrite in rsl_lite_pack, X pack right, %d > %d\n",
	        xp_curs + RANGE( js, je, kps, kpe, ipe-shw+1, ipe, 1, typesize ), nbytes ) ;
#endif
	    MPI_Abort(MPI_COMM_WORLD, 99) ;
          }
          if ( typesize == 8 ) {
            F_PACK_LINT ( buf, p+xp_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xp_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_PACK_INT ( buf, p+xp_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xp_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"A internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
	  }
	}
      } else {
        if ( recvwp > 0 ) {
          js = JMAX(jps-shw) ; je = JMIN(jpe+shw) ;
          ks = kps           ; ke = kpe ;
          is = ipe+recvbegp  ; ie = is + recvwp - 1 ;
          if ( typesize == 8 ) {
            F_UNPACK_LINT ( p+xp_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                  &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xp_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_UNPACK_INT ( p+xp_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                 &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xp_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"B internal error: %s %d\n",__FILE__,__LINE__) ;
            fprintf(stderr,"  stenbeg %d stenw  %d \n",is,ie) ;
            fprintf(stderr,"  is %d ie %d \n",is,ie) ;
#endif
          }
        }
      }
    }
    if ( xm != MPI_PROC_NULL  && ips >= ids && ids != ips ) {
      p = buffer_for_proc( xm , 0 , da_buf ) ;
      if ( pu == 0 ) {
        if ( sendwm > 0 ) {
          js = JMAX(jps-shw) ; je = JMIN(jpe+shw) ;
          ks = kps           ; ke = kpe ;
          is = ips+sendbegm-1 ; ie = is + sendwm-1 ;
          nbytes = buffer_size_for_proc( xm, da_buf ) ;
          if ( xm_curs + RANGE( js, je, kps, kpe, ips, ips+shw-1, 1, typesize ) > nbytes ) {
#ifndef MS_SUA
	    fprintf(stderr,"memory overwrite in rsl_lite_pack, X left , %d > %d\n",
	        xm_curs + RANGE( js, je, kps, kpe, ips, ips+shw-1, 1, typesize ), nbytes ) ;
#endif
	    MPI_Abort(MPI_COMM_WORLD, 99) ;
          }
          if ( typesize == 8 ) {
            F_PACK_LINT ( buf, p+xm_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xm_curs += wcount*typesize ;
          }
	  else if ( typesize == 4 ) {
            F_PACK_INT ( buf, p+xm_curs, imemord, &js, &je, &ks, &ke, &is, &ie,
                                               &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xm_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
          }
        }
      } else {
        if ( recvwm > 0 ) {
          js = JMAX(jps-shw) ; je = JMIN(jpe+shw) ;
          ks = kps           ; ke = kpe ;
          ie = ips-recvbegm ; is = ie - recvwm + 1 ;
          if ( typesize == 8 ) {
            F_UNPACK_LINT ( p+xm_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                  &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xm_curs += wcount*typesize ;
          } 
          else if ( typesize == 4 ) {
            F_UNPACK_INT ( p+xm_curs, buf, imemord, &js, &je, &ks, &ke, &is, &ie,
                                                 &jms,&jme,&kms,&kme,&ims,&ime, &wcount ) ;
            xm_curs += wcount*typesize ;
	  }
	  else {
#ifndef MS_SUA
            fprintf(stderr,"internal error: %s %d\n",__FILE__,__LINE__) ;
#endif
          }
        }
      }
    }
  }
  }
#endif

}
Exemplo n.º 4
0
	4, {
		BIP_RANGE(5),
		BIP_RANGE(10),
		UNI_RANGE(5),
		UNI_RANGE(10)
	}
};

static const struct comedi_lrange pcmmio_ao_ranges = {
	6, {
		UNI_RANGE(5),
		UNI_RANGE(10),
		BIP_RANGE(5),
		BIP_RANGE(10),
		BIP_RANGE(2.5),
		RANGE(-2.5, 7.5)
	}
};

struct pcmmio_private {
	spinlock_t pagelock;	/* protects the page registers */
	spinlock_t spinlock;	/* protects the member variables */
	unsigned int enabled_mask;
	unsigned int stop_count;
	unsigned int active:1;

	unsigned int ao_readback[8];
};

static void pcmmio_dio_write(struct comedi_device *dev, unsigned int val,
			     int page, int port)
Exemplo n.º 5
0
	  1 = [-2.5, 2.5]
	  2 = [0, 5]
  [4] - D/A 0 range (same choices)
  [4] - D/A 1 range (same choices)
*/

#include <linux/interrupt.h>
#include "../comedidev.h"

#include <linux/ioport.h>

static const char *driver_name = "dt2811";

static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = {
	4, {
		RANGE(0, 5),
		RANGE(0, 2.5),
		RANGE(0, 1.25),
		RANGE(0, 0.625)
	}
};

static const struct comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = {
	4, {
		RANGE(-2.5, 2.5),
		RANGE(-1.25, 1.25),
		RANGE(-0.625, 0.625),
		RANGE(-0.3125, 0.3125)
	}
};
Exemplo n.º 6
0
void Skybox::InitializePresets(Renderer* pRenderer, const Settings::Rendering& renderSettings)
{
	EnvironmentMap::Initialize(pRenderer);
	EnvironmentMap::LoadShaders();
	
	const std::string extension = ".hdr";
	const std::string BRDFLUTTextureFileName = "BRDFIntegrationLUT";
	const std::string BRDFLUTTextureFilePath = EnvironmentMap::sTextureCacheDirectory + BRDFLUTTextureFileName + extension;
	
	const bool bUseCache = Engine::GetSettings().bCacheEnvironmentMapsOnDisk && DirectoryUtil::FileExists(BRDFLUTTextureFilePath);

	if(bUseCache)
	{ 
		EnvironmentMap::sBRDFIntegrationLUTTexture = pRenderer->CreateHDRTexture(BRDFLUTTextureFileName + extension, EnvironmentMap::sTextureCacheDirectory);
	}
	else
	{
		Texture LUTTexture = EnvironmentMap::CreateBRDFIntegralLUTTexture();
		EnvironmentMap::sBRDFIntegrationLUTTexture = LUTTexture._id;

		if (Engine::GetSettings().bCacheEnvironmentMapsOnDisk)
		{
			pRenderer->SaveTextureToDisk(EnvironmentMap::sBRDFIntegrationLUTTexture, BRDFLUTTextureFilePath, false);
		}

		// todo: we can unload shaders / render targets here
	}


	// Cubemap Skyboxes
	//------------------------------------------------------------------------------------------------------------------------------------
	{	// NIGHTSKY		
		// #AsyncLoad: Mutex DEVICE

		const bool bEquirectangular = false;
		const auto offsetIter = s_filePaths.begin() + ECubeMapPresets::NIGHT_SKY;
		const FilePaths filePaths = FilePaths(offsetIter, offsetIter + 6);
		
		TextureID skydomeTex = pRenderer->CreateCubemapFromFaceTextures(filePaths, false);
		//Skybox::SetPreset(ECubeMapPresets::NIGHT_SKY, std::move(Skybox(pRenderer, skydomeTex, bEquirectangular)));
		s_Presets[ECubeMapPresets::NIGHT_SKY] = Skybox(pRenderer, skydomeTex, bEquirectangular);
	}
	
	if (renderSettings.bEnableEnvironmentLighting)
	{
		// HDR / IBL - Equirectangular Skyboxes
		//------------------------------------------------------------------------------------------------------------------------------------
		//EnvironmentMap::Initialize(pRenderer);
		
		const bool bEquirectangular = true;

		EnvironmentMapFileNames files;

		const std::vector<EEnvironmentMapPresets> presets = 
		{
			EEnvironmentMapPresets::BARCELONA     ,
			EEnvironmentMapPresets::TROPICAL_BEACH,
			EEnvironmentMapPresets::MILKYWAY	  ,
			EEnvironmentMapPresets::TROPICAL_RUINS,
			EEnvironmentMapPresets::WALK_OF_FAME
		};
		std::for_each(RANGE(presets), [&](auto preset)
		{
			const auto rootAndFilesPair = GetsIBLFiles(preset);
			s_Presets[preset] = Skybox(pRenderer, bEquirectangular);
			s_Presets[preset].Initialize(rootAndFilesPair.second, rootAndFilesPair.first);
		});
	}
}
Exemplo n.º 7
0
static void DISKSIM_SYNTHGEN_PROBABILITY_OF_TIME_LIMITED_REQUEST_loader(synthio_generator ** result, double d) { 
if (! (RANGE(d,0.0,1.0))) { // foo 
 } 
 (*result)->probtmlim = d;

}
Exemplo n.º 8
0
static void DISKSIM_SIMPLEDISK_PRINT_STATS_loader(struct simpledisk * result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 result->printstats = i;

}
Exemplo n.º 9
0
static void DISKSIM_PF_STATS_PRINT_PER_PROCESS_STATS_loader(int result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 pf_print_perprocessstats = i;

}
Exemplo n.º 10
0
static void DISKSIM_PF_STATS_PRINT_SLEEP_STATS_loader(int result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 pf_print_sleepstats = i;

}
Exemplo n.º 11
0
static void DISKSIM_PF_STATS_PRINT_ALL_INTERRUPT_STATS_loader(int result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 pf_print_intrstats = i;

}
Exemplo n.º 12
0
static void DISKSIM_PF_STATS_PRINT_PER_CPU_STATS_loader(int result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 pf_print_percpustats = i;

}
Exemplo n.º 13
0
	// The input consists of six character sets in the Base64 alphabet,
	// which we need to map back to the 6-bit values they represent.
	// There are three ranges, two singles, and then there's the rest.
	//
	//  #  From       To        Add  Characters
	//  1  [43]       [62]      +19  +
	//  2  [47]       [63]      +16  /
	//  3  [48..57]   [52..61]   +4  0..9
	//  4  [65..90]   [0..25]   -65  A..Z
	//  5  [97..122]  [26..51]  -71  a..z
	// (6) Everything else => invalid input

	const __m256i set1 = CMPEQ(str, '+');
	const __m256i set2 = CMPEQ(str, '/');
	const __m256i set3 = RANGE(str, '0', '9');
	const __m256i set4 = RANGE(str, 'A', 'Z');
	const __m256i set5 = RANGE(str, 'a', 'z');

	__m256i delta = REPLACE(set1, 19);
	delta = _mm256_or_si256(delta, REPLACE(set2,  16));
	delta = _mm256_or_si256(delta, REPLACE(set3,   4));
	delta = _mm256_or_si256(delta, REPLACE(set4, -65));
	delta = _mm256_or_si256(delta, REPLACE(set5, -71));

	// Check for invalid input: if any of the delta values are zero,
	// fall back on bytewise code to do error checking and reporting:
	if (_mm256_movemask_epi8(CMPEQ(delta, 0))) {
		break;
	}
Exemplo n.º 14
0
void idct(int *block,int k)
{
  int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  int z5, z10, z11, z12, z13;
  int *ptr;
  int i;

  if (!k) { idct1(block); return; }

  ptr = block;
  for (i = 0; i< DCTSIZE; i++,ptr++) {

    if ((ptr[DCTSIZE*1] | ptr[DCTSIZE*2] | ptr[DCTSIZE*3] |
	 ptr[DCTSIZE*4] | ptr[DCTSIZE*5] | ptr[DCTSIZE*6] |
	 ptr[DCTSIZE*7]) == 0) {
      ptr[DCTSIZE*0] =
      ptr[DCTSIZE*1] =
      ptr[DCTSIZE*2] =
      ptr[DCTSIZE*3] =
      ptr[DCTSIZE*4] =
      ptr[DCTSIZE*5] =
      ptr[DCTSIZE*6] =
      ptr[DCTSIZE*7] =
      	ptr[DCTSIZE*0];

      continue;
    }

    z10 = ptr[DCTSIZE*0] + ptr[DCTSIZE*4];
    z11 = ptr[DCTSIZE*0] - ptr[DCTSIZE*4];
    z13 = ptr[DCTSIZE*2] + ptr[DCTSIZE*6];
    z12 = MULTIPLY(ptr[DCTSIZE*2] - ptr[DCTSIZE*6], FIX_1_414213562) - z13;

    tmp0 = z10 + z13;
    tmp3 = z10 - z13;
    tmp1 = z11 + z12;
    tmp2 = z11 - z12;

    z13 = ptr[DCTSIZE*3] + ptr[DCTSIZE*5];
    z10 = ptr[DCTSIZE*3] - ptr[DCTSIZE*5];
    z11 = ptr[DCTSIZE*1] + ptr[DCTSIZE*7];
    z12 = ptr[DCTSIZE*1] - ptr[DCTSIZE*7];

    z5 = MULTIPLY(z12 - z10, FIX_1_847759065);
    tmp7 = z11 + z13;
    tmp6 = MULTIPLY(z10, FIX_2_613125930) + z5 - tmp7;
    tmp5 = MULTIPLY(z11 - z13, FIX_1_414213562) - tmp6;
    tmp4 = MULTIPLY(z12, FIX_1_082392200) - z5 + tmp5;

    ptr[DCTSIZE*0] = (tmp0 + tmp7);
    ptr[DCTSIZE*7] = (tmp0 - tmp7);
    ptr[DCTSIZE*1] = (tmp1 + tmp6);
    ptr[DCTSIZE*6] = (tmp1 - tmp6);
    ptr[DCTSIZE*2] = (tmp2 + tmp5);
    ptr[DCTSIZE*5] = (tmp2 - tmp5);
    ptr[DCTSIZE*4] = (tmp3 + tmp4);
    ptr[DCTSIZE*3] = (tmp3 - tmp4);

  }

  ptr = block;
  for (i = 0; i < DCTSIZE; i++ ,ptr+=DCTSIZE) {

    if ((ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5] | ptr[6] |
	 ptr[7]) == 0) {
      ptr[0] =
      ptr[1] =
      ptr[2] =
      ptr[3] =
      ptr[4] =
      ptr[5] =
      ptr[6] =
      ptr[7] =
      	RANGE(DESCALE(ptr[0], PASS1_BITS+3));;

      continue;
    }

    z10 = ptr[0] + ptr[4];
    z11 = ptr[0] - ptr[4];
    z13 = ptr[2] + ptr[6];
    z12 = MULTIPLY(ptr[2] - ptr[6], FIX_1_414213562) - z13;

    tmp0 = z10 + z13;
    tmp3 = z10 - z13;
    tmp1 = z11 + z12;
    tmp2 = z11 - z12;

    z13 = ptr[3] + ptr[5];
    z10 = ptr[3] - ptr[5];
    z11 = ptr[1] + ptr[7];
    z12 = ptr[1] - ptr[7];

    z5 = MULTIPLY(z12 - z10, FIX_1_847759065);
    tmp7 = z11 + z13;
    tmp6 = MULTIPLY(z10, FIX_2_613125930) + z5 - tmp7;
    tmp5 = MULTIPLY(z11 - z13, FIX_1_414213562) - tmp6;
    tmp4 = MULTIPLY(z12, FIX_1_082392200) - z5 + tmp5;

    ptr[0] = RANGE(DESCALE(tmp0 + tmp7, PASS1_BITS+3));;
    ptr[7] = RANGE(DESCALE(tmp0 - tmp7, PASS1_BITS+3));;
    ptr[1] = RANGE(DESCALE(tmp1 + tmp6, PASS1_BITS+3));;
    ptr[6] = RANGE(DESCALE(tmp1 - tmp6, PASS1_BITS+3));;
    ptr[2] = RANGE(DESCALE(tmp2 + tmp5, PASS1_BITS+3));;
    ptr[5] = RANGE(DESCALE(tmp2 - tmp5, PASS1_BITS+3));;
    ptr[4] = RANGE(DESCALE(tmp3 + tmp4, PASS1_BITS+3));;
    ptr[3] = RANGE(DESCALE(tmp3 - tmp4, PASS1_BITS+3));;

  }
}
Exemplo n.º 15
0
static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
		int num_samples)
{
	struct sr_datafeed_packet packet;
	struct sr_datafeed_analog analog;
	struct sr_analog_encoding encoding;
	struct sr_analog_meaning meaning;
	struct sr_analog_spec spec;
	struct dev_context *devc = sdi->priv;
	GSList *channels = devc->enabled_channels;

	const float ch_bit[] = { RANGE(0) / 255, RANGE(1) / 255 };
	const float ch_center[] = { RANGE(0) / 2, RANGE(1) / 2 };

	sr_analog_init(&analog, &encoding, &meaning, &spec, 0);

	packet.type = SR_DF_ANALOG;
	packet.payload = &analog;

	analog.num_samples = num_samples;
	analog.meaning->mq = SR_MQ_VOLTAGE;
	analog.meaning->unit = SR_UNIT_VOLT;
	analog.meaning->mqflags = 0;

	analog.data = g_try_malloc(num_samples * sizeof(float));
	if (!analog.data) {
		sr_err("Analog data buffer malloc failed.");
		devc->dev_state = STOPPING;
		return;
	}

	for (int ch = 0; ch < 2; ch++) {
		if (!devc->ch_enabled[ch])
			continue;

		float vdivlog = log10f(ch_bit[ch]);
		int digits = -(int)vdivlog + (vdivlog < 0.0);
		analog.encoding->digits = digits;
		analog.spec->spec_digits = digits;
		analog.meaning->channels = g_slist_append(NULL, channels->data);

		for (int i = 0; i < num_samples; i++) {
			/*
			 * The device always sends data for both channels. If a channel
			 * is disabled, it contains a copy of the enabled channel's
			 * data. However, we only send the requested channels to
			 * the bus.
			 *
			 * Voltage values are encoded as a value 0-255, where the
			 * value is a point in the range represented by the vdiv
			 * setting. There are 10 vertical divs, so e.g. 500mV/div
			 * represents 5V peak-to-peak where 0 = -2.5V and 255 = +2.5V.
			 */
			((float *)analog.data)[i] = ch_bit[ch] * *(buf + i * 2 + ch) - ch_center[ch];
		}

		sr_session_send(sdi, &packet);
		g_slist_free(analog.meaning->channels);

		channels = channels->next;
	}
	g_free(analog.data);
}
Exemplo n.º 16
0
	PCHAR GetScriptByID(DWORD ID, bool &Created)
	{
		// Функция возвращает адреса скриптов в версии бота, которая
		// поддерживает шифрование и защиту алресов
		Created = true;
		DWORD Min1, Max1, Min2, Max2;
        bool IsGetScript = false;

		#define RANGE(IsGet, Mn1, Mx1, Mn2, Mx2) {Min1 = Mn1; Max1 = Mx1; \
												  Min2 = Mn2; Max2 = Mx2; \
												  IsGetScript = IsGet; \
												  break;}

        // Определяем границы скрипта
		switch (ID) {
			// Скрипты из папки GET
			case SCRIPT_FORM_GRABBER: RANGE(true, 1, 3, 24, 26);
			case SCRIPT_GRABBER:      RANGE(true, 4, 6, 27, 30);
			case SCRIPT_FTP_SNIFFER:  RANGE(true, 7, 9, 31, 33);
			case SCRIPT_CAB:          RANGE(true, 10, 12, 34, 36);
//            case SCRIPT_CAB_PART:     RANGE(true, 13, 15, 37, 39);
			case SCRIPT_KEYLOGGER:    RANGE(true, 16, 18, 40, 42);
//			case SCRIPT_SCREENSHOT:   RANGE(true, 22, 24, 46, 48);


			// Скрипты из папки SET
			case SCRIPT_TASK:         RANGE(false, 1, 6, 18, 24);
			case SCRIPT_FIRST_INFO:   RANGE(false, 7, 12, 25, 30);
			case SCRIPT_PLUGINS:      RANGE(false, 13, 17, 31, 36);
			case SCRIPT_COMMENT:      RANGE(false, 37, 48, 37, 48);
			case SCRIPT_HUNTER:       RANGE(false, 49, 56, 48, 56);
			case SCRIPT_PLUGINS_LIST: RANGE(false, 57, 64, 57, 64);


		default:
            return NULL;
		}


		// Генерируем путь

		DWORD ExtCount = 0;
		if (IsGetScript)
			ExtCount = sizeof(GETFolderExts) / sizeof(PCHAR);
		else
			ExtCount = sizeof(SETFolderExts) / sizeof(PCHAR);

		PCHAR *Exts = NULL;
		if (IsGetScript)
			Exts = (PCHAR*)&GETFolderExts[0];
		else
			Exts = (PCHAR*)&SETFolderExts[0];

		return GenerateRandomScript(Min1, Max1, Min2, Max2, ExtCount, Exts);

	}
Exemplo n.º 17
0
static void DISKSIM_SIMPLEDISK_NEVER_DISCONNECT_loader(struct simpledisk * result, int i) { 
if (! (RANGE(i,0,1))) { // foo 
 } 
 result->neverdisconnect = i;

}
Exemplo n.º 18
0
#define ESCAPE_CHAR	'~'

typedef enum {
	CTRL = 0, ASCII = 1, GB2312 = 2, CS94 = 3, CS96 = 4
} charset_t;

typedef struct {
	int	 end;
	int	 start;
	int	 width;
} range_t;

static const range_t ranges[] = {
#define RANGE(start, end) { start, end, (end - start) + 1 }
/* CTRL   */ RANGE(0x00, 0x1F),
/* ASCII  */ RANGE(0x20, 0x7F),
/* GB2312 */ RANGE(0x21, 0x7E),
/* CS94   */ RANGE(0x21, 0x7E),
/* CS96   */ RANGE(0x20, 0x7F),
#undef RANGE
};

typedef struct escape_t escape_t;
typedef struct {
	charset_t	 charset;
	escape_t	*escape;
	ssize_t		 length;
#define ROWCOL_MAX	3
} graphic_t;
Exemplo n.º 19
0
static void DISKSIM_SYNTHGEN_PROBABILITY_OF_READ_ACCESS_loader(synthio_generator ** result, double d) { 
if (! (RANGE(d,0.0,1.0))) { // foo 
 } 
 (*result)->probread = d;

}
Exemplo n.º 20
0
WireSyntax::WireSyntax()
{
    SYNTAX("Wire");

    DEFINE_VOID("Comment",
                CHOICE(
                    GLUE(
                        STRING("//"),
                        CHOICE(
                            FIND(AHEAD(CHAR('\n'))),
                            FIND(EOI())
                        )
                    ),
                    GLUE(
                        STRING("/*"),
                        REPEAT(
                            CHOICE(
                                INLINE("Comment"),
                                GLUE(
                                    NOT(STRING("*/")),
                                    ANY()
                                )
                            )
                        ),
                        STRING("*/")
                    )
                )
               );

    DEFINE_VOID("Whitespace",
                REPEAT(
                    CHOICE(
                        RANGE(" \t\n"),
                        INLINE("Comment")
                    )
                )
               );

    DEFINE("Name",
           REPEAT(1, EXCEPT(" \t\n:;"))
          );

    DEFINE("Value",
           CHOICE(
               REF("Atom"),
               REF("Properties"),
               REF("Items")
           )
          );

    DEFINE("Object",
           GLUE(
               REPEAT(0, 1,
                      GLUE(
                          REF("Name"),
                          INLINE("Whitespace"),
                          CHAR(':'),
                          INLINE("Whitespace")
                      )
                     ),
               INLINE("Value")
           )
          );

    DEFINE("Atom",
           REPEAT(
               GLUE(
                   NOT(
                       CHOICE(
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               INLINE("Name"),
                               REPEAT(RANGE(" \t")),
                               CHAR(':')
                           ),
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               RANGE("};,")
                           ),
                           STRING("\n\n")
                       )
                   ),
                   ANY()
               )
           )
          );

    DEFINE("Properties",
           GLUE(
               CHAR('{'),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Object"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR('}')
           )
          );

    DEFINE("Items",
           GLUE(
               CHAR('['),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Value"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR(']')
           )
          );

    ENTRY("Object");
}
Exemplo n.º 21
0
void Skybox::InitializePresets_Async(Renderer* pRenderer, const Settings::Rendering& renderSettings)
{
	EnvironmentMap::Initialize(pRenderer);
	{
		std::unique_lock<std::mutex> lck(Engine::mLoadRenderingMutex);
		EnvironmentMap::LoadShaders();
	}
	{
		std::unique_lock<std::mutex> lck(Engine::mLoadRenderingMutex);
		Texture LUTTexture = EnvironmentMap::CreateBRDFIntegralLUTTexture();
		EnvironmentMap::sBRDFIntegrationLUTTexture = LUTTexture._id;
	}

	// Cubemap Skyboxes
	//------------------------------------------------------------------------------------------------------------------------------------
	{	// NIGHTSKY		
		// #AsyncLoad: Mutex DEVICE

		const bool bEquirectangular = false;
		const auto offsetIter = s_filePaths.begin() + ECubeMapPresets::NIGHT_SKY;
		const FilePaths filePaths = FilePaths(offsetIter, offsetIter + 6);

		TextureID skydomeTex = -1;
		{
			std::unique_lock<std::mutex> lck(Engine::mLoadRenderingMutex);
			skydomeTex = pRenderer->CreateCubemapFromFaceTextures(filePaths, false);
		}
		s_Presets[ECubeMapPresets::NIGHT_SKY] = Skybox(pRenderer, skydomeTex, bEquirectangular);
	}

	if (renderSettings.bEnableEnvironmentLighting)
	{
		// HDR / IBL - Equirectangular Skyboxes
		//------------------------------------------------------------------------------------------------------------------------------------
		//EnvironmentMap::Initialize(pRenderer);
		const std::string sIBLDirectory = Renderer::sHDRTextureRoot + std::string("sIBL/");
		const bool bEquirectangular = true;

		EnvironmentMapFileNames files;

		const std::vector<EEnvironmentMapPresets> presets =
		{
			EEnvironmentMapPresets::BARCELONA     ,
			EEnvironmentMapPresets::TROPICAL_BEACH,
			EEnvironmentMapPresets::MILKYWAY	  ,
			EEnvironmentMapPresets::TROPICAL_RUINS,
			EEnvironmentMapPresets::WALK_OF_FAME
		};

		if (renderSettings.bPreLoadEnvironmentMaps)
		{
			std::for_each(RANGE(presets), [&](auto preset)
			{
				const auto rootAndFilesPair = GetsIBLFiles(preset);
				{
					s_Presets[preset] = Skybox(pRenderer, bEquirectangular);
					s_Presets[preset].Initialize(rootAndFilesPair.second, rootAndFilesPair.first);
				}
			});
		}
		else
		{
			auto& preset = presets.back();
			const auto rootAndFilesPair = GetsIBLFiles(preset);
			{
				s_Presets[preset] = Skybox(pRenderer, bEquirectangular);
				s_Presets[preset].Initialize(rootAndFilesPair.second, rootAndFilesPair.first);
			}
		}
	}
}
Exemplo n.º 22
0
static void DISKSIM_CACHEDEV_WRITE_SCHEME_loader(struct cache_dev * result, int i) { 
if (! (RANGE(i,CACHE_WRITE_MIN,CACHE_WRITE_MAX))) { // foo 
 } 
 result->writescheme = i;

}
Exemplo n.º 23
0
/* test the 4 extrapolations
 */
static
void test(uint32_t size)
{
    ADBM(dbm1);
    ADBM(dbm2);
    ADBM(dbm3);
    ADBM(dbm4);
    ADBM(dbm5);
    ADBM(dbm6);
    ADBM(dbm7);
    ADBM(dbm8);
    ADBM(dbm9);
    ADBM(dbm10);
    AVECT(lower);
    AVECT(upper);
    AVECT(max);
    uint32_t k, l;
    printf("*** Testing size=%u\n", size);


    for (k = 0; k < 2000; ++k)
    {
        PROGRESS();
        
        max[0] = lower[0] = upper[0] = 0;
        for (l = 1; l < size; l++) 
        {
            int32_t low = RANGE() - (MAXRANGE / 2);
            int32_t up  = RANGE() - (MAXRANGE / 2); /* low + RANGE()/2; */
            lower[l] = (low < 0 ? -dbm_INFINITY : low);
            upper[l] = (up < 0 ? -dbm_INFINITY : up);
            max[l] = (lower[l] < upper[l] ? upper[l] : lower[l]);
        }
        
        DBM_GEN(dbm1);
        dbm_copy(dbm10, dbm1, size);
        dbm_copy(dbm9, dbm1, size);
        dbm_copy(dbm8, dbm1, size); 
        dbm_copy(dbm7, dbm1, size); 
        dbm_copy(dbm6, dbm1, size); 
        dbm_copy(dbm5, dbm1, size); 
        dbm_copy(dbm4, dbm1, size); 
        dbm_copy(dbm3, dbm1, size); 
        dbm_copy(dbm2, dbm1, size); 
        assert(dbm_isClosed(dbm1, size));
        
        dbm_extrapolateMaxBounds(dbm2, size, max);
        dbm_extrapolateLUBounds(dbm3, size, max, max);
        dbm_extrapolateLUBounds(dbm4, size, lower, upper);
        dbm_diagonalExtrapolateMaxBounds(dbm5, size, max);
        test_diagonalExtrapolateMaxBounds(dbm8, size, max);
        dbm_diagonalExtrapolateLUBounds(dbm6, size, max, max);
        test_diagonalExtrapolateLUBounds(dbm9, size, max, max);
        dbm_diagonalExtrapolateLUBounds(dbm7, size, lower, upper);
        test_diagonalExtrapolateLUBounds(dbm10, size, lower, upper);
        
        assert(dbm_areEqual(dbm5, dbm8, size));
        assert(dbm_areEqual(dbm6, dbm9, size));
        assert(dbm_areEqual(dbm7, dbm10, size));

        /* 1 <= 2 == 3 <= 4 <= 7, 1 <= 2 == 3 <= 5 == 6 <= 7 */
        assert(dbm_relation(dbm1, dbm2, size) & base_SUBSET);
        assert(dbm_relation(dbm2, dbm3, size) == base_EQUAL);
        assert(dbm_relation(dbm3, dbm4, size) & base_SUBSET);
        assert(dbm_relation(dbm4, dbm7, size) & base_SUBSET);
        assert(dbm_relation(dbm3, dbm5, size) & base_SUBSET);
        assert(dbm_relation(dbm5, dbm6, size) == base_EQUAL);
        assert(dbm_relation(dbm6, dbm7, size) & base_SUBSET);
        
        /* further checks */
        assert(dbm_isValid(dbm2, size));
        assert(dbm_isValid(dbm3, size));
        assert(dbm_isValid(dbm4, size));
        assert(dbm_isValid(dbm5, size));
        assert(dbm_isValid(dbm6, size));
        assert(dbm_isValid(dbm7, size));
    }
    ENDL;

    free(lower);
    free(upper);
    free(max);
    free(dbm10);
    free(dbm9);
    free(dbm8);
    free(dbm7);
    free(dbm6);
    free(dbm5);
    free(dbm4);
    free(dbm3);
    free(dbm2);
    free(dbm1);
}
Exemplo n.º 24
0
static void DISKSIM_CACHEDEV_FLUSH_POLICY_loader(struct cache_dev * result, int i) { 
if (! (RANGE(i,CACHE_FLUSH_MIN,CACHE_FLUSH_MAX))) { // foo 
 } 
 result->flush_policy = i;

}
Exemplo n.º 25
0
	bool operator == (const Color& o)
	{
		return std::equal(RANGE(rgb), std::begin(o.rgb));
	}
Exemplo n.º 26
0
resPtr
xf86PciBusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;
    /*
     * On the Alpha the first 16MB of every 128 Mb segment in
     * sparse address space are an image of the ISA bus range
     */
    if (_bus_base_sparse()) {
	RANGE(range, 0x00000000, 0x07ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x09000000, 0x0fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x11000000, 0x17ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x19000000, 0x1fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x21000000, 0x27ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x29000000, 0x2fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x31000000, 0x37ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x39000000, 0x3fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x41000000, 0x47ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x49000000, 0x4fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x51000000, 0x57ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x59000000, 0x5fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x61000000, 0x67ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x69000000, 0x6fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x71000000, 0x77ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x79000000, 0x7fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x81000000, 0x87ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x89000000, 0x8fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x91000000, 0x97ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x99000000, 0x9fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xa1000000, 0xa7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xa9000000, 0xafffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xb1000000, 0xb7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xb9000000, 0xbfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xc1000000, 0xc7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xc9000000, 0xcfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xd1000000, 0xd7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xd9000000, 0xdfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xe1000000, 0xe7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xe9000000, 0xefffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xf1000000, 0xf7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xf9000000, 0xffffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
    } else {
	RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
    }
    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}
Exemplo n.º 27
0
#define DAQBOARD2000_SECRProgPinLo      0x8000767e
#define DAQBOARD2000_SECRLocalBusHi     0xc000767e
#define DAQBOARD2000_SECRLocalBusLo     0x8000767e
#define DAQBOARD2000_SECRReloadHi       0xa000767e
#define DAQBOARD2000_SECRReloadLo       0x8000767e

/* SECR status bits */
#define DAQBOARD2000_EEPROM_PRESENT     0x10000000

/* CPLD status bits */
#define DAQBOARD2000_CPLD_INIT 		0x0002
#define DAQBOARD2000_CPLD_DONE 		0x0004

/* Available ranges */
static const struct comedi_lrange range_daqboard2000_ai = { 13, {
								 RANGE(-10, 10),
								 RANGE(-5, 5),
								 RANGE(-2.5,
								       2.5),
								 RANGE(-1.25,
								       1.25),
								 RANGE(-0.625,
								       0.625),
								 RANGE(-0.3125,
								       0.3125),
								 RANGE(-0.156,
								       0.156),
								 RANGE(0, 10),
								 RANGE(0, 5),
								 RANGE(0, 2.5),
								 RANGE(0, 1.25),
Exemplo n.º 28
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
uint8 GetSampleSinusWave(Channel ch, int numSample)
{
    float dT = numSample * TSHIFT_2_ABS(1, TBASE);
    float voltage = ampl[ch] * sinf(2.0f * M_PI * freq[ch] * dT + angle[ch]) + NewNoiseValue(ch);
    return Math_VoltageToPoint(voltage, RANGE(ch), RSHIFT(ch));
}
Exemplo n.º 29
0
#define DT2821_DS1	0x0800	/* (R/W) DMA select 1                     */
#define DT2821_DS0	0x0400	/* (R/W) DMA select 0                     */
#define DT2821_BUFFB	0x0200	/* (R/W) buffer B selected                */
#define DT2821_SCDN	0x0100	/* (R)   scan done                        */
#define DT2821_DACON	0x0080	/* (W)   DAC single conversion            */
#define DT2821_ADCINIT	0x0040	/* (W)   A/D initialize                   */
#define DT2821_DACINIT	0x0020	/* (W)   D/A initialize                   */
#define DT2821_PRLD	0x0010	/* (W)   preload multiplexer              */
#define DT2821_STRIG	0x0008	/* (W)   software trigger         */
#define DT2821_XTRIG	0x0004	/* (R/W) external trigger enable  */
#define DT2821_XCLK	0x0002	/* (R/W) external clock enable            */
#define DT2821_BDINIT	0x0001	/* (W)   initialize board         */

static const struct comedi_lrange range_dt282x_ai_lo_bipolar = {
	4, {
		RANGE(-10, 10),
		RANGE(-5, 5),
		RANGE(-2.5, 2.5),
		RANGE(-1.25, 1.25)
	}
};

static const struct comedi_lrange range_dt282x_ai_lo_unipolar = {
	4, {
		RANGE(0, 10),
		RANGE(0, 5),
		RANGE(0, 2.5),
		RANGE(0, 1.25)
	}
};
Exemplo n.º 30
0
isc_result_t
dns_time64_fromtext(const char *source, isc_int64_t *target) {
	int year, month, day, hour, minute, second;
	isc_int64_t value;
	int secs;
	int i;

#define RANGE(min, max, value) \
	do { \
		if (value < (min) || value > (max)) \
			return (ISC_R_RANGE); \
	} while (/*CONSTCOND*/0)

	if (strlen(source) != 14U)
		return (DNS_R_SYNTAX);
	/*
	 * Confirm the source only consists digits.  sscanf() allows some
	 * minor exceptions.
	 */
	for (i = 0; i < 14; i++) {
		if (!isdigit((unsigned char)source[i]))
			return (DNS_R_SYNTAX);
	}
	if (sscanf(source, "%4d%2d%2d%2d%2d%2d",
		   &year, &month, &day, &hour, &minute, &second) != 6)
		return (DNS_R_SYNTAX);

	RANGE(0, 9999, year);
	RANGE(1, 12, month);
	RANGE(1, days[month - 1] +
		 ((month == 2 && is_leap(year)) ? 1 : 0), day);
#ifdef __COVERITY__
	/*
	 * Use a simplified range to silence Coverity warning (in
	 * arithmetic with day below).
	 */
	RANGE(1, 31, day);
#endif /* __COVERITY__ */

	RANGE(0, 23, hour);
	RANGE(0, 59, minute);
	RANGE(0, 60, second);		/* 60 == leap second. */

	/*
	 * Calculate seconds from epoch.
	 * Note: this uses a idealized calendar.
	 */
	value = second + (60 * minute) + (3600 * hour) + ((day - 1) * 86400);
	for (i = 0; i < (month - 1); i++)
		value += days[i] * 86400;
	if (is_leap(year) && month > 2)
		value += 86400;
	if (year < 1970) {
		for (i = 1969; i >= year; i--) {
			secs = (is_leap(i) ? 366 : 365) * 86400;
			value -= secs;
		}
	} else {
		for (i = 1970; i < year; i++) {
			secs = (is_leap(i) ? 366 : 365) * 86400;
			value += secs;
		}
	}

	*target = value;
	return (ISC_R_SUCCESS);
}