On 14 March 2014 08:51, 1100110 <0b1100...@gmail.com> wrote: > On 3/14/14, 3:02, Walter Bright wrote: >> >> On 3/14/2014 12:34 AM, 1100110 wrote: >>> >>> ...And code duplication everywhere! >> >> >> Actually, very little of that. > > I don't know what you'd call this then... > Exact same bit of code, repeated multiple times for versions which could be > OR'd together. > > > version (X86) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0x00000; > } > else version (X86_64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0x00000; > } > else version (MIPS32) > { > enum RTLD_LAZY = 0x0001; > enum RTLD_NOW = 0x0002; > enum RTLD_GLOBAL = 0x0004; > enum RTLD_LOCAL = 0; > } > else version (PPC) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > else version (PPC64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > else version (ARM) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > else version (AArch64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > > Yeah there are a few differences, but it would be trivial to collapse this > down... > > Just for funsies: > > version (X86 || X86_64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0x00000; > } > else version (MIPS32) > { > enum RTLD_LAZY = 0x0001; > enum RTLD_NOW = 0x0002; > enum RTLD_GLOBAL = 0x0004; > enum RTLD_LOCAL = 0; > } > else version (PPC) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > else version (PPC64 || ARM || AArch64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0; > } > > > Oh wait, isn't 0x00000 the same as 0? (I honestly don't know if that > matters, but assuming it doesn't...) > > version (X86 || X86_64 || PPC || PPC64 || ARM || AArch64) > { > enum RTLD_LAZY = 0x00001; > enum RTLD_NOW = 0x00002; > enum RTLD_GLOBAL = 0x00100; > enum RTLD_LOCAL = 0x00000; > } > else version (MIPS32) > { > enum RTLD_LAZY = 0x0001; > enum RTLD_NOW = 0x0002; > enum RTLD_GLOBAL = 0x0004; > enum RTLD_LOCAL = 0; > } > > Huh, for not having any code duplication it sure is a hell of a lot shorter > when combined...
This is exactly the problem I wanted to avoid in druntime. Someone needs to pull their finger out and decide how we are going to tackle the porting chasm we are heading into.