Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 07 Dec 2016, 14:27
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Google's style guide gives Linux a disadvantage
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4695

PostPosted: Mon 19 Oct 2015, 05:55    Post subject:  Google's style guide gives Linux a disadvantage  

Google's style guide states:

Quote:
When defining a function, parameter order is: inputs, then outputs.

Parameters to C/C++ functions are either input to the function, output from the function, or both. Input parameters are usually values or const references, while output and input/output parameters will be non-const pointers. When ordering function parameters, put all input-only parameters before any output parameters


This is bad, because in UNIX/Linux the calling convention uses the following registers:
    RDI, RSI, RDX, RCX, R8, and R9
while Windows uses:
    RCX, RDX, R8, R9


Note that the DI in RDI stands for _D_estination _I_ndex while the SI in RSI stands for _S_ource _I_ndex.

On Windows that would mean just MOVing parameters to RSI and RDI, but on other UNIX-like platforms it requires an extra temp register whereas if the recommendation was reversed, Windows should perform the same and other platforms could potentially shave 3 operations (both MOVs and the temp) off of every function that moves data.

Not to mention it would match the rest of the world:
void *memmove(void *dest, const void *src, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
char *strcpy(char *dest, const char *src);
... and practically every other standard function

Further reading:
https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI - shows differences in various calling conventions
https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Function_Parameter_Ordering - google's C++ style guide
http://stackoverflow.com/a/4438515/1162141 - discusses reasons behind the calling convention
http://www.swansontec.com/sregisters.html - tells what function each register is designed for

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 12276
Location: Arizona USA

PostPosted: Mon 19 Oct 2015, 11:45    Post subject:  

Have you tried to tell Google about this?
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4695

PostPosted: Tue 20 Oct 2015, 19:49    Post subject:  

I doubt it is something google would "fix". Once a large corporate entity has a code base as vast a theirs, you only get "bolt-on" fixes. It just goes to show that the old project management adage that "an hour spent in planning phase saves 10 in production" is applicable to software as well.

Most of the people at google who would have known better, were busy working on the Go language, which has its own design problems (I thought they had already figured out that register based calling conventions were superior to stack based calling conventions).

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0373s ][ Queries: 11 (0.0065s) ][ GZIP on ]