Example #1
0
static void run_buffer_path_simplify(buffer *psrc, buffer *pdest, const char *in, size_t in_len, const char *out, size_t out_len) {
	buffer_copy_string_len(psrc, in, in_len);

	buffer_path_simplify(pdest, psrc);

	if (!buffer_is_equal_string(pdest, out, out_len)) {
		fprintf(stderr,
			"%s.%d: buffer_path_simplify('%s') failed: expected '%s', got '%s'\n",
			__FILE__,
			__LINE__,
			in,
			out,
			pdest->ptr ? pdest->ptr : "");
		fflush(stderr);
		abort();
	} else {
		if (psrc != pdest) buffer_copy_buffer(psrc, pdest);
		buffer_path_simplify(pdest, psrc);

		if (!buffer_is_equal_string(pdest, out, out_len)) {
			fprintf(stderr,
				"%s.%d: buffer_path_simplify('%s') failed - not idempotent: expected '%s', got '%s'\n",
				__FILE__,
				__LINE__,
				in,
				out,
				pdest->ptr ? pdest->ptr : "");
			fflush(stderr);
			abort();
		}
	}
}
int
main (int argc, char *argv[])
{
  __vector __int128 loaded_v;
  __vector unsigned __int128 loaded_uv;

  /* Usage:
   *  <Type> result = vec_ld (int index, __vector <Type> v)
   * is equivalent to:
   *  result = v [index];
   */
  doInitialization ();
  loaded_v = vec_ld (0, pv);
  if (loaded_v[0] != -1)
    abort ();

  loaded_uv = vec_ld (0, puv);
  if (loaded_uv[0] != 0xcafebabe)
    abort ();

  loaded_v = vec_ld (0, pi128);
  if (loaded_v[0] != 0xfabeabe)
    abort ();

  loaded_uv = vec_ld (0, pu128);
  if (loaded_uv[0] != 0xabefabe)
    abort ();

  return 0;
}
Example #3
0
Object
constant(DCEparsestate* state, Object val, int tag)
{
    DCEconstant* con = (DCEconstant*)dcecreate(CES_CONST);
    char* text = (char*)val;
    char* endpoint = NULL;
    switch (tag) {
    case SCAN_STRINGCONST:
	con->discrim = CES_STR;
	con->text = nulldup(text);
	break;
    case SCAN_NUMBERCONST:
	con->intvalue = strtoll(text,&endpoint,10);
	if(*text != '\0' && *endpoint == '\0') {
	    con->discrim = CES_INT;
	} else {
	    con->floatvalue = strtod(text,&endpoint);
	    if(*text != '\0' && *endpoint == '\0')
	        con->discrim = CES_FLOAT;
	    else abort();
	}
	break;
    default: abort(); break;
    }
    return con;
}
Example #4
0
slong
hypgeom_estimate_terms(const mag_t z, int r, slong prec)
{
    double y, t;

    t = mag_get_d(z);

    if (t == 0)
        return 1;

    if (r == 0)
    {
        if (t >= 1)
        {
            flint_printf("z must be smaller than 1\n");
            abort();
        }

        y = (log(1-t) - prec * LOG2) / log(t) + 1;
    }
    else
    {
        y = (prec * LOG2) / (d_root(t, r) * EXP1 * r);
        y = (prec * LOG2) / (r * d_lambertw(y)) + 1;
    }

    if (y >= WORD_MAX / 2)
    {
        flint_printf("error: series will converge too slowly\n");
        abort();
    }

    return y;
}
Example #5
0
static void
ctfdump_output(const char *out)
{
	int fd, ret;
	const void *data;
	size_t len;

	ctf_dataptr(g_fp, &data, &len);
	if ((fd = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
		ctfdump_fatal("failed to open output file %s: %s\n", out,
		    strerror(errno));

	while (len > 0) {
		ret = write(fd, data, len);
		if (ret == -1 && errno == EINTR)
			continue;
		else if (ret == -1 && (errno == EFAULT || errno == EBADF))
			abort();
		else if (ret == -1)
			ctfdump_fatal("failed to write to %s: %s\n", out,
			    strerror(errno));
		data += ret;
		len -= ret;
	}

	do {
		ret = close(fd);
	} while (ret == -1 && errno == EINTR);
	if (ret != 0 && errno == EBADF)
		abort();
	if (ret != 0)
		ctfdump_fatal("failed to close %s: %s\n", out, strerror(errno));
}
Example #6
0
void wvtest_check(bool cond, const char *reason)
{
#ifndef _WIN32
    alarm(MAX_TEST_TIME); // restart per-test timeout
#endif
    if (!start_time) start_time = time(NULL);

    if (time(NULL) - start_time > MAX_TOTAL_TIME)
    {
	printf("\n! WvTest   Total run time exceeded %d seconds!  FAILED\n",
	       MAX_TOTAL_TIME);
	fflush(stdout);
	abort();
    }

    runs++;

    print_result_str(false, NULL, 0, NULL, cond ? "ok" : (reason ? reason : "FAILED"));

    if (!cond)
    {
	fails++;

	if (getenv("WVTEST_DIE_FAST"))
	    abort();
    }
}
void PeerWireClient::timerEvent(QTimerEvent *event)
{
    if (event->timerId() == transferSpeedTimer) {
        // Rotate the upload / download records.
        for (int i = 6; i >= 0; --i) {
            uploadSpeedData[i + 1] = uploadSpeedData[i];
            downloadSpeedData[i + 1] = downloadSpeedData[i];
        }
        uploadSpeedData[0] = 0;
        downloadSpeedData[0] = 0;
    } else if (event->timerId() == timeoutTimer) {
        // Disconnect if we timed out; otherwise the timeout is
        // restarted.
        if (invalidateTimeout) {
            invalidateTimeout = false;
        } else {
            abort();
            emit infoHashReceived(QByteArray());
        }
    } else if (event->timerId() == pendingRequestTimer) {
        abort();
    } else if (event->timerId() == keepAliveTimer) {
        sendKeepAlive();
    }
    QTcpSocket::timerEvent(event);
}
Example #8
0
/* Raise a fatal error condition. */
void
AG_FatalError(const char *fmt, ...)
{
	va_list args;
  char *buf;

	/* Use callback if defined. The callback must gracefully exit. */
	if (agErrorCallback != NULL) {
		if (fmt != NULL) {
			va_start(args, fmt);
			Vasprintf(&buf, fmt, args);
			va_end(args);
			agErrorCallback(buf);
			abort(); /* not reached */
		} else {
			agErrorCallback(AG_GetError());
			abort(); /* not reached */
		}
	} else {
		fprintf(stderr, "Fatal error: ");
		if (fmt != NULL) {
			va_start(args, fmt);
			vfprintf(stderr, fmt, args);
			va_end(args);
		} else {
			fprintf(stderr, "%s", AG_GetError());
		}
		fprintf(stderr, "\n");
		abort();
  }
}
Example #9
0
/*************************MAIN*************************/
int main (int argc, char **argv)
{
	int nflag=0;
	int iflag=0;
	char* ivalue =NULL;
	char* nvalue =NULL;

	/******************INICIO FUNCION GETOPT******************/
	int c;
	while ((c = getopt (argc, argv, "i:n:")) != -1)
		switch (c){
			case 'i':
				iflag = 1;
				ivalue=optarg;
				break;

			case 'n':
				nflag = 1;
				nvalue=optarg;
				break;

			case '?':
				if (optopt == 'n'||optopt == 'i')
					fprintf (stderr, "La opcion -%c requiere argumento (numero).\n", optopt);
				else if (isprint (optopt))
					fprintf (stderr, "-%c es una opción desconocida.\n", optopt);
				else
					fprintf (stderr,"Caracter de opción desconocida `\\x%x'.\n",optopt);
				return 1;	

			default:
				abort ();
				
		}
	/******************FIN FUNCION GETOPT******************/
	
	/******************************************************/
	/***************VALIDACIÓN DE ARGUMENTOS***************/
	if(iflag==1&&ivalue[0]=='-'&&nflag==0)
	{
		printf("ERROR: faltan argumentos de las opciones\n");
		abort();
	}
	if(nflag==1&&nvalue[0]=='-'&&iflag==0)
	{
		printf("ERROR: faltan argumentos de las opciones\n");
		abort();
	}

	/************FIN DE VALIDACIÓN DE ARGUMENTOS***********/
	/******************************************************/

	int n,i,iteraciones;
	float final;
	n = atoi(nvalue);
	i = atoi(ivalue);
	for (iteraciones = 0;iteraciones <i;iteraciones++)
	{
		final = ln(n);
	}
Example #10
0
int main(int argc, char *argv[]) {
	FILE *inputFile = NULL;		// Default place to get input
	bool fromInp = false;

	// -Options
	// -t prints syntax tree after each statement
	int fileArg = 1;

	if (argc > 1 && argv[1][0] == '-') {
		// Can't just have '-' as an argument
		if (argv[1][1] == '\0') {
			fprintf(stderr, "Option must be specified\n");
			printUsage(argv[0]);
			abort();
		}

		for (int i=1; argv[1][i] != '\0'; i++) {
			switch (argv[1][i]) {
				case 't':
					SHOWTREE = true;
					break;

				case 'v':
					VARDUMP = true;
					break;

				default:
					fprintf(stderr, "Unknown option '%c'\n", argv[1][i]);
					printUsage(argv[0]);
					abort();
			}
		}
		argc--; fileArg = 2;		// So we can continue as normal
	}

	if (argc == 1) {
		inputFile = stdin;
		fromInp = true;
	} else if (argc == 2) {
		inputFile = fopen(argv[fileArg], "r");
		if (!inputFile) {
			fprintf(stderr, "Failed to open '%s'\n", argv[fileArg]);
			return 1;
		}
		printf("Taking input from file '%s'\n", argv[fileArg]);
	} else {
		printUsage(argv[0]);
		return 1;
	}

	if (!parse(inputFile)) {
		fprintf(stderr, "!Failed to parse!\n");
	}

	if (!fromInp) {
		fclose(inputFile);
	}

	return 0;
}
Example #11
0
static void falcon_prep(struct disisa *isa) {
	isa->vardata = vardata_new("falcon");
	int f_fuc0op = vardata_add_feature(isa->vardata, "fuc0op", "v0 exclusive opcodes");
	/* XXX rename variants */
	int f_fuc3op = vardata_add_feature(isa->vardata, "fuc3op", "v3+ opcodes");
	int f_fuc4op = vardata_add_feature(isa->vardata, "fuc4op", "v4+ opcodes");
	int f_crypt = vardata_add_feature(isa->vardata, "crypt", "Cryptographic coprocessor");
	int f_fuc5op = vardata_add_feature(isa->vardata, "fuc5op", "v5+ opcodes");
	int f_fucold = vardata_add_feature(isa->vardata, "fucold", "v0-v4 opcodes");
	if (f_fuc0op == -1 || f_fuc3op == -1 || f_fuc4op == -1 || f_crypt == -1 || f_fuc5op == -1 || f_fucold == -1)
		abort();
	int vs_fucver = vardata_add_varset(isa->vardata, "version", "falcon version");
	if (vs_fucver == -1)
		abort();
	int v_fuc0 = vardata_add_variant(isa->vardata, "fuc0", "falcon v0", vs_fucver);
	int v_fuc3 = vardata_add_variant(isa->vardata, "fuc3", "falcon v3", vs_fucver);
	int v_fuc4 = vardata_add_variant(isa->vardata, "fuc4", "falcon v4", vs_fucver);
	int v_fuc5 = vardata_add_variant(isa->vardata, "fuc5", "falcon v5", vs_fucver);
	if (v_fuc0 == -1 || v_fuc3 == -1 || v_fuc4 == -1 || v_fuc5 == -1)
		abort();
	vardata_variant_feature(isa->vardata, v_fuc0, f_fuc0op);
	vardata_variant_feature(isa->vardata, v_fuc0, f_fucold);
	vardata_variant_feature(isa->vardata, v_fuc3, f_fuc3op);
	vardata_variant_feature(isa->vardata, v_fuc3, f_fucold);
	vardata_variant_feature(isa->vardata, v_fuc4, f_fuc3op);
	vardata_variant_feature(isa->vardata, v_fuc4, f_fucold);
	vardata_variant_feature(isa->vardata, v_fuc4, f_fuc4op);
	vardata_variant_feature(isa->vardata, v_fuc5, f_fuc3op);
	vardata_variant_feature(isa->vardata, v_fuc5, f_fuc4op);
	vardata_variant_feature(isa->vardata, v_fuc5, f_fuc5op);
	if (vardata_validate(isa->vardata))
		abort();
}
Example #12
0
void LoadCertificates(SSL_CTX* ctx, char* CertFile, char* KeyFile)
{
    if (SSL_CTX_load_verify_locations(ctx, CertFile, KeyFile) != 1)
        ERR_print_errors_fp(stderr);

    if (SSL_CTX_set_default_verify_paths(ctx) != 1)
        ERR_print_errors_fp(stderr);

    if (SSL_CTX_use_certificate_file(ctx, CertFile, SSL_FILETYPE_PEM) <= 0)
    {
        ERR_print_errors_fp(stderr);
        abort();
    }

    if (SSL_CTX_use_PrivateKey_file(ctx, KeyFile, SSL_FILETYPE_PEM) <= 0)
    {
        ERR_print_errors_fp(stderr);
        abort();
    }

    if (!SSL_CTX_check_private_key(ctx))
    {
        fprintf(stderr, "Private key does not match the public certificate\n");
        abort();
    }

    SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
}
Example #13
0
SSL_CTX* InitServerCTX(void)
{
    const SSL_METHOD *method;
    SSL_CTX *ctx;
    char server_key[] = "server.key";
    char server_crt[] = "server.crt";

    SSL_library_init(); /* this functions always returns 1. */

    OpenSSL_add_all_algorithms();  /* void return values */
    SSL_load_error_strings();

    if((method = SSLv3_server_method()) == NULL)
    {
        ERR_print_errors_fp(stderr);
        abort();
    }

    if((ctx = SSL_CTX_new(method)) == NULL)
    {
        ERR_print_errors_fp(stderr);
        abort();
    }

    LoadCertificates(ctx, server_crt, server_key); /* load certs */
    return ctx;
}
Example #14
0
int validate_client_server_cert(SSL_CTX* ctx, X509 *client_cert, const char *keyfile)
{
	if ( client_cert != NULL )
	{
		if (SSL_CTX_use_certificate(ctx, client_cert) <= 0)
		{
			ERR_print_errors_fp(stderr);
		        abort();
		}
		else
			printf("SSL_CTX_use_certificate OK\n");


		if (SSL_CTX_use_PrivateKey_file(ctx, keyfile, SSL_FILETYPE_PEM) <= 0)
    		{
        		ERR_print_errors_fp(stderr);
        		abort();
    		}
		else
			printf("SSL_CTX_use_PrivateKey_file OK\n");

		/* verify private key between client certificate and stored private key to see if they match*/
		if (!SSL_CTX_check_private_key(ctx))
		{
        		fprintf(stderr, "Private key of server does not match the public client certificate\n");
		        abort();
	   	}
		return 0;
	}
	return 1;
}
Example #15
0
int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
{
  blake2b_param P[1];

  if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) abort();

  if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) abort();

  P->digest_length = outlen;
  P->key_length    = keylen;
  P->fanout        = 1;
  P->depth         = 1;
  STORE32_LE( P->leaf_length, 0 );
  STORE64_LE( P->node_offset, 0 );
  P->node_depth    = 0;
  P->inner_length  = 0;
  memset( P->reserved, 0, sizeof( P->reserved ) );
  memset( P->salt,     0, sizeof( P->salt ) );
  memset( P->personal, 0, sizeof( P->personal ) );

  if( blake2b_init_param( S, P ) < 0 ) abort();

  {
    uint8_t block[BLAKE2B_BLOCKBYTES];
    memset( block, 0, BLAKE2B_BLOCKBYTES );
    memcpy( block, key, keylen );
    blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
    secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
  }
  return 0;
}
Example #16
0
int gcjEventAPI_GetHostName(const unsigned char * domain,unsigned char *address,unsigned char *address_len)
{
	int ret = DEBUG_SIGN;
	int tmpSem = gcj_StubNewSemphone();
	gcj_TraceOut(0,"func:%s,tmpSem=%d\n",__FUNCTION__,tmpSem);	
	COS_EVENT evt;
	_NET_EVENT_GET_HOST_T *data = (_NET_EVENT_GET_HOST_T *)OslMalloc(sizeof (_NET_EVENT_GET_HOST_T));
	if (!data)
		abort();
	
	data->semp = tmpSem;
	data->domain = domain;
	data->address = address;
	data->adress_len = address_len;
	data->finish = EventNetworkFinish;
	data->result = &ret;
	evt.nEventId = (unsigned int)MSG_ID_GCJ_GET_HOST_NAME_REQ;
	evt.nParam1 = data;
	recordSempInEventApi(tmpSem);	
	gcj_StubSendEvent(&evt,MOD_MMI);	
	gcj_StubTakeSemphone(tmpSem);
	/*
	ret = gcjEventApi_NetRet;
	if (gcjEventApi_NetRet == DEBUG_SIGN)
		abort();
	gcjEventApi_NetRet = DEBUG_SIGN;
	*/
	removeSempInEventApi(tmpSem);
	//sxr_ReleaseSemaphore(netResultSem);
	if (ret == DEBUG_SIGN)
		abort();
	return ret;
}
Example #17
0
int
main(void)
{
	int i;
	char buf[1024];

	(void) memset(buf, 'a', sizeof (buf));

	/*
	 * Try to go ahead and corrupt ourselves NTRIES times.
	 */
	for (i = 0; i < NTRIES; i++) {
		(void) getrandom(buf + NOFF, NBYTES, 0);
	}

	for (i = 0; i < NOFF; i++) {
		if (buf[i] != 'a')
			abort();
	}

	for (i = NBYTES + NOFF; i < sizeof (buf); i++) {
		if (buf[i] != 'a')
			abort();
	}

	return (0);
}
Example #18
0
int gcjEventAPI_SocketClose(SOCKET nSocket)
{
	int ret = DEBUG_SIGN;
	
	if (nSocket>5)
		abort();
	int tmpSem = gcj_StubNewSemphone();
	gcj_TraceOut(0,"func:%s,tmpSem=%d\n",__FUNCTION__,tmpSem);	
	COS_EVENT evt;
	_NET_EVENT_SOC_CLOSE_T *data = (_NET_EVENT_SOC_CLOSE_T *)OslMalloc(sizeof (_NET_EVENT_SOC_CLOSE_T));
	if (!data)
		abort();
	
	data->semp = tmpSem;
	data->nSocket = nSocket;
	data->finish = EventNetworkFinish;	
	data->result = &ret;
	evt.nEventId = (unsigned int)MSG_ID_GCJ_SOCKET_CLOSE_REQ;
	evt.nParam1 = data;
	recordSempInEventApi(tmpSem);	
	gcj_StubSendEvent(&evt,MOD_MMI);	
	gcj_StubTakeSemphone(tmpSem);
	/*
	ret = gcjEventApi_NetRet;
	if (gcjEventApi_NetRet == DEBUG_SIGN)
		abort();
	gcjEventApi_NetRet = DEBUG_SIGN;
	*/
	removeSempInEventApi(tmpSem);
	//sxr_ReleaseSemaphore(netResultSem);
	
	if (ret == DEBUG_SIGN)
		abort();
	return ret;
}
Example #19
0
static void
free_pedestrian (ModeInfo *mi, pedestrian *p)
{
  camera_configuration *bp = &bps[MI_SCREEN(mi)];
  Bool ok = False;
  if (!p) abort();
  if (p == bp->pedestrians)
    {
      bp->pedestrians = p->next;
      ok = True;
    }
  else
    {
      pedestrian *p0;
      for (p0 = bp->pedestrians; p0; p0 = p0->next)
        if (p0->next == p)
          {
            p0->next = p0->next ? p0->next->next : 0;
            ok = True;
            break;
          }
    }
  if (!ok) abort();
  p->next = 0;
  free (p);
}
Example #20
0
void Foam::simpleMatrix<Type>::operator=(const simpleMatrix<Type>& m)
{
    if (this == &m)
    {
        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
                << "Attempted assignment to self"
                << abort(FatalError);
    }

    if (n() != m.n())
    {
        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
                << "Different size matrices"
                << abort(FatalError);
    }

    if (source_.size() != m.source_.size())
    {
        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
                << "Different size source vectors"
                << abort(FatalError);
    }

    scalarSquareMatrix::operator=(m);
    source_ = m.source_;
}
Example #21
0
/* Insert a new boundary in cache C; it will have cache index I,
   and have the specified POS and VALUE.  */
static void
insert_cache_boundary (struct region_cache *c, EMACS_INT i, EMACS_INT pos,
		       int value)
{
  /* i must be a valid cache index.  */
  if (i < 0 || i > c->cache_len)
    abort ();

  /* We must never want to insert something before the dummy first
     boundary.  */
  if (i == 0)
    abort ();

  /* We must only be inserting things in order.  */
  if (! (BOUNDARY_POS (c, i - 1) < pos
         && (i == c->cache_len
             || pos < BOUNDARY_POS (c, i))))
    abort ();

  /* The value must be different from the ones around it.  However, we
     temporarily create boundaries that establish the same value as
     the subsequent boundary, so we're not going to flag that case.  */
  if (BOUNDARY_VALUE (c, i - 1) == value)
    abort ();

  move_cache_gap (c, i, 1);

  c->boundaries[i].pos = pos - c->buffer_beg;
  c->boundaries[i].value = value;
  c->gap_start++;
  c->gap_len--;
  c->cache_len++;
}
Example #22
0
void * test_and_set_thr(void * id)
{
  unsigned long i;

  for (i = 0; i < NITERS/10; ++i)
    {
      while (AO_test_and_set_acquire(&lock) != AO_TS_CLEAR);
      ++locked_counter;
      if (locked_counter != 1)
        {
          fprintf(stderr, "Test and set failure 1, counter = %ld, id = %d\n",
                  (long)locked_counter, (int)(AO_PTRDIFF_T)id);
          abort();
        }
      locked_counter *= 2;
      locked_counter -= 1;
      locked_counter *= 5;
      locked_counter -= 4;
      if (locked_counter != 1)
        {
          fprintf(stderr, "Test and set failure 2, counter = %ld, id = %d\n",
                  (long)locked_counter, (int)(AO_PTRDIFF_T)id);
          abort();
        }
      --locked_counter;
      AO_CLEAR(&lock);
      /* Spend a bit of time outside the lock. */
        junk *= 17;
        junk *= 17;
    }
  return 0;
}
Example #23
0
/*
** Handle Security command
*/
static void ThumbnailDoCmdSecurity(void) {
  FormType* frm = FrmGetActiveForm();
  Boolean wasHiding = d.privateRecordStatus == hidePrivateRecords;
  UInt16 mode;

  d.privateRecordStatus = SecSelectViewStatus();

  if (wasHiding ^ (d.privateRecordStatus == hidePrivateRecords)) {
    /* We have to close the database first */
    if (DmCloseDatabase(d.dbR) != errNone) abort();

    mode = dmModeReadWrite;
    if (d.privateRecordStatus != hidePrivateRecords)
      mode |= dmModeShowSecret;

    /* Re-open the database */
    if ((d.dbR = DmOpenDatabaseByTypeCreator(DBType, AppType, mode)) == NULL)
      abort();

    /* Update cached values */
    d.records_in_cat = DmNumRecordsInCategory(d.dbR, p.category);
    if (d.privateRecordStatus == hidePrivateRecords)
      SetTopVisibleRecord(0);

    ThumbnailViewLoadRecords (frm);
  }
}
void
check_all (mpq_ptr x, mpq_ptr y, mpq_ptr want_add, mpq_ptr want_sub)
{
  mpq_t  got;
  int    neg_x, neg_y, swap;

  mpq_init (got);

  MPQ_CHECK_FORMAT (want_add);
  MPQ_CHECK_FORMAT (want_sub);
  MPQ_CHECK_FORMAT (x);
  MPQ_CHECK_FORMAT (y);

  for (swap = 0; swap <= 1; swap++)
    {
      for (neg_x = 0; neg_x <= 1; neg_x++)
        {
          for (neg_y = 0; neg_y <= 1; neg_y++)
            {
              mpq_add (got, x, y);
              MPQ_CHECK_FORMAT (got);
              if (! mpq_equal (got, want_add))
                {
                  printf ("mpq_add wrong\n");
                  mpq_trace ("  x   ", x);
                  mpq_trace ("  y   ", y);
                  mpq_trace ("  got ", got);
                  mpq_trace ("  want", want_add);
                  abort ();
                }

              mpq_sub (got, x, y);
              MPQ_CHECK_FORMAT (got);
              if (! mpq_equal (got, want_sub))
                {
                  printf ("mpq_sub wrong\n");
                  mpq_trace ("  x   ", x);
                  mpq_trace ("  y   ", y);
                  mpq_trace ("  got ", got);
                  mpq_trace ("  want", want_sub);
                  abort ();
                }


              mpq_neg (y, y);
              mpq_swap (want_add, want_sub);
            }

          mpq_neg (x, x);
          mpq_swap (want_add, want_sub);
          mpq_neg (want_add, want_add);
          mpq_neg (want_sub, want_sub);
        }

      mpq_swap (x, y);
      mpq_neg (want_sub, want_sub);
    }

  mpq_clear (got);
}
Example #25
0
File: r5.c Project: 0day-ci/gcc
int main (void)
{
  struct R1 A1 = My_R1;
  struct R2 A2 = My_R2;

  put ("A1 :");
  dump (&A1, sizeof (struct R1));
  new_line ();
  /* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */

  put ("A2 :");
  dump (&A2, sizeof (struct R2));
  new_line ();
  /* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */

  if (Get_Elem1 (A1) != 0xAB0012) abort ();

  Set_Elem1 (&A1, 0xCD0034);
  if (Get_Elem1 (A1) != 0xCD0034) abort ();

  if (Get_Elem2 (A2) != 0xAB0012) abort ();

  Set_Elem2 (&A2, 0xCD0034);
  if (Get_Elem2 (A2) != 0xCD0034) abort ();

  new_line ();
  return 0;
}
Example #26
0
GRPCAPI grpc_stream_compression_algorithm
grpc_stream_compression_algorithm_for_level(
    grpc_stream_compression_level level, uint32_t accepted_stream_encodings) {
  GRPC_API_TRACE("grpc_stream_compression_algorithm_for_level(level=%d)", 1,
                 ((int)level));
  if (level > GRPC_STREAM_COMPRESS_LEVEL_HIGH) {
    gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
    abort();
  }

  switch (level) {
    case GRPC_STREAM_COMPRESS_LEVEL_NONE:
      return GRPC_STREAM_COMPRESS_NONE;
    case GRPC_STREAM_COMPRESS_LEVEL_LOW:
    case GRPC_STREAM_COMPRESS_LEVEL_MED:
    case GRPC_STREAM_COMPRESS_LEVEL_HIGH:
      if (GPR_BITGET(accepted_stream_encodings, GRPC_STREAM_COMPRESS_GZIP) ==
          1) {
        return GRPC_STREAM_COMPRESS_GZIP;
      } else {
        return GRPC_STREAM_COMPRESS_NONE;
      }
    default:
      abort();
  }
}
Example #27
0
int main()
{

    X( coo[0].kay() );
    X( coo[1].kay() );
    X( coo[2].kay() );
    X( koo[0].kay() );
    X( koo[1].kay() );
    X( koo[2].kay() );
    if ( 0x3f != x ) abort ();

    X( foo.kay() );
    if ( 0x7f != x ) abort ();

    X( goo.kay() );
    if ( 0xff != x ) abort ();

    X( xoo[0].kay() );
    X( xoo[1].kay() );
    X( xoo[2].kay() );
    X( zoo[0].kay() );
    X( zoo[1].kay() );
    X( zoo[2].kay() );
    if ( 0x3fff != x ) abort ();

    X( doo[0].kay() );
    X( doo[1].kay() );
    X( doo[2].kay() );
    X( hoo[0].kay() );
    X( hoo[1].kay() );
    X( hoo[2].kay() );
    if ( 0xfffff != x ) abort ();

    exit (0);
}
Example #28
0
static void delONode(FILE *file)
{
  struct oListNode **pcur = &oList;
  struct oListNode *todel;
  char file_name[30];

  while((*pcur) && (*pcur)->file != file)
    pcur = &((*pcur)->pnext);

  todel = (*pcur);
  if(todel == NULL){ //not found
    // WARNING(("Trying to close a simple FILE* with close_memstream()"));
  } else {
    if(EOF == fflush(file))
      abort();
    if((*(todel->length) = ftell(file)) == -1)
      abort();
    if((*(todel->buf) = calloc(1, *(todel->length) + 1)) == NULL)
      abort();
    if(EOF == fseek(file, 0, SEEK_SET))
      abort();
    fread(*(todel->buf), 1, *(todel->length), file);

    sprintf(file_name,"o_stream_%d",todel->o_stream_number);
    if(-1 == remove(file_name))
      abort();

    (*pcur) = todel->pnext;
    free(todel);
  }
}
Example #29
0
void
TEST (void)
{
  int i;
  UNION_TYPE (AVX512F_LEN, i_b) src1, src2;
  MASK_TYPE res_ref, res1, res2;
  MASK_TYPE mask = MASK_VALUE;

  for (i = 0; i < SIZE / 2; i++)
    {
      src1.a[i * 2] = i;
      src1.a[i * 2 + 1] = i * i;
      src2.a[i * 2] = 2 * i;
      src2.a[i * 2 + 1] = i * i;
    }

  res1 = INTRINSIC (_cmple_epi8_mask) (src1.x, src2.x);
  res2 = INTRINSIC (_mask_cmple_epi8_mask) (mask, src1.x, src2.x);

  CALC (&res_ref, src1.a, src2.a);

  if (res_ref != res1)
    abort ();

  res_ref &= mask;

  if (res_ref != res2)
    abort ();
}
Example #30
0
void
manager_workqueue_create(struct _pthread_workqueue *workq)
{
    pthread_mutex_lock(&wqlist_mtx);
    if (!workq->overcommit && !wqlist_has_manager)
        manager_start();

    if (workq->overcommit) {
        if (ocwq[workq->queueprio] == NULL) {
            ocwq[workq->queueprio] = workq;
            workq->wqlist_index = workq->queueprio;
        } else {
            puts("queue already exists\n");
            abort();
        }
    } else {
        if (wqlist[workq->queueprio] == NULL) {
            wqlist[workq->queueprio] = workq; //FIXME: sort by priority
            workq->wqlist_index = workq->queueprio;
        } else {
            puts("queue already exists\n");
            abort();
        }
    }
    pthread_mutex_unlock(&wqlist_mtx);
}