Skip to content

Commit c09aba7

Browse files
committed
Factorize code for Windows compatibility.
1 parent d66fb24 commit c09aba7

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ install(FILES ${headers} DESTINATION include/gpuarray)
132132

133133
if(NOT UNIX)
134134
install(FILES gpuarray/wincompat/stdint.h DESTINATION include/gpuarray/wincompat)
135+
install(FILES gpuarray/wincompat/util.h DESTINATION include/gpuarray/wincompat)
135136
endif()
136137

137138
install(TARGETS gpuarray gpuarray-static

src/gpuarray/array.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
#include <gpuarray/buffer.h>
99
#include <gpuarray/util.h>
1010

11-
#ifdef _MSC_VER
12-
#ifndef inline
13-
#define inline __inline
14-
#endif
15-
#endif
16-
1711
#ifdef __cplusplus
1812
extern "C" {
1913
#endif

src/gpuarray/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#endif
3333
#define ssize_t intptr_t
3434
#define SSIZE_MAX INTPTR_MAX
35+
#include <gpuarray/wincompat/util.h>
3536
#else
3637
#include <sys/types.h>
3738
#include <stdint.h>

src/gpuarray/util.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ extern "C" {
1515
#include <gpuarray/elemwise.h>
1616
#include <gpuarray/types.h>
1717

18-
/* MSVC 2008 does not support "inline". */
19-
#ifdef _MSC_VER
20-
#ifndef inline
21-
#define inline __inline
22-
#endif
23-
#endif
24-
2518
/**
2619
* Registers a type with the kernel machinery.
2720
*

src/gpuarray/wincompat/util.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef WINCOMPAT_UTIL
2+
#define WINCOMPAT_UTIL
3+
4+
#ifdef _MSC_VER
5+
/* MSVC 2008 does not support "inline". */
6+
#ifndef inline
7+
#define inline __inline
8+
#endif
9+
#ifndef snprintf
10+
#define snprintf _snprintf
11+
#endif
12+
#ifndef strdup
13+
#define strdup _strdup
14+
#endif
15+
#ifndef alloca
16+
#define alloca _alloca
17+
#endif
18+
#endif
19+
20+
#endif

src/gpuarray_buffer_opencl.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#include "loaders/libclblas.h"
1616
#include "loaders/libclblast.h"
1717

18-
#ifdef _MSC_VER
19-
#define strdup _strdup
20-
#endif
21-
2218
#define _unused(x) ((void)x)
2319
#define SSIZE_MIN (-(SSIZE_MAX-1))
2420

src/util/error.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
#include <gpuarray/error.h>
88

9-
/* MSVC 2008 does not support "inline". */
10-
#ifdef _MSC_VER
11-
#ifndef inline
12-
#define inline __inline
13-
#endif
14-
#endif
15-
169
/* 1024 - 4 for the int that goes after */
1710
#define ERROR_MSGBUF_LEN 1020
1811

0 commit comments

Comments
 (0)