diff options
author | Tim-Phillip Müller <tim@centricular.net> | 2013-02-19 12:23:16 -0800 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2013-02-19 12:38:07 -0800 |
commit | 9664aabdf45fbe38e43c7041b234548a2c1bf0ff (patch) | |
tree | 56bd497f91e98c01154df7fe017a5be37fdd0a10 | |
parent | b4f7fcaf99a4d952e59f2a9fa9286d24cc4b3a5a (diff) |
orcc: add --internal option to mark symbols with internal visibility
Fixes: #52184
-rw-r--r-- | orc/orcprogram-c.c | 15 | ||||
-rw-r--r-- | orc/orcutils.h | 10 | ||||
-rw-r--r-- | tools/orcc.c | 13 |
3 files changed, 34 insertions, 4 deletions
diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c index dac0fe6..83994a1 100644 --- a/orc/orcprogram-c.c +++ b/orc/orcprogram-c.c @@ -83,7 +83,20 @@ orc_target_c_get_typedefs (void) "#else\n" "#define ORC_RESTRICT\n" "#endif\n" - "#endif\n"; + "#endif\n" + "\n" + "#ifndef ORC_INTERNAL\n" + "#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)\n" + "#define ORC_INTERNAL __attribute__((visibility(\"hidden\")))\n" + "#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)\n" + "#define ORC_INTERNAL __hidden\n" + "#elif defined (__GNUC__)\n" + "#define ORC_INTERNAL __attribute__((visibility(\"hidden\")))\n" + "#else\n" + "#define ORC_INTERNAL\n" + "#endif\n" + "#endif\n" + "\n"; } const char * diff --git a/orc/orcutils.h b/orc/orcutils.h index 1ca45b2..d973ba8 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -162,11 +162,17 @@ typedef unsigned int orc_bool; #define ORC_GNUC_PREREQ(maj, min) 0 #endif -#if ORC_GNUC_PREREQ(3,3) && defined(__ELF__) -#define ORC_INTERNAL __attribute__ ((visibility ("internal"))) +#ifndef ORC_INTERNAL +#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define ORC_INTERNAL __hidden +#elif defined (__GNUC__) && ORC_GNUC_PREREQ(3,3) && defined(__ELF__) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) #else #define ORC_INTERNAL #endif +#endif #if ORC_GNUC_PREREQ(3,3) /* guess */ #define ORC_GNU_PRINTF(a,b) __attribute__((__format__ (__printf__, a, b))) diff --git a/tools/orcc.c b/tools/orcc.c index ad4968a..974e241 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -35,6 +35,7 @@ int use_inline = FALSE; int use_code = FALSE; int use_lazy_init = FALSE; int use_backup = TRUE; +int use_internal = FALSE; const char *init_function = NULL; @@ -76,6 +77,8 @@ void help (void) printf(" --compat VERSION Generate code compatible with Orc version VERSION\n"); printf(" --inline Generate inline functions in header\n"); printf(" --no-inline Do not generate inline functions in header\n"); + printf(" --internal Mark functions in header for internal visibility\n"); + printf(" --no-internal Do not mark functions in header for internal visibility\n"); printf(" --init-function FUNCTION Generate initialization function\n"); printf(" --lazy-init Do Orc compile at function execution\n"); printf(" --no-backup Do not generate backup functions\n"); @@ -135,6 +138,10 @@ main (int argc, char *argv[]) use_inline = TRUE; } else if (strcmp(argv[i], "--no-inline") == 0) { use_inline = FALSE; + } else if (strcmp(argv[i], "--internal") == 0) { + use_internal = TRUE; + } else if (strcmp(argv[i], "--no-internal") == 0) { + use_internal = FALSE; } else if (strcmp(argv[i], "--init-function") == 0) { if (i+1 < argc) { init_function = argv[i+1]; @@ -619,7 +626,11 @@ output_prototype (OrcProgram *p, FILE *output) void output_code_header (OrcProgram *p, FILE *output) { - fprintf(output, "void "); + if(use_internal) { + fprintf(output, "ORC_INTERNAL void "); + } else { + fprintf(output, "void "); + } output_prototype (p, output); fprintf(output, ";\n"); } |