IRC logs for #openrisc Wednesday, 2015-11-11

--- Log opened Wed Nov 11 00:00:04 2015
olofkI'm really really bad at C06:53
olofkTrying to add some stuff to the elf-loader, but it gives me 'implicit declaration of function' when I try to use a function from libelf06:54
olofkBut it's not complaining on the other functions06:54
olofkoh...06:55
olofkApparently C is sensitive to spelling06:55
jkent:)06:56
stekernwhat? aren't you writing code in word, so you get spell correction?06:58
stekernno joking though, I've seen it happen in real life06:59
stekerninhereted an old 8051 asm project where the source was a .doc, with macro fields to automatically update a string with a date ;)07:01
olofkstekern: woah.... that's really really scary07:01
olofkActually... that might be the worst thing I've heard. Can't think of anything that comes close07:01
olofkHow is elf_getident supposed to work? I've blindly tried all combinations of &,  *, defining char* or char [] without success09:37
andrzejrstekern, but you get a built-in revision control ;-)09:41
olofkAnyone up for a quick review? Would be good to get some comments from an actual C coder :)10:02
GeneralStupidolofk: ill try :)10:02
olofkhttp://pastebin.com/fzYBABJp10:04
olofkTested it with picorv32 (Little Endian) in Verilator and mor1kx-generic (Big endian) in Verilator10:05
olofkWorks fine with mor1kx-generic in Icarus too, so the VPI stuff seems to be holding up10:06
olofkand modelsim10:06
olofkI considered using the conversion functions from endian.h in read_32, but I couldn't figure out which one to use. Endian conversions is a mess10:07
GeneralStupidolofk: i think you should use {} in line 26 and the following lines10:12
GeneralStupidolofk: its no problem, just consistency in setting curled bracktes10:13
GeneralStupidyou hate thes brackets, dont you?10:14
GeneralStupid{} <310:14
GeneralStupidolofk: one thing which may be a real reason is, you should use uint8_t types instead of char10:16
olofkGeneralStupid: I was a bit careless with the indentation and bracketing10:18
olofkBut regarding char/uint8_t, elf_getident returns a char *, so I guess that's what I should use10:19
GeneralStupidolofk: thats just a personal thing10:19
GeneralStupidolofk: i already saw plattforms where char is signed 8 bit or unsigned 8 bit10:20
GeneralStupidolofk: but if they return this they hopefully take care of the different compilers :)10:20
olofkI was a bit worried about using a global variable for the endianness. Is that ok?10:23
GeneralStupidiam a fan of types.h but due to the fact that getident is a systemcall...10:23
GeneralStupidit is only set when loading an elf file?10:24
olofkyes10:25
GeneralStupidi think in that case its no problem.10:27
GeneralStupidif you are scared about that, you could do that check twice10:29
olofkI'm not that worried about the two functions will be called in the wrong order, but I'm not sure about what happens with global variables in a shared library, in case someone uses several instances10:31
GeneralStupidno but it is ok. You load a file, then you read that file. There will be no concurrency in that10:31
olofkThanks. gtg10:32
GeneralStupidolofk: no problem. If anyone changes your internal variable he should live with the results :-D10:34
_franck_olofk: line 48: if(big_endian) space after "if"11:01
olofkok, you had your chances. I'm pushing now12:09
stekerndo you have to make a global bigendian variable?12:12
stekerntoo lazy too open the actual file and check12:12
olofkstekern: Too lazy to implement it another way :)12:13
olofkI could add endianness as a parameter to the read_32 function instead, but then I would break API.12:13
olofkI think verilator_tb_utils and the vpi_wrapper are the only users, so it's not that big change, but this was quicker12:14
_franck_olofk: too bad you miss some spaces line 194 "address+3"12:46
olofk_franck_: Are you sure? Look again12:49
GeneralStupidstekern: i think its fine this way. global variables are stupid, redundant checks too ... so, you need to do it any way14:00
-!- knz_ is now known as knz14:34
-!- heroux_ is now known as heroux16:17
_franck_olofk: :)18:53
--- Log closed Thu Nov 12 00:00:06 2015

Generated by irclog2html.py 2.15.2 by Marius Gedminas - find it at mg.pov.lt!