Mercurial > hg > forks > bilotrip-mj12
annotate src/platform.c @ 45:d85542c96791
Clean up the build some more, move platform specifics again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Aug 2013 00:23:45 +0300 |
parents | 785057719d9b |
children |
rev | line source |
---|---|
0 | 1 #include "platform.h" |
2 | |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
3 |
0 | 4 #if defined(_WIN32) || defined(_WIN64) |
5 #include <math.h> | |
6 | |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
7 double round(float v) |
0 | 8 { |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
9 return floor(v + 0.5f); |
0 | 10 } |
11 | |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
12 #endif |
0 | 13 |
14 | |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
15 #if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
16 |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
17 char * strndup(const char *s, size_t n) |
0 | 18 { |
45
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
19 char *result = malloc(n + 1); |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
20 if (result == NULL) |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
21 return NULL; |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
23 memcpy(result, s, n); |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
24 result[n] = 0; |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
25 return result; |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
26 } |
d85542c96791
Clean up the build some more, move platform specifics again.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
27 |
0 | 28 #endif |