aboutsummaryrefslogtreecommitdiff
path: root/dtoa_config.h
diff options
context:
space:
mode:
Diffstat (limited to 'dtoa_config.h')
-rw-r--r--dtoa_config.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/dtoa_config.h b/dtoa_config.h
new file mode 100644
index 0000000..294351d
--- /dev/null
+++ b/dtoa_config.h
@@ -0,0 +1,66 @@
1#ifndef _DTOA_CONFIG_H
2#define _DTOA_CONFIG_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <stdint.h>
7
8/* Ensure dtoa.c does not USE_LOCALE. Lua CJSON must not use locale
9 * aware conversion routines. */
10#undef USE_LOCALE
11
12/* dtoa.c should not touch errno, Lua CJSON does not use it, and it
13 * may not be threadsafe */
14#define NO_ERRNO
15
16#define Long int32_t
17#define ULong uint32_t
18#define Llong int64_t
19#define ULLong uint64_t
20
21#ifdef IEEE_BIG_ENDIAN
22#define IEEE_MC68k
23#else
24#define IEEE_8087
25#endif
26
27#define MALLOC(n) xmalloc(n)
28
29static void *xmalloc(size_t size)
30{
31 void *p;
32
33 p = malloc(size);
34 if (!p) {
35 fprintf(stderr, "Out of memory");
36 abort();
37 }
38
39 return p;
40}
41
42#ifdef MULTIPLE_THREADS
43
44/* Enable locking to support multi-threaded applications */
45
46#include <pthread.h>
47
48static pthread_mutex_t private_dtoa_lock[2] = {
49 PTHREAD_MUTEX_INITIALIZER,
50 PTHREAD_MUTEX_INITIALIZER
51};
52
53#define ACQUIRE_DTOA_LOCK(n) do { \
54 pthread_mutex_lock(&private_dtoa_lock[n]); \
55} while (0)
56
57#define FREE_DTOA_LOCK(n) do { \
58 pthread_mutex_unlock(&private_dtoa_lock[n]); \
59} while (0)
60
61#endif /* MULTIPLE_THREADS */
62
63#endif /* _DTOA_CONFIG_H */
64
65/* vi:ai et sw=4 ts=4:
66 */