Add 32bit time64 syscalls for arm, mips32, ppc32 and x86.
[valgrind.git] / memcheck / tests / error_counts.c
blob271dc9a4385778a9f29cb69411c410408cea8905
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <assert.h>
4 #include "../memcheck.h"
5 #include "leak.h"
7 int main(void)
9 int x;
10 int y = 0;
11 int* reachable __attribute__((unused));
12 int* dubious;
13 int* leaked __attribute__((unused));
14 DECLARE_LEAK_COUNTERS;
16 /* we require these longs to have same size as a machine word */
17 assert(sizeof(long) == sizeof(void*));
19 /* Error counting */
20 fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
22 if (x == 0) {
23 y++;
24 } else {
25 y--;
28 fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
30 // Get a baseline, after start-up and also after printf (because Darwin
31 // printf allocates memory the first time it's called!)
32 GET_INITIAL_LEAK_COUNTS;
34 fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
36 /* Leak checking */
37 GET_FINAL_LEAK_COUNTS;
38 PRINT_LEAK_COUNTS(stderr);
39 fprintf(stderr, "\n");
41 fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
43 leaked = malloc(77);
44 leaked = 0;
46 dubious = malloc(88);
47 dubious += 10;
49 reachable = malloc(99);
51 GET_FINAL_LEAK_COUNTS;
52 PRINT_LEAK_COUNTS(stderr);
53 fprintf(stderr, "\n");
55 fprintf(stderr, "errors: %d\n", VALGRIND_COUNT_ERRORS);
57 return 0;