Fix for Windows where deprecated realization itoa exists
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.structsBenchmarks
|
package org.jetbrains.structsBenchmarks
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
import platform.posix.*
|
||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
const val benchmarkSize = 10000
|
const val benchmarkSize = 10000
|
||||||
@@ -38,7 +39,7 @@ actual fun structBenchmark() {
|
|||||||
val element = alloc<ElementS>()
|
val element = alloc<ElementS>()
|
||||||
element.floatValue = i + sqrt(i.toDouble()).toFloat()
|
element.floatValue = i + sqrt(i.toDouble()).toFloat()
|
||||||
element.integer = i.toLong()
|
element.integer = i.toLong()
|
||||||
itoa(i, element.string, 10)
|
sprintf(element.string, "%d", i)
|
||||||
element.contains = containsFunction
|
element.contains = containsFunction
|
||||||
|
|
||||||
elementsList.add(element)
|
elementsList.add(element)
|
||||||
|
|||||||
@@ -75,14 +75,6 @@ struct ElementS multiplyElementS(struct ElementS element, int coefficient) {
|
|||||||
return newElement;
|
return newElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
void itoa(int val, char* buffer, int base){
|
|
||||||
int i = 30;
|
|
||||||
for(; val && i ; --i, val /= base)
|
|
||||||
buffer[i] = "0123456789abcdef"[val % base];
|
|
||||||
buffer[31] = '\0';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
union ElementU* sumElementUPtr(const union ElementU* first, const union ElementU* second) {
|
union ElementU* sumElementUPtr(const union ElementU* first, const union ElementU* second) {
|
||||||
if (first == NULL || second == NULL) {
|
if (first == NULL || second == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -99,7 +91,7 @@ struct ElementS* sumElementSPtr(const struct ElementS* first, const struct Eleme
|
|||||||
struct ElementS* newElement = (struct ElementS*)malloc(sizeof(struct ElementS));
|
struct ElementS* newElement = (struct ElementS*)malloc(sizeof(struct ElementS));
|
||||||
newElement->integer = first->integer + second->integer;
|
newElement->integer = first->integer + second->integer;
|
||||||
newElement->floatValue = first->floatValue + second->floatValue;
|
newElement->floatValue = first->floatValue + second->floatValue;
|
||||||
itoa(newElement->integer, newElement->string, 10);
|
sprintf(newElement->string, "%d", newElement->integer);
|
||||||
return newElement;
|
return newElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user