3 ms·
By that logic most HLLs shouldn't have been made. Remember - write once run many times. Implementing it in GCC / etc once means that many people won't have to
by TheLoneWolfling 12y ago
By that logic most HLLs shouldn't have been made.
Remember - write once run many times. Implementing it in GCC / etc once means that many people won't have to do it themselves - especially as it's far more likely that one implementation will be bug-free than many people writing their own.
- acqq 12y agoIt's not the feature that anybody would use as is, when you'd use it you'd prefer to call the function. But then what's behind the function is irrelevant for the users of the function. We don't force compiler authors to put in the compiler what can be nicely put in the libraries. It's: write one header with a few #if's once, everybody use it, whenever she needs it. You'd just call is_safe_to_add_ints( s, t[i] ) and be sure that on the common platform it's optimal thanks to the #if's in the header, and not write bool bsafe = (t[i] < 0) ? s >= INT_MIN - t[i] : s <= INT_MAX - t[i]; every time you'd want to check if the addition would be safe.
- Someone 12y agoBut you want if( !canSafelyAdd(a,b)) return ERROR; c = a + b; To compile down to an add and a check of the overflow bit. For that, you need help from the compiler. There are many examples where compilers special-case what is in a library. For example, compilers know they do not have to call strlen every time through this loop: for(int i = 0; i < strlen(s); ++i)
- acqq 12y agoThe enough help you need is, in the implementation of the library function #if X86 #if GCC etc and then the assembly for each case, otherwise the slow but standard implementation. And that's one file, the code never to be directly used but by function name. It's already done this way in the current libraries for a lot processor specific stuff.