fix fuzzbug regarding signed 64-bit extension
This commit is contained in:
Родитель
3d4bce8844
Коммит
c2692a1acb
|
@ -684,9 +684,9 @@ function analyzer(data, sidePass) {
|
|||
params: [(signed && j + whole > sourceElements.length) ? signedKeepAlive : null],
|
||||
type: 'i32',
|
||||
};
|
||||
if (j == 0 && isUnsignedOp(value.op) && sourceBits < 32) {
|
||||
if (j == 0 && sourceBits < 32) {
|
||||
// zext sign correction
|
||||
result.ident = makeSignOp(result.ident, 'i' + sourceBits, 'un', 1, 1);
|
||||
result.ident = makeSignOp(result.ident, 'i' + sourceBits, isUnsignedOp(value.op) ? 'un' : 're', 1, 1);
|
||||
}
|
||||
if (fraction != 0) {
|
||||
var other = {
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* This is a RANDOMLY GENERATED PROGRAM.
|
||||
*
|
||||
* Generator: csmith 2.2.0
|
||||
* Git version: a8697aa
|
||||
* Options: --no-volatiles --no-math64 --max-block-depth 2 --max-block-size 2 --max-expr-complexity 2 --max-funcs 2
|
||||
* Seed: 1880513882
|
||||
*/
|
||||
|
||||
#include "csmith.h"
|
||||
|
||||
|
||||
static long __undefined;
|
||||
|
||||
/* --- Struct/Union Declarations --- */
|
||||
union U0 {
|
||||
int32_t f0;
|
||||
int8_t f1;
|
||||
const int8_t f2;
|
||||
};
|
||||
|
||||
/* --- GLOBAL VARIABLES --- */
|
||||
static uint32_t g_4 = 9UL;
|
||||
static int32_t g_6 = 0xB9DD952EL;
|
||||
static const int32_t *g_5 = &g_6;
|
||||
static union U0 g_7[3][9][6] = {{{{-8L},{5L},{0x901516EAL},{7L},{7L},{0x901516EAL}},{{0x520EA0C8L},{0x520EA0C8L},{0x0920A6FFL},{0x0021FBB9L},{0x888C5540L},{-8L}},{{0xDC87A9B6L},{0x42B48371L},{8L},{7L},{-8L},{0x0920A6FFL}},{{-1L},{0xDC87A9B6L},{8L},{5L},{0x520EA0C8L},{-8L}},{{-3L},{5L},{0x0920A6FFL},{0x865B49D5L},{0xDC87A9B6L},{0x901516EAL}},{{0x865B49D5L},{0xDC87A9B6L},{0x901516EAL},{0x0021FBB9L},{-1L},{-1L}},{{0x865B49D5L},{0x42B48371L},{0x42B48371L},{0x865B49D5L},{-3L},{0x0920A6FFL}},{{-3L},{0x520EA0C8L},{0x0021FBB9L},{5L},{0x865B49D5L},{-1L}},{{-1L},{5L},{0L},{7L},{0x865B49D5L},{0x901516EAL}}},{{{0xDC87A9B6L},{0x520EA0C8L},{7L},{0x0021FBB9L},{-3L},{-8L}},{{0x520EA0C8L},{0x42B48371L},{5L},{7L},{-1L},{0x0920A6FFL}},{{-8L},{0xDC87A9B6L},{5L},{5L},{0xDC87A9B6L},{-8L}},{{0x888C5540L},{5L},{7L},{0x865B49D5L},{0x520EA0C8L},{0x901516EAL}},{{7L},{0xDC87A9B6L},{0L},{0x0021FBB9L},{-8L},{-1L}},{{7L},{0x42B48371L},{0x0021FBB9L},{0x865B49D5L},{0x888C5540L},{0x0920A6FFL}},{{0x888C5540L},{0x520EA0C8L},{0x42B48371L},{5L},{7L},{-1L}},{{-8L},{5L},{0x901516EAL},{7L},{7L},{0x901516EAL}},{{0x520EA0C8L},{0x520EA0C8L},{0x0920A6FFL},{0x0021FBB9L},{0x888C5540L},{-8L}}},{{{0xDC87A9B6L},{0x42B48371L},{8L},{7L},{-8L},{0x0920A6FFL}},{{-1L},{0xDC87A9B6L},{8L},{5L},{0x520EA0C8L},{-8L}},{{-3L},{5L},{0x0920A6FFL},{0x865B49D5L},{0xDC87A9B6L},{0x901516EAL}},{{0x865B49D5L},{0xDC87A9B6L},{0x901516EAL},{0x0021FBB9L},{-1L},{-1L}},{{0x865B49D5L},{0x42B48371L},{0x42B48371L},{0x865B49D5L},{-3L},{0x0920A6FFL}},{{-3L},{0x520EA0C8L},{0x0021FBB9L},{5L},{0x865B49D5L},{-1L}},{{-1L},{5L},{0L},{7L},{0x865B49D5L},{0x901516EAL}},{{0xDC87A9B6L},{0x520EA0C8L},{7L},{0x0021FBB9L},{-3L},{-8L}},{{0x520EA0C8L},{0x42B48371L},{5L},{7L},{-1L},{0x0920A6FFL}}}};
|
||||
static int32_t g_31 = 1L;
|
||||
static uint32_t g_32 = 4294967289UL;
|
||||
|
||||
|
||||
/* --- FORWARD DECLARATIONS --- */
|
||||
static uint16_t func_1(void);
|
||||
static int32_t * func_9(int32_t * p_10, uint16_t p_11);
|
||||
|
||||
|
||||
/* --- FUNCTIONS --- */
|
||||
/* ------------------------------------------ */
|
||||
/*
|
||||
* reads : g_4 g_5 g_7 g_32
|
||||
* writes: g_5 g_32
|
||||
*/
|
||||
static uint16_t func_1(void)
|
||||
{ /* block id: 0 */
|
||||
int32_t l_3 = (-1L);
|
||||
if (((safe_unary_minus_func_int16_t_s(l_3)) >= g_4))
|
||||
{ /* block id: 1 */
|
||||
int32_t *l_8 = &l_3;
|
||||
g_5 = g_5;
|
||||
(*l_8) ^= (g_7[1][3][2] , 0x44688D23L);
|
||||
}
|
||||
else
|
||||
{ /* block id: 4 */
|
||||
int32_t *l_12 = &l_3;
|
||||
int32_t **l_13 = &l_12;
|
||||
(*l_13) = func_9(((*l_13) = l_12), l_3);
|
||||
}
|
||||
return l_3;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------ */
|
||||
/*
|
||||
* reads : g_32
|
||||
* writes: g_32
|
||||
*/
|
||||
static int32_t * func_9(int32_t * p_10, uint16_t p_11)
|
||||
{ /* block id: 6 */
|
||||
int32_t *l_14 = &g_6;
|
||||
int32_t *l_15 = &g_7[1][3][2].f0;
|
||||
int32_t *l_16 = &g_6;
|
||||
int32_t *l_17 = &g_6;
|
||||
int32_t *l_18 = &g_6;
|
||||
int32_t *l_19 = &g_6;
|
||||
int32_t *l_20 = &g_6;
|
||||
int32_t *l_21 = &g_6;
|
||||
int32_t *l_22 = &g_6;
|
||||
int32_t *l_23 = &g_7[1][3][2].f0;
|
||||
int32_t l_24[8] = {0xF9F11119L,0xF9F11119L,0xF9F11119L,0xF9F11119L,0xF9F11119L,0xF9F11119L,0xF9F11119L,0xF9F11119L};
|
||||
int32_t *l_25 = &l_24[7];
|
||||
int32_t *l_26 = &l_24[2];
|
||||
int32_t *l_27 = &l_24[2];
|
||||
int32_t *l_28 = &l_24[0];
|
||||
int32_t *l_29 = &g_7[1][3][2].f0;
|
||||
int32_t *l_30[10] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
|
||||
int i;
|
||||
++g_32;
|
||||
return p_10;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------- */
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int i, j, k;
|
||||
int print_hash_value = 0;
|
||||
if (argc == 2 && strcmp(argv[1], "1") == 0) print_hash_value = 1;
|
||||
platform_main_begin();
|
||||
crc32_gentab();
|
||||
func_1();
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 1; j++)
|
||||
{
|
||||
for (k = 0; k < 1; k++)
|
||||
{
|
||||
transparent_crc(g_7[i][j][k].f0, "g_7[i][j][k].f0", print_hash_value);
|
||||
transparent_crc(g_7[i][j][k].f1, "g_7[i][j][k].f1", print_hash_value);
|
||||
if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
checksum = 504CCDC
|
|
@ -0,0 +1,130 @@
|
|||
/* -*- mode: C -*-
|
||||
*
|
||||
* Copyright (c) 2007-2010 The University of Utah
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of `csmith', a random generator of C programs.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_RUNTIME_H
|
||||
#define RANDOM_RUNTIME_H
|
||||
|
||||
#ifdef CSMITH_MINIMAL
|
||||
#include "csmith_minimal.h"
|
||||
#else
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#include "random_inc.h"
|
||||
|
||||
static uint32_t crc32_tab[256];
|
||||
static uint32_t crc32_context = 0xFFFFFFFFUL;
|
||||
|
||||
static void
|
||||
crc32_gentab (void)
|
||||
{
|
||||
uint32_t crc;
|
||||
const uint32_t poly = 0xEDB88320UL;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
crc = i;
|
||||
for (j = 8; j > 0; j--) {
|
||||
if (crc & 1) {
|
||||
crc = (crc >> 1) ^ poly;
|
||||
} else {
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
crc32_tab[i] = crc;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
crc32_byte (uint8_t b) {
|
||||
crc32_context =
|
||||
((crc32_context >> 8) & 0x00FFFFFF) ^
|
||||
crc32_tab[(crc32_context ^ b) & 0xFF];
|
||||
}
|
||||
|
||||
#if defined(__SPLAT__) || defined (__COMPCERT__) || defined(NO_LONGLONG)
|
||||
static void
|
||||
crc32_8bytes (uint32_t val)
|
||||
{
|
||||
crc32_byte ((val>>0) & 0xff);
|
||||
crc32_byte ((val>>8) & 0xff);
|
||||
crc32_byte ((val>>16) & 0xff);
|
||||
crc32_byte ((val>>24) & 0xff);
|
||||
}
|
||||
|
||||
static void
|
||||
transparent_crc (uint32_t val, char* vname, int flag)
|
||||
{
|
||||
crc32_8bytes(val);
|
||||
if (flag) {
|
||||
printf("...checksum after hashing %s : %X\n", vname, crc32_context ^ 0xFFFFFFFFU);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void
|
||||
crc32_8bytes (uint64_t val)
|
||||
{
|
||||
crc32_byte ((val>>0) & 0xff);
|
||||
crc32_byte ((val>>8) & 0xff);
|
||||
crc32_byte ((val>>16) & 0xff);
|
||||
crc32_byte ((val>>24) & 0xff);
|
||||
crc32_byte ((val>>32) & 0xff);
|
||||
crc32_byte ((val>>40) & 0xff);
|
||||
crc32_byte ((val>>48) & 0xff);
|
||||
crc32_byte ((val>>56) & 0xff);
|
||||
}
|
||||
|
||||
static void
|
||||
transparent_crc (uint64_t val, char* vname, int flag)
|
||||
{
|
||||
crc32_8bytes(val);
|
||||
if (flag) {
|
||||
printf("...checksum after hashing %s : %lX\n", vname, crc32_context ^ 0xFFFFFFFFUL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* RANDOM_RUNTIME_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
/* End of file. */
|
|
@ -0,0 +1,132 @@
|
|||
/* -*- mode: C -*-
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2007, 2008 The University of Utah
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of `csmith', a random generator of C programs.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_GENERIC_H
|
||||
#define PLATFORM_GENERIC_H
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef STANDALONE
|
||||
extern int printf (const char *, ...);
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
platform_main_begin(void)
|
||||
{
|
||||
/* Nothing to do. */
|
||||
}
|
||||
|
||||
static void
|
||||
platform_main_end(uint32_t crc, int flag)
|
||||
{
|
||||
#if defined (__FRAMAC)
|
||||
Frama_C_dump_assert_each();
|
||||
#endif
|
||||
printf ("checksum = %X\n", crc);
|
||||
#if defined (LOG_WRAPPERS)
|
||||
{
|
||||
int i, first;
|
||||
|
||||
printf ("executed wrappers: ");
|
||||
first = 1;
|
||||
for (i=1; i<N_WRAP+1; i++) {
|
||||
if (__executed_checks[i]) {
|
||||
if (!first) {
|
||||
printf (",");
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
printf ("%d", i);
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
printf ("dead wrappers: ");
|
||||
first = 1;
|
||||
for (i=1; i<N_WRAP+1; i++) {
|
||||
if (!__executed_checks[i]) {
|
||||
if (!first) {
|
||||
printf (",");
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
printf ("%d", i);
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
printf ("wrappers that failed at least once: ");
|
||||
first = 1;
|
||||
for (i=1; i<N_WRAP+1; i++) {
|
||||
if (__failed_checks[i]) {
|
||||
if (!first) {
|
||||
printf (",");
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
printf ("%d", i);
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
printf ("wrappers that never failed (or never executed): ");
|
||||
first = 1;
|
||||
for (i=1; i<N_WRAP+1; i++) {
|
||||
if (!__failed_checks[i]) {
|
||||
if (!first) {
|
||||
printf (",");
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
printf ("%d", i);
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#define MB (1<<20)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* PLATFORM_GENERIC_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
/* End of file. */
|
|
@ -0,0 +1,129 @@
|
|||
/* -*- mode: C -*-
|
||||
*
|
||||
* Copyright (c) 2007-2010 The University of Utah
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of `csmith', a random generator of C programs.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_INC_H
|
||||
#define RANDOM_INC_H
|
||||
|
||||
|
||||
#if defined(STANDALONE)
|
||||
#if defined(_MSC_VER)
|
||||
#include <limits.h>
|
||||
#include "windows/stdint.h"
|
||||
#elif defined (IA32_ARCH)
|
||||
#include "stdint_ia32.h"
|
||||
#elif defined (IA64_ARCH)
|
||||
#include "stdint_ia64.h"
|
||||
#elif defined (MSP430)
|
||||
#include "stdint_msp430.h"
|
||||
#elif defined (AVR_ARCH)
|
||||
#include "stdint_avr.h"
|
||||
#else
|
||||
#include "stdint_ia32.h"
|
||||
#endif
|
||||
#else
|
||||
#include <limits.h>
|
||||
#if defined(_MSC_VER)
|
||||
#include "windows/stdint.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef DEPUTY
|
||||
#define COUNT(n)
|
||||
#define TC
|
||||
#define SAFE
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef LOG_WRAPPERS
|
||||
#include "wrapper.h"
|
||||
char __failed_checks[N_WRAP+1];
|
||||
char __executed_checks[N_WRAP+1];
|
||||
#define UNDEFINED(__val) (__failed_checks[index]=1,(__val))
|
||||
#define LOG_INDEX , int index
|
||||
#define LOG_EXEC __executed_checks[index]=1;
|
||||
#else
|
||||
#define UNDEFINED(__val) (__val)
|
||||
#define LOG_INDEX
|
||||
#define LOG_EXEC
|
||||
#endif
|
||||
|
||||
#if defined(AVR_ARCH)
|
||||
#include "platform_avr.h"
|
||||
#elif defined (MSP430)
|
||||
#include "platform_msp430.h"
|
||||
#else
|
||||
#include "platform_generic.h"
|
||||
#endif
|
||||
|
||||
#define STATIC static
|
||||
|
||||
#if defined (USE_MATH_MACROS_NOTMP)
|
||||
#include "safe_math_macros_notmp.h"
|
||||
#elif defined (USE_MATH_MACROS)
|
||||
#include "safe_math_macros.h"
|
||||
#else
|
||||
#define FUNC_NAME(x) (safe_##x)
|
||||
#include "safe_math.h"
|
||||
#undef FUNC_NAME
|
||||
#endif
|
||||
|
||||
#define INT_BIT (sizeof(int)*CHAR_BIT)
|
||||
#define _CSMITH_BITFIELD(x) (((x)>INT_BIT)?((x)%INT_BIT):(x))
|
||||
|
||||
#ifdef TCC
|
||||
|
||||
void* memcpy(void* dest, const void* src, size_t count) {
|
||||
char* dst8 = (char*)dest;
|
||||
char* src8 = (char*)src;
|
||||
|
||||
while (count--) {
|
||||
*dst8++ = *src8++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n)
|
||||
{
|
||||
unsigned char* p=s;
|
||||
while(n--)
|
||||
*p++ = (unsigned char)c;
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // RANDOM_INC_H
|
|
@ -0,0 +1,947 @@
|
|||
|
||||
#ifndef SAFE_MATH_H
|
||||
#define SAFE_MATH_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(unary_minus_func_int8_t_s)(int8_t si LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT8_MAX>=INT_MAX)
|
||||
(si==INT8_MIN) ?
|
||||
(UNDEFINED(si)) :
|
||||
#endif
|
||||
#endif
|
||||
-si;
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(add_func_int8_t_s_s)(int8_t si1, int8_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT8_MAX>=INT_MAX)
|
||||
(((si1>0) && (si2>0) && (si1 > (INT8_MAX-si2))) || ((si1<0) && (si2<0) && (si1 < (INT8_MIN-si2)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 + si2);
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(sub_func_int8_t_s_s)(int8_t si1, int8_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT8_MAX>=INT_MAX)
|
||||
(((si1^si2) & (((si1 ^ ((si1^si2) & (~INT8_MAX)))-si2)^si2)) < 0) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 - si2);
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(mul_func_int8_t_s_s)(int8_t si1, int8_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT8_MAX>=INT_MAX)
|
||||
(((si1 > 0) && (si2 > 0) && (si1 > (INT8_MAX / si2))) || ((si1 > 0) && (si2 <= 0) && (si2 < (INT8_MIN / si1))) || ((si1 <= 0) && (si2 > 0) && (si1 < (INT8_MIN / si2))) || ((si1 <= 0) && (si2 <= 0) && (si1 != 0) && (si2 < (INT8_MAX / si1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
si1 * si2;
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(mod_func_int8_t_s_s)(int8_t si1, int8_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT8_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 % si2);
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(div_func_int8_t_s_s)(int8_t si1, int8_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT8_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 / si2);
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(lshift_func_int8_t_s_s)(int8_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left > (INT8_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(lshift_func_int8_t_s_u)(int8_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32) || (left > (INT8_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(rshift_func_int8_t_s_s)(int8_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32))?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC int8_t
|
||||
FUNC_NAME(rshift_func_int8_t_s_u)(int8_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(unary_minus_func_int16_t_s)(int16_t si LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT16_MAX>=INT_MAX)
|
||||
(si==INT16_MIN) ?
|
||||
(UNDEFINED(si)) :
|
||||
#endif
|
||||
#endif
|
||||
-si;
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(add_func_int16_t_s_s)(int16_t si1, int16_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT16_MAX>=INT_MAX)
|
||||
(((si1>0) && (si2>0) && (si1 > (INT16_MAX-si2))) || ((si1<0) && (si2<0) && (si1 < (INT16_MIN-si2)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 + si2);
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(sub_func_int16_t_s_s)(int16_t si1, int16_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT16_MAX>=INT_MAX)
|
||||
(((si1^si2) & (((si1 ^ ((si1^si2) & (~INT16_MAX)))-si2)^si2)) < 0) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 - si2);
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(mul_func_int16_t_s_s)(int16_t si1, int16_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT16_MAX>=INT_MAX)
|
||||
(((si1 > 0) && (si2 > 0) && (si1 > (INT16_MAX / si2))) || ((si1 > 0) && (si2 <= 0) && (si2 < (INT16_MIN / si1))) || ((si1 <= 0) && (si2 > 0) && (si1 < (INT16_MIN / si2))) || ((si1 <= 0) && (si2 <= 0) && (si1 != 0) && (si2 < (INT16_MAX / si1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
si1 * si2;
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(mod_func_int16_t_s_s)(int16_t si1, int16_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT16_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 % si2);
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(div_func_int16_t_s_s)(int16_t si1, int16_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT16_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 / si2);
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(lshift_func_int16_t_s_s)(int16_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left > (INT16_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(lshift_func_int16_t_s_u)(int16_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32) || (left > (INT16_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(rshift_func_int16_t_s_s)(int16_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32))?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC int16_t
|
||||
FUNC_NAME(rshift_func_int16_t_s_u)(int16_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(unary_minus_func_int32_t_s)(int32_t si LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT32_MAX>=INT_MAX)
|
||||
(si==INT32_MIN) ?
|
||||
(UNDEFINED(si)) :
|
||||
#endif
|
||||
#endif
|
||||
-si;
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(add_func_int32_t_s_s)(int32_t si1, int32_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT32_MAX>=INT_MAX)
|
||||
(((si1>0) && (si2>0) && (si1 > (INT32_MAX-si2))) || ((si1<0) && (si2<0) && (si1 < (INT32_MIN-si2)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 + si2);
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(sub_func_int32_t_s_s)(int32_t si1, int32_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT32_MAX>=INT_MAX)
|
||||
(((si1^si2) & (((si1 ^ ((si1^si2) & (~INT32_MAX)))-si2)^si2)) < 0) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 - si2);
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(mul_func_int32_t_s_s)(int32_t si1, int32_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT32_MAX>=INT_MAX)
|
||||
(((si1 > 0) && (si2 > 0) && (si1 > (INT32_MAX / si2))) || ((si1 > 0) && (si2 <= 0) && (si2 < (INT32_MIN / si1))) || ((si1 <= 0) && (si2 > 0) && (si1 < (INT32_MIN / si2))) || ((si1 <= 0) && (si2 <= 0) && (si1 != 0) && (si2 < (INT32_MAX / si1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
si1 * si2;
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(mod_func_int32_t_s_s)(int32_t si1, int32_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT32_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 % si2);
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(div_func_int32_t_s_s)(int32_t si1, int32_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT32_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 / si2);
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(lshift_func_int32_t_s_s)(int32_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left > (INT32_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(lshift_func_int32_t_s_u)(int32_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32) || (left > (INT32_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(rshift_func_int32_t_s_s)(int32_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32))?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC int32_t
|
||||
FUNC_NAME(rshift_func_int32_t_s_u)(int32_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
#ifndef NO_LONGLONG
|
||||
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(unary_minus_func_int64_t_s)(int64_t si LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT64_MAX>=INT_MAX)
|
||||
(si==INT64_MIN) ?
|
||||
(UNDEFINED(si)) :
|
||||
#endif
|
||||
#endif
|
||||
-si;
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(add_func_int64_t_s_s)(int64_t si1, int64_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT64_MAX>=INT_MAX)
|
||||
(((si1>0) && (si2>0) && (si1 > (INT64_MAX-si2))) || ((si1<0) && (si2<0) && (si1 < (INT64_MIN-si2)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 + si2);
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(sub_func_int64_t_s_s)(int64_t si1, int64_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT64_MAX>=INT_MAX)
|
||||
(((si1^si2) & (((si1 ^ ((si1^si2) & (~INT64_MAX)))-si2)^si2)) < 0) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
(si1 - si2);
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(mul_func_int64_t_s_s)(int64_t si1, int64_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
#if (INT64_MAX>=INT_MAX)
|
||||
(((si1 > 0) && (si2 > 0) && (si1 > (INT64_MAX / si2))) || ((si1 > 0) && (si2 <= 0) && (si2 < (INT64_MIN / si1))) || ((si1 <= 0) && (si2 > 0) && (si1 < (INT64_MIN / si2))) || ((si1 <= 0) && (si2 <= 0) && (si1 != 0) && (si2 < (INT64_MAX / si1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
#endif
|
||||
si1 * si2;
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(mod_func_int64_t_s_s)(int64_t si1, int64_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT64_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 % si2);
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(div_func_int64_t_s_s)(int64_t si1, int64_t si2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((si2 == 0) || ((si1 == INT64_MIN) && (si2 == (-1)))) ?
|
||||
(UNDEFINED(si1)) :
|
||||
#endif
|
||||
(si1 / si2);
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(lshift_func_int64_t_s_s)(int64_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left > (INT64_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(lshift_func_int64_t_s_u)(int64_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32) || (left > (INT64_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(rshift_func_int64_t_s_s)(int64_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((int)right) < 0) || (((int)right) >= 32))?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC int64_t
|
||||
FUNC_NAME(rshift_func_int64_t_s_u)(int64_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((left < 0) || (((unsigned int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(unary_minus_func_uint8_t_u)(uint8_t ui LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return -ui;
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(add_func_uint8_t_u_u)(uint8_t ui1, uint8_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 + ui2;
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(sub_func_uint8_t_u_u)(uint8_t ui1, uint8_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 - ui2;
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(mul_func_uint8_t_u_u)(uint8_t ui1, uint8_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ((unsigned int)ui1) * ((unsigned int)ui2);
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(mod_func_uint8_t_u_u)(uint8_t ui1, uint8_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 % ui2);
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(div_func_uint8_t_u_u)(uint8_t ui1, uint8_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 / ui2);
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(lshift_func_uint8_t_u_s)(uint8_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32) || (left > (UINT8_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(lshift_func_uint8_t_u_u)(uint8_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((unsigned int)right) >= 32) || (left > (UINT8_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(rshift_func_uint8_t_u_s)(uint8_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint8_t
|
||||
FUNC_NAME(rshift_func_uint8_t_u_u)(uint8_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(((unsigned int)right) >= 32) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(unary_minus_func_uint16_t_u)(uint16_t ui LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return -ui;
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(add_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 + ui2;
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(sub_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 - ui2;
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(mul_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ((unsigned int)ui1) * ((unsigned int)ui2);
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(mod_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 % ui2);
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(div_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 / ui2);
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(lshift_func_uint16_t_u_s)(uint16_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32) || (left > (UINT16_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(lshift_func_uint16_t_u_u)(uint16_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((unsigned int)right) >= 32) || (left > (UINT16_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(rshift_func_uint16_t_u_s)(uint16_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
FUNC_NAME(rshift_func_uint16_t_u_u)(uint16_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(((unsigned int)right) >= 32) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(unary_minus_func_uint32_t_u)(uint32_t ui LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return -ui;
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(add_func_uint32_t_u_u)(uint32_t ui1, uint32_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 + ui2;
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(sub_func_uint32_t_u_u)(uint32_t ui1, uint32_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 - ui2;
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(mul_func_uint32_t_u_u)(uint32_t ui1, uint32_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ((unsigned int)ui1) * ((unsigned int)ui2);
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(mod_func_uint32_t_u_u)(uint32_t ui1, uint32_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 % ui2);
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(div_func_uint32_t_u_u)(uint32_t ui1, uint32_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 / ui2);
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(lshift_func_uint32_t_u_s)(uint32_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32) || (left > (UINT32_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(lshift_func_uint32_t_u_u)(uint32_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((unsigned int)right) >= 32) || (left > (UINT32_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(rshift_func_uint32_t_u_s)(uint32_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint32_t
|
||||
FUNC_NAME(rshift_func_uint32_t_u_u)(uint32_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(((unsigned int)right) >= 32) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
#ifndef NO_LONGLONG
|
||||
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(unary_minus_func_uint64_t_u)(uint64_t ui LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return -ui;
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(add_func_uint64_t_u_u)(uint64_t ui1, uint64_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 + ui2;
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(sub_func_uint64_t_u_u)(uint64_t ui1, uint64_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ui1 - ui2;
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(mul_func_uint64_t_u_u)(uint64_t ui1, uint64_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return ((unsigned long long int)ui1) * ((unsigned long long int)ui2);
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(mod_func_uint64_t_u_u)(uint64_t ui1, uint64_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 % ui2);
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(div_func_uint64_t_u_u)(uint64_t ui1, uint64_t ui2 LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(ui2 == 0) ?
|
||||
(UNDEFINED(ui1)) :
|
||||
#endif
|
||||
(ui1 / ui2);
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(lshift_func_uint64_t_u_s)(uint64_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32) || (left > (UINT64_MAX >> ((int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(lshift_func_uint64_t_u_u)(uint64_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((unsigned int)right) >= 32) || (left > (UINT64_MAX >> ((unsigned int)right)))) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left << ((unsigned int)right));
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(rshift_func_uint64_t_u_s)(uint64_t left, int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
((((int)right) < 0) || (((int)right) >= 32)) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((int)right));
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
FUNC_NAME(rshift_func_uint64_t_u_u)(uint64_t left, unsigned int right LOG_INDEX)
|
||||
{
|
||||
LOG_EXEC
|
||||
return
|
||||
#ifndef UNSAFE
|
||||
(((unsigned int)right) >= 32) ?
|
||||
(UNDEFINED(left)) :
|
||||
#endif
|
||||
(left >> ((unsigned int)right));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -7197,6 +7197,16 @@ def process(filename):
|
|||
finally:
|
||||
del os.environ['EMCC_LEAVE_INPUTS_RAW']
|
||||
|
||||
def test_fuzz(self):
|
||||
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
|
||||
|
||||
Building.COMPILER_TEST_OPTS += ['-I' + path_from_root('tests', 'fuzz')]
|
||||
|
||||
for name in glob.glob(path_from_root('tests', 'fuzz', '*.c')):
|
||||
print name
|
||||
self.do_run(open(path_from_root('tests', 'fuzz', name)).read(),
|
||||
open(path_from_root('tests', 'fuzz', name + '.txt')).read(), force_c=True)
|
||||
|
||||
# Autodebug the code
|
||||
def do_autodebug(self, filename):
|
||||
output = Popen([PYTHON, AUTODEBUGGER, filename+'.o.ll', filename+'.o.ll.ll'], stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]
|
||||
|
|
Загрузка…
Ссылка в новой задаче