Comments (16)
Is that important ?
Specifically, does it improve performance, or modify the generated binary ?
Regards
Original comment by [email protected]
on 3 May 2012 at 2:02
from lz4.
[deleted comment]
from lz4.
If it's not importent, why you add these lines to your source code:
#ifdef _MSC_VER
#define inline __forceinline ...
If you think forceinline in VC is important, why not in GCC?
Original comment by [email protected]
on 3 May 2012 at 2:08
from lz4.
Well, ok, i understand,
but that's not the main point here.
Without this define, the source code does not even compile in VC.
So it's true that i could have written
#define inline __inline
instead.
It just happen that i'm using this #define inline __forceinline generically
across my source codes. I simply copy/pasted it. I have not really paid
attention at the difference. I guess it does not really matter in 99% of time,
and might result in a small difference in others.
The point is just that a #define is necessary for VC. So, while at it...
Original comment by [email protected]
on 3 May 2012 at 10:37
from lz4.
[deleted comment]
from lz4.
Ok, the GCC equivalent of VC's "__inline" is "__inline__". Any way, 'inline' is
not a traditional "C Keyword" (C89), For maximum portability and performance,
you may have the following defines:
#ifdef "VC or VC Like (e.g: ICL for windows, etc.)"
# define yourinline __forceinline
#elif "GCC or GCC Like (e.g.: clang, etc.)"
# define yourinline __inline__ __attribute__((always_inline))
#elif __cplusplus
# define yourinline inline
... // other compilers ?
#else
# define yourinline
#endif
Of couse, it may occupy more lines, but the readability of code doesn't only
rely on the number of lines of the code. Contrarily, just write every thing
within just one line of code cause it unreadable.
With well and consistent coding standard used, code could be very easy to read
even if it has a bit of more lines, right? So keep it simple and clear is very
important. But firstly, it not the whole world. And secondly, we could solve it
by not only reduce the number of lines of the code, but also other methods
(e.g: well coding standard and formatting, etc.).
Original comment by [email protected]
on 4 May 2012 at 4:19
from lz4.
Isn't 'inline' C99 compliant ?
Original comment by [email protected]
on 4 May 2012 at 7:01
from lz4.
[deleted comment]
from lz4.
1. As I have been sad, it's not only a standard compliant problem, but also a
performance issue. For compute-intensive algorithm like lz4, even 1%
performance boost are valuable.
2. There are lot of guys using a compiler which is NOT C99 compliant.
Especially for some embedded enviroments. So I have been emphasized "C Keyword"
as C89 :-)
Original comment by [email protected]
on 4 May 2012 at 7:10
from lz4.
OK, these are 2 separate objectives :
Regarding performance : i'm not interested in making the generic code more
complex for the perspective of maybe 1% speed improvement in some circumstances.
As has been said, if you feel this is a better fit for your needs, i invite you
to fork the generic code. Such adaptation is in fact welcomed : the generic
code cannot expect to be the end solution for all needs.
The second objective is more interesting, for Compilers of embedded
environments.
A word on C89 vs C99 : my initial intention was to be C99 compliant only, but
well, as you say, not all compilers have reached that level (even though we are
in 2012!). The most important one which comes to mind being Visual. Surely
other ones are on the list too.
I'm not going to be "totally sticking" to C89 either.
As far as know, all "limited" compilers i'm aware of are at least C89 plus a
good subset of C99, with only a few missing features which forbid it to be
called "completely C99 compliant".
For example, i do like much the '//' mark for comments, which is C99, and i'm
not aware of any compiler which does not support it. So I do not plan to get
rid of it, since it is much too convenient for code reading and maintenance.
However, if it is possible to make LZ4 easier to use for "limited" (i.e. not
C99) compilers, this is welcomed.
I don't think that introducing complex and GCC-only attributes is going into
the right direction. Rather, a simpler and more generic route would be to
remove 'inline' keyword entirely (as i did with "restrict" for example).
So it would give something like this :
#if __STDC_VERSION__ >= 199901L // C99
/* "restrict" is a known keyword */
#else
# define restrict // Disable restrict
# define inline // Disable inline
#endif
The only problem i have with this modification is that i have receive no
problem report regarding the use of 'inline' keyword up to now. This is like
removing an imaginary problem that no one seems to experience. So is this
change worth introducing ?
Original comment by [email protected]
on 10 May 2012 at 12:11
from lz4.
[deleted comment]
from lz4.
[deleted comment]
from lz4.
En ... may be you are right, So you may delay this "fix" until some one have
been encounter it in a real case.
Although I think it's realy common case for some embedded enviroments.
Original comment by [email protected]
on 10 May 2012 at 10:05
from lz4.
Delayed or cancelled. Possible "inline" disabling if issue with compilers for
embedded target really show up.
Original comment by [email protected]
on 10 May 2012 at 11:38
- Changed state: Invalid
from lz4.
just to say I'm now getting this issue with inline using latest xcode 4.4 on
both Apple LLVM complier 4.0 and LLVM GCC 4.2
Undefined symbols for architecture x86_64:
"_LZ4_compress64kCtx", referenced from:
_LZ4_compress_limitedOutput in lz4.o
"_LZ4_compressCtx", referenced from:
_LZ4_compress_limitedOutput in lz4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Original comment by [email protected]
on 5 Aug 2012 at 1:29
from lz4.
Could it be related to issue 29, currently opened ?
Original comment by [email protected]
on 5 Aug 2012 at 9:18
from lz4.
Related Issues (20)
- Clang compiler warnings HOT 6
- LZ4F_compressBound() using null PreferencesPtr HOT 3
- lz4io license HOT 6
- Commandline lz4 stops when decompressing a concatenated lz4 file representing an empty file HOT 4
- Kernel wont boot with CONFIG_DYNAMIC_DEBUG=y HOT 2
- Bad alignment detection & setting on Sparc Solaris HOT 2
- lz4 r124 breaks ABI without bumping soname HOT 22
- Do not call sudo in Makefile HOT 3
- LZ4 HC r126 crashes when compiled with GCC 4.9 on highest optimization settings HOT 1
- lz4frame should correctly handle skipped frames HOT 4
- LZ4 cli invocation should match other compressors for non-option arguments HOT 14
- sudo make install does not cp files to /usr/local HOT 6
- lz4 auto-decompress does not work HOT 3
- Force should pass thru bytes unchanged HOT 5
- lz4 cli should support sparse file HOT 22
- decompression same file on different platforms HOT 3
- Static code analysis warnings HOT 10
- Google Code will close HOT 3
- [Query]Can LZo algorithm optimized for ARM NEON (SIMD instructions). HOT 3
- Potential Size Extension Problem in LZ4F_readLE64 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lz4.