t_atomic.c revision beb52a4b18a198a26103ad03f6ac6ec46a91d812
/*
* Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: t_atomic.c,v 1.1 2011/01/11 21:36:22 mgraff Exp $ */
#include <config.h>
#include <ctype.h>
#include <stdlib.h>
char *progname;
#if defined(ISC_PLATFORM_HAVEXADD) || defined(ISC_PLATFORM_HAVEXADDQ)
static void
setup(void) {
}
static void
teardown(void) {
}
#endif
#define TASKS 32
#define ITERATIONS 10000
#define COUNTS_PER_ITERATION 1000
typedef struct {
} counter_t;
#if defined(ISC_PLATFORM_HAVEXADD)
void
int i;
for (i = 0 ; i < COUNTS_PER_ITERATION ; i++) {
}
} else {
isc_event_free(&ev);
}
}
static void
test_atomic_xadd() {
int test_result;
int i;
"ensure that isc_atomic_xadd() works.");
setup();
counter_32 = 0;
/*
* Create our tasks, and allocate an event to get the counters going.
*/
for (i = 0 ; i < TASKS ; i++) {
}
teardown();
if (counter_32 != EXPECTED_COUNT_32)
counter_32 = 0;
}
#endif
#if defined(ISC_PLATFORM_HAVEXADDQ)
void
int i;
for (i = 0 ; i < COUNTS_PER_ITERATION ; i++) {
}
} else {
isc_event_free(&ev);
}
}
static void
int test_result;
int i;
"ensure that isc_atomic_xaddq() works.");
setup();
counter_64 = 0;
/*
* Create our tasks, and allocate an event to get the counters going.
*/
for (i = 0 ; i < TASKS ; i++) {
}
teardown();
if (counter_64 != EXPECTED_COUNT_64)
counter_64 = 0;
}
#endif
testspec_t T_testlist[] = {
#if defined(ISC_PLATFORM_HAVEXADD)
{ test_atomic_xadd, "test_atomic_xadd" },
#endif
#if defined(ISC_PLATFORM_HAVEXADDQ)
{ test_atomic_xaddq, "test_atomic_xaddq" },
#endif
};