ruby-changes:15603
From: nobu <ko1@a...>
Date: Tue, 27 Apr 2010 15:24:11 +0900 (JST)
Subject: [ruby-changes:15603] Ruby:r27511 (ruby_1_8): * version.c (ruby_description, ruby_copyright): unaligned and
nobu 2010-04-27 15:21:31 +0900 (Tue, 27 Apr 2010) New Revision: 27511 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27511 Log: * version.c (ruby_description, ruby_copyright): unaligned and optimized. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/version.c Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 27510) +++ ruby_1_8/ChangeLog (revision 27511) @@ -1,5 +1,8 @@ -Tue Apr 27 12:53:20 2010 Nobuyoshi Nakada <nobu@r...> +Tue Apr 27 15:21:27 2010 Nobuyoshi Nakada <nobu@r...> + * 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. Index: ruby_1_8/version.c =================================================================== --- ruby_1_8/version.c (revision 27510) +++ ruby_1_8/version.c (revision 27511) @@ -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 @@ 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 @@ 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 @@ #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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/