platform.zlib: fix + mingw + test (#1880)
This commit is contained in:
committed by
Nikolay Igotti
parent
d3d6d49b68
commit
3ad52b8736
@@ -2841,6 +2841,12 @@ task interop_libiconv(type: RunStandaloneKonanTest) {
|
||||
goldValue = "72 72\n101 101\n108 108\n108 108\n111 111\n33 33\n"
|
||||
}
|
||||
|
||||
task interop_zlib(type: RunStandaloneKonanTest) {
|
||||
disabled = (project.testTarget != null)
|
||||
source = "interop/platform_zlib.kt"
|
||||
goldValue = "Hello!\nHello!\n"
|
||||
}
|
||||
|
||||
task produce_dynamic(type: DynamicKonanTest) {
|
||||
disabled = (project.testTarget != null && project.testTarget != project.hostName)
|
||||
source = "produce_dynamic/simple/hello.kt"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import kotlinx.cinterop.*
|
||||
import platform.zlib.*
|
||||
|
||||
val source = immutableBinaryBlobOf(0xF3, 0x48, 0xCD, 0xC9, 0xC9, 0x57, 0x04, 0x00).asCPointer(0)!!
|
||||
val golden = immutableBinaryBlobOf(0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21, 0x00).asCPointer(0)!!
|
||||
|
||||
fun main(args: Array<String>) = memScoped {
|
||||
val buffer = allocArray<ByteVar>(32)
|
||||
|
||||
val z = alloc<z_stream>().apply {
|
||||
next_in = source
|
||||
avail_in = 8
|
||||
next_out = buffer
|
||||
avail_out = 32
|
||||
}.ptr
|
||||
|
||||
if (inflateInit2(z, -15) == Z_OK && inflate(z, Z_FINISH) == Z_STREAM_END && inflateEnd(z) == Z_OK)
|
||||
println(buffer.toKString())
|
||||
|
||||
println(golden.toKString())
|
||||
}
|
||||
@@ -1,5 +1,34 @@
|
||||
depends = posix
|
||||
package = platform.zlib
|
||||
headers = zconf.h zlib.h
|
||||
headerFilter = **
|
||||
headerFilter = zlib.h
|
||||
compilerOpts = -DByte=uByte -DBytef=uBytef
|
||||
linkerOpts = -lz
|
||||
|
||||
---
|
||||
#undef deflateInit
|
||||
static inline int deflateInit(z_streamp strm, int level) {
|
||||
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef deflateInit2
|
||||
static inline int deflateInit2(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy) {
|
||||
return deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit
|
||||
static inline int inflateInit(z_streamp strm) {
|
||||
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit2
|
||||
static inline int inflateInit2(z_streamp strm, int windowBits) {
|
||||
return inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateBackInit
|
||||
static inline int inflateBackInit(z_streamp strm, int windowBits, unsigned char *window) {
|
||||
return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
depends = posix
|
||||
package = platform.zlib
|
||||
headers = zconf.h zlib.h
|
||||
headerFilter = zlib.h
|
||||
compilerOpts = -DByte=uByte -DBytef=uBytef
|
||||
linkerOpts = -lz
|
||||
|
||||
---
|
||||
#undef deflateInit
|
||||
static inline int deflateInit(z_streamp strm, int level) {
|
||||
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef deflateInit2
|
||||
static inline int deflateInit2(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy) {
|
||||
return deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit
|
||||
static inline int inflateInit(z_streamp strm) {
|
||||
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit2
|
||||
static inline int inflateInit2(z_streamp strm, int windowBits) {
|
||||
return inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateBackInit
|
||||
static inline int inflateBackInit(z_streamp strm, int windowBits, unsigned char *window) {
|
||||
return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
depends = posix
|
||||
package = platform.zlib
|
||||
headers = zconf.h zlib.h
|
||||
compilerOpts = -D_ANSI_SOURCE -D_POSIX_C_SOURCE=199309 -D_BSD_SOURCE -D_XOPEN_SOURCE=700
|
||||
headerFilter = zlib.h
|
||||
compilerOpts = -DByte=uByte -DBytef=uBytef -D_ANSI_SOURCE -D_POSIX_C_SOURCE=199309 -D_BSD_SOURCE -D_XOPEN_SOURCE=700
|
||||
linkerOpts = -lz
|
||||
depends = posix
|
||||
|
||||
---
|
||||
#undef deflateInit
|
||||
static inline int deflateInit(z_streamp strm, int level) {
|
||||
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef deflateInit2
|
||||
static inline int deflateInit2(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy) {
|
||||
return deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit
|
||||
static inline int inflateInit(z_streamp strm) {
|
||||
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit2
|
||||
static inline int inflateInit2(z_streamp strm, int windowBits) {
|
||||
return inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateBackInit
|
||||
static inline int inflateBackInit(z_streamp strm, int windowBits, unsigned char *window) {
|
||||
return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
depends = posix
|
||||
package = platform.zlib
|
||||
headers = zconf.h zlib.h
|
||||
headerFilter = zlib.h
|
||||
compilerOpts = -DByte=uByte -DBytef=uBytef
|
||||
linkerOpts = -Wl,-Bstatic -lz -Wl,-Bdynamic
|
||||
|
||||
---
|
||||
#undef deflateInit
|
||||
static inline int deflateInit(z_streamp strm, int level) {
|
||||
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef deflateInit2
|
||||
static inline int deflateInit2(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy) {
|
||||
return deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit
|
||||
static inline int inflateInit(z_streamp strm) {
|
||||
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit2
|
||||
static inline int inflateInit2(z_streamp strm, int windowBits) {
|
||||
return inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateBackInit
|
||||
static inline int inflateBackInit(z_streamp strm, int windowBits, unsigned char *window) {
|
||||
return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
@@ -1,4 +1,34 @@
|
||||
depends = posix
|
||||
package = platform.zlib
|
||||
headers = zconf.h zlib.h
|
||||
headerFilter = zlib.h
|
||||
compilerOpts = -DByte=uByte -DBytef=uBytef
|
||||
linkerOpts = -lz
|
||||
|
||||
---
|
||||
#undef deflateInit
|
||||
static inline int deflateInit(z_streamp strm, int level) {
|
||||
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef deflateInit2
|
||||
static inline int deflateInit2(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy) {
|
||||
return deflateInit2_(strm, level, method, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit
|
||||
static inline int inflateInit(z_streamp strm) {
|
||||
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateInit2
|
||||
static inline int inflateInit2(z_streamp strm, int windowBits) {
|
||||
return inflateInit2_(strm, windowBits, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
#undef inflateBackInit
|
||||
static inline int inflateBackInit(z_streamp strm, int windowBits, unsigned char *window) {
|
||||
return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, (int)sizeof(z_stream));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user