File: scalar.h

package info (click to toggle)
valgrind 1%3A3.24.0-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 176,332 kB
  • sloc: ansic: 795,029; exp: 26,134; xml: 23,472; asm: 14,393; cpp: 9,397; makefile: 7,464; sh: 6,122; perl: 5,446; python: 1,498; javascript: 981; awk: 166; csh: 1
file content (64 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (11)
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
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

#include "pub_tool_basics.h"
#include "vki/vki-scnums-darwin.h"
#include "pub_tool_vkiscnums.h"

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

// 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, N, s) \
   fprintf(stderr, "-----------------------------------------------------\n"  \
                   "x%lx(%d):%20s %s\n"                                       \
                   "-----------------------------------------------------\n", \
                   (unsigned long)__NR_xxx, N, #__NR_xxx, s);

#define GO_UNIMP(n, s) \
   fprintf(stderr, "-----------------------------------------------------\n"  \
                   "%-17s%s\n"                                                \
                   "-----------------------------------------------------\n", \
                   "("#n"):     ", s);

#define SY(__NR_xxx, args...)    res = syscall(__NR_xxx, ##args);

#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);