Merging upstream version 0.7.1 (Closes: #991419).
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
05c588e9d7
commit
9e09e0ef69
99 changed files with 6727 additions and 943 deletions
|
@ -1,6 +1,8 @@
|
|||
.PHONY: clean
|
||||
|
||||
all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 ck_pr_add_64 ck_pr_faa_64 ck_pr_neg_64 fp
|
||||
OBJECTS=ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 ck_pr_add_64 ck_pr_faa_64 ck_pr_neg_64 fp
|
||||
|
||||
all: $(OBJECTS)
|
||||
|
||||
fp: fp.c
|
||||
$(CC) $(CFLAGS) -o fp fp.c
|
||||
|
@ -24,8 +26,7 @@ ck_pr_neg_64: ck_pr_neg_64.c
|
|||
$(CC) $(CFLAGS) -o ck_pr_neg_64 ck_pr_neg_64.c -lm
|
||||
|
||||
clean:
|
||||
rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 ck_pr_add_64 \
|
||||
ck_pr_faa_64 ck_pr_neg_64 *.dSYM *.exe
|
||||
rm -rf *.dSYM *.exe *.o $(OBJECTS)
|
||||
|
||||
include ../../../build/regressions.build
|
||||
CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE
|
||||
|
|
|
@ -4,7 +4,7 @@ OBJECTS=ck_pr_cas ck_pr_faa ck_pr_inc ck_pr_dec ck_pr_bts \
|
|||
ck_pr_btr ck_pr_btc ck_pr_load ck_pr_store \
|
||||
ck_pr_and ck_pr_or ck_pr_xor ck_pr_add ck_pr_sub \
|
||||
ck_pr_fas ck_pr_bin ck_pr_btx ck_pr_fax ck_pr_n \
|
||||
ck_pr_unary
|
||||
ck_pr_unary ck_pr_fence ck_pr_dec_zero ck_pr_inc_zero
|
||||
|
||||
all: $(OBJECTS)
|
||||
|
||||
|
@ -20,12 +20,21 @@ ck_pr_cas: ck_pr_cas.c
|
|||
ck_pr_inc: ck_pr_inc.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_inc ck_pr_inc.c
|
||||
|
||||
ck_pr_inc_zero: ck_pr_inc_zero.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_inc_zero ck_pr_inc_zero.c
|
||||
|
||||
ck_pr_dec: ck_pr_dec.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_dec ck_pr_dec.c
|
||||
|
||||
ck_pr_dec_zero: ck_pr_dec_zero.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_dec_zero ck_pr_dec_zero.c
|
||||
|
||||
ck_pr_faa: ck_pr_faa.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_faa ck_pr_faa.c
|
||||
|
||||
ck_pr_fence: ck_pr_fence.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_fence ck_pr_fence.c
|
||||
|
||||
ck_pr_btc: ck_pr_btc.c
|
||||
$(CC) $(CFLAGS) -o ck_pr_btc ck_pr_btc.c
|
||||
|
||||
|
|
105
regressions/ck_pr/validate/ck_pr_dec_zero.c
Normal file
105
regressions/ck_pr/validate/ck_pr_dec_zero.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ck_pr.h>
|
||||
|
||||
#define EXPECT(ACTUAL, IS_ZERO, TYPE, INITIAL) do { \
|
||||
TYPE expected = (TYPE)((TYPE)INITIAL - (TYPE)1); \
|
||||
if ((ACTUAL) != expected) { \
|
||||
printf("FAIL [ %" PRIx64" != %" PRIx64" ]\n", \
|
||||
(uint64_t)(ACTUAL), \
|
||||
(uint64_t)expected); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
\
|
||||
if ((IS_ZERO) != ((ACTUAL) == 0)) { \
|
||||
printf("FAIL [ %s != %s ]\n", \
|
||||
((IS_ZERO) ? "true" : "false"), \
|
||||
(((ACTUAL) == 0) ? "true" : "false")); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TEST_ZERO(TYPE, SUFFIX) do { \
|
||||
TYPE datum; \
|
||||
bool is_zero; \
|
||||
\
|
||||
datum = 0; \
|
||||
ck_pr_dec_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 0); \
|
||||
\
|
||||
datum = (TYPE)-1; \
|
||||
ck_pr_dec_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, -1); \
|
||||
\
|
||||
datum = (TYPE)1; \
|
||||
ck_pr_dec_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 1); \
|
||||
\
|
||||
datum = (TYPE)2; \
|
||||
ck_pr_dec_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 2); \
|
||||
} while (0)
|
||||
|
||||
#define TEST_IS_ZERO(TYPE, SUFFIX) do { \
|
||||
TYPE datum; \
|
||||
bool is_zero; \
|
||||
\
|
||||
datum = 0; \
|
||||
is_zero = ck_pr_dec_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 0); \
|
||||
\
|
||||
datum = (TYPE)-1; \
|
||||
is_zero = ck_pr_dec_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, -1); \
|
||||
\
|
||||
datum = (TYPE)1; \
|
||||
is_zero = ck_pr_dec_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 1); \
|
||||
\
|
||||
datum = (TYPE)2; \
|
||||
is_zero = ck_pr_dec_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 2); \
|
||||
} while (0)
|
||||
|
||||
#define TEST(TYPE, SUFFIX) do { \
|
||||
TEST_ZERO(TYPE, SUFFIX); \
|
||||
TEST_IS_ZERO(TYPE, SUFFIX); \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
#ifdef CK_F_PR_DEC_64_ZERO
|
||||
TEST(uint64_t, 64);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_32_ZERO
|
||||
TEST(uint32_t, 32);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_16_ZERO
|
||||
TEST(uint16_t, 16);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_8_ZERO
|
||||
TEST(uint8_t, 8);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_UINT_ZERO
|
||||
TEST(unsigned int, uint);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_INT_ZERO
|
||||
TEST(int, int);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_DEC_CHAR_ZERO
|
||||
TEST(char, char);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
80
regressions/ck_pr/validate/ck_pr_fence.c
Normal file
80
regressions/ck_pr/validate/ck_pr_fence.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2009-2018 Samy Al Bahra.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <ck_pr.h>
|
||||
#include "../../common.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
/* Below serves as a marker. */
|
||||
ck_pr_sub_int(&r, 31337);
|
||||
|
||||
/*
|
||||
* This is a simple test to help ensure all fences compile or crash
|
||||
* on target. Below are generated according to the underlying memory
|
||||
* model's ordering.
|
||||
*/
|
||||
ck_pr_fence_atomic();
|
||||
ck_pr_fence_atomic_store();
|
||||
ck_pr_fence_atomic_load();
|
||||
ck_pr_fence_store_atomic();
|
||||
ck_pr_fence_load_atomic();
|
||||
ck_pr_fence_load();
|
||||
ck_pr_fence_load_store();
|
||||
ck_pr_fence_store();
|
||||
ck_pr_fence_store_load();
|
||||
ck_pr_fence_memory();
|
||||
ck_pr_fence_release();
|
||||
ck_pr_fence_acquire();
|
||||
ck_pr_fence_acqrel();
|
||||
ck_pr_fence_lock();
|
||||
ck_pr_fence_unlock();
|
||||
|
||||
/* Below serves as a marker. */
|
||||
ck_pr_sub_int(&r, 31337);
|
||||
|
||||
/* The following are generating assuming RMO. */
|
||||
ck_pr_fence_strict_atomic();
|
||||
ck_pr_fence_strict_atomic_store();
|
||||
ck_pr_fence_strict_atomic_load();
|
||||
ck_pr_fence_strict_store_atomic();
|
||||
ck_pr_fence_strict_load_atomic();
|
||||
ck_pr_fence_strict_load();
|
||||
ck_pr_fence_strict_load_store();
|
||||
ck_pr_fence_strict_store();
|
||||
ck_pr_fence_strict_store_load();
|
||||
ck_pr_fence_strict_memory();
|
||||
ck_pr_fence_strict_release();
|
||||
ck_pr_fence_strict_acquire();
|
||||
ck_pr_fence_strict_acqrel();
|
||||
ck_pr_fence_strict_lock();
|
||||
ck_pr_fence_strict_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
105
regressions/ck_pr/validate/ck_pr_inc_zero.c
Normal file
105
regressions/ck_pr/validate/ck_pr_inc_zero.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ck_pr.h>
|
||||
|
||||
#define EXPECT(ACTUAL, IS_ZERO, TYPE, INITIAL) do { \
|
||||
TYPE expected = (TYPE)((TYPE)INITIAL + (TYPE)1); \
|
||||
if ((ACTUAL) != expected) { \
|
||||
printf("FAIL [ %" PRIx64" != %" PRIx64" ]\n", \
|
||||
(uint64_t)(ACTUAL), \
|
||||
(uint64_t)expected); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
\
|
||||
if ((IS_ZERO) != ((ACTUAL) == 0)) { \
|
||||
printf("FAIL [ %s != %s ]\n", \
|
||||
((IS_ZERO) ? "true" : "false"), \
|
||||
(((ACTUAL) == 0) ? "true" : "false")); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TEST_ZERO(TYPE, SUFFIX) do { \
|
||||
TYPE datum; \
|
||||
bool is_zero; \
|
||||
\
|
||||
datum = 0; \
|
||||
ck_pr_inc_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 0); \
|
||||
\
|
||||
datum = (TYPE)-1; \
|
||||
ck_pr_inc_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, -1); \
|
||||
\
|
||||
datum = (TYPE)1; \
|
||||
ck_pr_inc_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 1); \
|
||||
\
|
||||
datum = (TYPE)2; \
|
||||
ck_pr_inc_##SUFFIX##_zero(&datum, &is_zero); \
|
||||
EXPECT(datum, is_zero, TYPE, 2); \
|
||||
} while (0)
|
||||
|
||||
#define TEST_IS_ZERO(TYPE, SUFFIX) do { \
|
||||
TYPE datum; \
|
||||
bool is_zero; \
|
||||
\
|
||||
datum = 0; \
|
||||
is_zero = ck_pr_inc_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 0); \
|
||||
\
|
||||
datum = (TYPE)-1; \
|
||||
is_zero = ck_pr_inc_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, -1); \
|
||||
\
|
||||
datum = (TYPE)1; \
|
||||
is_zero = ck_pr_inc_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 1); \
|
||||
\
|
||||
datum = (TYPE)2; \
|
||||
is_zero = ck_pr_inc_##SUFFIX##_is_zero(&datum); \
|
||||
EXPECT(datum, is_zero, TYPE, 2); \
|
||||
} while (0)
|
||||
|
||||
#define TEST(TYPE, SUFFIX) do { \
|
||||
TEST_ZERO(TYPE, SUFFIX); \
|
||||
TEST_IS_ZERO(TYPE, SUFFIX); \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
#ifdef CK_F_PR_INC_64_ZERO
|
||||
TEST(uint64_t, 64);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_32_ZERO
|
||||
TEST(uint32_t, 32);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_16_ZERO
|
||||
TEST(uint16_t, 16);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_8_ZERO
|
||||
TEST(uint8_t, 8);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_UINT_ZERO
|
||||
TEST(unsigned int, uint);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_INT_ZERO
|
||||
TEST(int, int);
|
||||
#endif
|
||||
|
||||
#ifdef CK_F_PR_INC_CHAR_ZERO
|
||||
TEST(char, char);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -118,6 +118,7 @@ rg_width(int m)
|
|||
int
|
||||
main(void)
|
||||
{
|
||||
void *ptr = (void *)(intptr_t)-1;
|
||||
|
||||
common_srand((unsigned int)getpid());
|
||||
|
||||
|
@ -143,6 +144,11 @@ main(void)
|
|||
ck_pr_load_64_2(&b, &a);
|
||||
printf("%" PRIx64 ":%" PRIx64 "\n", a[0], a[1]);
|
||||
#endif
|
||||
printf("ck_pr_load_ptr: ");
|
||||
if (ck_pr_load_ptr(&ptr) != (void *)(intptr_t)(-1))
|
||||
printf("Failed : %p != %p\n", ck_pr_load_ptr(&ptr), (void *)(intptr_t)(-1));
|
||||
else
|
||||
printf("SUCCESS\n");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ rg_width(int m)
|
|||
int
|
||||
main(void)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
#if defined(CK_F_PR_STORE_DOUBLE) && defined(CK_F_PR_LOAD_DOUBLE)
|
||||
double d;
|
||||
|
||||
|
@ -145,6 +147,12 @@ main(void)
|
|||
#ifdef CK_F_PR_STORE_8
|
||||
CK_PR_STORE_B(8);
|
||||
#endif
|
||||
printf("ck_pr_store_ptr: ");
|
||||
ck_pr_store_ptr(&ptr, (void *)(intptr_t)-1);
|
||||
if (ptr != (void *)(intptr_t)(-1))
|
||||
printf("Failed : %p != %p\n", ptr, (void *)(intptr_t)-1);
|
||||
else
|
||||
printf("SUCCESS\n");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue