File: callingconv.c

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (109 lines) | stat: -rw-r--r-- 2,780 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#undef NDEBUG
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <callingconv.h>

/* Note, not all of these are necessarily used */
t_charp v_t_charp[16];
t_int v_t_int[16];
t_long v_t_long[16];
t_llong v_t_llong[16];
t_double v_t_double[16];
t_ldouble v_t_ldouble[16];
t_char v_t_char[16];
t_short v_t_short[16];
t_float v_t_float[16];
t_tiny v_t_tiny[16];
t_big v_t_big[16];

/* Keep track of current function, call, and satisfied asserts */
int current_module = -1;
int current_call = -1;
int current_function = -1;
int *current_index_p = NULL;
int assert_count = 0;

extern const char *script_argv;
void module0(void) __attribute__((weak));
void module1(void) __attribute__((weak));
void module2(void) __attribute__((weak));
void module3(void) __attribute__((weak));
void module4(void) __attribute__((weak));
void module5(void) __attribute__((weak));

int main(int argc, const char *argv[]) {
  if (module0) module0();
  if (module1) module1();
  if (module2) module2();
  if (module3) module3();
  if (module4) module4();
  if (module5) module5();

  printf("generate.py arguments: %s\n", script_argv);
  printf("SUCCESS: %d calls OK.\n", assert_count);
  return 0;
}


/* Helper for setting values in tiny_t struct */
void set_tiny(t_tiny *ptr, char a, short b) {
  ptr->a = a;
  ptr->b = b;
}

/* Helper for setting values in big_t struct */
void set_big(t_big *ptr, char a, char b, int c, char d, int e, char f,
             long long g, char h, int i, char j, short k, char l,
             double m, char n) {
  ptr->a = a;
  ptr->b = b;
  ptr->c = c;
  ptr->d = d;
  ptr->e = e;
  ptr->f = f;
  ptr->g = g;
  ptr->h = h;
  ptr->i = i;
  ptr->j = j;
  ptr->k = k;
  ptr->l = l;
  ptr->m = m;
  ptr->n = n;
}


void assert_func(int condition, const char *expr, const char *file, int line) {
  assert_count++;
  if (!condition) {
    printf("Assertion Failure: %s\n", expr);
    printf("Location         : %s:%d\n", file, line);
    printf("Module           : %d\n", current_module);
    printf("Call Name        : C%d\n", current_call);
    printf("Function Name    : F%d\n", current_function);
    if (current_index_p != NULL)
      printf("Argument         : a_%d\n", *current_index_p);
    exit(1);
  }
}

#define EQ(_v)  (x._v == y._v)

int tiny_cmp(const t_tiny x, const t_tiny y) {
  return EQ(a) && EQ(b);
}

int big_cmp(const t_big x, const t_big y) {
  return EQ(a) && EQ(b) && EQ(c) && EQ(d) &&
         EQ(e) && EQ(f) && EQ(g) && EQ(h) &&
         EQ(i) && EQ(j) && EQ(k) && EQ(l) && EQ(m) && EQ(n);
}