File: scalar.h

package info (click to toggle)
valgrind 1%3A3.2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,372 kB
  • ctags: 23,091
  • sloc: ansic: 192,648; xml: 10,723; sh: 4,750; perl: 4,023; makefile: 2,103; asm: 1,813; cpp: 140; haskell: 139
file content (60 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download
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
#include "../../../coregrind/vki_unistd-x86-linux.h"

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <sys/ptrace.h>
#include <sys/types.h>

// Since we use vki_unistd.h, we can't include <unistd.h>.  So we have to
// declare this ourselves.
extern long int syscall (long int __sysno, ...) __THROW;

// Thorough syscall scalar arg checking.  Also serves as thorough checking
// for (very) basic syscall use.  Generally not trying to do anything
// meaningful with the syscalls.

#define GO(__NR_xxx, s) \
   fprintf(stderr, "-----------------------------------------------------\n"  \
                   "%3d:%20s %s\n"                                            \
                   "-----------------------------------------------------\n", \
                   __NR_xxx, #__NR_xxx, s);

#define SY  res = syscall

#define FAIL  assert(-1 == res);
#define SUCC  assert(-1 != res);
#define SUCC_OR_FAIL    /* no test */

#define FAILx(E) \
   do { \
      int myerrno = errno; \
      if (-1 == res) { \
         if (E == myerrno) { \
            /* as expected */ \
         } else { \
         fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
         exit(1); \
         } \
      } else { \
         fprintf(stderr, "Expected error %s (%d), got success\n", #E, E); \
         exit(1); \
      } \
   } while (0);

#define SUCC_OR_FAILx(E) \
   do { \
      int myerrno = errno; \
      if (-1 == res) { \
         if (E == myerrno) { \
            /* as expected */ \
         } else { \
         fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
         exit(1); \
         } \
      } \
   } while (0);