File: header-ref-2.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (37 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (2)
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
// This test checks whether ISPC generates correct C and C++ header regarding reference as output value.
// Check here that this test is compilable with ISPC/C/CPP compilers and runnable producing the sane output.

// RUN: %{ispc} --pic --target=host -h %t.h %s -o %t.o
// RUN: %{cc} -x c -c %s -o %t.c.o --include %t.h
// RUN: %{cc} %t.o %t.c.o -o %t.c.bin
// RUN: %t.c.bin | FileCheck %s
// RUN: %{cc} -x c++ -c %s -o %t.cpp.o --include %t.h
// RUN: %{cc} %t.o %t.cpp.o -o %t.cpp.bin
// RUN: %t.cpp.bin | FileCheck %s

// REQUIRES: !MACOS_HOST

// CHECK: uint x=99

#ifdef ISPC
uniform uint x = 99;
export uniform uint& def() {
    return x;
}
#else
#include <stdio.h>
#if defined(__cplusplus)
using namespace ispc;
int main(int argc, char **argv) {
    uint32_t x = def();
    printf("uint x=%d\n", x);
    return 0;
}
#else
int main(int argc, char **argv) {
    uint32_t *x = def();
    printf("uint x=%d\n", *x);
    return 0;
}
#endif
#endif