Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove code for old ruby versions
  • Loading branch information
kubo committed Mar 13, 2022
1 parent 52b2e89 commit 5fca2bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 85 deletions.
82 changes: 0 additions & 82 deletions ext/oci8/oci8.h
Expand Up @@ -89,88 +89,6 @@ typedef orasb8 sb8;
#endif
#endif

/*
* Use TypedData on ruby 1.9.3 and later.
*/
#ifndef HAVE_RB_DATA_TYPE_T_FUNCTION

/*
* Don't use TypedData even though ruby 1.9.2 has it because the
* definitions are slightly different from ruby 1.9.3 and later.
*/
#define rb_data_type_t oci8_data_type_t
#undef TypedData_Make_Struct
#undef TypedData_Wrap_Struct
#undef TypedData_Get_Struct
#undef RTYPEDDATA_DATA
#undef RUBY_DEFAULT_FREE

/*
* To pass compilation on ruby 1.9.2 and earlier.
*/
typedef struct oci8_data_type_struct rb_data_type_t;
struct oci8_data_type_struct {
const char *wrap_struct_name;
struct {
void (*dmark)(void*);
void (*dfree)(void*);
size_t (*dsize)(const void *);
} function;
const rb_data_type_t *parent;
void *data;
};
#define TypedData_Make_Struct(klass, type, data_type, sval) \
Data_Make_Struct((klass), type, (data_type)->function.dmark, (data_type)->function.dfree, (sval))
#define TypedData_Wrap_Struct(klass, data_type, sval) \
Data_Wrap_Struct((klass), (data_type)->function.dmark, (data_type)->function.dfree, (sval))
#define TypedData_Get_Struct(obj, type, data_type, sval) \
Data_Get_Struct((obj), type, (sval))
#define RTYPEDDATA_DATA(obj) DATA_PTR(obj)
#define RUBY_DEFAULT_FREE xfree
#endif

/* a new function in ruby 1.9.3.
* define a compatible macro for ruby 1.9.2 or lower.
*/
#ifndef HAVE_RB_CLASS_SUPERCLASS
#ifdef RCLASS_SUPER
#define rb_class_superclass(cls) RCLASS_SUPER(cls)
#else
#define rb_class_superclass(cls) (RCLASS(cls)->super)
#endif
#endif

/* new macros in ruby 2.1.0
*/
#ifndef RARRAY_AREF
#define RARRAY_AREF(a, i) (RARRAY_PTR(a)[i])
#endif
#ifndef RARRAY_CONST_PTR
#define RARRAY_CONST_PTR(a) RARRAY_PTR(a)
#endif
#ifndef RB_OBJ_WRITE
#define RB_OBJ_WRITE(a, slot, b) do {*(slot) = (b);} while (0)
#endif
#ifndef RB_OBJ_WRITTEN
#define RB_OBJ_WRITTEN(a, oldv, b) do {(void)oldv;} while (0)
#endif

/* new macros in ruby 2.4.0
*/
#ifndef ALWAYS_INLINE
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
/* gcc version >= 3.1 */
#define ALWAYS_INLINE(x) __attribute__((always_inline)) x
#endif
#ifdef _MSC_VER
/* microsoft c */
#define ALWAYS_INLINE(x) __forceinline x
#endif
#ifndef ALWAYS_INLINE
#define ALWAYS_INLINE(x) x
#endif
#endif /* ALWAYS_INLINE */

/* macros depends on the compiler.
* LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
* UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
Expand Down
4 changes: 1 addition & 3 deletions pre-distclean.rb
@@ -1,6 +1,4 @@
rm_f "#{curr_objdir}/lib/oci8.rb"
rm_f "#{curr_objdir}/ext/oci8/oci8lib_18.map"
rm_f "#{curr_objdir}/ext/oci8/oci8lib_191.map"
rm_f "#{curr_objdir}/ext/oci8/oci8lib_*.map"
if RUBY_PLATFORM =~ /cygwin/
rm_f "#{curr_objdir}/ext/oci8/OCI.def"
rm_f "#{curr_objdir}/ext/oci8/libOCI.a"
Expand Down

0 comments on commit 5fca2bf

Please sign in to comment.