[PATCH] Make static variables const

Hi,

this is a set of simple changes which make some of SDL’s internal static
arrays constant. The purpose is to shrink the number of write-able
static bytes and thus increase the number of memory pages shared between
SDL applications.

The patch set is against trunk at 4513. Each of the attached patch files is
specific to a sub-system. The set is completed by a second mail, because
of the list’s 40 KiB limit.

The files readelf-r4513.txt and readelf-const-patch.txt where made by
calling ‘readelf -S libSDL.so’. They show the difference in ELF sections
without and with the patch. Some numbers measured on my x86-64:

Before

[13] .rodata PROGBITS 00000000000eaaa0 000eaaa0
0000000000008170 0000000000000000 A 0 0 32
[19] .data.rel.ro PROGBITS 00000000003045e0 001045e0
00000000000023d0 0000000000000000 WA 0 0 32
[23] .data PROGBITS 00000000003076e0 001076e0
0000000000004988 0000000000000000 WA 0 0 32

After

[13] .rodata PROGBITS 00000000000eaaa0 000eaaa0
0000000000009a50 0000000000000000 A 0 0 32
[19] .data.rel.ro PROGBITS 0000000000306040 00106040
0000000000002608 0000000000000000 WA 0 0 32
[23] .data PROGBITS 0000000000309360 00109360
0000000000002e88 0000000000000000 WA 0 0 32

The size of the write-able data section decreased considerably. Some
entries became const-after-relocation, while most of its content went
straight into the read-only data section.

Best regards, Thomas–
GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08

jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: audio.const.patch
Type: text/x-patch
Size: 843 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: events.const.patch
Type: text/x-patch
Size: 4646 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment-0001.bin
-------------- next part --------------
There are 39 section headers, starting at offset 0x9ba828:

Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .hash HASH 0000000000000158 00000158
0000000000000bb0 0000000000000004 A 3 0 8
[ 2] .gnu.hash GNU_HASH 0000000000000d08 00000d08
0000000000000b00 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000001808 00001808
0000000000002d48 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 0000000000004550 00004550
0000000000001e18 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 0000000000006368 00006368
00000000000003c6 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 0000000000006730 00006730
0000000000000090 0000000000000000 A 4 4 8
[ 7] .rela.dyn RELA 00000000000067c0 000067c0
0000000000005cd0 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 000000000000c490 0000c490
0000000000001c20 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 000000000000e0b0 0000e0b0
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 000000000000e0c8 0000e0c8
00000000000012d0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 000000000000f3a0 0000f3a0
00000000000db6d8 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 00000000000eaa78 000eaa78
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 00000000000eaaa0 000eaaa0
0000000000009a50 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 00000000000f44f0 000f44f0
0000000000003854 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 00000000000f7d48 000f7d48
000000000000e134 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 0000000000306000 00106000
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 0000000000306010 00106010
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 0000000000306020 00106020
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 0000000000306040 00106040
0000000000002608 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 0000000000308648 00108648
00000000000001d0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 0000000000308818 00108818
00000000000001d0 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 00000000003089e8 001089e8
0000000000000978 0000000000000008 WA 0 0 8
[23] .data PROGBITS 0000000000309360 00109360
0000000000002e88 0000000000000000 WA 0 0 32
[24] .bss NOBITS 000000000030c200 0010c1e8
000000000000bc50 0000000000000000 WA 0 0 32
[25] .comment PROGBITS 0000000000000000 0010c1e8
0000000000000cd0 0000000000000000 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 0010cec0
00000000000011d0 0000000000000000 0 0 16
[27] .debug_pubnames PROGBITS 0000000000000000 0010e090
0000000000004ef3 0000000000000000 0 0 1
[28] .debug_info PROGBITS 0000000000000000 00112f83
00000000000e1819 0000000000000000 0 0 1
[29] .debug_abbrev PROGBITS 0000000000000000 001f479c
000000000000a35d 0000000000000000 0 0 1
[30] .debug_line PROGBITS 0000000000000000 001feaf9
000000000002b847 0000000000000000 0 0 1
[31] .debug_frame PROGBITS 0000000000000000 0022a340
000000000000ed58 0000000000000000 0 0 8
[32] .debug_str PROGBITS 0000000000000000 00239098
00000000000150d4 0000000000000001 MS 0 0 1
[33] .debug_loc PROGBITS 0000000000000000 0024e16c
0000000000021660 0000000000000000 0 0 1
[34] .debug_macinfo PROGBITS 0000000000000000 0026f7cc
000000000074ae62 0000000000000000 0 0 1
[35] .debug_ranges PROGBITS 0000000000000000 009ba630
0000000000000090 0000000000000000 0 0 16
[36] .shstrtab STRTAB 0000000000000000 009ba6c0
0000000000000167 0000000000000000 0 0 1
[37] .symtab SYMTAB 0000000000000000 009bb1e8
000000000000e9e8 0000000000000018 38 2014 8
[38] .strtab STRTAB 0000000000000000 009c9bd0
000000000000bf26 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
-------------- next part --------------
There are 39 section headers, starting at offset 0x9ba618:

Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .hash HASH 0000000000000158 00000158
0000000000000bb0 0000000000000004 A 3 0 8
[ 2] .gnu.hash GNU_HASH 0000000000000d08 00000d08
0000000000000b00 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000001808 00001808
0000000000002d48 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 0000000000004550 00004550
0000000000001e18 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 0000000000006368 00006368
00000000000003c6 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 0000000000006730 00006730
0000000000000090 0000000000000000 A 4 4 8
[ 7] .rela.dyn RELA 00000000000067c0 000067c0
0000000000005cd0 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 000000000000c490 0000c490
0000000000001c20 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 000000000000e0b0 0000e0b0
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 000000000000e0c8 0000e0c8
00000000000012d0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 000000000000f3a0 0000f3a0
00000000000db6d8 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 00000000000eaa78 000eaa78
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 00000000000eaaa0 000eaaa0
0000000000008170 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 00000000000f2c10 000f2c10
0000000000003854 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 00000000000f6468 000f6468
000000000000e134 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 00000000003045a0 001045a0
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 00000000003045b0 001045b0
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 00000000003045c0 001045c0
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 00000000003045e0 001045e0
00000000000023d0 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 00000000003069b0 001069b0
00000000000001d0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 0000000000306b80 00106b80
00000000000001d0 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 0000000000306d50 00106d50
0000000000000978 0000000000000008 WA 0 0 8
[23] .data PROGBITS 00000000003076e0 001076e0
0000000000004988 0000000000000000 WA 0 0 32
[24] .bss NOBITS 000000000030c080 0010c068
000000000000bc50 0000000000000000 WA 0 0 32
[25] .comment PROGBITS 0000000000000000 0010c068
0000000000000cd0 0000000000000000 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 0010cd40
00000000000011d0 0000000000000000 0 0 16
[27] .debug_pubnames PROGBITS 0000000000000000 0010df10
0000000000004ef3 0000000000000000 0 0 1
[28] .debug_info PROGBITS 0000000000000000 00112e03
00000000000e179d 0000000000000000 0 0 1
[29] .debug_abbrev PROGBITS 0000000000000000 001f45a0
000000000000a348 0000000000000000 0 0 1
[30] .debug_line PROGBITS 0000000000000000 001fe8e8
000000000002b847 0000000000000000 0 0 1
[31] .debug_frame PROGBITS 0000000000000000 0022a130
000000000000ed58 0000000000000000 0 0 8
[32] .debug_str PROGBITS 0000000000000000 00238e88
00000000000150d4 0000000000000001 MS 0 0 1
[33] .debug_loc PROGBITS 0000000000000000 0024df5c
0000000000021660 0000000000000000 0 0 1
[34] .debug_macinfo PROGBITS 0000000000000000 0026f5bc
000000000074ae62 0000000000000000 0 0 1
[35] .debug_ranges PROGBITS 0000000000000000 009ba420
0000000000000090 0000000000000000 0 0 16
[36] .shstrtab STRTAB 0000000000000000 009ba4b0
0000000000000167 0000000000000000 0 0 1
[37] .symtab SYMTAB 0000000000000000 009bafd8
000000000000e9e8 0000000000000018 38 2014 8
[38] .strtab STRTAB 0000000000000000 009c99c0
000000000000bf26 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_fatal.c.const.patch
Type: text/x-patch
Size: 335 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: stdlib.const.patch
Type: text/x-patch
Size: 457 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment-0003.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: thread.const.patch
Type: text/x-patch
Size: 499 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment-0004.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/3e2abaf2/attachment.pgp

This is the second half of the patch set.

Thomas–
GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08

jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libm.const.patch
Type: text/x-patch
Size: 5000 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/b44debf3/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: video.const.patch
Type: text/x-patch
Size: 6096 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/b44debf3/attachment-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/b44debf3/attachment.pgp

Excellent work! Thanks!On Tue, May 19, 2009 at 1:45 PM, Thomas Zimmermann wrote:

this is a set of simple changes which make some of SDL’s internal static
arrays constant. The purpose is to shrink the number of write-able
static bytes and thus increase the number of memory pages shared between
SDL applications.


http://codebad.com/

Hi

this is a set of simple changes which make some of SDL’s internal static
arrays constant.

Sorry for the fuss; but is anyone going to apply these patches, or give
me a review why not?

Best regards, Thomas–
GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08

jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090527/986d48bf/attachment.pgp

They’re probably more likely to get looked at (eventually) if you
submit them as a bug to bugzilla.On Wed, 27 May 2009 20:14:22 +0200 Thomas wrote:

this is a set of simple changes which make some of SDL’s internal
static arrays constant.

Sorry for the fuss; but is anyone going to apply these patches, or
give me a review why not?

Hi

this is a set of simple changes which make some of SDL’s internal static
arrays constant.

Sorry for the fuss; but is anyone going to apply these patches, or give
me a review why not?

Yeah. Sam’s been real busy with other stuff lately. I’ve got a couple
patches I submitted to SDL_Image more than a month ago that I’m
still waiting to hear back about.>From: Thomas Zimmermann

Subject: Re: [SDL] [PATCH] Make static variables const

Hi

this is a set of simple changes which make some of SDL’s internal static
arrays constant.

Sorry for the fuss; but is anyone going to apply these patches, or give
me a review why not?

Yeah. Sam’s been real busy with other stuff lately. I’ve got a couple
patches I submitted to SDL_Image more than a month ago that I’m
still waiting to hear back about.

Perhaps there needs to be another group to do just SDL maintenance? So Sam
and others can concentrate on 1.3?

This group would prepare, and review patches for the main tree… to make it
easier for Sam to approve/review.

Could work with git on a mirror of svn, where people could test/review/ fix
up, before sending nice clean patches to Sam for inclusion, or make it easy
for Sam to make decisions about how things should be done.

Could use bugzilla to collect existing patches, apply them to the
review-tree, and write down notes about the patches/discuss patches… then
post cleaned up/reviewed patches back to bugzilla.

The idea would be to make it easier for Sam, so more patches could get
incorporated, more quickly.

cu,On Thu, May 28, 2009 at 7:14 AM, Mason Wheeler wrote:

From: Thomas Zimmermann
Subject: Re: [SDL] [PATCH] Make static variables const

These have been committed to subversion.

Thanks!
–SamOn Wed, May 27, 2009 at 11:14 AM, Thomas Zimmermann < tdz at users.sourceforge.net> wrote:

Hi

this is a set of simple changes which make some of SDL’s internal static
arrays constant.

Sorry for the fuss; but is anyone going to apply these patches, or give
me a review why not?

Best regards, Thomas


GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08

jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org