Skip to content

Commit bff997e

Browse files
committed
defines.h: RUBY_SYMBOL_EXPORT_{BEGIN,END}
* include/ruby/defines.h (RUBY_SYMBOL_EXPORT_{BEGIN,END}): visibility control macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 5f77f23 commit bff997e

31 files changed

+75
-191
lines changed

configure.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ if test "$GCC" = yes; then
769769
AC_SUBST(WERRORFLAG, "-Werror")
770770
if test "$visibility_option" = yes; then
771771
RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)
772+
AC_DEFINE(RUBY_SYMBOL_EXPORT_BEGIN, [_Pragma("GCC visibility push(default)")])
773+
AC_DEFINE(RUBY_SYMBOL_EXPORT_END, [_Pragma("GCC visibility pop")])
772774
else
773775
RUBY_TRY_LDFLAGS([-Wl,-unexported_symbol,_Init_*], [visibility_option=ld], [visibility_option=no])
774776
fi

cont.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,7 @@ Init_Cont(void)
15401540
rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
15411541
}
15421542

1543-
#if defined __GNUC__ && __GNUC__ >= 4
1544-
#pragma GCC visibility push(default)
1545-
#endif
1543+
RUBY_SYMBOL_EXPORT_BEGIN
15461544

15471545
void
15481546
ruby_Init_Continuation_body(void)
@@ -1563,6 +1561,4 @@ ruby_Init_Fiber_as_Coroutine(void)
15631561
rb_define_singleton_method(rb_cFiber, "current", rb_fiber_s_current, 0);
15641562
}
15651563

1566-
#if defined __GNUC__ && __GNUC__ >= 4
1567-
#pragma GCC visibility pop
1568-
#endif
1564+
RUBY_SYMBOL_EXPORT_END

dln.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
# define _(args) ()
2929
#endif
3030

31-
#if defined __GNUC__ && __GNUC__ >= 4
32-
#pragma GCC visibility push(default)
33-
#endif
31+
RUBY_SYMBOL_EXPORT_BEGIN
3432

3533
DEPRECATED(char *dln_find_exe(const char*,const char*));
3634
DEPRECATED(char *dln_find_file(const char*,const char*));
@@ -43,8 +41,6 @@ extern char *dln_argv0;
4341

4442
void *dln_load(const char*);
4543

46-
#if defined __GNUC__ && __GNUC__ >= 4
47-
#pragma GCC visibility pop
48-
#endif
44+
RUBY_SYMBOL_EXPORT_END
4945

5046
#endif

gc.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
8383
#endif
8484
#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
8585

86-
#if defined __GNUC__ && __GNUC__ >= 4
87-
#pragma GCC visibility push(default)
88-
#endif
86+
RUBY_SYMBOL_EXPORT_BEGIN
8987

9088
/* exports for objspace module */
9189
size_t rb_objspace_data_type_memsize(VALUE obj);
@@ -97,8 +95,6 @@ void rb_objspace_each_objects(
9795
int (*callback)(void *start, void *end, size_t stride, void *data),
9896
void *data);
9997

100-
#if defined __GNUC__ && __GNUC__ >= 4
101-
#pragma GCC visibility pop
102-
#endif
98+
RUBY_SYMBOL_EXPORT_END
10399

104100
#endif /* RUBY_GC_H */

include/ruby/backward/rubysig.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ extern "C" {
2727
#endif
2828
#endif
2929

30-
#if defined __GNUC__ && __GNUC__ >= 4
31-
#pragma GCC visibility push(default)
32-
#endif
30+
RUBY_SYMBOL_EXPORT_BEGIN
3331

3432
struct rb_blocking_region_buffer;
3533
DEPRECATED(RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void));
@@ -42,9 +40,7 @@ DEPRECATED(RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_reg
4240
#define ALLOW_INTS do {CHECK_INTS;} while (0)
4341
#define CHECK_INTS rb_thread_check_ints()
4442

45-
#if defined __GNUC__ && __GNUC__ >= 4
46-
#pragma GCC visibility pop
47-
#endif
43+
RUBY_SYMBOL_EXPORT_END
4844

4945
#if defined(__cplusplus)
5046
#if 0

include/ruby/debug.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ extern "C" {
1919
#endif
2020
#endif
2121

22-
#if defined __GNUC__ && __GNUC__ >= 4
23-
#pragma GCC visibility push(default)
24-
#endif
22+
RUBY_SYMBOL_EXPORT_BEGIN
2523

2624
/* Note: This file contains experimental APIs. */
2725
/* APIs can be replaced at Ruby 2.0.1 or later */
@@ -79,9 +77,7 @@ typedef enum {
7977
void rb_add_event_hook2(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flag);
8078
void rb_thread_add_event_hook2(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flag);
8179

82-
#if defined __GNUC__ && __GNUC__ >= 4
83-
#pragma GCC visibility pop
84-
#endif
80+
RUBY_SYMBOL_EXPORT_END
8581

8682
#if defined(__cplusplus)
8783
#if 0

include/ruby/defines.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ extern "C" {
8888
#define ANYARGS
8989
#endif
9090

91-
#if defined __GNUC__ && __GNUC__ >= 4
92-
#pragma GCC visibility push(default)
91+
#ifndef RUBY_SYMBOL_EXPORT_BEGIN
92+
# define RUBY_SYMBOL_EXPORT_BEGIN /* begin */
93+
# define RUBY_SYMBOL_EXPORT_END /* end */
9394
#endif
9495

96+
RUBY_SYMBOL_EXPORT_BEGIN
97+
9598
#define xmalloc ruby_xmalloc
9699
#define xmalloc2 ruby_xmalloc2
97100
#define xcalloc ruby_xcalloc
@@ -281,9 +284,7 @@ void rb_ia64_flushrs(void);
281284
RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
282285
#endif
283286

284-
#if defined __GNUC__ && __GNUC__ >= 4
285-
#pragma GCC visibility pop
286-
#endif
287+
RUBY_SYMBOL_EXPORT_END
287288

288289
#if defined(__cplusplus)
289290
#if 0

include/ruby/encoding.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ extern "C" {
2222
#include <stdarg.h>
2323
#include "ruby/oniguruma.h"
2424

25-
#if defined __GNUC__ && __GNUC__ >= 4
26-
#pragma GCC visibility push(default)
27-
#endif
25+
RUBY_SYMBOL_EXPORT_BEGIN
2826

2927
#define ENCODING_INLINE_MAX 1023
3028
#define ENCODING_SHIFT (FL_USHIFT+10)
@@ -340,9 +338,7 @@ void rb_econv_binmode(rb_econv_t *ec);
340338
#define ECONV_AFTER_OUTPUT 0x00020000
341339
/* end of flags for rb_econv_convert */
342340

343-
#if defined __GNUC__ && __GNUC__ >= 4
344-
#pragma GCC visibility pop
345-
#endif
341+
RUBY_SYMBOL_EXPORT_END
346342

347343
#if defined(__cplusplus)
348344
#if 0

include/ruby/intern.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ extern "C" {
3434

3535
#include "ruby/st.h"
3636

37-
#if defined __GNUC__ && __GNUC__ >= 4
38-
#pragma GCC visibility push(default)
39-
#endif
37+
RUBY_SYMBOL_EXPORT_BEGIN
4038

4139
/*
4240
* Functions and variables that are used by more than one source file of
@@ -909,9 +907,7 @@ int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
909907
VALUE rb_make_backtrace(void);
910908
VALUE rb_make_exception(int, VALUE*);
911909

912-
#if defined __GNUC__ && __GNUC__ >= 4
913-
#pragma GCC visibility pop
914-
#endif
910+
RUBY_SYMBOL_EXPORT_END
915911

916912
#if defined(__cplusplus)
917913
#if 0

include/ruby/io.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ extern "C" {
4949
# define RB_WAITFD_OUT 0x004
5050
#endif
5151

52-
#if defined __GNUC__ && __GNUC__ >= 4
53-
#pragma GCC visibility push(default)
54-
#endif
52+
RUBY_SYMBOL_EXPORT_BEGIN
5553

5654
typedef struct {
5755
char *ptr; /* off + len <= capa */
@@ -199,9 +197,7 @@ void rb_io_read_check(rb_io_t*);
199197
int rb_io_read_pending(rb_io_t*);
200198
DEPRECATED(void rb_read_check(FILE*));
201199

202-
#if defined __GNUC__ && __GNUC__ >= 4
203-
#pragma GCC visibility pop
204-
#endif
200+
RUBY_SYMBOL_EXPORT_END
205201

206202
#if defined(__cplusplus)
207203
#if 0

0 commit comments

Comments
 (0)