C++ (Cpp) abort Examples

C++ (Cpp) abort - 30 examples found. These are the top rated real world C++ (Cpp) examples of abort extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
static void
cts_dec (unsigned char *out, unsigned char *in, unsigned char *iv,
         unsigned int len)
{
    int r;
    unsigned int len2;
    unsigned char pn1[B], pn[B], cn[B], cn1[B];

    if (len < B + 1) abort ();
    len2 = (len - B - 1) & ~(B-1);
    cbc_dec (out, in, iv, len2);
    out += len2;
    in += len2;
    len -= len2;
    if (len2)
        iv = in - B;
    if (len <= B || len > 2 * B)
        abort ();

    memcpy (cn1, in, B);
    r = aes_dec_blk (cn1, pn, &dctx);
    if (!r) fprintf(stderr, "error, line %d\n", __LINE__), exit(1);
    memset (cn, 0, sizeof(cn));
    memcpy (cn, in+B, len-B);
    xor (pn, pn, cn);
    memcpy (cn+len-B, pn+len-B, 2*B-len);
    r = aes_dec_blk (cn, pn1, &dctx);
    if (!r) fprintf(stderr, "error, line %d\n", __LINE__), exit(1);
    xor (pn1, pn1, iv);
    memcpy(out, pn1, B);
    memcpy(out+B, pn, len-B);
}
Example #2
0
int
main ()
{
    int n[4] = { -1, -1, -1, -1 };
    static int a = 2, b = 4;
    omp_set_num_threads (4);
    omp_set_dynamic (0);
    omp_set_nested (1);
    #pragma omp parallel private(b)
    {
        b = omp_get_thread_num ();
        #pragma omp parallel firstprivate(a)
        {
            a = (omp_get_thread_num () + a) + 1;
            if (b == omp_get_thread_num ())
                n[omp_get_thread_num ()] = a + (b << 4);
        }
    }
    if (n[0] != 3)
        abort ();
    if (n[3] != -1
            && (n[1] != 0x14 || n[2] != 0x25 || n[3] != 0x36))
        abort ();
    return 0;
}
Example #3
0
void aout_lock (unsigned i)
{
    unsigned allowed;
    switch (i)
    {
    case VOLUME_VARS_LOCK:
        allowed = 0;
        break;
    case MIXER_LOCK:
        allowed = VOLUME_VARS_LOCK;
        break;
    case INPUT_LOCK:
        allowed = VOLUME_VARS_LOCK|MIXER_LOCK;
        break;
    case INPUT_FIFO_LOCK:
        allowed = VOLUME_VARS_LOCK|MIXER_LOCK|INPUT_LOCK;
        break;
    case OUTPUT_FIFO_LOCK:
        allowed = VOLUME_VARS_LOCK|MIXER_LOCK|INPUT_LOCK|INPUT_FIFO_LOCK;
        break;
    default:
        abort ();
    }

    if (aout_locks & ~allowed)
    {
        fprintf (stderr, "Illegal audio lock transition (%x -> %x)\n",
                 aout_locks, aout_locks|i);
        vlc_backtrace ();
        abort ();
    }
    aout_locks |= i;
}
Example #4
0
int main(int argc, char **argv)
{
    int r;
    struct __res_state state;

    r = res_ninit(&state);
    if (r) {
        herror("ninit");
        abort();
    }
    r = res_init();
    if (r) {
        herror("init");
        abort();
    }

#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
    res_close();
#endif
#ifdef __UCLIBC__
    /* assume there is at least one resolver configured */
    assert (state._u._ext.nscount > 0);
#else
    assert (state._u._ext.nscount == 0);
#endif
    assert (state.options & RES_INIT);
    res_nclose(&state);
#ifdef __UCLIBC__
    /* We wipe the whole thing */
    assert ((state.options & RES_INIT) == 0);
#endif
    assert (state._u._ext.nscount == 0);

    return 0;
}
Example #5
0
static void *pthread_wrapper(void *arg)
{
    struct cbs_struct *cs;
    timer_t timer;
    struct sigevent se;
    struct itimerspec its, itsoff;
    double mi_frac;
    cs = arg;

    memset(&se, 0, sizeof(se));
    se.sigev_notify = SIGEV_THREAD_ID;
    se.sigev_signo = SIGXCPU;
    se.sigev_notify_thread_id = syscall(__NR_gettid);
    if (timer_create(CLOCK_MONOTONIC, &se, &timer) != 0)
        abort();

    mi_frac = cs->cpu / BOGO_MIPS;
    memset(&its, 0, sizeof(its));
    if (cs->type == CBS_RT)
    {
        its.it_value.tv_sec = mi_frac;
        its.it_value.tv_nsec = (long)(mi_frac * NANO) % NANO;

        if (its.it_value.tv_sec > cs->period.tv_sec)
            its.it_value.tv_sec = cs->period.tv_sec;
        if (its.it_value.tv_nsec > cs->period.tv_usec * 1000)
            its.it_value.tv_nsec = cs->period.tv_usec * 1000;
    }

    memset(&itsoff, 0, sizeof(itsoff));

    cs->ret = 0;
    while (cs->ret == 0)
    {
        pthread_mutex_lock(&cs->run_lock);
        while (cs->run != CBS_STATE_READY)
            pthread_cond_wait(&cs->run_signal, &cs->run_lock);

        cs->run = CBS_STATE_RUNNING;
        pthread_mutex_unlock(&cs->run_lock);

        if (timer_settime(timer, 0, &its, NULL) != 0)
            abort();

        cs->ret = cs->entry(cs->arg);

        if (timer_settime(timer, 0, &itsoff, NULL) != 0)
            abort();

        pthread_mutex_lock(&cs->run_lock);
        cs->run = CBS_STATE_SLEEP;
        pthread_mutex_unlock(&cs->run_lock);
    }

    pthread_mutex_lock(&cs->run_lock);
    cs->run = CBS_STATE_DONE;
    pthread_mutex_unlock(&cs->run_lock);

    return NULL;
}
Example #6
0
int
main (int argc, char **argv)
{
    const int N = 256;
    int i;
    unsigned char *h;
    void *d;

    h = (unsigned char *) malloc (N);

    for (i = 0; i < N; i++)
    {
        h[i] = i;
    }

    d = acc_copyin (h, N);
    if (!d)
        abort ();

    memset (&h[0], 0, N);

    acc_update_self (h, N);

    for (i = 0; i < N; i++)
    {
        if (h[i] != i)
            abort ();
    }

    acc_delete (h, N);

    free (h);

    return 0;
}