1313#ifndef SWIFT_PLUGINSERVER_PLUGINSERVER_H
1414#define SWIFT_PLUGINSERVER_PLUGINSERVER_H
1515
16- #include <stddef.h>
16+ // NOTE: Partially ported from SwiftShim's SwiftStdint.h. We cannot include
17+ // that header here because it belongs to the runtime, but we need the same
18+ // logic for interoperability with Swift code in the compiler itself.
19+ // stdint.h is provided by Clang, but it dispatches to libc's stdint.h. As a
20+ // result, using stdint.h here would pull in Darwin module (which includes
21+ // libc). This creates a dependency cycle, so we can't use stdint.h in
22+ // SwiftShims.
23+ // On Linux, the story is different. We get the error message
24+ // "/usr/include/x86_64-linux-gnu/sys/types.h:146:10: error: 'stddef.h' file not
25+ // found"
26+ // This is a known Clang/Ubuntu bug.
27+
28+ // Clang has been defining __INTxx_TYPE__ macros for a long time.
29+ // __UINTxx_TYPE__ are defined only since Clang 3.5.
30+ #if defined(_MSC_VER ) && !defined(__clang__ )
31+ typedef __int64 __swiftc_int64_t ;
32+ typedef unsigned __int64 __swiftc_uint64_t ;
33+ typedef int __swiftc_int32_t ;
34+ typedef unsigned int __swiftc_uint32_t ;
35+ #elif !defined(__APPLE__ ) && !defined(__linux__ ) && !defined(__OpenBSD__ ) && !defined(__wasi__ )
1736#include <stdint.h>
37+ typedef int64_t __swiftc_int64_t ;
38+ typedef uint64_t __swiftc_uint64_t ;
39+ typedef int32_t __swiftc_int32_t ;
40+ typedef uint32_t __swiftc_uint32_t ;
41+ typedef intptr_t __swiftc_intptr_t ;
42+ typedef uintptr_t __swiftc_uintptr_t ;
43+ #else
44+ typedef __INT64_TYPE__ __swiftc_int64_t ;
45+ #ifdef __UINT64_TYPE__
46+ typedef __UINT64_TYPE__ __swiftc_uint64_t ;
47+ #else
48+ typedef unsigned __INT64_TYPE__ __swiftc_uint64_t ;
49+ #endif
50+
51+ typedef __INT32_TYPE__ __swiftc_int32_t ;
52+ #ifdef __UINT32_TYPE__
53+ typedef __UINT32_TYPE__ __swiftc_uint32_t ;
54+ #else
55+ typedef unsigned __INT32_TYPE__ __swiftc_uint32_t ;
56+ #endif
57+ #endif
58+
59+ #define __swiftc_join3 (a ,b ,c ) a ## b ## c
60+
61+ #define __swiftc_intn_t (n ) __swiftc_join3(__swiftc_int, n, _t)
62+ #define __swiftc_uintn_t (n ) __swiftc_join3(__swiftc_uint, n, _t)
63+
64+ #if defined(_MSC_VER ) && !defined(__clang__ )
65+ #if defined(_WIN64 )
66+ typedef __swiftc_int64_t SwiftInt ;
67+ typedef __swiftc_uint64_t SwiftUInt ;
68+ #elif defined(_WIN32 )
69+ typedef __swiftc_int32_t SwiftInt ;
70+ typedef __swiftc_uint32_t SwiftUInt ;
71+ #else
72+ #error unknown windows pointer width
73+ #endif
74+ #else
75+ typedef __swiftc_intn_t (__INTPTR_WIDTH__ ) SwiftInt ;
76+ typedef __swiftc_uintn_t (__INTPTR_WIDTH__ ) SwiftUInt ;
77+ #endif
1878
1979#ifdef __cplusplus
2080extern "C" {
@@ -32,10 +92,10 @@ const void *PluginServer_createConnection(const char **errorMessage);
3292void PluginServer_destroyConnection (const void * connHandle );
3393
3494/// Read bytes from the IPC communication handle.
35- size_t PluginServer_read (const void * connHandle , void * data , size_t nbyte );
95+ SwiftInt PluginServer_read (const void * connHandle , void * data , SwiftUInt nbyte );
3696
3797/// Write bytes to the IPC communication handle.
38- size_t PluginServer_write (const void * connHandle , const void * data , size_t nbyte );
98+ SwiftInt PluginServer_write (const void * connHandle , const void * data , SwiftUInt nbyte );
3999
40100//===----------------------------------------------------------------------===//
41101// Dynamic link
0 commit comments