rbuv 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +0 -1
- data/README.md +6 -1
- data/Rakefile +42 -0
- data/deps/libuv/.gitignore +34 -0
- data/deps/libuv/.mailmap +16 -0
- data/deps/libuv/AUTHORS +81 -0
- data/deps/libuv/ChangeLog +45 -0
- data/deps/libuv/LICENSE +41 -0
- data/deps/libuv/Makefile +53 -0
- data/deps/libuv/README.md +118 -0
- data/deps/libuv/build.mk +164 -0
- data/deps/libuv/checksparse.sh +230 -0
- data/deps/libuv/common.gypi +197 -0
- data/deps/libuv/config-mingw.mk +48 -0
- data/deps/libuv/config-unix.mk +167 -0
- data/deps/libuv/gyp_uv +98 -0
- data/deps/libuv/include/uv-private/ngx-queue.h +129 -0
- data/deps/libuv/include/uv-private/stdint-msvc2008.h +247 -0
- data/deps/libuv/include/uv-private/tree.h +768 -0
- data/deps/libuv/include/uv-private/uv-bsd.h +34 -0
- data/deps/libuv/include/uv-private/uv-darwin.h +61 -0
- data/deps/libuv/include/uv-private/uv-linux.h +34 -0
- data/deps/libuv/include/uv-private/uv-sunos.h +44 -0
- data/deps/libuv/include/uv-private/uv-unix.h +332 -0
- data/deps/libuv/include/uv-private/uv-win.h +585 -0
- data/deps/libuv/include/uv.h +1987 -0
- data/deps/libuv/src/fs-poll.c +248 -0
- data/deps/libuv/src/inet.c +298 -0
- data/deps/libuv/src/unix/aix.c +393 -0
- data/deps/libuv/src/unix/async.c +281 -0
- data/deps/libuv/src/unix/core.c +714 -0
- data/deps/libuv/src/unix/cygwin.c +93 -0
- data/deps/libuv/src/unix/darwin-proctitle.m +78 -0
- data/deps/libuv/src/unix/darwin.c +431 -0
- data/deps/libuv/src/unix/dl.c +83 -0
- data/deps/libuv/src/unix/error.c +109 -0
- data/deps/libuv/src/unix/freebsd.c +343 -0
- data/deps/libuv/src/unix/fs.c +869 -0
- data/deps/libuv/src/unix/fsevents.c +299 -0
- data/deps/libuv/src/unix/getaddrinfo.c +159 -0
- data/deps/libuv/src/unix/internal.h +259 -0
- data/deps/libuv/src/unix/kqueue.c +347 -0
- data/deps/libuv/src/unix/linux-core.c +724 -0
- data/deps/libuv/src/unix/linux-inotify.c +236 -0
- data/deps/libuv/src/unix/linux-syscalls.c +388 -0
- data/deps/libuv/src/unix/linux-syscalls.h +150 -0
- data/deps/libuv/src/unix/loop-watcher.c +64 -0
- data/deps/libuv/src/unix/loop.c +114 -0
- data/deps/libuv/src/unix/netbsd.c +353 -0
- data/deps/libuv/src/unix/openbsd.c +304 -0
- data/deps/libuv/src/unix/pipe.c +261 -0
- data/deps/libuv/src/unix/poll.c +108 -0
- data/deps/libuv/src/unix/process.c +501 -0
- data/deps/libuv/src/unix/proctitle.c +103 -0
- data/deps/libuv/src/unix/signal.c +455 -0
- data/deps/libuv/src/unix/stream.c +1380 -0
- data/deps/libuv/src/unix/sunos.c +647 -0
- data/deps/libuv/src/unix/tcp.c +357 -0
- data/deps/libuv/src/unix/thread.c +431 -0
- data/deps/libuv/src/unix/threadpool.c +286 -0
- data/deps/libuv/src/unix/timer.c +153 -0
- data/deps/libuv/src/unix/tty.c +179 -0
- data/deps/libuv/src/unix/udp.c +715 -0
- data/deps/libuv/src/uv-common.c +431 -0
- data/deps/libuv/src/uv-common.h +204 -0
- data/deps/libuv/src/version.c +60 -0
- data/deps/libuv/src/win/async.c +99 -0
- data/deps/libuv/src/win/atomicops-inl.h +56 -0
- data/deps/libuv/src/win/core.c +310 -0
- data/deps/libuv/src/win/dl.c +86 -0
- data/deps/libuv/src/win/error.c +164 -0
- data/deps/libuv/src/win/fs-event.c +506 -0
- data/deps/libuv/src/win/fs.c +1951 -0
- data/deps/libuv/src/win/getaddrinfo.c +365 -0
- data/deps/libuv/src/win/handle-inl.h +164 -0
- data/deps/libuv/src/win/handle.c +153 -0
- data/deps/libuv/src/win/internal.h +346 -0
- data/deps/libuv/src/win/loop-watcher.c +124 -0
- data/deps/libuv/src/win/pipe.c +1656 -0
- data/deps/libuv/src/win/poll.c +615 -0
- data/deps/libuv/src/win/process-stdio.c +503 -0
- data/deps/libuv/src/win/process.c +1048 -0
- data/deps/libuv/src/win/req-inl.h +224 -0
- data/deps/libuv/src/win/req.c +25 -0
- data/deps/libuv/src/win/signal.c +354 -0
- data/deps/libuv/src/win/stream-inl.h +67 -0
- data/deps/libuv/src/win/stream.c +198 -0
- data/deps/libuv/src/win/tcp.c +1422 -0
- data/deps/libuv/src/win/thread.c +666 -0
- data/deps/libuv/src/win/threadpool.c +82 -0
- data/deps/libuv/src/win/timer.c +230 -0
- data/deps/libuv/src/win/tty.c +1857 -0
- data/deps/libuv/src/win/udp.c +744 -0
- data/deps/libuv/src/win/util.c +946 -0
- data/deps/libuv/src/win/winapi.c +152 -0
- data/deps/libuv/src/win/winapi.h +4476 -0
- data/deps/libuv/src/win/winsock.c +560 -0
- data/deps/libuv/src/win/winsock.h +171 -0
- data/deps/libuv/test/benchmark-async-pummel.c +119 -0
- data/deps/libuv/test/benchmark-async.c +139 -0
- data/deps/libuv/test/benchmark-fs-stat.c +136 -0
- data/deps/libuv/test/benchmark-getaddrinfo.c +91 -0
- data/deps/libuv/test/benchmark-list.h +163 -0
- data/deps/libuv/test/benchmark-loop-count.c +90 -0
- data/deps/libuv/test/benchmark-million-async.c +112 -0
- data/deps/libuv/test/benchmark-million-timers.c +77 -0
- data/deps/libuv/test/benchmark-multi-accept.c +432 -0
- data/deps/libuv/test/benchmark-ping-pongs.c +212 -0
- data/deps/libuv/test/benchmark-pound.c +325 -0
- data/deps/libuv/test/benchmark-pump.c +459 -0
- data/deps/libuv/test/benchmark-sizes.c +45 -0
- data/deps/libuv/test/benchmark-spawn.c +163 -0
- data/deps/libuv/test/benchmark-tcp-write-batch.c +141 -0
- data/deps/libuv/test/benchmark-thread.c +64 -0
- data/deps/libuv/test/benchmark-udp-pummel.c +238 -0
- data/deps/libuv/test/blackhole-server.c +118 -0
- data/deps/libuv/test/dns-server.c +329 -0
- data/deps/libuv/test/echo-server.c +384 -0
- data/deps/libuv/test/fixtures/empty_file +0 -0
- data/deps/libuv/test/fixtures/load_error.node +1 -0
- data/deps/libuv/test/run-benchmarks.c +64 -0
- data/deps/libuv/test/run-tests.c +159 -0
- data/deps/libuv/test/runner-unix.c +328 -0
- data/deps/libuv/test/runner-unix.h +36 -0
- data/deps/libuv/test/runner-win.c +318 -0
- data/deps/libuv/test/runner-win.h +43 -0
- data/deps/libuv/test/runner.c +394 -0
- data/deps/libuv/test/runner.h +165 -0
- data/deps/libuv/test/task.h +122 -0
- data/deps/libuv/test/test-active.c +83 -0
- data/deps/libuv/test/test-async.c +136 -0
- data/deps/libuv/test/test-barrier.c +98 -0
- data/deps/libuv/test/test-callback-order.c +77 -0
- data/deps/libuv/test/test-callback-stack.c +204 -0
- data/deps/libuv/test/test-condvar.c +173 -0
- data/deps/libuv/test/test-connection-fail.c +150 -0
- data/deps/libuv/test/test-cwd-and-chdir.c +64 -0
- data/deps/libuv/test/test-delayed-accept.c +189 -0
- data/deps/libuv/test/test-dlerror.c +58 -0
- data/deps/libuv/test/test-embed.c +136 -0
- data/deps/libuv/test/test-error.c +59 -0
- data/deps/libuv/test/test-fail-always.c +29 -0
- data/deps/libuv/test/test-fs-event.c +504 -0
- data/deps/libuv/test/test-fs-poll.c +148 -0
- data/deps/libuv/test/test-fs.c +1899 -0
- data/deps/libuv/test/test-get-currentexe.c +63 -0
- data/deps/libuv/test/test-get-loadavg.c +36 -0
- data/deps/libuv/test/test-get-memory.c +38 -0
- data/deps/libuv/test/test-getaddrinfo.c +120 -0
- data/deps/libuv/test/test-getsockname.c +344 -0
- data/deps/libuv/test/test-hrtime.c +54 -0
- data/deps/libuv/test/test-idle.c +82 -0
- data/deps/libuv/test/test-ipc-send-recv.c +218 -0
- data/deps/libuv/test/test-ipc.c +625 -0
- data/deps/libuv/test/test-list.h +492 -0
- data/deps/libuv/test/test-loop-handles.c +337 -0
- data/deps/libuv/test/test-loop-stop.c +73 -0
- data/deps/libuv/test/test-multiple-listen.c +103 -0
- data/deps/libuv/test/test-mutexes.c +63 -0
- data/deps/libuv/test/test-pass-always.c +28 -0
- data/deps/libuv/test/test-ping-pong.c +250 -0
- data/deps/libuv/test/test-pipe-bind-error.c +144 -0
- data/deps/libuv/test/test-pipe-connect-error.c +98 -0
- data/deps/libuv/test/test-platform-output.c +87 -0
- data/deps/libuv/test/test-poll-close.c +73 -0
- data/deps/libuv/test/test-poll.c +575 -0
- data/deps/libuv/test/test-process-title.c +49 -0
- data/deps/libuv/test/test-ref.c +415 -0
- data/deps/libuv/test/test-run-nowait.c +46 -0
- data/deps/libuv/test/test-run-once.c +49 -0
- data/deps/libuv/test/test-semaphore.c +111 -0
- data/deps/libuv/test/test-shutdown-close.c +105 -0
- data/deps/libuv/test/test-shutdown-eof.c +184 -0
- data/deps/libuv/test/test-signal-multiple-loops.c +270 -0
- data/deps/libuv/test/test-signal.c +152 -0
- data/deps/libuv/test/test-spawn.c +938 -0
- data/deps/libuv/test/test-stdio-over-pipes.c +250 -0
- data/deps/libuv/test/test-tcp-bind-error.c +198 -0
- data/deps/libuv/test/test-tcp-bind6-error.c +159 -0
- data/deps/libuv/test/test-tcp-close-while-connecting.c +81 -0
- data/deps/libuv/test/test-tcp-close.c +130 -0
- data/deps/libuv/test/test-tcp-connect-error-after-write.c +96 -0
- data/deps/libuv/test/test-tcp-connect-error.c +71 -0
- data/deps/libuv/test/test-tcp-connect-timeout.c +86 -0
- data/deps/libuv/test/test-tcp-connect6-error.c +69 -0
- data/deps/libuv/test/test-tcp-flags.c +52 -0
- data/deps/libuv/test/test-tcp-open.c +175 -0
- data/deps/libuv/test/test-tcp-read-stop.c +73 -0
- data/deps/libuv/test/test-tcp-shutdown-after-write.c +132 -0
- data/deps/libuv/test/test-tcp-unexpected-read.c +114 -0
- data/deps/libuv/test/test-tcp-write-to-half-open-connection.c +136 -0
- data/deps/libuv/test/test-tcp-writealot.c +171 -0
- data/deps/libuv/test/test-thread.c +183 -0
- data/deps/libuv/test/test-threadpool-cancel.c +311 -0
- data/deps/libuv/test/test-threadpool.c +77 -0
- data/deps/libuv/test/test-timer-again.c +142 -0
- data/deps/libuv/test/test-timer.c +266 -0
- data/deps/libuv/test/test-tty.c +111 -0
- data/deps/libuv/test/test-udp-dgram-too-big.c +87 -0
- data/deps/libuv/test/test-udp-ipv6.c +158 -0
- data/deps/libuv/test/test-udp-multicast-join.c +140 -0
- data/deps/libuv/test/test-udp-multicast-ttl.c +87 -0
- data/deps/libuv/test/test-udp-open.c +154 -0
- data/deps/libuv/test/test-udp-options.c +87 -0
- data/deps/libuv/test/test-udp-send-and-recv.c +210 -0
- data/deps/libuv/test/test-util.c +97 -0
- data/deps/libuv/test/test-walk-handles.c +78 -0
- data/deps/libuv/uv.gyp +431 -0
- data/deps/libuv/vcbuild.bat +128 -0
- data/ext/rbuv/debug.h +27 -0
- data/ext/rbuv/error.c +7 -0
- data/ext/rbuv/error.h +10 -0
- data/ext/rbuv/extconf.rb +35 -0
- data/ext/rbuv/handle.c +40 -0
- data/ext/rbuv/handle.h +14 -0
- data/ext/rbuv/libuv.mk +12 -0
- data/ext/rbuv/loop.c +50 -0
- data/ext/rbuv/loop.h +13 -0
- data/ext/rbuv/rbuv.c +15 -0
- data/ext/rbuv/rbuv.h +27 -0
- data/ext/rbuv/timer.c +133 -0
- data/ext/rbuv/timer.h +13 -0
- data/lib/rbuv/timer.rb +7 -0
- data/lib/rbuv/version.rb +1 -1
- data/lib/rbuv.rb +24 -2
- data/rbuv.gemspec +5 -1
- data/spec/spec_helper.rb +22 -0
- data/spec/timer_spec.rb +144 -0
- metadata +278 -9
data/deps/libuv/gyp_uv
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
import glob
|
4
|
+
import platform
|
5
|
+
import os
|
6
|
+
import subprocess
|
7
|
+
import sys
|
8
|
+
|
9
|
+
CC = os.environ.get('CC', 'cc')
|
10
|
+
script_dir = os.path.dirname(__file__)
|
11
|
+
uv_root = os.path.normpath(script_dir)
|
12
|
+
output_dir = os.path.join(os.path.abspath(uv_root), 'out')
|
13
|
+
|
14
|
+
sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib'))
|
15
|
+
try:
|
16
|
+
import gyp
|
17
|
+
except ImportError:
|
18
|
+
print('You need to install gyp in build/gyp first. See the README.')
|
19
|
+
sys.exit(42)
|
20
|
+
|
21
|
+
|
22
|
+
def host_arch():
|
23
|
+
machine = platform.machine()
|
24
|
+
if machine == 'i386': return 'ia32'
|
25
|
+
if machine == 'x86_64': return 'x64'
|
26
|
+
if machine.startswith('arm'): return 'arm'
|
27
|
+
return machine # Return as-is and hope for the best.
|
28
|
+
|
29
|
+
|
30
|
+
def compiler_version():
|
31
|
+
proc = subprocess.Popen(CC.split() + ['--version'], stdout=subprocess.PIPE)
|
32
|
+
is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
|
33
|
+
proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE)
|
34
|
+
version = proc.communicate()[0].split('.')
|
35
|
+
version = map(int, version[:2])
|
36
|
+
version = tuple(version)
|
37
|
+
return (version, is_clang)
|
38
|
+
|
39
|
+
|
40
|
+
def run_gyp(args):
|
41
|
+
rc = gyp.main(args)
|
42
|
+
if rc != 0:
|
43
|
+
print 'Error running GYP'
|
44
|
+
sys.exit(rc)
|
45
|
+
|
46
|
+
|
47
|
+
if __name__ == '__main__':
|
48
|
+
args = sys.argv[1:]
|
49
|
+
|
50
|
+
# GYP bug.
|
51
|
+
# On msvs it will crash if it gets an absolute path.
|
52
|
+
# On Mac/make it will crash if it doesn't get an absolute path.
|
53
|
+
if sys.platform == 'win32':
|
54
|
+
args.append(os.path.join(uv_root, 'uv.gyp'))
|
55
|
+
common_fn = os.path.join(uv_root, 'common.gypi')
|
56
|
+
options_fn = os.path.join(uv_root, 'options.gypi')
|
57
|
+
# we force vs 2010 over 2008 which would otherwise be the default for gyp
|
58
|
+
if not os.environ.get('GYP_MSVS_VERSION'):
|
59
|
+
os.environ['GYP_MSVS_VERSION'] = '2010'
|
60
|
+
else:
|
61
|
+
args.append(os.path.join(os.path.abspath(uv_root), 'uv.gyp'))
|
62
|
+
common_fn = os.path.join(os.path.abspath(uv_root), 'common.gypi')
|
63
|
+
options_fn = os.path.join(os.path.abspath(uv_root), 'options.gypi')
|
64
|
+
|
65
|
+
if os.path.exists(common_fn):
|
66
|
+
args.extend(['-I', common_fn])
|
67
|
+
|
68
|
+
if os.path.exists(options_fn):
|
69
|
+
args.extend(['-I', options_fn])
|
70
|
+
|
71
|
+
args.append('--depth=' + uv_root)
|
72
|
+
|
73
|
+
# There's a bug with windows which doesn't allow this feature.
|
74
|
+
if sys.platform != 'win32':
|
75
|
+
if '-f' not in args:
|
76
|
+
args.extend('-f make'.split())
|
77
|
+
if 'ninja' not in args:
|
78
|
+
args.extend(['-Goutput_dir=' + output_dir])
|
79
|
+
args.extend(['--generator-output', output_dir])
|
80
|
+
(major, minor), is_clang = compiler_version()
|
81
|
+
args.append('-Dgcc_version=%d' % (10 * major + minor))
|
82
|
+
args.append('-Dclang=%d' % int(is_clang))
|
83
|
+
|
84
|
+
if not any(a.startswith('-Dhost_arch=') for a in args):
|
85
|
+
args.append('-Dhost_arch=%s' % host_arch())
|
86
|
+
|
87
|
+
if not any(a.startswith('-Dtarget_arch=') for a in args):
|
88
|
+
args.append('-Dtarget_arch=%s' % host_arch())
|
89
|
+
|
90
|
+
if not any(a.startswith('-Dlibrary=') for a in args):
|
91
|
+
args.append('-Dlibrary=static_library')
|
92
|
+
|
93
|
+
if not any(a.startswith('-Dcomponent=') for a in args):
|
94
|
+
args.append('-Dcomponent=static_library')
|
95
|
+
|
96
|
+
gyp_args = list(args)
|
97
|
+
print gyp_args
|
98
|
+
run_gyp(gyp_args)
|
@@ -0,0 +1,129 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#ifndef NGX_QUEUE_H_INCLUDED_
|
8
|
+
#define NGX_QUEUE_H_INCLUDED_
|
9
|
+
|
10
|
+
|
11
|
+
typedef struct ngx_queue_s ngx_queue_t;
|
12
|
+
|
13
|
+
struct ngx_queue_s {
|
14
|
+
ngx_queue_t *prev;
|
15
|
+
ngx_queue_t *next;
|
16
|
+
};
|
17
|
+
|
18
|
+
|
19
|
+
#define ngx_queue_init(q) \
|
20
|
+
do { \
|
21
|
+
(q)->prev = q; \
|
22
|
+
(q)->next = q; \
|
23
|
+
} \
|
24
|
+
while (0)
|
25
|
+
|
26
|
+
|
27
|
+
#define ngx_queue_empty(h) \
|
28
|
+
(h == (h)->prev)
|
29
|
+
|
30
|
+
|
31
|
+
#define ngx_queue_insert_head(h, x) \
|
32
|
+
do { \
|
33
|
+
(x)->next = (h)->next; \
|
34
|
+
(x)->next->prev = x; \
|
35
|
+
(x)->prev = h; \
|
36
|
+
(h)->next = x; \
|
37
|
+
} \
|
38
|
+
while (0)
|
39
|
+
|
40
|
+
|
41
|
+
#define ngx_queue_insert_after ngx_queue_insert_head
|
42
|
+
|
43
|
+
|
44
|
+
#define ngx_queue_insert_tail(h, x) \
|
45
|
+
do { \
|
46
|
+
(x)->prev = (h)->prev; \
|
47
|
+
(x)->prev->next = x; \
|
48
|
+
(x)->next = h; \
|
49
|
+
(h)->prev = x; \
|
50
|
+
} \
|
51
|
+
while (0)
|
52
|
+
|
53
|
+
|
54
|
+
#define ngx_queue_head(h) \
|
55
|
+
(h)->next
|
56
|
+
|
57
|
+
|
58
|
+
#define ngx_queue_last(h) \
|
59
|
+
(h)->prev
|
60
|
+
|
61
|
+
|
62
|
+
#define ngx_queue_sentinel(h) \
|
63
|
+
(h)
|
64
|
+
|
65
|
+
|
66
|
+
#define ngx_queue_next(q) \
|
67
|
+
(q)->next
|
68
|
+
|
69
|
+
|
70
|
+
#define ngx_queue_prev(q) \
|
71
|
+
(q)->prev
|
72
|
+
|
73
|
+
|
74
|
+
#if defined(NGX_DEBUG)
|
75
|
+
|
76
|
+
#define ngx_queue_remove(x) \
|
77
|
+
do { \
|
78
|
+
(x)->next->prev = (x)->prev; \
|
79
|
+
(x)->prev->next = (x)->next; \
|
80
|
+
(x)->prev = NULL; \
|
81
|
+
(x)->next = NULL; \
|
82
|
+
} \
|
83
|
+
while (0)
|
84
|
+
|
85
|
+
#else
|
86
|
+
|
87
|
+
#define ngx_queue_remove(x) \
|
88
|
+
do { \
|
89
|
+
(x)->next->prev = (x)->prev; \
|
90
|
+
(x)->prev->next = (x)->next; \
|
91
|
+
} \
|
92
|
+
while (0)
|
93
|
+
|
94
|
+
#endif
|
95
|
+
|
96
|
+
|
97
|
+
#define ngx_queue_split(h, q, n) \
|
98
|
+
do { \
|
99
|
+
(n)->prev = (h)->prev; \
|
100
|
+
(n)->prev->next = n; \
|
101
|
+
(n)->next = q; \
|
102
|
+
(h)->prev = (q)->prev; \
|
103
|
+
(h)->prev->next = h; \
|
104
|
+
(q)->prev = n; \
|
105
|
+
} \
|
106
|
+
while (0)
|
107
|
+
|
108
|
+
|
109
|
+
#define ngx_queue_add(h, n) \
|
110
|
+
do { \
|
111
|
+
(h)->prev->next = (n)->next; \
|
112
|
+
(n)->next->prev = (h)->prev; \
|
113
|
+
(h)->prev = (n)->prev; \
|
114
|
+
(h)->prev->next = h; \
|
115
|
+
} \
|
116
|
+
while (0)
|
117
|
+
|
118
|
+
|
119
|
+
#define ngx_queue_data(q, type, link) \
|
120
|
+
((type *) ((unsigned char *) q - offsetof(type, link)))
|
121
|
+
|
122
|
+
|
123
|
+
#define ngx_queue_foreach(q, h) \
|
124
|
+
for ((q) = ngx_queue_head(h); \
|
125
|
+
(q) != ngx_queue_sentinel(h) && !ngx_queue_empty(h); \
|
126
|
+
(q) = ngx_queue_next(q))
|
127
|
+
|
128
|
+
|
129
|
+
#endif /* NGX_QUEUE_H_INCLUDED_ */
|
@@ -0,0 +1,247 @@
|
|
1
|
+
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
2
|
+
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
3
|
+
//
|
4
|
+
// Copyright (c) 2006-2008 Alexander Chemeris
|
5
|
+
//
|
6
|
+
// Redistribution and use in source and binary forms, with or without
|
7
|
+
// modification, are permitted provided that the following conditions are met:
|
8
|
+
//
|
9
|
+
// 1. Redistributions of source code must retain the above copyright notice,
|
10
|
+
// this list of conditions and the following disclaimer.
|
11
|
+
//
|
12
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
// notice, this list of conditions and the following disclaimer in the
|
14
|
+
// documentation and/or other materials provided with the distribution.
|
15
|
+
//
|
16
|
+
// 3. The name of the author may be used to endorse or promote products
|
17
|
+
// derived from this software without specific prior written permission.
|
18
|
+
//
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
20
|
+
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
21
|
+
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
22
|
+
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
25
|
+
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
26
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
27
|
+
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
28
|
+
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
//
|
30
|
+
///////////////////////////////////////////////////////////////////////////////
|
31
|
+
|
32
|
+
#ifndef _MSC_VER // [
|
33
|
+
#error "Use this header only with Microsoft Visual C++ compilers!"
|
34
|
+
#endif // _MSC_VER ]
|
35
|
+
|
36
|
+
#ifndef _MSC_STDINT_H_ // [
|
37
|
+
#define _MSC_STDINT_H_
|
38
|
+
|
39
|
+
#if _MSC_VER > 1000
|
40
|
+
#pragma once
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#include <limits.h>
|
44
|
+
|
45
|
+
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
46
|
+
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
47
|
+
// or compiler give many errors like this:
|
48
|
+
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
49
|
+
#ifdef __cplusplus
|
50
|
+
extern "C" {
|
51
|
+
#endif
|
52
|
+
# include <wchar.h>
|
53
|
+
#ifdef __cplusplus
|
54
|
+
}
|
55
|
+
#endif
|
56
|
+
|
57
|
+
// Define _W64 macros to mark types changing their size, like intptr_t.
|
58
|
+
#ifndef _W64
|
59
|
+
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
60
|
+
# define _W64 __w64
|
61
|
+
# else
|
62
|
+
# define _W64
|
63
|
+
# endif
|
64
|
+
#endif
|
65
|
+
|
66
|
+
|
67
|
+
// 7.18.1 Integer types
|
68
|
+
|
69
|
+
// 7.18.1.1 Exact-width integer types
|
70
|
+
|
71
|
+
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
72
|
+
// realize that, e.g. char has the same size as __int8
|
73
|
+
// so we give up on __intX for them.
|
74
|
+
#if (_MSC_VER < 1300)
|
75
|
+
typedef signed char int8_t;
|
76
|
+
typedef signed short int16_t;
|
77
|
+
typedef signed int int32_t;
|
78
|
+
typedef unsigned char uint8_t;
|
79
|
+
typedef unsigned short uint16_t;
|
80
|
+
typedef unsigned int uint32_t;
|
81
|
+
#else
|
82
|
+
typedef signed __int8 int8_t;
|
83
|
+
typedef signed __int16 int16_t;
|
84
|
+
typedef signed __int32 int32_t;
|
85
|
+
typedef unsigned __int8 uint8_t;
|
86
|
+
typedef unsigned __int16 uint16_t;
|
87
|
+
typedef unsigned __int32 uint32_t;
|
88
|
+
#endif
|
89
|
+
typedef signed __int64 int64_t;
|
90
|
+
typedef unsigned __int64 uint64_t;
|
91
|
+
|
92
|
+
|
93
|
+
// 7.18.1.2 Minimum-width integer types
|
94
|
+
typedef int8_t int_least8_t;
|
95
|
+
typedef int16_t int_least16_t;
|
96
|
+
typedef int32_t int_least32_t;
|
97
|
+
typedef int64_t int_least64_t;
|
98
|
+
typedef uint8_t uint_least8_t;
|
99
|
+
typedef uint16_t uint_least16_t;
|
100
|
+
typedef uint32_t uint_least32_t;
|
101
|
+
typedef uint64_t uint_least64_t;
|
102
|
+
|
103
|
+
// 7.18.1.3 Fastest minimum-width integer types
|
104
|
+
typedef int8_t int_fast8_t;
|
105
|
+
typedef int16_t int_fast16_t;
|
106
|
+
typedef int32_t int_fast32_t;
|
107
|
+
typedef int64_t int_fast64_t;
|
108
|
+
typedef uint8_t uint_fast8_t;
|
109
|
+
typedef uint16_t uint_fast16_t;
|
110
|
+
typedef uint32_t uint_fast32_t;
|
111
|
+
typedef uint64_t uint_fast64_t;
|
112
|
+
|
113
|
+
// 7.18.1.4 Integer types capable of holding object pointers
|
114
|
+
#ifdef _WIN64 // [
|
115
|
+
typedef signed __int64 intptr_t;
|
116
|
+
typedef unsigned __int64 uintptr_t;
|
117
|
+
#else // _WIN64 ][
|
118
|
+
typedef _W64 signed int intptr_t;
|
119
|
+
typedef _W64 unsigned int uintptr_t;
|
120
|
+
#endif // _WIN64 ]
|
121
|
+
|
122
|
+
// 7.18.1.5 Greatest-width integer types
|
123
|
+
typedef int64_t intmax_t;
|
124
|
+
typedef uint64_t uintmax_t;
|
125
|
+
|
126
|
+
|
127
|
+
// 7.18.2 Limits of specified-width integer types
|
128
|
+
|
129
|
+
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
130
|
+
|
131
|
+
// 7.18.2.1 Limits of exact-width integer types
|
132
|
+
#define INT8_MIN ((int8_t)_I8_MIN)
|
133
|
+
#define INT8_MAX _I8_MAX
|
134
|
+
#define INT16_MIN ((int16_t)_I16_MIN)
|
135
|
+
#define INT16_MAX _I16_MAX
|
136
|
+
#define INT32_MIN ((int32_t)_I32_MIN)
|
137
|
+
#define INT32_MAX _I32_MAX
|
138
|
+
#define INT64_MIN ((int64_t)_I64_MIN)
|
139
|
+
#define INT64_MAX _I64_MAX
|
140
|
+
#define UINT8_MAX _UI8_MAX
|
141
|
+
#define UINT16_MAX _UI16_MAX
|
142
|
+
#define UINT32_MAX _UI32_MAX
|
143
|
+
#define UINT64_MAX _UI64_MAX
|
144
|
+
|
145
|
+
// 7.18.2.2 Limits of minimum-width integer types
|
146
|
+
#define INT_LEAST8_MIN INT8_MIN
|
147
|
+
#define INT_LEAST8_MAX INT8_MAX
|
148
|
+
#define INT_LEAST16_MIN INT16_MIN
|
149
|
+
#define INT_LEAST16_MAX INT16_MAX
|
150
|
+
#define INT_LEAST32_MIN INT32_MIN
|
151
|
+
#define INT_LEAST32_MAX INT32_MAX
|
152
|
+
#define INT_LEAST64_MIN INT64_MIN
|
153
|
+
#define INT_LEAST64_MAX INT64_MAX
|
154
|
+
#define UINT_LEAST8_MAX UINT8_MAX
|
155
|
+
#define UINT_LEAST16_MAX UINT16_MAX
|
156
|
+
#define UINT_LEAST32_MAX UINT32_MAX
|
157
|
+
#define UINT_LEAST64_MAX UINT64_MAX
|
158
|
+
|
159
|
+
// 7.18.2.3 Limits of fastest minimum-width integer types
|
160
|
+
#define INT_FAST8_MIN INT8_MIN
|
161
|
+
#define INT_FAST8_MAX INT8_MAX
|
162
|
+
#define INT_FAST16_MIN INT16_MIN
|
163
|
+
#define INT_FAST16_MAX INT16_MAX
|
164
|
+
#define INT_FAST32_MIN INT32_MIN
|
165
|
+
#define INT_FAST32_MAX INT32_MAX
|
166
|
+
#define INT_FAST64_MIN INT64_MIN
|
167
|
+
#define INT_FAST64_MAX INT64_MAX
|
168
|
+
#define UINT_FAST8_MAX UINT8_MAX
|
169
|
+
#define UINT_FAST16_MAX UINT16_MAX
|
170
|
+
#define UINT_FAST32_MAX UINT32_MAX
|
171
|
+
#define UINT_FAST64_MAX UINT64_MAX
|
172
|
+
|
173
|
+
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
174
|
+
#ifdef _WIN64 // [
|
175
|
+
# define INTPTR_MIN INT64_MIN
|
176
|
+
# define INTPTR_MAX INT64_MAX
|
177
|
+
# define UINTPTR_MAX UINT64_MAX
|
178
|
+
#else // _WIN64 ][
|
179
|
+
# define INTPTR_MIN INT32_MIN
|
180
|
+
# define INTPTR_MAX INT32_MAX
|
181
|
+
# define UINTPTR_MAX UINT32_MAX
|
182
|
+
#endif // _WIN64 ]
|
183
|
+
|
184
|
+
// 7.18.2.5 Limits of greatest-width integer types
|
185
|
+
#define INTMAX_MIN INT64_MIN
|
186
|
+
#define INTMAX_MAX INT64_MAX
|
187
|
+
#define UINTMAX_MAX UINT64_MAX
|
188
|
+
|
189
|
+
// 7.18.3 Limits of other integer types
|
190
|
+
|
191
|
+
#ifdef _WIN64 // [
|
192
|
+
# define PTRDIFF_MIN _I64_MIN
|
193
|
+
# define PTRDIFF_MAX _I64_MAX
|
194
|
+
#else // _WIN64 ][
|
195
|
+
# define PTRDIFF_MIN _I32_MIN
|
196
|
+
# define PTRDIFF_MAX _I32_MAX
|
197
|
+
#endif // _WIN64 ]
|
198
|
+
|
199
|
+
#define SIG_ATOMIC_MIN INT_MIN
|
200
|
+
#define SIG_ATOMIC_MAX INT_MAX
|
201
|
+
|
202
|
+
#ifndef SIZE_MAX // [
|
203
|
+
# ifdef _WIN64 // [
|
204
|
+
# define SIZE_MAX _UI64_MAX
|
205
|
+
# else // _WIN64 ][
|
206
|
+
# define SIZE_MAX _UI32_MAX
|
207
|
+
# endif // _WIN64 ]
|
208
|
+
#endif // SIZE_MAX ]
|
209
|
+
|
210
|
+
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
211
|
+
#ifndef WCHAR_MIN // [
|
212
|
+
# define WCHAR_MIN 0
|
213
|
+
#endif // WCHAR_MIN ]
|
214
|
+
#ifndef WCHAR_MAX // [
|
215
|
+
# define WCHAR_MAX _UI16_MAX
|
216
|
+
#endif // WCHAR_MAX ]
|
217
|
+
|
218
|
+
#define WINT_MIN 0
|
219
|
+
#define WINT_MAX _UI16_MAX
|
220
|
+
|
221
|
+
#endif // __STDC_LIMIT_MACROS ]
|
222
|
+
|
223
|
+
|
224
|
+
// 7.18.4 Limits of other integer types
|
225
|
+
|
226
|
+
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
227
|
+
|
228
|
+
// 7.18.4.1 Macros for minimum-width integer constants
|
229
|
+
|
230
|
+
#define INT8_C(val) val##i8
|
231
|
+
#define INT16_C(val) val##i16
|
232
|
+
#define INT32_C(val) val##i32
|
233
|
+
#define INT64_C(val) val##i64
|
234
|
+
|
235
|
+
#define UINT8_C(val) val##ui8
|
236
|
+
#define UINT16_C(val) val##ui16
|
237
|
+
#define UINT32_C(val) val##ui32
|
238
|
+
#define UINT64_C(val) val##ui64
|
239
|
+
|
240
|
+
// 7.18.4.2 Macros for greatest-width integer constants
|
241
|
+
#define INTMAX_C INT64_C
|
242
|
+
#define UINTMAX_C UINT64_C
|
243
|
+
|
244
|
+
#endif // __STDC_CONSTANT_MACROS ]
|
245
|
+
|
246
|
+
|
247
|
+
#endif // _MSC_STDINT_H_ ]
|