oboe 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +99 -0
- data/README.md +6 -23
- data/ext/oboe_metal/extconf.rb +9 -2
- data/ext/oboe_metal/src/bson/bson.h +221 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/oboe.h +275 -0
- data/ext/oboe_metal/src/oboe.hpp +101 -11
- data/ext/oboe_metal/src/oboe_wrap.cxx +310 -23
- data/lib/joboe_metal.rb +6 -14
- data/lib/oboe/api/layerinit.rb +17 -8
- data/lib/oboe/api/logging.rb +1 -1
- data/lib/oboe/config.rb +9 -0
- data/lib/oboe/frameworks/rails.rb +2 -0
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +0 -2
- data/lib/oboe/inst/rack.rb +1 -0
- data/lib/oboe/inst/resque.rb +4 -4
- data/lib/oboe/loading.rb +61 -0
- data/lib/oboe/ruby.rb +1 -1
- data/lib/oboe/version.rb +1 -1
- data/lib/oboe_metal.rb +6 -14
- data/oboe.gemspec +10 -0
- metadata +17 -5
data/CHANGELOG
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
|
2
|
+
# oboe 2.1.3 (07/16/13)
|
3
|
+
|
4
|
+
* Allow _Access Key_ assignment via Environment variable: TRACEVIEW_CUUID
|
5
|
+
|
6
|
+
# oboe 2.1.1 (07/04/13)
|
7
|
+
|
8
|
+
* The gem now logs via a standard Ruby logger: Oboe.logger
|
9
|
+
* Add in rspec tests
|
10
|
+
* JRuby now supports Smart Tracing
|
11
|
+
* Fixed an invalid Profile name in ActionView Partial tracing
|
12
|
+
|
13
|
+
# oboe 1.4.2.2 (05/16/13)
|
14
|
+
|
15
|
+
* Rack - add handling for potential nil result
|
16
|
+
|
17
|
+
# oboe 1.4.2 (05/02/13)
|
18
|
+
|
19
|
+
* Cassandra - ensure all keys are captured when reporting exceptions
|
20
|
+
* JRuby detection fix
|
21
|
+
|
22
|
+
# oboe 1.4.1.2 (04/29/13)
|
23
|
+
|
24
|
+
* HTTP keys now captured at Rack level instead of Rails
|
25
|
+
* RUM templates are now pre-loaded
|
26
|
+
* Improved layer agnostic info event reporting
|
27
|
+
|
28
|
+
# oboe 1.4.0.2 (03/08/13)
|
29
|
+
|
30
|
+
* Resque support
|
31
|
+
* Fix Rails 2 bug where SET and SHOW could result in recursive calls
|
32
|
+
* Memcache - multi-get calls now report a total for number of keys and number
|
33
|
+
of hits
|
34
|
+
* Configuration - added ability to identify components to skip from
|
35
|
+
instrumentation
|
36
|
+
* Configuration - sending Resque parameters can be skipped if privacy an issue.
|
37
|
+
|
38
|
+
# oboe 1.3.9.1 (02/04/13)
|
39
|
+
|
40
|
+
* Add in Rack instrumentation
|
41
|
+
* Fix Function profiling of class methods bug
|
42
|
+
* Add backtraces to Cassandra and Mongo operations
|
43
|
+
* Rename the "render" layer to "actionview"
|
44
|
+
|
45
|
+
# oboe 1.3.8 (01/04/13)
|
46
|
+
|
47
|
+
* More comprehensive JRuby support
|
48
|
+
|
49
|
+
# oboe 1.3.7 (12/10/12)
|
50
|
+
|
51
|
+
* Added Moped driver instrumentation (Mongo/Mongoid)
|
52
|
+
|
53
|
+
# oboe 1.3.6 (12/10/12)
|
54
|
+
|
55
|
+
* Added Rails ActionView partial and collection rendering instrumentation
|
56
|
+
|
57
|
+
# oboe 1.3.5 (11/14/12)
|
58
|
+
|
59
|
+
* Added cassandra instrumentation
|
60
|
+
|
61
|
+
# oboe 1.3.4 (10/23/12)
|
62
|
+
|
63
|
+
* Added mongo-ruby-driver support
|
64
|
+
|
65
|
+
# oboe 1.3.3 (10/18/12)
|
66
|
+
|
67
|
+
* Updated RUM instrumentation templates
|
68
|
+
|
69
|
+
# oboe 1.3.2 (10/17/12)
|
70
|
+
|
71
|
+
* Fix a case when the RUM instrumentation header/footer methods would not
|
72
|
+
return JS output, depending on how the way they were called from HAML.
|
73
|
+
|
74
|
+
# oboe 1.3.1 (10/15/12)
|
75
|
+
|
76
|
+
* Support for RUM instrumentation.
|
77
|
+
Fix for certain cases where exceptions were not properly propagated up to Rails
|
78
|
+
error handlers.
|
79
|
+
|
80
|
+
# oboe 1.3.0 (9/26/12)
|
81
|
+
|
82
|
+
* The oboe and oboe_fu gems have been merged to simplify installation. The
|
83
|
+
final oboe_fu gem (1.3.0) simply calls "require 'oboe'" now for backwards
|
84
|
+
compatibility.
|
85
|
+
* Please note our updated installation instructions for the new location of
|
86
|
+
Ruby oboe API methods.
|
87
|
+
* Our gem now successfully installs even if your platform does not have our
|
88
|
+
base packages (liboboe) installed, so you can deploy to environments with or
|
89
|
+
without TraceView support.
|
90
|
+
|
91
|
+
# oboe_fu 1.2.1 (9/12/12)
|
92
|
+
|
93
|
+
* Support for instrumenting the dalli module.
|
94
|
+
|
95
|
+
# oboe_fu 1.2.0 (8/28/12)
|
96
|
+
|
97
|
+
* Support for Rails 2.3, 3.0, 3.1, and 3.2.
|
98
|
+
|
99
|
+
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
|
1
|
+
## oboe - TraceView Ruby Instrumentation
|
2
2
|
|
3
|
-
|
4
|
-
common components used to build rails applications.
|
3
|
+
The oboe gem provides AppNeta [TraceView](http://www.appneta.com/application-performance-management/) instrumentation for Ruby and Ruby frameworks.
|
5
4
|
|
6
5
|
## Installing
|
7
6
|
|
8
|
-
See the [Ruby Knowedge Base article](http://support.
|
9
|
-
for information on how to install.
|
7
|
+
The oboe gem is [available on Rubygems](https://rubygems.org/gems/oboe). See the [Ruby Knowedge Base article](http://support.tv.appneta.com/kb/ruby/instrumenting-ruby-apps)
|
8
|
+
for information on how to install.
|
9
|
+
|
10
|
+
Release notes can be found in the CHANGELOG or also [here](http://support.tv.appneta.com/kb/ruby/ruby-instrumentation-release-notes)
|
10
11
|
|
11
12
|
## Supported Technologies
|
12
13
|
|
@@ -16,21 +17,3 @@ Check the [support matrix](https://github.com/tracelytics/oboe-ruby/wiki/Support
|
|
16
17
|
|
17
18
|
General tips using, installing and debugging the oboe gem can be found [here](https://github.com/tracelytics/oboe-ruby/wiki/Ruby-Oboe-Tips).
|
18
19
|
|
19
|
-
## liboboe Linking Notes
|
20
|
-
|
21
|
-
Build instructions
|
22
|
-
|
23
|
-
- Requires: liboboe development headers, available from the
|
24
|
-
liboboe-dev (Ubuntu) and liboboe-devel (Red Hat) packages.
|
25
|
-
|
26
|
-
Build and install a gem the normal way:
|
27
|
-
|
28
|
-
gem build oboe.gemspec
|
29
|
-
gem install oboe-VERSION.gem
|
30
|
-
|
31
|
-
Compile a binary gem from a regular gem, using gem-compile [1]:
|
32
|
-
|
33
|
-
sudo gem install gem-compile
|
34
|
-
gem compile oboe-VERSION.gem
|
35
|
-
|
36
|
-
[1] https://github.com/frsyuki/gem-compile
|
data/ext/oboe_metal/extconf.rb
CHANGED
@@ -20,7 +20,7 @@ if jruby or ENV.has_key?('TRACEVIEW_URL')
|
|
20
20
|
# FIXME: For JRuby we need to remove the c extension entirely
|
21
21
|
create_makefile('oboe_noop', 'noop')
|
22
22
|
|
23
|
-
elsif have_library('oboe')
|
23
|
+
elsif have_library('oboe', 'oboe_config_get_revision', 'oboe/oboe.h')
|
24
24
|
|
25
25
|
$libs = append_library($libs, "oboe")
|
26
26
|
$libs = append_library($libs, "stdc++")
|
@@ -29,10 +29,17 @@ elsif have_library('oboe')
|
|
29
29
|
$CPPFLAGS << " #{ENV["CPPFLAGS"]}"
|
30
30
|
$LIBS << " #{ENV["LIBS"]}"
|
31
31
|
|
32
|
-
|
32
|
+
if RUBY_VERSION < '1.9'
|
33
|
+
cpp_command('g++')
|
34
|
+
$CPPFLAGS << "-I./src/"
|
35
|
+
end
|
33
36
|
create_makefile('oboe_metal', 'src')
|
34
37
|
|
35
38
|
else
|
39
|
+
if have_library('oboe')
|
40
|
+
$stderr.puts "Error: The oboe gem requires an updated liboboe. Please update your liboboe packages."
|
41
|
+
end
|
42
|
+
|
36
43
|
$stderr.puts "Error: Could not find the base liboboe libraries. No tracing will occur."
|
37
44
|
create_makefile('oboe_noop', 'noop')
|
38
45
|
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
/* bson.h */
|
2
|
+
|
3
|
+
/* Copyright 2009, 2010 10gen Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#ifndef _BSON_H_
|
19
|
+
#define _BSON_H_
|
20
|
+
|
21
|
+
#define MONGO_HAVE_STDINT
|
22
|
+
#include "platform_hacks.h"
|
23
|
+
#include <time.h>
|
24
|
+
|
25
|
+
MONGO_EXTERN_C_START
|
26
|
+
|
27
|
+
typedef enum {
|
28
|
+
bson_error=-1,
|
29
|
+
bson_eoo=0,
|
30
|
+
bson_double=1,
|
31
|
+
bson_string=2,
|
32
|
+
bson_object=3,
|
33
|
+
bson_array=4,
|
34
|
+
bson_bindata=5,
|
35
|
+
bson_undefined=6,
|
36
|
+
bson_oid=7,
|
37
|
+
bson_bool=8,
|
38
|
+
bson_date=9,
|
39
|
+
bson_null=10,
|
40
|
+
bson_regex=11,
|
41
|
+
bson_dbref=12, /* deprecated */
|
42
|
+
bson_code=13,
|
43
|
+
bson_symbol=14,
|
44
|
+
bson_codewscope=15,
|
45
|
+
bson_int = 16,
|
46
|
+
bson_timestamp = 17,
|
47
|
+
bson_long = 18
|
48
|
+
} bson_type;
|
49
|
+
|
50
|
+
typedef int bson_bool_t;
|
51
|
+
|
52
|
+
typedef struct {
|
53
|
+
char * data;
|
54
|
+
bson_bool_t owned;
|
55
|
+
} bson;
|
56
|
+
|
57
|
+
typedef struct {
|
58
|
+
const char * cur;
|
59
|
+
bson_bool_t first;
|
60
|
+
} bson_iterator;
|
61
|
+
|
62
|
+
typedef struct {
|
63
|
+
char * buf;
|
64
|
+
char * cur;
|
65
|
+
int bufSize;
|
66
|
+
bson_bool_t finished;
|
67
|
+
int stack[32];
|
68
|
+
int stackPos;
|
69
|
+
} bson_buffer;
|
70
|
+
|
71
|
+
#pragma pack(1)
|
72
|
+
typedef union{
|
73
|
+
char bytes[12];
|
74
|
+
int ints[3];
|
75
|
+
} bson_oid_t;
|
76
|
+
#pragma pack()
|
77
|
+
|
78
|
+
typedef int64_t bson_date_t; /* milliseconds since epoch UTC */
|
79
|
+
|
80
|
+
/* ----------------------------
|
81
|
+
READING
|
82
|
+
------------------------------ */
|
83
|
+
|
84
|
+
|
85
|
+
bson * bson_empty(bson * obj); /* returns pointer to static empty bson object */
|
86
|
+
int bson_copy(bson* out, const bson* in); /* puts data in new buffer. NOOP if out==NULL */
|
87
|
+
bson * bson_from_buffer(bson * b, bson_buffer * buf);
|
88
|
+
bson * bson_init( bson * b , char * data , bson_bool_t mine );
|
89
|
+
bson * bson_init_safe( bson * b , char * data , bson_bool_t mine , size_t buflen);
|
90
|
+
int bson_size(const bson * b );
|
91
|
+
void bson_destroy( bson * b );
|
92
|
+
|
93
|
+
void bson_print( bson * b );
|
94
|
+
void bson_print_raw( const char * bson , int depth );
|
95
|
+
|
96
|
+
/* advances iterator to named field */
|
97
|
+
/* returns bson_eoo (which is false) if field not found */
|
98
|
+
bson_type bson_find(bson_iterator* it, const bson* obj, const char* name);
|
99
|
+
|
100
|
+
void bson_iterator_init( bson_iterator * i , const char * bson );
|
101
|
+
|
102
|
+
/* more returns true for eoo. best to loop with bson_iterator_next(&it) */
|
103
|
+
bson_bool_t bson_iterator_more( const bson_iterator * i );
|
104
|
+
bson_type bson_iterator_next( bson_iterator * i );
|
105
|
+
|
106
|
+
bson_type bson_iterator_type( const bson_iterator * i );
|
107
|
+
const char * bson_iterator_key( const bson_iterator * i );
|
108
|
+
const char * bson_iterator_value( const bson_iterator * i );
|
109
|
+
|
110
|
+
/* these convert to the right type (return 0 if non-numeric) */
|
111
|
+
double bson_iterator_double( const bson_iterator * i );
|
112
|
+
int bson_iterator_int( const bson_iterator * i );
|
113
|
+
int64_t bson_iterator_long( const bson_iterator * i );
|
114
|
+
|
115
|
+
/* false: boolean false, 0 in any type, or null */
|
116
|
+
/* true: anything else (even empty strings and objects) */
|
117
|
+
bson_bool_t bson_iterator_bool( const bson_iterator * i );
|
118
|
+
|
119
|
+
/* these assume you are using the right type */
|
120
|
+
double bson_iterator_double_raw( const bson_iterator * i );
|
121
|
+
int bson_iterator_int_raw( const bson_iterator * i );
|
122
|
+
int64_t bson_iterator_long_raw( const bson_iterator * i );
|
123
|
+
bson_bool_t bson_iterator_bool_raw( const bson_iterator * i );
|
124
|
+
bson_oid_t* bson_iterator_oid( const bson_iterator * i );
|
125
|
+
|
126
|
+
/* these can also be used with bson_code and bson_symbol*/
|
127
|
+
const char * bson_iterator_string( const bson_iterator * i );
|
128
|
+
int bson_iterator_string_len( const bson_iterator * i );
|
129
|
+
|
130
|
+
/* works with bson_code, bson_codewscope, and bson_string */
|
131
|
+
/* returns NULL for everything else */
|
132
|
+
const char * bson_iterator_code(const bson_iterator * i);
|
133
|
+
|
134
|
+
/* calls bson_empty on scope if not a bson_codewscope */
|
135
|
+
void bson_iterator_code_scope(const bson_iterator * i, bson * scope);
|
136
|
+
|
137
|
+
/* both of these only work with bson_date */
|
138
|
+
bson_date_t bson_iterator_date(const bson_iterator * i);
|
139
|
+
time_t bson_iterator_time_t(const bson_iterator * i);
|
140
|
+
|
141
|
+
int bson_iterator_bin_len( const bson_iterator * i );
|
142
|
+
char bson_iterator_bin_type( const bson_iterator * i );
|
143
|
+
const char * bson_iterator_bin_data( const bson_iterator * i );
|
144
|
+
|
145
|
+
const char * bson_iterator_regex( const bson_iterator * i );
|
146
|
+
const char * bson_iterator_regex_opts( const bson_iterator * i );
|
147
|
+
|
148
|
+
/* these work with bson_object and bson_array */
|
149
|
+
void bson_iterator_subobject(const bson_iterator * i, bson * sub);
|
150
|
+
void bson_iterator_subiterator(const bson_iterator * i, bson_iterator * sub);
|
151
|
+
|
152
|
+
/* str must be at least 24 hex chars + null byte */
|
153
|
+
void bson_oid_from_string(bson_oid_t* oid, const char* str);
|
154
|
+
void bson_oid_to_string(const bson_oid_t* oid, char* str);
|
155
|
+
void bson_oid_gen(bson_oid_t* oid);
|
156
|
+
|
157
|
+
time_t bson_oid_generated_time(bson_oid_t* oid); /* Gives the time the OID was created */
|
158
|
+
|
159
|
+
/* ----------------------------
|
160
|
+
BUILDING
|
161
|
+
------------------------------ */
|
162
|
+
|
163
|
+
bson_buffer * bson_buffer_init( bson_buffer * b );
|
164
|
+
bson_buffer * bson_ensure_space( bson_buffer * b , const int bytesNeeded );
|
165
|
+
|
166
|
+
/**
|
167
|
+
* @return the raw data. you either should free this OR call bson_destroy not both
|
168
|
+
*/
|
169
|
+
char * bson_buffer_finish( bson_buffer * b );
|
170
|
+
void bson_buffer_destroy( bson_buffer * b );
|
171
|
+
|
172
|
+
bson_buffer * bson_append_oid( bson_buffer * b , const char * name , const bson_oid_t* oid );
|
173
|
+
bson_buffer * bson_append_new_oid( bson_buffer * b , const char * name );
|
174
|
+
bson_buffer * bson_append_int( bson_buffer * b , const char * name , const int i );
|
175
|
+
bson_buffer * bson_append_long( bson_buffer * b , const char * name , const int64_t i );
|
176
|
+
bson_buffer * bson_append_double( bson_buffer * b , const char * name , const double d );
|
177
|
+
bson_buffer * bson_append_string( bson_buffer * b , const char * name , const char * str );
|
178
|
+
bson_buffer * bson_append_symbol( bson_buffer * b , const char * name , const char * str );
|
179
|
+
bson_buffer * bson_append_code( bson_buffer * b , const char * name , const char * str );
|
180
|
+
bson_buffer * bson_append_code_w_scope( bson_buffer * b , const char * name , const char * code , const bson * scope);
|
181
|
+
bson_buffer * bson_append_binary( bson_buffer * b, const char * name, char type, const char * str, int len );
|
182
|
+
bson_buffer * bson_append_bool( bson_buffer * b , const char * name , const bson_bool_t v );
|
183
|
+
bson_buffer * bson_append_null( bson_buffer * b , const char * name );
|
184
|
+
bson_buffer * bson_append_undefined( bson_buffer * b , const char * name );
|
185
|
+
bson_buffer * bson_append_regex( bson_buffer * b , const char * name , const char * pattern, const char * opts );
|
186
|
+
bson_buffer * bson_append_bson( bson_buffer * b , const char * name , const bson* bson);
|
187
|
+
bson_buffer * bson_append_element( bson_buffer * b, const char * name_or_null, const bson_iterator* elem);
|
188
|
+
|
189
|
+
/* these both append a bson_date */
|
190
|
+
bson_buffer * bson_append_date(bson_buffer * b, const char * name, bson_date_t millis);
|
191
|
+
bson_buffer * bson_append_time_t(bson_buffer * b, const char * name, time_t secs);
|
192
|
+
|
193
|
+
bson_buffer * bson_append_start_object( bson_buffer * b , const char * name );
|
194
|
+
bson_buffer * bson_append_start_array( bson_buffer * b , const char * name );
|
195
|
+
bson_buffer * bson_append_finish_object( bson_buffer * b );
|
196
|
+
|
197
|
+
void bson_numstr(char* str, int i);
|
198
|
+
void bson_incnumstr(char* str);
|
199
|
+
|
200
|
+
|
201
|
+
/* ------------------------------
|
202
|
+
ERROR HANDLING - also used in mongo code
|
203
|
+
------------------------------ */
|
204
|
+
|
205
|
+
void * bson_malloc(int size); /* checks return value */
|
206
|
+
|
207
|
+
/* bson_err_handlers shouldn't return!!! */
|
208
|
+
typedef void(*bson_err_handler)(const char* errmsg);
|
209
|
+
|
210
|
+
/* returns old handler or NULL */
|
211
|
+
/* default handler prints error then exits with failure*/
|
212
|
+
bson_err_handler set_bson_err_handler(bson_err_handler func);
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
/* does nothing is ok != 0 */
|
217
|
+
void bson_fatal( int ok );
|
218
|
+
int bson_fatal_msg( int ok, const char* msg );
|
219
|
+
|
220
|
+
MONGO_EXTERN_C_END
|
221
|
+
#endif
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/* platform_hacks.h */
|
2
|
+
/* Copyright 2009, 2010 10gen Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
|
18
|
+
/* all platform-specific ifdefs should go here */
|
19
|
+
|
20
|
+
#ifndef _PLATFORM_HACKS_H_
|
21
|
+
#define _PLATFORM_HACKS_H_
|
22
|
+
|
23
|
+
#ifdef __GNUC__
|
24
|
+
#define MONGO_INLINE static __inline__
|
25
|
+
#else
|
26
|
+
#define MONGO_INLINE static
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifdef __cplusplus
|
30
|
+
#define MONGO_EXTERN_C_START extern "C" {
|
31
|
+
#define MONGO_EXTERN_C_END }
|
32
|
+
#else
|
33
|
+
#define MONGO_EXTERN_C_START
|
34
|
+
#define MONGO_EXTERN_C_END
|
35
|
+
#endif
|
36
|
+
|
37
|
+
|
38
|
+
#if defined(MONGO_HAVE_STDINT) || __STDC_VERSION__ >= 199901L
|
39
|
+
#include <stdint.h>
|
40
|
+
#elif defined(MONGO_HAVE_UNISTD)
|
41
|
+
#include <unistd.h>
|
42
|
+
#elif defined(MONGO_USE__INT64)
|
43
|
+
typedef __int64 int64_t;
|
44
|
+
#elif defined(MONGO_USE_LONG_LONG_INT)
|
45
|
+
typedef long long int int64_t;
|
46
|
+
#else
|
47
|
+
#error must have a 64bit int type
|
48
|
+
#endif
|
49
|
+
|
50
|
+
/* big endian is only used for OID generation. little is used everywhere else */
|
51
|
+
#ifdef MONGO_BIG_ENDIAN
|
52
|
+
#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) )
|
53
|
+
#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) )
|
54
|
+
#define bson_big_endian64(out, in) ( memcpy(out, in, 8) )
|
55
|
+
#define bson_big_endian32(out, in) ( memcpy(out, in, 4) )
|
56
|
+
#else
|
57
|
+
#define bson_little_endian64(out, in) ( memcpy(out, in, 8) )
|
58
|
+
#define bson_little_endian32(out, in) ( memcpy(out, in, 4) )
|
59
|
+
#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) )
|
60
|
+
#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) )
|
61
|
+
#endif
|
62
|
+
|
63
|
+
MONGO_EXTERN_C_START
|
64
|
+
|
65
|
+
MONGO_INLINE void bson_swap_endian64(void* outp, const void* inp){
|
66
|
+
const char *in = (const char*)inp;
|
67
|
+
char *out = (char*)outp;
|
68
|
+
|
69
|
+
out[0] = in[7];
|
70
|
+
out[1] = in[6];
|
71
|
+
out[2] = in[5];
|
72
|
+
out[3] = in[4];
|
73
|
+
out[4] = in[3];
|
74
|
+
out[5] = in[2];
|
75
|
+
out[6] = in[1];
|
76
|
+
out[7] = in[0];
|
77
|
+
|
78
|
+
}
|
79
|
+
MONGO_INLINE void bson_swap_endian32(void* outp, const void* inp){
|
80
|
+
const char *in = (const char*)inp;
|
81
|
+
char *out = (char*)outp;
|
82
|
+
|
83
|
+
out[0] = in[3];
|
84
|
+
out[1] = in[2];
|
85
|
+
out[2] = in[1];
|
86
|
+
out[3] = in[0];
|
87
|
+
}
|
88
|
+
|
89
|
+
MONGO_EXTERN_C_END
|
90
|
+
|
91
|
+
#endif
|