* add amalgamation option to eet (disabled by default,

as no real gain is seen (compilation time, size))
 * add namespace for words_bigendian, to make amalagamation happy
 * don't redefine macros, for the same purpose


SVN revision: 43409
This commit is contained in:
Vincent Torri 2009-11-02 08:41:43 +00:00
parent 204d2976e2
commit 35bd81e535
5 changed files with 207 additions and 39 deletions

View File

@ -51,6 +51,18 @@ requirement_eet=""
### Additional options to configure
AC_ARG_ENABLE([amalgamation],
[AC_HELP_STRING([--enable-amalgamation], [enable generation of one single file with all source code in it, helps compiler optimizations.])],
[if test "x${enableval}" = "xyes"; then
do_amalgamation="yes"
else
do_amalgamation="no"
fi
],
[do_amalgamation="no"]
)
AM_CONDITIONAL(EET_AMALGAMATION, test "x${do_amalgamation}" = "xyes")
# Old eet file format support
old_eet_file_format="yes"
@ -401,6 +413,7 @@ echo " Openssl..............: ${have_openssl}"
echo " Cipher support.....: ${have_cipher}"
echo " Signature..........: ${have_signature}"
echo
echo " Amalgamation.........: ${do_amalgamation}"
echo " Documentation........: ${build_doc}"
echo " Tests................: ${enable_tests}"
echo " Coverage.............: ${enable_coverage}"

View File

@ -20,7 +20,7 @@ include_HEADERS = Eet.h
lib_LTLIBRARIES = libeet.la
libeet_la_SOURCES = \
base_sources = \
eet_lib.c \
eet_data.c \
eet_image.c \
@ -29,6 +29,127 @@ eet_dictionary.c \
eet_node.c \
eet_utils.c
if EET_AMALGAMATION
eet_sources_used = eet_amalgamation.c
BUILT_SOURCES = eet_amalgamation.c
eet_amalgamation.c: $(base_sources) Makefile
-rm -f eet_amalgamation.c
@echo "#ifdef HAVE_CONFIG_H" >> eet_amalgamation.c
@echo "# include \"config.h\"" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_ALLOCA_H" >> eet_amalgamation.c
@echo "# include <alloca.h>" >> eet_amalgamation.c
@echo "#elif defined __GNUC__" >> eet_amalgamation.c
@echo "# define alloca __builtin_alloca" >> eet_amalgamation.c
@echo "#elif defined _AIX" >> eet_amalgamation.c
@echo "# define alloca __alloca" >> eet_amalgamation.c
@echo "#elif defined _MSC_VER" >> eet_amalgamation.c
@echo "# include <malloc.h>" >> eet_amalgamation.c
@echo "# define alloca _alloca" >> eet_amalgamation.c
@echo "#else" >> eet_amalgamation.c
@echo "# include <stddef.h>" >> eet_amalgamation.c
@echo "# ifdef __cplusplus" >> eet_amalgamation.c
@echo "#extern \"C\"" >> eet_amalgamation.c
@echo "# endif" >> eet_amalgamation.c
@echo "#void *alloca (size_t);" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#include <stdio.h>" >> eet_amalgamation.c
@echo "#include <string.h>" >> eet_amalgamation.c
@echo "#include <math.h>" >> eet_amalgamation.c
@echo "#include <ctype.h>" >> eet_amalgamation.c
@echo "#include <limits.h>" >> eet_amalgamation.c
@echo "#include <sys/types.h>" >> eet_amalgamation.c
@echo "#include <sys/stat.h>" >> eet_amalgamation.c
@echo "#include <sys/mman.h>" >> eet_amalgamation.c
@echo "#include <setjmp.h>" >> eet_amalgamation.c
@echo "#include <errno.h>" >> eet_amalgamation.c
@echo "#include <time.h>" >> eet_amalgamation.c
@echo "#include <fnmatch.h>" >> eet_amalgamation.c
@echo "#include <fcntl.h>" >> eet_amalgamation.c
@echo "#ifdef _WIN32" >> eet_amalgamation.c
@echo "# include <winsock2.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifndef _MSC_VER" >> eet_amalgamation.c
@echo "# include <unistd.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_NETINET_IN_H" >> eet_amalgamation.c
@echo "# include <netinet/in.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_GNUTLS" >> eet_amalgamation.c
@echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
@echo "# include <gcrypt.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_OPENSSL" >> eet_amalgamation.c
@echo "# include <openssl/err.h>" >> eet_amalgamation.c
@echo "# include <openssl/evp.h>" >> eet_amalgamation.c
@echo "# include <openssl/sha.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_SIGNATURE" >> eet_amalgamation.c
@echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
@echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
@echo "# include <gnutls/x509.h>" >> eet_amalgamation.c
@echo "# else" >> eet_amalgamation.c
@echo "# include <openssl/rsa.h>" >> eet_amalgamation.c
@echo "# include <openssl/objects.h>" >> eet_amalgamation.c
@echo "# include <openssl/err.h>" >> eet_amalgamation.c
@echo "# include <openssl/ssl.h>" >> eet_amalgamation.c
@echo "# include <openssl/dh.h>" >> eet_amalgamation.c
@echo "# include <openssl/dsa.h>" >> eet_amalgamation.c
@echo "# include <openssl/evp.h>" >> eet_amalgamation.c
@echo "# include <openssl/x509.h>" >> eet_amalgamation.c
@echo "# include <openssl/pem.h>" >> eet_amalgamation.c
@echo "# endif" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#ifdef HAVE_CIPHER" >> eet_amalgamation.c
@echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
@echo "# include <gnutls/x509..h>" >> eet_amalgamation.c
@echo "# include <gcrypt.h>" >> eet_amalgamation.c
@echo "# else" >> eet_amalgamation.c
@echo "# include <openssl/evp.h>" >> eet_amalgamation.c
@echo "# include <openssl/hmac.h>" >> eet_amalgamation.c
@echo "# include <openssl/rand.h>" >> eet_amalgamation.c
@echo "# endif" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#include <zlib.h>" >> eet_amalgamation.c
@echo "#include <jpeglib.h>" >> eet_amalgamation.c
@echo "#ifdef HAVE_EVIL" >> eet_amalgamation.c
@echo "# include <Evil.h>" >> eet_amalgamation.c
@echo "#endif" >> eet_amalgamation.c
@echo "#include <Eet.h>" >> eet_amalgamation.c
@echo "#include \"Eet_private.h\"" >> eet_amalgamation.c
@echo "#include \"Eet.h\"" >> eet_amalgamation.c
@for f in $(base_sources); do \
if [ `expr substr $$f 1 1` != '/' ]; then \
file="$(srcdir)/$$f" ; \
else \
file="$$f" ; \
fi ; \
echo "/* file: $$file */" >> eet_amalgamation.c; \
grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|stdio\|string\|math\|ctype\|limits\|types\|stat\|mman\|setjmp\|errno\|time\|fnmatch\|fcntl\|winsowk2\|unistd\|in\|gnutls\|gcrypt\|x509\|rsa\|objects\|err\|ssl\|dh\|dsa\|evp\|pem\|sha\|hmac\|rand\|zlib\|jpeglib\|Eet_private\|Eet\)[.]h.*' $$file >> eet_amalgamation.c; \
done
@echo "eet_amalgamation.c generated"
else
eet_sources_used = $(base_sources)
endif
libeet_la_SOURCES = $(eet_sources_used)
libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@
libeet_la_LIBADD = @GNUTLS_LIBS@ @OPENSSL_LIBS@ @EFL_COVERAGE_LIBS@ @EET_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ -lz -ljpeg -lm
libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
@ -36,4 +157,4 @@ libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version
EXTRA_DIST = Eet_private.h
clean-local:
@rm -rf *.gcno
@rm -rf *.gcno eet_amalgamation.c

View File

@ -7,9 +7,9 @@
#endif
#if HAVE___ATTRIBUTE__
#define __UNUSED__ __attribute__((unused))
# define __UNUSED__ __attribute__((unused))
#else
#define __UNUSED__
# define __UNUSED__
#endif
#include <stdio.h>
@ -292,7 +292,7 @@ static const Eet_Data_Group_Type_Codec eet_group_codec[] =
{ eet_data_get_hash, eet_data_put_hash }
};
static int words_bigendian = -1;
static int _eet_data_words_bigendian = -1;
/*---*/
@ -314,10 +314,23 @@ static int words_bigendian = -1;
((((short)(x) & 0x00ff ) << 8) |\
(((short)(x) & 0xff00 ) >> 8))
#ifdef CONV8
# undef CONV8
#endif
#ifdef CONV16
# undef CONV16
#endif
#ifdef CONV32
# undef CONV32
#endif
#ifdef CONV64
# undef CONV64
#endif
#define CONV8(x)
#define CONV16(x) {if (words_bigendian) SWAP16(x);}
#define CONV32(x) {if (words_bigendian) SWAP32(x);}
#define CONV64(x) {if (words_bigendian) SWAP64(x);}
#define CONV16(x) {if (_eet_data_words_bigendian) SWAP16(x);}
#define CONV32(x) {if (_eet_data_words_bigendian) SWAP32(x);}
#define CONV64(x) {if (_eet_data_words_bigendian) SWAP64(x);}
#define IS_SIMPLE_TYPE(Type) (Type > EET_T_UNKNOW && Type < EET_T_LAST)
@ -1814,13 +1827,13 @@ _eet_data_dump_encode(Eet_Dictionary *ed,
int csize, size;
Eet_Node *n;
if (words_bigendian == -1)
if (_eet_data_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_data_words_bigendian = 1;
else _eet_data_words_bigendian = 0;
}
if (node == NULL) return NULL;
@ -2335,13 +2348,13 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
int size, i, dump;
Eet_Data_Chunk chnk;
if (words_bigendian == -1)
if (_eet_data_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_data_words_bigendian = 1;
else _eet_data_words_bigendian = 0;
}
if (edd)
@ -2808,6 +2821,10 @@ eet_data_dump_simple_type(int type, const char *name, void *dd,
_eet_data_dump_string_escape(dumpdata, dumpfunc, name);
dumpfunc(dumpdata, "\" ");
#ifdef EET_T_TYPE
# undef EET_T_TYPE
#endif
#define EET_T_TYPE(Eet_Type, Type) \
case Eet_Type: \
{ \
@ -3257,13 +3274,13 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed,
int csize;
int i;
if (words_bigendian == -1)
if (_eet_data_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_data_words_bigendian = 1;
else _eet_data_words_bigendian = 0;
}
ds = eet_data_stream_new();

View File

@ -217,7 +217,7 @@ static void *eet_data_image_jpeg_alpha_convert(int *size, const void *data, unsi
/*---*/
static int words_bigendian = -1;
static int _eet_image_words_bigendian = -1;
/*---*/
@ -239,10 +239,23 @@ static int words_bigendian = -1;
((((short)(x) & 0x00ff ) << 8) |\
(((short)(x) & 0xff00 ) >> 8))
#ifdef CONV8
# undef CONV8
#endif
#ifdef CONV16
# undef CONV16
#endif
#ifdef CONV32
# undef CONV32
#endif
#ifdef CONV64
# undef CONV64
#endif
#define CONV8(x)
#define CONV16(x) {if (words_bigendian) SWAP16(x);}
#define CONV32(x) {if (words_bigendian) SWAP32(x);}
#define CONV64(x) {if (words_bigendian) SWAP64(x);}
#define CONV16(x) {if (_eet_image_words_bigendian) SWAP16(x);}
#define CONV32(x) {if (_eet_image_words_bigendian) SWAP32(x);}
#define CONV64(x) {if (_eet_image_words_bigendian) SWAP64(x);}
/*---*/
@ -546,13 +559,13 @@ eet_data_image_jpeg_alpha_decode(const void *data, int size, unsigned int src_x,
static void *
eet_data_image_lossless_convert(int *size, const void *data, unsigned int w, unsigned int h, int alpha)
{
if (words_bigendian == -1)
if (_eet_image_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_image_words_bigendian = 1;
else _eet_image_words_bigendian = 0;
}
{
unsigned char *d;
@ -571,7 +584,7 @@ eet_data_image_lossless_convert(int *size, const void *data, unsigned int w, uns
memcpy(d + 32, data, w * h * 4);
if (words_bigendian)
if (_eet_image_words_bigendian)
{
unsigned int i;
@ -585,13 +598,13 @@ eet_data_image_lossless_convert(int *size, const void *data, unsigned int w, uns
static void *
eet_data_image_lossless_compressed_convert(int *size, const void *data, unsigned int w, unsigned int h, int alpha, int compression)
{
if (words_bigendian == -1)
if (_eet_image_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_image_words_bigendian = 1;
else _eet_image_words_bigendian = 0;
}
{
@ -620,7 +633,7 @@ eet_data_image_lossless_compressed_convert(int *size, const void *data, unsigned
header[4] = compression;
memcpy(d + 32, data, w * h * 4);
if (words_bigendian)
if (_eet_image_words_bigendian)
{
unsigned int i;
@ -725,13 +738,13 @@ eet_data_image_jpeg_alpha_convert(int *size, const void *data, unsigned int w, u
(void) alpha; /* unused */
if (words_bigendian == -1)
if (_eet_image_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_image_words_bigendian = 1;
else _eet_image_words_bigendian = 0;
}
{
@ -876,7 +889,7 @@ eet_data_image_jpeg_alpha_convert(int *size, const void *data, unsigned int w, u
header[0] = 0xbeeff00d;
header[1] = sz1;
header[2] = sz2;
if (words_bigendian)
if (_eet_image_words_bigendian)
{
int i;
@ -1090,19 +1103,19 @@ eet_data_image_header_decode_cipher(const void *data, const char *key, int size,
if (deciphered_d) free(deciphered_d);
}
if (words_bigendian == -1)
if (_eet_image_words_bigendian == -1)
{
unsigned long int v;
v = htonl(0x12345678);
if (v == 0x12345678) words_bigendian = 1;
else words_bigendian = 0;
if (v == 0x12345678) _eet_image_words_bigendian = 1;
else _eet_image_words_bigendian = 0;
}
if (size < 32) return 0;
memcpy(header, data, 32);
if (words_bigendian)
if (_eet_image_words_bigendian)
{
int i;
@ -1239,7 +1252,7 @@ _eet_data_image_decode_inside(const void *data, int size, unsigned int src_x, un
}
/* Fix swapiness. */
if (words_bigendian)
if (_eet_image_words_bigendian)
{
unsigned int x;
@ -1255,7 +1268,7 @@ _eet_data_image_decode_inside(const void *data, int size, unsigned int src_x, un
int sz1, sz2;
memcpy(header, data, 32);
if (words_bigendian)
if (_eet_image_words_bigendian)
{
int i;

View File

@ -316,6 +316,10 @@ eet_node_dump_simple_type(Eet_Node *n, int level,
eet_node_dump_string_escape(dumpdata, dumpfunc, n->name);
dumpfunc(dumpdata, "\" ");
#ifdef EET_T_TYPE
# undef EET_T_TYPE
#endif
#define EET_T_TYPE(Eet_Type, Type) \
case Eet_Type: \
{ \