Hi Vicky,
Yes, the 'clang' compiler used by OS X and iOS will fail to compile TrouSerS
the way it is currently written.
Compilers vary regarding how the 'inline' keyword is handled. See:
http://clang.llvm.org/compatibility.html#inline
Given the fact that various combinations of 'inline' and other keywords
result in undefined (or at least inconsistently-defined) behavior, I prefer to
rely on behavior that will be consistent across all supported platforms. (That
is, unless there is a compelling reason to enable platform-specific compiler
optimizations, I would prefer to keep the code simple and clear.)
In this case, the clang manual suggests using "static inline" as "usually
the right solution". This is what you would use if you wanted a
performance-critical section of code to be inlined for use within a single
object file. However, since the functions were being used in multiple files, it
was unlikely that 'inline' had much of an effect anyway. So I chose the 2nd
option listed on that page in the clang manual, "Remove the inline keyword from
this definition of add. The inline keyword is not required for a function to be
inlined, nor does it guarantee that it will be. Some compilers ignore it
completely. Clang treats it as a mild suggestion from the programmer."
Regards,
Mike
From: Hon Ching Lo <[email protected]<mailto:[email protected]>>
Date: Wednesday, December 24, 2014 at 9:02 PM
To: Mike Pontillo <[email protected]<mailto:[email protected]>>
Cc:
"[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: Re: [TrouSerS-tech] [PATCH] Support for compiling on OS X
The patch looks good to me. But there was one change that I've kept wondering:
> Removal of 'inline' inside 'extern' functions which were being made
> available to other object files.
> (I believe this is undefined behavior; I'm not sure how the compiler would
> inline these anyway;
> maybe it's a special feature?)
The code might have intended to inline some functions for other platforms aside
from SOLARIS
i.e. to take advantage of compiler optimization in those platforms. Does
anyone know the true
motive behind?
Mike, if we didn't remove the inline keywords, would the code still work for
IOS? Just wondering.
Regards,
Vicky
On Wed, Oct 1, 2014 at 12:34 AM, Mike Pontillo
<[email protected]<mailto:[email protected]>> wrote:
Hi all,
Even though we're using TrouSerS on Linux, it's convenient for
developers to
be able to compile it on OS X. (it would be nice for testing, in
conjunction
with the TPM emulator.)
I went through and created a set of changes to allow this, including:
* Not using GCC-specific LDFLAGS when compiling tcsd
* Use of a public domain portable_endian.h to abstract the fact that you
cannot #include <endian.h> on the Apple platform.
* Addition of __APPLE__ to some places where __OpenBSD__ and __FreeBSD__
appear
* Definition of HOST_NAME_MAX to avoid including bits/local_lim.h on
__APPLE__
(I think this is a Linux-specific header)
* Removal of 'inline' inside 'extern' functions which were being made
available to other object files. (I believe this is undefined behavior;
I'm
not sure how the compiler would inline these anyway; maybe it's a
special
feature?)
* Minor change to 'gitignore' to also ignore the 'compile' script that
gets
generated.
Also, I noticed some other changes that should be made which are not
included
in this patch:
* bootstrap.sh should not use libtoolize
(on OS X and Linux, I've used "autoreconf -f -i -v" successfully)
* Fix compiler warnings regarding memset optimization
(could have security considerations!)
Please let me know if you're willing to accept this patch, and/or if it
should be improved upon first. I have attached the patch.
Thanks,
Mike Pontillo
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-tech mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/trousers-tech
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech