~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/fuzz/random_inc.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C -*-
 
2
 *
 
3
 * Copyright (c) 2007-2010 The University of Utah
 
4
 * All rights reserved.
 
5
 *
 
6
 * This file is part of `csmith', a random generator of C programs.
 
7
 *
 
8
 * Redistribution and use in source and binary forms, with or without
 
9
 * modification, are permitted provided that the following conditions are met:
 
10
 *
 
11
 *   * Redistributions of source code must retain the above copyright notice,
 
12
 *     this list of conditions and the following disclaimer.
 
13
 *
 
14
 *   * Redistributions in binary form must reproduce the above copyright
 
15
 *     notice, this list of conditions and the following disclaimer in the
 
16
 *     documentation and/or other materials provided with the distribution.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
22
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
23
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
24
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
25
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
26
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
27
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
28
 * POSSIBILITY OF SUCH DAMAGE.
 
29
 */
 
30
 
 
31
#ifndef RANDOM_INC_H
 
32
#define RANDOM_INC_H
 
33
 
 
34
 
 
35
#if defined(STANDALONE)
 
36
  #if defined(_MSC_VER)
 
37
    #include <limits.h>
 
38
    #include "windows/stdint.h"
 
39
  #elif defined (IA32_ARCH)
 
40
    #include "stdint_ia32.h"
 
41
  #elif defined (IA64_ARCH)
 
42
    #include "stdint_ia64.h"
 
43
  #elif defined (MSP430)
 
44
    #include "stdint_msp430.h"
 
45
  #elif defined (AVR_ARCH)
 
46
    #include "stdint_avr.h"
 
47
  #else
 
48
    #include "stdint_ia32.h"
 
49
  #endif
 
50
#else
 
51
  #include <limits.h>
 
52
  #if defined(_MSC_VER)
 
53
    #include "windows/stdint.h"
 
54
  #else
 
55
    #include <stdint.h>
 
56
  #endif
 
57
#endif
 
58
 
 
59
#include <assert.h>
 
60
 
 
61
/*****************************************************************************/
 
62
 
 
63
#ifndef DEPUTY
 
64
#define COUNT(n)
 
65
#define TC
 
66
#define SAFE
 
67
#endif
 
68
 
 
69
/*****************************************************************************/
 
70
 
 
71
#ifdef LOG_WRAPPERS
 
72
#include "wrapper.h"
 
73
char __failed_checks[N_WRAP+1];
 
74
char __executed_checks[N_WRAP+1];
 
75
#define UNDEFINED(__val) (__failed_checks[index]=1,(__val))
 
76
#define LOG_INDEX , int index
 
77
#define LOG_EXEC __executed_checks[index]=1;
 
78
#else
 
79
#define UNDEFINED(__val) (__val)
 
80
#define LOG_INDEX
 
81
#define LOG_EXEC
 
82
#endif
 
83
 
 
84
#if defined(AVR_ARCH)
 
85
#include "platform_avr.h"
 
86
#elif defined (MSP430)
 
87
#include "platform_msp430.h"
 
88
#else
 
89
#include "platform_generic.h"
 
90
#endif
 
91
 
 
92
#define STATIC static
 
93
 
 
94
#if defined (USE_MATH_MACROS_NOTMP)
 
95
#include "safe_math_macros_notmp.h"
 
96
#elif defined (USE_MATH_MACROS)
 
97
#include "safe_math_macros.h"
 
98
#else
 
99
#define FUNC_NAME(x) (safe_##x)
 
100
#include "safe_math.h"
 
101
#undef FUNC_NAME
 
102
#endif
 
103
 
 
104
#define INT_BIT (sizeof(int)*CHAR_BIT)
 
105
#define _CSMITH_BITFIELD(x) (((x)>INT_BIT)?((x)%INT_BIT):(x))
 
106
 
 
107
#ifdef TCC
 
108
 
 
109
void* memcpy(void* dest, const void* src, size_t count) {
 
110
  char* dst8 = (char*)dest;
 
111
  char* src8 = (char*)src;
 
112
  
 
113
  while (count--) {
 
114
    *dst8++ = *src8++;
 
115
  }
 
116
  return dest;
 
117
}
 
118
 
 
119
void *memset(void *s, int c, size_t n)
 
120
{
 
121
    unsigned char* p=s;
 
122
    while(n--)
 
123
        *p++ = (unsigned char)c;
 
124
    return s;
 
125
}
 
126
 
 
127
#endif
 
128
 
 
129
#endif // RANDOM_INC_H