Skip to content

Commit 105c9f0

Browse files
tamirdsodabrew
authored andcommitted
Remove more 1.8.7, REE compatibility shims (#908)
1 parent a2fadb6 commit 105c9f0

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

ext/mysql2/mysql2_ext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ void Init_mysql2(void);
1818
#endif
1919

2020
#include <ruby/encoding.h>
21+
// ruby/thread.h was added in 2.0.0. See:
22+
// https://github.com/ruby/ruby/commit/c51a826
23+
//
24+
// Rubinius doesn't define this, but it ships an empty thread.h (the symbols we
25+
// care about are in ruby.h); this is safe to remove when < 2.0.0 is no longer
26+
// supported.
2127
#ifdef HAVE_RUBY_THREAD_H
2228
#include <ruby/thread.h>
2329
#endif

ext/mysql2/statement.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
202202
{
203203
unsigned LONG_LONG num;
204204
size_t len;
205+
// rb_absint_size was added in 2.1.0. See:
206+
// https://github.com/ruby/ruby/commit/9fea875
205207
#ifdef HAVE_RB_ABSINT_SIZE
206208
int nlz_bits = 0;
207209
len = rb_absint_size(bignum, &nlz_bits);
@@ -220,16 +222,15 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
220222
#ifdef HAVE_RB_ABSINT_SIZE
221223
nlz_bits == 0 &&
222224
#endif
225+
// rb_absint_singlebit_p was added in 2.1.0. See:
226+
// https://github.com/ruby/ruby/commit/e5ff9d5
223227
#if defined(HAVE_RB_ABSINT_SIZE) && defined(HAVE_RB_ABSINT_SINGLEBIT_P)
224228
/* Optimized to avoid object allocation for Ruby 2.1+
225229
* only -0x8000000000000000 is safe if `len == 8 && nlz_bits == 0`
226230
*/
227231
!rb_absint_singlebit_p(bignum)
228-
#elif defined(HAVE_RB_BIG_CMP)
229-
rb_big_cmp(bignum, LL2NUM(LLONG_MIN)) == INT2FIX(-1)
230232
#else
231-
/* Ruby 1.8.7 and REE doesn't have rb_big_cmp */
232-
rb_funcall(bignum, id_cmp, 1, LL2NUM(LLONG_MIN)) == INT2FIX(-1)
233+
rb_big_cmp(bignum, LL2NUM(LLONG_MIN)) == INT2FIX(-1)
233234
#endif
234235
) {
235236
goto overflow;

ext/mysql2/wait_for_single_fd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* backwards compatibility for pre-1.9.3 C API
2+
* backwards compatibility for Rubinius. See
3+
* https://github.com/rubinius/rubinius/issues/3771.
34
*
45
* Ruby 1.9.3 provides this API which allows the use of ppoll() on Linux
56
* to minimize select() and malloc() overhead on high-numbered FDs.

spec/mysql2/client_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ def run_gc
670670
end
671671

672672
it "evented async queries should be supported" do
673-
skip("ruby 1.8 doesn't support IO.for_fd options") if RUBY_VERSION.start_with?("1.8.")
674673
# should immediately return nil
675674
expect(@client.query("SELECT sleep(0.1)", :async => true)).to eql(nil)
676675

spec/mysql2/statement_spec.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,16 @@ def stmt_count
147147
now = Time.now
148148
statement = @client.prepare('SELECT ? AS a')
149149
result = statement.execute(now)
150-
if RUBY_VERSION =~ /1.8/
151-
expect(result.first['a'].strftime('%F %T %z')).to eql(now.strftime('%F %T %z'))
152-
else
153-
# microseconds is six digits after the decimal, but only test on 5 significant figures
154-
expect(result.first['a'].strftime('%F %T.%5N %z')).to eql(now.strftime('%F %T.%5N %z'))
155-
end
150+
# microseconds is six digits after the decimal, but only test on 5 significant figures
151+
expect(result.first['a'].strftime('%F %T.%5N %z')).to eql(now.strftime('%F %T.%5N %z'))
156152
end
157153

158154
it "should prepare DateTime values with microseconds" do
159155
now = DateTime.now
160156
statement = @client.prepare('SELECT ? AS a')
161157
result = statement.execute(now)
162-
if RUBY_VERSION =~ /1.8/
163-
expect(result.first['a'].strftime('%F %T %z')).to eql(now.strftime('%F %T %z'))
164-
else
165-
# microseconds is six digits after the decimal, but only test on 5 significant figures
166-
expect(result.first['a'].strftime('%F %T.%5N %z')).to eql(now.strftime('%F %T.%5N %z'))
167-
end
158+
# microseconds is six digits after the decimal, but only test on 5 significant figures
159+
expect(result.first['a'].strftime('%F %T.%5N %z')).to eql(now.strftime('%F %T.%5N %z'))
168160
end
169161

170162
it "should tell us about the fields" do

0 commit comments

Comments
 (0)