diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-27 06:21:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-27 06:21:31 +0000 |
commit | 3a69ab7b294d0db4054d5712aee65228abedae35 (patch) | |
tree | 8e9817a8f38f44fb8acbe795e6b61099751d8921 | |
parent | c17052a0f0768935c063e28c649bf1614f8b5c76 (diff) |
* version.c (ruby_description, ruby_copyright): unaligned and
optimized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | version.c | 19 |
2 files changed, 16 insertions, 8 deletions
@@ -1,4 +1,7 @@ -Tue Apr 27 12:53:20 2010 Nobuyoshi Nakada <[email protected]> +Tue Apr 27 15:21:27 2010 Nobuyoshi Nakada <[email protected]> + + * version.c (ruby_description, ruby_copyright): unaligned and + optimized. * version.c (ruby_description, ruby_copyright): construct literals statically even if string literal concatenation is not available. @@ -19,12 +19,17 @@ #ifndef rb_str_new_cstr #define rb_str_new_cstr(str) rb_str_new(str, strlen(str)) #endif -#define MKSTR(type) rb_obj_freeze(rb_str_new_cstr(TOKEN_PASTE(ruby_,type))) +#define MKSTR(type) rb_obj_freeze(rb_str_new(TOKEN_PASTE(ruby_,type), sizeof(TOKEN_PASTE(ruby_,type))-1)) +#ifdef __GNUC__ +#define UNALIGNED __attribute__((aligned(1))) +#else +#define UNALIGNED +#endif +const int ruby_patchlevel = RUBY_PATCHLEVEL; const char ruby_version[] = RUBY_VERSION; const char ruby_release_date[] = RUBY_RELEASE_DATE; const char ruby_platform[] = RUBY_PLATFORM; -const int ruby_patchlevel = RUBY_PATCHLEVEL; #ifdef RUBY_DESCRIPTION const char ruby_description[] = RUBY_DESCRIPTION; #else @@ -38,14 +43,14 @@ const struct { char pad2[3]; char platform[sizeof(RUBY_PLATFORM)-1]; char pad3[2]; -} ruby_description[1] = { +} ruby_description[1] UNALIGNED = { { "ruby ", RUBY_VERSION, RUBY_PATCHLEVEL_STR, " (", RUBY_RELEASE_DATE, RUBY_REVISION_STR, ") [", RUBY_PLATFORM, "]" } }; -#define ruby_description ((const char *)ruby_description) +#define ruby_description (*(const char (*)[sizeof(ruby_description)])ruby_description) #endif #ifdef RUBY_COPYRIGHT @@ -58,14 +63,14 @@ const struct { char release[sizeof(STRINGIZE(RUBY_RELEASE_YEAR))-1]; char pad2[1]; char author[sizeof(RUBY_AUTHOR)]; -} ruby_copyright[1] = { +} ruby_copyright[1] UNALIGNED = { { "ruby - Copyright (C) ", STRINGIZE(RUBY_BIRTH_YEAR), "-", STRINGIZE(RUBY_RELEASE_YEAR), " ", RUBY_AUTHOR } }; -#define ruby_copyright ((const char *)ruby_copyright) +#define ruby_copyright (*(const char (*)[sizeof(ruby_copyright[0])])ruby_copyright) #endif const struct ruby_initial_loadpath { @@ -92,7 +97,7 @@ const struct ruby_initial_loadpath { #endif char archlib[sizeof(RUBY_ARCHLIB)]; char terminator[1]; -} ruby_initial_load_paths = { +} ruby_initial_load_paths UNALIGNED = { #ifdef RUBY_SEARCH_PATH RUBY_SEARCH_PATH, #endif |