Skip to content

Commit a6dc882

Browse files
committed
Merge branch 'andreas-schwab-master'
* andreas-schwab-master: Ruby wstring - only include endian.h on linux
2 parents 430a44e + 58ffbe6 commit a6dc882

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Lib/ruby/std_wstring.i

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
%{
2+
#if defined(__linux__)
3+
#include <endian.h>
4+
#if BYTE_ORDER == LITTLE_ENDIAN
5+
#define SWIG_RUBY_ENDIAN "LE"
6+
#elif BYTE_ORDER == BIG_ENDIAN
7+
#define SWIG_RUBY_ENDIAN "BE"
8+
#endif
9+
#else
10+
#define SWIG_RUBY_ENDIAN "LE"
11+
#endif
12+
213
#ifdef __cplusplus
314
extern "C" {
415
#endif
@@ -15,9 +26,9 @@ extern "C" {
1526
#ifndef SWIG_RUBY_WSTRING_ENCODING
1627

1728
#if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff
18-
#define SWIG_RUBY_WSTRING_ENCODING "UTF-16LE"
29+
#define SWIG_RUBY_WSTRING_ENCODING "UTF-16" SWIG_RUBY_ENDIAN
1930
#elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff
20-
#define SWIG_RUBY_WSTRING_ENCODING "UTF-32LE"
31+
#define SWIG_RUBY_WSTRING_ENCODING "UTF-32" SWIG_RUBY_ENDIAN
2132
#else
2233
#error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given.
2334
#endif

0 commit comments

Comments
 (0)