prometheus-client-mmap 0.7.0.beta25 → 0.7.0.beta26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/fast_mmaped_file/fast_mmaped_file.c +27 -0
- data/ext/fast_mmaped_file/mmap.h +58 -0
- data/lib/fast_mmaped_file.bundle +0 -0
- data/lib/prometheus/client/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f086e3c44e2839e24cf984fe1d900eebe1a4c486
|
4
|
+
data.tar.gz: 134edab2af138f3fd3b7c50eda90a49bad59f995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e72e61bde828fb4fb36f76066e18c7656dbae957136a75ceb11f78e095183184e188dbc348a883293fe5542b2636674f601a9740b8543b2849318338d019f0b
|
7
|
+
data.tar.gz: 6fdf77bd432a2cca25f1eee7baa412ccf5489823584a87dc1ff6635f71bb1d8026861a54618283f02ff0c7b760acd27e53c8b3997b9eb39a5e99537091d442b1
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include "mmap.h"
|
3
|
+
|
4
|
+
VALUE MMAPED_FILE = Qnil;
|
5
|
+
|
6
|
+
|
7
|
+
VALUE method_get_double(VALUE self, VALUE index) {
|
8
|
+
mm_ipc *i_mm;
|
9
|
+
GetMmap(self, i_mm, MM_MODIFY);
|
10
|
+
|
11
|
+
Check_Type(index, T_FIXNUM);
|
12
|
+
size_t idx = NUM2UINT(index);
|
13
|
+
|
14
|
+
if ((i_mm->t->real + sizeof(double)) <= idx) {
|
15
|
+
rb_raise(rb_eIndexError, "index %ld out of string", idx);
|
16
|
+
}
|
17
|
+
|
18
|
+
double tmp;
|
19
|
+
|
20
|
+
memcpy(&tmp, (char *)i_mm->t->addr + idx, sizeof(double));
|
21
|
+
return DBL2NUM(tmp);
|
22
|
+
}
|
23
|
+
|
24
|
+
void Init_fast_mmaped_file() {
|
25
|
+
MMAPED_FILE = rb_define_module("FastMmapedFile");
|
26
|
+
rb_define_method(MMAPED_FILE, "get_double", method_get_double, 1);
|
27
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#ifndef MMAP_H
|
2
|
+
#define MMAP_H
|
3
|
+
|
4
|
+
#define MM_MODIFY 1
|
5
|
+
#define MM_ORIGIN 2
|
6
|
+
#define MM_CHANGE (MM_MODIFY | 4)
|
7
|
+
#define MM_PROTECT 8
|
8
|
+
|
9
|
+
#define MM_FROZEN (1 << 0)
|
10
|
+
#define MM_FIXED (1 << 1)
|
11
|
+
#define MM_ANON (1 << 2)
|
12
|
+
#define MM_LOCK (1 << 3)
|
13
|
+
#define MM_IPC (1 << 4)
|
14
|
+
#define MM_TMP (1 << 5)
|
15
|
+
|
16
|
+
#ifndef MMAP_RETTYPE
|
17
|
+
#ifndef _POSIX_C_SOURCE
|
18
|
+
#define _POSIX_C_SOURCE 199309
|
19
|
+
#endif /* !_POSIX_C_SOURCE */
|
20
|
+
#ifdef _POSIX_VERSION
|
21
|
+
#if _POSIX_VERSION >= 199309
|
22
|
+
#define MMAP_RETTYPE void *
|
23
|
+
#endif /* _POSIX_VERSION >= 199309 */
|
24
|
+
#endif /* _POSIX_VERSION */
|
25
|
+
#endif /* !MMAP_RETTYPE */
|
26
|
+
|
27
|
+
#ifndef MMAP_RETTYPE
|
28
|
+
#define MMAP_RETTYPE caddr_t
|
29
|
+
#endif
|
30
|
+
|
31
|
+
typedef struct {
|
32
|
+
MMAP_RETTYPE addr;
|
33
|
+
int smode, pmode, vscope;
|
34
|
+
int advice, flag;
|
35
|
+
VALUE key;
|
36
|
+
int semid, shmid;
|
37
|
+
size_t len, real, incr;
|
38
|
+
off_t offset;
|
39
|
+
char *path, *template;
|
40
|
+
} mm_mmap;
|
41
|
+
|
42
|
+
typedef struct {
|
43
|
+
int count;
|
44
|
+
mm_mmap *t;
|
45
|
+
} mm_ipc;
|
46
|
+
|
47
|
+
|
48
|
+
#define GetMmap(obj, i_mm, t_modify) \
|
49
|
+
Data_Get_Struct(obj, mm_ipc, i_mm); \
|
50
|
+
if (!i_mm->t->path) { \
|
51
|
+
rb_raise(rb_eIOError, "unmapped file"); \
|
52
|
+
} \
|
53
|
+
if ((t_modify & MM_MODIFY) && (i_mm->t->flag & MM_FROZEN)) { \
|
54
|
+
rb_error_frozen("mmap"); \
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
#endif
|
data/lib/fast_mmaped_file.bundle
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.beta26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
@@ -70,6 +70,8 @@ extra_rdoc_files: []
|
|
70
70
|
files:
|
71
71
|
- README.md
|
72
72
|
- ext/fast_mmaped_file/extconf.rb
|
73
|
+
- ext/fast_mmaped_file/fast_mmaped_file.c
|
74
|
+
- ext/fast_mmaped_file/mmap.h
|
73
75
|
- lib/fast_mmaped_file.bundle
|
74
76
|
- lib/prometheus.rb
|
75
77
|
- lib/prometheus/client.rb
|