From: Enlightenment S. <no-...@en...> - 2009-09-16 17:22:14
|
Log: * fix compilation on Windows when using amalgamation * put alloca declaration at the beginning Author: caro Date: 2009-09-16 10:22:01 -0700 (Wed, 16 Sep 2009) New Revision: 42517 Modified: trunk/eina/src/lib/Makefile.am Modified: trunk/eina/src/lib/Makefile.am =================================================================== --- trunk/eina/src/lib/Makefile.am 2009-09-16 16:28:30 UTC (rev 42516) +++ trunk/eina/src/lib/Makefile.am 2009-09-16 17:22:01 UTC (rev 42517) @@ -75,21 +75,41 @@ @echo "#ifndef _WIN32" >> $(builddir)/eina_amalgamation.c @echo "#define _GNU_SOURCE" >> $(builddir)/eina_amalgamation.c + @echo "#endif" >> $(builddir)/eina_amalgamation.c + + @echo "#ifdef HAVE_ALLOCA_H" >> $(builddir)/eina_amalgamation.c + @echo "# include <alloca.h>" >> $(builddir)/eina_amalgamation.c + @echo "#elif defined __GNUC__" >> $(builddir)/eina_amalgamation.c + @echo "# define alloca __builtin_alloca" >> $(builddir)/eina_amalgamation.c + @echo "#elif defined _AIX" >> $(builddir)/eina_amalgamation.c + @echo "# define alloca __alloca" >> $(builddir)/eina_amalgamation.c + @echo "#elif defined _MSC_VER" >> $(builddir)/eina_amalgamation.c + @echo "# include <malloc.h>" >> $(builddir)/eina_amalgamation.c + @echo "# define alloca _alloca" >> $(builddir)/eina_amalgamation.c @echo "#else" >> $(builddir)/eina_amalgamation.c + @echo "# include <stddef.h>" >> $(builddir)/eina_amalgamation.c + @echo "# ifdef __cplusplus" >> $(builddir)/eina_amalgamation.c + @echo "#extern \"C\"" >> $(builddir)/eina_amalgamation.c + @echo "# endif" >> $(builddir)/eina_amalgamation.c + @echo "#void *alloca (size_t);" >> $(builddir)/eina_amalgamation.c + @echo "#endif" >> $(builddir)/eina_amalgamation.c + + @echo "#include <stdio.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <stdlib.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <string.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <dlfcn.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <sys/types.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <dirent.h>" >> $(builddir)/eina_amalgamation.c + @echo "#ifdef HAVE_EVIL" >> $(builddir)/eina_amalgamation.c @echo "# include <Evil.h>" >> $(builddir)/eina_amalgamation.c @echo "#endif" >> $(builddir)/eina_amalgamation.c - @echo "#endif" >> $(builddir)/eina_amalgamation.c @echo "#include \"eina_config.h\"" >> $(builddir)/eina_amalgamation.c @echo "#include \"eina_private.h\"" >> $(builddir)/eina_amalgamation.c @echo "#include \"eina_safety_checks.h\"" >> $(builddir)/eina_amalgamation.c @echo "#include \"Eina.h\"" >> $(builddir)/eina_amalgamation.c - @echo "#include <stdio.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <stdlib.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <string.h>" >> $(builddir)/eina_amalgamation.c - @for f in $(sources_used); do \ if [ `expr substr $$f 1 1` != '/' ]; then \ file="$(srcdir)/$$f" ; \ @@ -97,7 +117,7 @@ file="$$f" ; \ fi ; \ echo "/* file: $$file */" >> $(builddir)/eina_amalgamation.c; \ - grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\)[.]h.*' $$file >> $(builddir)/eina_amalgamation.c; \ + grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\)[.]h.*' $$file >> $(builddir)/eina_amalgamation.c; \ done @echo "eina_amalgamation.c generated" |
From: Enlightenment S. <no-...@en...> - 2009-09-25 08:44:16
|
Log: * add documentation for eina_convert_fptoa() * fix typo in doc Author: caro Date: 2009-09-25 01:44:04 -0700 (Fri, 25 Sep 2009) New Revision: 42691 Modified: trunk/eina/src/lib/eina_convert.c Modified: trunk/eina/src/lib/eina_convert.c =================================================================== --- trunk/eina/src/lib/eina_convert.c 2009-09-25 06:24:48 UTC (rev 42690) +++ trunk/eina/src/lib/eina_convert.c 2009-09-25 08:44:04 UTC (rev 42691) @@ -310,7 +310,7 @@ * converted string is in decimal base. As no check is done, @p s must * be a buffer that is sufficiently large to store the integer. * - * The returned value is the length os the string, including the nul + * The returned value is the length of the string, including the nul * terminated character. */ EAPI int @@ -352,7 +352,7 @@ * cyphers are in lower case. As no check is done, @p s must be a * buffer that is sufficiently large to store the integer. * - * The returned value is the length os the string, including the nul + * The returned value is the length of the string, including the nul * terminated character. */ EAPI int @@ -517,7 +517,7 @@ * * This function converts the double @p d to a string. The string is * stored in the buffer pointed by @p des and must be sufficiently - * large to contain the converted double. The returned string is + * large to contain the converted double. The returned string is nul * terminated and has the following format: * * @code @@ -592,6 +592,33 @@ return length + eina_convert_itoa(p, des); } +/** + * @brief Convert a 32.32 fixed point number to a string + * + * @param fp The fixed point number to convert. + * @param des The destination buffer to store the converted fixed point number. + * @return #EINA_TRUE on success, #EINA_FALSE otherwise. + * + * This function converts the 32.32 fixed point number @fp to a + * string. The string is stored in the buffer pointed by @p des and + * must be sufficiently large to contain the converted fixed point + * number. The returned string is terminated and has the following + * format: + * + * @code + * [-]0xh.hhhhhp[+-]e + * @endcode + * + * where the h are the hexadecimal cyphers of the mantiss and e the + * exponent (a decimal number). + * + * The returned value is the length of the string, including the nul + * character. + * + * @note The code is the same than eina_convert_dtoa() except that it + * implements the frexp() function for fixed point numbers and does + * some optimisations. + */ EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des) { |
From: Enlightenment S. <no-...@en...> - 2009-09-25 11:23:51
|
Log: * convert string to fp only if fp is not NULL * add doc of eina_convert_atofp() * minor doc cleanup Author: caro Date: 2009-09-25 04:23:37 -0700 (Fri, 25 Sep 2009) New Revision: 42697 Modified: trunk/eina/src/lib/eina_convert.c Modified: trunk/eina/src/lib/eina_convert.c =================================================================== --- trunk/eina/src/lib/eina_convert.c 2009-09-25 10:45:26 UTC (rev 42696) +++ trunk/eina/src/lib/eina_convert.c 2009-09-25 11:23:37 UTC (rev 42697) @@ -353,7 +353,7 @@ } /** - * @brief Convert a string to a double + * @brief Convert a string to a double. * * @param src The string to convert. * @param length The length of the string. @@ -487,7 +487,7 @@ } /** - * @brief Convert a double to a string + * @brief Convert a double to a string. * * @param d The double to convert. * @param des The destination buffer to store the converted double. @@ -571,7 +571,7 @@ } /** - * @brief Convert a 32.32 fixed point number to a string + * @brief Convert a 32.32 fixed point number to a string. * * @param fp The fixed point number to convert. * @param des The destination buffer to store the converted fixed point number. @@ -685,22 +685,66 @@ return length + eina_convert_itoa(p, des); } +/** + * @brief Convert a string to a 32.32 fixed point number. + * + * @param src The string to convert. + * @param length The length of the string. + * @param fp The fixed point number. + * @return #EINA_TRUE on success, #EINA_FALSE otherwise. + * + * This function converts the string @p src of length @p length that + * represent a double in hexadecimal base to a 32.32 fixed point + * number stored in @p fp. If @fp is @c NULL, nothing is done and + * #EINA_TRUE is returned. + * + * The string must have the following format: + * + * @code + * [-]0xh.hhhhhp[+-]e + * @endcode + * + * where the h are the hexadecimal cyphers of the mantiss and e the + * exponent (a decimal number). If n is the number of cypers after the + * point, the returned mantiss and exponents are: + * + * @code + * mantiss : [-]hhhhhh + * exponent : 2^([+-]e - 4 * n) + * @endcode + * + * The mantiss and exponent are stored in the buffers pointed + * respectively by @p m and @p e. + * + * If the string is invalid, the error is set to: + * + * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found, + * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found, + * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not + * correct. + * + * In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is + * returned. + * + * @note The code uses eina_convert_atod() and do the correct bit + * shift to compute the fixed point number. + */ EAPI Eina_Bool eina_convert_atofp(const char *src, int length, Eina_F32p32 *fp) { long long m; long e; + if (!fp) + return EINA_TRUE; + if (!eina_convert_atod(src, length, &m, &e)) return EINA_FALSE; - if (fp) - { - e += 32; + e += 32; - if (e > 0) *fp = m << e; - else *fp = m >> e; - } + if (e > 0) *fp = m << e; + else *fp = m >> e; return EINA_TRUE; } |
From: Enlightenment S. <no-...@en...> - 2009-09-25 11:52:07
|
Log: return false if fp is NULL, update doc accordingly Author: caro Date: 2009-09-25 04:51:52 -0700 (Fri, 25 Sep 2009) New Revision: 42699 Modified: trunk/eina/src/lib/eina_convert.c Modified: trunk/eina/src/lib/eina_convert.c =================================================================== --- trunk/eina/src/lib/eina_convert.c 2009-09-25 11:36:56 UTC (rev 42698) +++ trunk/eina/src/lib/eina_convert.c 2009-09-25 11:51:52 UTC (rev 42699) @@ -695,8 +695,8 @@ * * This function converts the string @p src of length @p length that * represent a double in hexadecimal base to a 32.32 fixed point - * number stored in @p fp. If @fp is @c NULL, nothing is done and - * #EINA_TRUE is returned. + * number stored in @p fp. The function always tries to convert the + * string with eina_convert_atod(). * * The string must have the following format: * @@ -723,8 +723,8 @@ * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not * correct. * - * In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * In those cases, or if @p fp is @c NULL, #EINA_FALSE is returned, + * otherwise @p fp is computed and #EINA_TRUE is returned. * * @note The code uses eina_convert_atod() and do the correct bit * shift to compute the fixed point number. @@ -735,10 +735,7 @@ long long m; long e; - if (!fp) - return EINA_TRUE; - - if (!eina_convert_atod(src, length, &m, &e)) + if (!eina_convert_atod(src, length, &m, &e) || !fp) return EINA_FALSE; e += 32; |
From: Enlightenment S. <no-...@en...> - 2009-10-13 17:15:01
|
Log: Add some more headers at the top of eina_amalgamation.c. Fix compilation on Windows CE Author: caro Date: 2009-10-13 10:14:50 -0700 (Tue, 13 Oct 2009) New Revision: 43054 Modified: trunk/eina/src/lib/Makefile.am Modified: trunk/eina/src/lib/Makefile.am =================================================================== --- trunk/eina/src/lib/Makefile.am 2009-10-13 17:11:58 UTC (rev 43053) +++ trunk/eina/src/lib/Makefile.am 2009-10-13 17:14:50 UTC (rev 43054) @@ -101,6 +101,8 @@ @echo "#include <dlfcn.h>" >> $(builddir)/eina_amalgamation.c @echo "#include <sys/types.h>" >> $(builddir)/eina_amalgamation.c @echo "#include <dirent.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <assert.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <errno.h>" >> $(builddir)/eina_amalgamation.c @echo "#ifdef HAVE_EVIL" >> $(builddir)/eina_amalgamation.c @echo "# include <Evil.h>" >> $(builddir)/eina_amalgamation.c @@ -118,7 +120,7 @@ file="$$f" ; \ fi ; \ echo "/* file: $$file */" >> $(builddir)/eina_amalgamation.c; \ - grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\)[.]h.*' $$file >> $(builddir)/eina_amalgamation.c; \ + grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\|dirent\|assert\|errno\)[.]h.*' $$file >> $(builddir)/eina_amalgamation.c; \ done @echo "eina_amalgamation.c generated" |
From: Enlightenment S. <no-...@en...> - 2009-11-01 21:00:39
|
Log: remove useless $(builddir)/ (also confirmed by a autoconf dev), as anyway, '$(builddir)' is always '.' make distcheck passes. Thanks to cantona who reported it. Author: caro Date: 2009-11-01 13:00:22 -0800 (Sun, 01 Nov 2009) New Revision: 43401 Modified: trunk/eina/src/lib/Makefile.am Modified: trunk/eina/src/lib/Makefile.am =================================================================== --- trunk/eina/src/lib/Makefile.am 2009-11-01 20:13:12 UTC (rev 43400) +++ trunk/eina/src/lib/Makefile.am 2009-11-01 21:00:22 UTC (rev 43401) @@ -67,51 +67,51 @@ eina_sources_used = eina_amalgamation.c BUILT_SOURCES = eina_amalgamation.c -$(builddir)/ eina_amalgamation.c: $(sources_used) Makefile - -rm -f $(builddir)/eina_amalgamation.c +eina_amalgamation.c: $(sources_used) Makefile + -rm -f eina_amalgamation.c - @echo "#ifdef HAVE_CONFIG_H" >> $(builddir)/eina_amalgamation.c - @echo "#include \"config.h\"" >> $(builddir)/eina_amalgamation.c - @echo "#endif" >> $(builddir)/eina_amalgamation.c + @echo "#ifdef HAVE_CONFIG_H" >> eina_amalgamation.c + @echo "#include \"config.h\"" >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c - @echo "#ifndef _WIN32" >> $(builddir)/eina_amalgamation.c - @echo "#define _GNU_SOURCE" >> $(builddir)/eina_amalgamation.c - @echo "#endif" >> $(builddir)/eina_amalgamation.c + @echo "#ifndef _WIN32" >> eina_amalgamation.c + @echo "#define _GNU_SOURCE" >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c - @echo "#ifdef HAVE_ALLOCA_H" >> $(builddir)/eina_amalgamation.c - @echo "# include <alloca.h>" >> $(builddir)/eina_amalgamation.c - @echo "#elif defined __GNUC__" >> $(builddir)/eina_amalgamation.c - @echo "# define alloca __builtin_alloca" >> $(builddir)/eina_amalgamation.c - @echo "#elif defined _AIX" >> $(builddir)/eina_amalgamation.c - @echo "# define alloca __alloca" >> $(builddir)/eina_amalgamation.c - @echo "#elif defined _MSC_VER" >> $(builddir)/eina_amalgamation.c - @echo "# include <malloc.h>" >> $(builddir)/eina_amalgamation.c - @echo "# define alloca _alloca" >> $(builddir)/eina_amalgamation.c - @echo "#else" >> $(builddir)/eina_amalgamation.c - @echo "# include <stddef.h>" >> $(builddir)/eina_amalgamation.c - @echo "# ifdef __cplusplus" >> $(builddir)/eina_amalgamation.c - @echo "#extern \"C\"" >> $(builddir)/eina_amalgamation.c - @echo "# endif" >> $(builddir)/eina_amalgamation.c - @echo "#void *alloca (size_t);" >> $(builddir)/eina_amalgamation.c - @echo "#endif" >> $(builddir)/eina_amalgamation.c + @echo "#ifdef HAVE_ALLOCA_H" >> eina_amalgamation.c + @echo "# include <alloca.h>" >> eina_amalgamation.c + @echo "#elif defined __GNUC__" >> eina_amalgamation.c + @echo "# define alloca __builtin_alloca" >> eina_amalgamation.c + @echo "#elif defined _AIX" >> eina_amalgamation.c + @echo "# define alloca __alloca" >> eina_amalgamation.c + @echo "#elif defined _MSC_VER" >> eina_amalgamation.c + @echo "# include <malloc.h>" >> eina_amalgamation.c + @echo "# define alloca _alloca" >> eina_amalgamation.c + @echo "#else" >> eina_amalgamation.c + @echo "# include <stddef.h>" >> eina_amalgamation.c + @echo "# ifdef __cplusplus" >> eina_amalgamation.c + @echo "#extern \"C\"" >> eina_amalgamation.c + @echo "# endif" >> eina_amalgamation.c + @echo "#void *alloca (size_t);" >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c - @echo "#include <stdio.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <stdlib.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <string.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <dlfcn.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <sys/types.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <dirent.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <assert.h>" >> $(builddir)/eina_amalgamation.c - @echo "#include <errno.h>" >> $(builddir)/eina_amalgamation.c + @echo "#include <stdio.h>" >> eina_amalgamation.c + @echo "#include <stdlib.h>" >> eina_amalgamation.c + @echo "#include <string.h>" >> eina_amalgamation.c + @echo "#include <dlfcn.h>" >> eina_amalgamation.c + @echo "#include <sys/types.h>" >> eina_amalgamation.c + @echo "#include <dirent.h>" >> eina_amalgamation.c + @echo "#include <assert.h>" >> eina_amalgamation.c + @echo "#include <errno.h>" >> eina_amalgamation.c - @echo "#ifdef HAVE_EVIL" >> $(builddir)/eina_amalgamation.c - @echo "# include <Evil.h>" >> $(builddir)/eina_amalgamation.c - @echo "#endif" >> $(builddir)/eina_amalgamation.c + @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c + @echo "# include <Evil.h>" >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c - @echo "#include \"eina_config.h\"" >> $(builddir)/eina_amalgamation.c - @echo "#include \"eina_private.h\"" >> $(builddir)/eina_amalgamation.c - @echo "#include \"eina_safety_checks.h\"" >> $(builddir)/eina_amalgamation.c - @echo "#include \"Eina.h\"" >> $(builddir)/eina_amalgamation.c + @echo "#include \"eina_config.h\"" >> eina_amalgamation.c + @echo "#include \"eina_private.h\"" >> eina_amalgamation.c + @echo "#include \"eina_safety_checks.h\"" >> eina_amalgamation.c + @echo "#include \"Eina.h\"" >> eina_amalgamation.c @for f in $(sources_used); do \ if [ `expr substr $$f 1 1` != '/' ]; then \ @@ -119,8 +119,8 @@ else \ file="$$f" ; \ fi ; \ - echo "/* file: $$file */" >> $(builddir)/eina_amalgamation.c; \ - grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\|dirent\|assert\|errno\)[.]h.*' $$file >> $(builddir)/eina_amalgamation.c; \ + echo "/* file: $$file */" >> eina_amalgamation.c; \ + grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\|dirent\|assert\|errno\)[.]h.*' $$file >> eina_amalgamation.c; \ done @echo "eina_amalgamation.c generated" |
From: Enlightenment S. <no-...@en...> - 2009-11-06 01:02:52
|
Log: fix dist/distcheck rule Author: caro Date: 2009-11-05 17:02:35 -0800 (Thu, 05 Nov 2009) New Revision: 43474 Modified: trunk/eina/src/lib/Makefile.am Modified: trunk/eina/src/lib/Makefile.am =================================================================== --- trunk/eina/src/lib/Makefile.am 2009-11-06 00:38:07 UTC (rev 43473) +++ trunk/eina/src/lib/Makefile.am 2009-11-06 01:02:35 UTC (rev 43474) @@ -37,35 +37,32 @@ eina_hamster.c \ eina_safety_checks.c -sources_used = $(base_sources) - if EINA_STATIC_BUILD_CHAINED_POOL -sources_used += $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c +base_sources += $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c endif if EINA_STATIC_BUILD_EMEMOA_FIXED -sources_used += $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c +base_sources += $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c endif if EINA_STATIC_BUILD_EMEMOA_UNKNOWN -sources_used += $(top_srcdir)/src/modules/mp/ememoa_unknown/eina_ememoa_unknown.c +base_sources += $(top_srcdir)/src/modules/mp/ememoa_unknown/eina_ememoa_unknown.c endif if EINA_STATIC_BUILD_FIXED_BITMAP -sources_used += $(top_srcdir)/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c +base_sources += $(top_srcdir)/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c endif if EINA_STATIC_BUILD_PASS_THROUGH -sources_used += $(top_srcdir)/src/modules/mp/pass_through/eina_pass_through.c +base_sources += $(top_srcdir)/src/modules/mp/pass_through/eina_pass_through.c endif lib_LTLIBRARIES = libeina.la if EINA_AMALGAMATION -eina_sources_used = eina_amalgamation.c -BUILT_SOURCES = eina_amalgamation.c +nodist_libeina_la_SOURCES = eina_amalgamation.c -eina_amalgamation.c: $(sources_used) Makefile +eina_amalgamation.c: $(base_sources) Makefile -rm -f eina_amalgamation.c @echo "#ifdef HAVE_CONFIG_H" >> eina_amalgamation.c @@ -111,7 +108,7 @@ @echo "#include \"eina_safety_checks.h\"" >> eina_amalgamation.c @echo "#include \"Eina.h\"" >> eina_amalgamation.c - @for f in $(sources_used); do \ + @for f in $(base_sources); do \ if [ `expr substr $$f 1 1` != '/' ]; then \ file="$(srcdir)/$$f" ; \ else \ @@ -123,10 +120,9 @@ @echo "eina_amalgamation.c generated" else -eina_sources_used = $(sources_used) +libeina_la_SOURCES = $(base_sources) endif -libeina_la_SOURCES = $(eina_sources_used) libeina_la_LIBADD = @EINA_LIBS@ @dlopen_libs@ libeina_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ @EFL_PTHREAD_LIBS@ libeina_la_CFLAGS = @EINA_CFLAGS@ @EFL_PTHREAD_CFLAGS@ |
From: Enlightenment S. <no-...@en...> - 2009-11-07 16:10:14
|
Log: fix compilation of eina_amalgamation.c on Windows Author: caro Date: 2009-11-07 08:09:58 -0800 (Sat, 07 Nov 2009) New Revision: 43513 Modified: trunk/eina/src/lib/Makefile.am Modified: trunk/eina/src/lib/Makefile.am =================================================================== --- trunk/eina/src/lib/Makefile.am 2009-11-07 08:47:57 UTC (rev 43512) +++ trunk/eina/src/lib/Makefile.am 2009-11-07 16:09:58 UTC (rev 43513) @@ -98,6 +98,7 @@ @echo "#include <dirent.h>" >> eina_amalgamation.c @echo "#include <assert.h>" >> eina_amalgamation.c @echo "#include <errno.h>" >> eina_amalgamation.c + @echo "#include <fnmatch.h>" >> eina_amalgamation.c @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c @echo "# include <Evil.h>" >> eina_amalgamation.c @@ -115,7 +116,7 @@ file="$$f" ; \ fi ; \ echo "/* file: $$file */" >> eina_amalgamation.c; \ - grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\|dirent\|assert\|errno\)[.]h.*' $$file >> eina_amalgamation.c; \ + grep -v -e '^# *include \+.\(config\|eina_[a-z_]\+\|Evil\|stdio\|stdlib\|string\|dlfcn\|dirent\|assert\|errno\|fnmatch\)[.]h.*' $$file >> eina_amalgamation.c; \ done @echo "eina_amalgamation.c generated" |
From: Enlightenment S. <no-...@en...> - 2009-11-07 19:44:51
|
Log: fix compilation on OpenBSD Author: caro Date: 2009-11-07 11:44:39 -0800 (Sat, 07 Nov 2009) New Revision: 43516 Modified: trunk/eina/src/lib/eina_cpu.c Modified: trunk/eina/src/lib/eina_cpu.c =================================================================== --- trunk/eina/src/lib/eina_cpu.c 2009-11-07 19:10:08 UTC (rev 43515) +++ trunk/eina/src/lib/eina_cpu.c 2009-11-07 19:44:39 UTC (rev 43516) @@ -28,6 +28,7 @@ # include <unistd.h> # elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) # include <unistd.h> +# include <sys/param.h> # include <sys/sysctl.h> # elif defined (__linux__) # define _GNU_SOURCE |
From: Enlightenment S. <no-...@en...> - 2009-12-09 08:23:46
|
Log: add always config.h in source file so that EAPI is correctly defined, especially on Windows (otherwise, ICE in gcc... and vc++ is not happy at all) Author: caro Date: 2009-12-09 00:23:34 -0800 (Wed, 09 Dec 2009) New Revision: 44317 Modified: trunk/eina/src/lib/eina_fp.c Modified: trunk/eina/src/lib/eina_fp.c =================================================================== --- trunk/eina/src/lib/eina_fp.c 2009-12-09 08:20:37 UTC (rev 44316) +++ trunk/eina/src/lib/eina_fp.c 2009-12-09 08:23:34 UTC (rev 44317) @@ -1,7 +1,12 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> #include <math.h> -#include <stdio.h> -#include "Eina.h" +#include "eina_types.h" +#include "eina_fp.h" #define MAX_PREC 1025 static const Eina_F32p32 eina_trigo[MAX_PREC] = @@ -111,7 +116,7 @@ 0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af, 0x0000000000653d02, 0x0000000000000000 }; -Eina_F32p32 +EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a) { Eina_F32p32 F32P32_2PI; @@ -151,7 +156,7 @@ return result; } -Eina_F32p32 +EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a) { Eina_F32p32 F32P32_2PI; |
From: Enlightenment S. <no-...@en...> - 2009-12-09 08:34:21
|
Log: useless variable if pthread is not used Author: caro Date: 2009-12-09 00:34:09 -0800 (Wed, 09 Dec 2009) New Revision: 44319 Modified: trunk/eina/src/lib/eina_main.c Modified: trunk/eina/src/lib/eina_main.c =================================================================== --- trunk/eina/src/lib/eina_main.c 2009-12-09 08:25:58 UTC (rev 44318) +++ trunk/eina/src/lib/eina_main.c 2009-12-09 08:34:09 UTC (rev 44319) @@ -48,7 +48,9 @@ */ static int _eina_main_count = 0; +#ifdef EFL_HAVE_PTHREAD static int _eina_main_thread_count = 0; +#endif static int _eina_log_dom = -1; #ifdef ERR |
From: Enlightenment S. <no-...@en...> - 2009-12-19 10:30:59
|
Log: include Evil.h so that getenv is declared on Windows CE Author: caro Date: 2009-12-19 02:30:49 -0800 (Sat, 19 Dec 2009) New Revision: 44563 Modified: trunk/eina/src/lib/eina_rectangle.c Modified: trunk/eina/src/lib/eina_rectangle.c =================================================================== --- trunk/eina/src/lib/eina_rectangle.c 2009-12-19 08:39:11 UTC (rev 44562) +++ trunk/eina/src/lib/eina_rectangle.c 2009-12-19 10:30:49 UTC (rev 44563) @@ -23,6 +23,10 @@ #include <stdio.h> #include <stdlib.h> +#ifdef HAVE_EVIL +# include <Evil.h> +#endif + #include "eina_config.h" #include "eina_private.h" #include "eina_magic.h" |
From: Enlightenment S. <no-...@en...> - 2009-12-20 10:02:47
|
Log: support of Debian/kFreeBSD (FreeBSD using the glibc on top of a FreeBSD kernel) Author: caro Date: 2009-12-20 02:02:41 -0800 (Sun, 20 Dec 2009) New Revision: 44597 Modified: trunk/eina/src/lib/eina_cpu.c Modified: trunk/eina/src/lib/eina_cpu.c =================================================================== --- trunk/eina/src/lib/eina_cpu.c 2009-12-20 07:29:57 UTC (rev 44596) +++ trunk/eina/src/lib/eina_cpu.c 2009-12-20 10:02:41 UTC (rev 44597) @@ -30,7 +30,7 @@ # include <unistd.h> # include <sys/param.h> # include <sys/sysctl.h> -# elif defined (__linux__) +# elif defined (__linux__) || defined(__GLIBC__) # define _GNU_SOURCE # include <sched.h> # endif @@ -164,7 +164,7 @@ return cpus; -# elif defined (__linux__) +# elif defined (__linux__) || defined(__GLIBC__) cpu_set_t cpu; int i; static int cpus = 0; |
From: Enlightenment S. <no-...@en...> - 2009-12-25 11:59:53
|
Log: add benchmark tutoriel Author: caro Date: 2009-12-25 03:59:40 -0800 (Fri, 25 Dec 2009) New Revision: 44719 Modified: trunk/eina/src/lib/eina_benchmark.c Modified: trunk/eina/src/lib/eina_benchmark.c =================================================================== --- trunk/eina/src/lib/eina_benchmark.c 2009-12-25 11:30:41 UTC (rev 44718) +++ trunk/eina/src/lib/eina_benchmark.c 2009-12-25 11:59:40 UTC (rev 44719) @@ -20,8 +20,131 @@ /** * @page tutorial_benchmark_page Benchmark Tutorial * - * to be written... + * The Benchmark module allows you to write easily benchmarks + * framework in a project for timing critical part and detect slow + * parts of code. In addition it automatically creates data files of + * these benchmark, as well as a gnuplot file which can display the + * comparison curves of the benchmarks. * + * @section tutorial_benchmark_basic_usage Basic Usage + * + * To create a basic benchmark, you have to follow these steps: + * + * @li Create a new bechmark + * @li Write the functions that wraps the the functions you want to + * bechmark. + * @li Register these wrappers functions. + * @li Run the benchmark. + * @li Free the memory. + * + * Here is a basic example which bechmark which creates two functions + * that will be run. These functions just print a message. + * + * @code + * #include <stdlib.h> + * #include <stdio.h> + * + * #include <Eina.h> + * + * static + * void work1(int request) + * { + * printf ("work1 in progress... Request: %d\n", request); + * } + * + * static + * void work2(int request) + * { + * printf ("work2 in progress... Request: %d\n", request); + * } + * + * int main() + * { + * Eina_Benchmark *test; + * Eina_Array *ea; + * + * if (!eina_init()) + * return EXIT_FAILURE; + * + * test = eina_benchmark_new("test", "run"); + * if (!test) + * goto shutdown_eina; + * + * eina_benchmark_register(test, "work-1", EINA_BENCHMARK(work1), 200, 300, 10); + * eina_benchmark_register(test, "work-2", EINA_BENCHMARK(work2), 100, 150, 5); + * + * ea = eina_benchmark_run(test); + * + * if(ea) + * { + * Eina_Array_Iterator it; + * char *tmp; + * unsigned int i; + * + * EINA_ARRAY_ITER_NEXT(ea, i, tmp, it) + * free(tmp); + * + * eina_array_free(ea); + * } + * + * eina_benchmark_free(test); + * eina_shutdown(); + * + * return EXIT_SUCCESS; + * + * shutdown_eina: + * eina_shutdown(); + * + * return EXIT_FAILURE; + * } + * @endcode + * + * As "test", "run" are passed to eina_benchmark_new() and as the tests + * "work-1" and "work-2" are registered, the data files + * bench_test_run.work-1.data and bench_test_run.work-2.data will be + * created after the eina_benchmark_run() call. They contain four + * columns. The file bench_test_run.work-1.data contains for example: + * + * @code + * # specimen experiment time starting time ending time + * 200 23632 2852446 2876078 + * 210 6924 2883046 2889970 + * 220 6467 2895962 2902429 + * 230 6508 2908271 2914779 + * 240 6278 2920610 2926888 + * 250 6342 2932830 2939172 + * 260 6252 2944954 2951206 + * 270 6463 2956978 2963441 + * 280 6347 2969548 2975895 + * 290 6457 2981702 2988159 + * @endcode + * + * The first column (specimen) is the integer passed to the work1() + * function when the test is run. The second column (experiment time) + * is the time, in nanosecond, that work1() takes. The third and + * fourth columnd are self-explicit. + * + * You can see that the integer passed work1() starts from 200 and + * finishes at 290, with a step of 10. These values are computed withe + * last 3 values passed to eina_benchmark_register(). See the document + * of that function for the detailed behavior. + * + * The Gnuplot file will be named bench_test_run.gnuplot. Just run: + * + * @code + * gnuplot bench_test_run.gnuplot + * @endcode + * + * to create the graphic of the comparison curves. The image file is + * named output_test_run.png. + * + * @section tutorial_benchmark_advanced_usage More Advanced Usage + * + * In this section, several test will be created and run. The idea is + * exactly the same than in the previous section. + * + * to be done. + * */ #ifdef HAVE_CONFIG_H |
From: Enlightenment S. <no-...@en...> - 2010-01-16 16:41:31
|
Log: basename() can modify its argument, so get a copy first Author: caro Date: 2010-01-16 08:41:24 -0800 (Sat, 16 Jan 2010) New Revision: 45228 Modified: trunk/eina/src/lib/eina_module.c Modified: trunk/eina/src/lib/eina_module.c =================================================================== --- trunk/eina/src/lib/eina_module.c 2010-01-16 16:35:52 UTC (rev 45227) +++ trunk/eina/src/lib/eina_module.c 2010-01-16 16:41:24 UTC (rev 45228) @@ -45,6 +45,7 @@ #include <sys/types.h> #include <dirent.h> #include <string.h> +#include <libgen.h> #include <dlfcn.h> @@ -564,10 +565,16 @@ EINA_ARRAY_ITER_NEXT(array, i, m, iterator) { - const char *file_m; + char *file_m; + char *tmp; ssize_t len; - file_m = basename(eina_module_file_get(m)); + /* basename() can modify its argument, so we first get a copie */ + /* do not use strdupa, as opensolaris does not have it */ + len = strlen(eina_module_file_get(m)); + tmp = alloca(len + 1); + memcpy(tmp, eina_module_file_get(m), len + 1); + file_m = basename(tmp); len = strlen(file_m); len -= sizeof(MODULE_EXTENSION) - 1; if (len <= 0) continue; |
From: Enlightenment S. <no-...@en...> - 2010-01-28 10:03:40
|
Log: fix header inclusion Author: caro Date: 2010-01-28 02:03:31 -0800 (Thu, 28 Jan 2010) New Revision: 45655 Modified: trunk/eina/src/lib/eina_log.c trunk/eina/src/lib/eina_main.c trunk/eina/src/lib/eina_stringshare.c Modified: trunk/eina/src/lib/eina_log.c =================================================================== --- trunk/eina/src/lib/eina_log.c 2010-01-28 01:39:34 UTC (rev 45654) +++ trunk/eina/src/lib/eina_log.c 2010-01-28 10:03:31 UTC (rev 45655) @@ -294,7 +294,12 @@ #include <string.h> #include <stdlib.h> #include <fnmatch.h> +#include <assert.h> +#ifdef EFL_HAVE_PTHREAD +# include <pthread.h> +#endif + #ifdef HAVE_EVIL # include <Evil.h> #endif @@ -307,8 +312,6 @@ #include "eina_safety_checks.h" #include "eina_log.h" -#include <assert.h> - /* TODO * + printing logs to stdout or stderr can be implemented * using a queue, useful for multiple threads printing @@ -359,7 +362,6 @@ static int _abort_level_on_critical = EINA_LOG_LEVEL_CRITICAL; #ifdef EFL_HAVE_PTHREAD -#include <pthread.h> static Eina_Bool _threads_enabled = EINA_FALSE; static pthread_t _main_thread; Modified: trunk/eina/src/lib/eina_main.c =================================================================== --- trunk/eina/src/lib/eina_main.c 2010-01-28 01:39:34 UTC (rev 45654) +++ trunk/eina/src/lib/eina_main.c 2010-01-28 10:03:31 UTC (rev 45655) @@ -22,6 +22,10 @@ # include "config.h" #endif +#ifdef EFL_HAVE_PTHREAD +# include <pthread.h> +#endif + #include "eina_config.h" #include "eina_private.h" #include "eina_types.h" @@ -64,7 +68,6 @@ #define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__) #ifdef EFL_HAVE_PTHREAD -#include <pthread.h> static Eina_Bool _threads_activated = EINA_FALSE; static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER; #define LOCK() if(_threads_activated) pthread_mutex_lock(&_mutex); Modified: trunk/eina/src/lib/eina_stringshare.c =================================================================== --- trunk/eina/src/lib/eina_stringshare.c 2010-01-28 01:39:34 UTC (rev 45654) +++ trunk/eina/src/lib/eina_stringshare.c 2010-01-28 10:03:31 UTC (rev 45655) @@ -70,6 +70,10 @@ #include <stdio.h> #include <string.h> +#ifdef EFL_HAVE_PTHREAD +# include <pthread.h> +#endif + #ifdef HAVE_EVIL # include <Evil.h> #endif @@ -177,7 +181,6 @@ #ifdef EFL_HAVE_PTHREAD -#include <pthread.h> static Eina_Bool _stringshare_threads_activated = EINA_FALSE; //string < 4 static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER; |
From: Enlightenment S. <no-...@en...> - 2010-02-11 15:22:50
|
Log: warning-- Author: caro Date: 2010-02-11 07:22:41 -0800 (Thu, 11 Feb 2010) New Revision: 46078 Modified: trunk/eina/src/lib/eina_mempool.c Modified: trunk/eina/src/lib/eina_mempool.c =================================================================== --- trunk/eina/src/lib/eina_mempool.c 2010-02-11 14:41:44 UTC (rev 46077) +++ trunk/eina/src/lib/eina_mempool.c 2010-02-11 15:22:41 UTC (rev 46078) @@ -175,7 +175,7 @@ _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); if (path) free(path); - path = eina_module_symbol_path_get(eina_init, "/eina/modules/mp"); + path = eina_module_symbol_path_get((const void *)eina_init, "/eina/modules/mp"); _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); if (path) free(path); |
From: Enlightenment S. <no-...@en...> - 2010-02-11 15:29:33
|
Log: warnings-- Author: caro Date: 2010-02-11 07:29:20 -0800 (Thu, 11 Feb 2010) New Revision: 46079 Modified: trunk/eina/src/lib/eina_hash.c Modified: trunk/eina/src/lib/eina_hash.c =================================================================== --- trunk/eina/src/lib/eina_hash.c 2010-02-11 15:22:41 UTC (rev 46078) +++ trunk/eina/src/lib/eina_hash.c 2010-02-11 15:29:20 UTC (rev 46079) @@ -265,7 +265,7 @@ /* add the new element to the hash. */ eh->head = eina_rbtree_inline_insert(eh->head, EINA_RBTREE_GET(el), - EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), hash->key_cmp_cb); + EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb); hash->population++; return EINA_TRUE; @@ -314,7 +314,7 @@ el = (Eina_Hash_El*) eina_rbtree_inline_lookup((*eh)->head, tuple, 0, - EINA_RBTREE_CMP_KEY_CB(_eina_hash_key_rbtree_cmp_key_data), hash->key_cmp_cb); + EINA_RBTREE_CMP_KEY_CB(_eina_hash_key_rbtree_cmp_key_data), (const void *)hash->key_cmp_cb); return el; } @@ -368,7 +368,7 @@ static Eina_Bool _eina_hash_del_by_hash_el(Eina_Hash *hash, Eina_Hash_El *el, Eina_Hash_Head *eh, int key_hash) { - eh->head = eina_rbtree_inline_remove(eh->head, EINA_RBTREE_GET(el), EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), hash->key_cmp_cb); + eh->head = eina_rbtree_inline_remove(eh->head, EINA_RBTREE_GET(el), EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb); _eina_hash_el_free(el, hash); if (!eh->head) |
From: Enlightenment S. <no-...@en...> - 2010-02-11 19:02:09
|
Log: missing " Author: caro Date: 2010-02-11 10:54:04 -0800 (Thu, 11 Feb 2010) New Revision: 46087 Modified: trunk/eina/src/lib/eina_magic.c Modified: trunk/eina/src/lib/eina_magic.c =================================================================== --- trunk/eina/src/lib/eina_magic.c 2010-02-11 18:49:12 UTC (rev 46086) +++ trunk/eina/src/lib/eina_magic.c 2010-02-11 18:54:04 UTC (rev 46087) @@ -232,7 +232,7 @@ _eina_magic_strings_find_cmp); if (ems) return ems->string ? ems->string : "(undefined)"; - return "(unknown); + return "(unknown)"; } /** |
From: Enlightenment S. <no-...@en...> - 2010-02-19 14:02:08
|
Log: add mempool description in the doc Author: caro Date: 2010-02-19 05:42:34 -0800 (Fri, 19 Feb 2010) New Revision: 46307 Modified: trunk/eina/src/lib/eina_mempool.c Modified: trunk/eina/src/lib/eina_mempool.c =================================================================== --- trunk/eina/src/lib/eina_mempool.c 2010-02-19 12:30:57 UTC (rev 46306) +++ trunk/eina/src/lib/eina_mempool.c 2010-02-19 13:42:34 UTC (rev 46307) @@ -261,6 +261,31 @@ * * @brief These functions provide memory pool management. * + * Several mempool are available: + * + * @li @c buddy: It uses the + * <a href="http://en.wikipedia.org/wiki/Buddy_memory_allocation">"buddy + * allocator" algorithm</a> but the Eina implementation differs in the + * sense that the chunk information is not stored on the chunk itself, + * but on another memory area. This is useful for cases where the + * momery to manage might be slower to access, or limited (like video + * memory). + * @li @c chained_pool: It is the default one. It allocates a big + * chunk of memory with malloc() and split the result in chnks of the + * requested size that are pushed inside a stack. When requested, t + * takes this pointer from the stack to give them to whoever wants + * them. + * @li @c ememoa_fixed and @c ememoa_unknown: experimental allocators + * which could be useful when a fixed amount of memory is needed. + * @li @c fixed_bitmap: It alocates with malloc) 32* the requested + * size and push the pool pointer in an rbtree. To find empty space in + * a pool, it will just search for the first bit set in an int (32 + * bits). Then, when a pointer is freed, it will do a search inside + * the rbtree. + * @li @c pass_through: it just call malloc() and free(). It may be + * faster on some computers than using our own allocators (like having + * a huge L2 cache, over 4MB). + * * @{ */ |
From: Enlightenment S. <no-...@en...> - 2010-03-23 05:45:42
|
Log: * declare variables at the beginning of the block * minor formatting Author: caro Date: 2010-03-22 22:45:35 -0700 (Mon, 22 Mar 2010) New Revision: 47383 Modified: trunk/eina/src/lib/eina_strbuf.c Modified: trunk/eina/src/lib/eina_strbuf.c =================================================================== --- trunk/eina/src/lib/eina_strbuf.c 2010-03-23 05:17:09 UTC (rev 47382) +++ trunk/eina/src/lib/eina_strbuf.c 2010-03-23 05:45:35 UTC (rev 47383) @@ -293,6 +293,7 @@ { EINA_MAGIC_CHECK_STRBUF(buf); EINA_MAGIC_SET(buf, EINA_MAGIC_NONE); + free(buf->buf); free(buf); } @@ -708,6 +709,7 @@ eina_strbuf_string_steal(Eina_Strbuf *buf) { char *ret; + EINA_MAGIC_CHECK_STRBUF(buf, NULL); ret = buf->buf; @@ -747,14 +749,14 @@ EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) { + size_t len1, len2; + char *spos; + size_t pos; + EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE); EINA_MAGIC_CHECK_STRBUF(buf, 0); - size_t len1, len2; - char *spos; - size_t pos; - if (n == 0) return EINA_FALSE; @@ -802,10 +804,6 @@ EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) { - EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0); - EINA_MAGIC_CHECK_STRBUF(buf, 0); - size_t len1, len2, len; char *tmp_buf = NULL; char *spos; @@ -813,6 +811,10 @@ size_t pos_tmp, start_tmp; int n = 0; + EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0); + EINA_MAGIC_CHECK_STRBUF(buf, 0); + spos = strstr(buf->buf, str); if (!spos || *spos == '\0') return 0; |
From: Enlightenment S. <no-...@en...> - 2010-03-26 07:47:18
|
Log: declare buddy init/shutdown functions it this mempool is statically linked Author: caro Date: 2010-03-26 00:47:11 -0700 (Fri, 26 Mar 2010) New Revision: 47484 Modified: trunk/eina/src/lib/eina_mempool.c Modified: trunk/eina/src/lib/eina_mempool.c =================================================================== --- trunk/eina/src/lib/eina_mempool.c 2010-03-26 06:47:55 UTC (rev 47483) +++ trunk/eina/src/lib/eina_mempool.c 2010-03-26 07:47:11 UTC (rev 47484) @@ -113,6 +113,11 @@ void fixed_bitmap_shutdown(void); #endif +#ifdef EINA_STATIC_BUILD_BUDDY +Eina_Bool buddy_init(void); +void buddy_shutdown(void); +#endif + /** * @endcond */ |
From: Enlightenment S. <no-...@en...> - 2010-03-26 08:08:59
|
Log: add colored log on Windows with the DOS console and MSYS without rxvt emulation. It does not work with MSYS with rxvt emulation. I don't know the status of the cygwin terminal. Author: caro Date: 2010-03-26 01:08:52 -0700 (Fri, 26 Mar 2010) New Revision: 47486 Modified: trunk/eina/src/lib/eina_log.c Modified: trunk/eina/src/lib/eina_log.c =================================================================== --- trunk/eina/src/lib/eina_log.c 2010-03-26 08:05:02 UTC (rev 47485) +++ trunk/eina/src/lib/eina_log.c 2010-03-26 08:08:52 UTC (rev 47486) @@ -423,6 +423,73 @@ "DBG", }; +#ifdef _WIN32 +static int +eina_log_win32_color_get(const char *domain_str) +{ + char *str; + char *tmp; + char *tmp2; + int code = -1; + int lighted = 0; + int ret = 0; + + str = strdup(domain_str); + if (!str) + return 0; + + /* this should not append */ + if (str[0] != '\033') + return 0; + + /* we skip the first char and the [ */ + tmp = tmp2 = str + 2; + while (*tmp != 'm') + { + if (*tmp == ';') + { + *tmp = '\0'; + code = atol(tmp2); + tmp++; + tmp2 = tmp; + } + tmp++; + } + *tmp = '\0'; + if (code < 0) + code = atol(tmp2); + else + lighted = atol(tmp2); + + free(str); + + if (code < lighted) + { + int c; + + c = code; + code = lighted; + lighted = c; + } + + if (lighted) ret = FOREGROUND_INTENSITY; + if (code == 31) + ret |= FOREGROUND_RED; + else if (code == 32) + ret |= FOREGROUND_GREEN; + else if (code == 33) + ret |= FOREGROUND_RED | FOREGROUND_GREEN; + else if (code == 34) + ret |= FOREGROUND_BLUE; + else if (code == 36) + ret |= FOREGROUND_GREEN | FOREGROUND_BLUE; + else if (code == 37) + ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + + return ret; +} +#endif + static inline void eina_log_print_level_name_get(int level, const char **p_name) { @@ -445,7 +512,33 @@ *p_name = _names[level]; } +#ifdef _WIN32 static inline void +eina_log_print_level_name_color_get(int level, const char **p_name, int *p_color) +{ + static char buf[4]; + /* NOTE: if you change this, also change: + * eina_log_print_level_name_get() + */ + if (EINA_UNLIKELY(level < 0)) + { + snprintf(buf, sizeof(buf), "%03d", level); + *p_name = buf; + } + else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS)) + { + snprintf(buf, sizeof(buf), "%03d", level); + *p_name = buf; + } + else + { + *p_name = _names[level]; + } + + *p_color = eina_log_win32_color_get(eina_log_level_color_get(level)); +} +#else +static inline void eina_log_print_level_name_color_get(int level, const char **p_name, const char **p_color) { static char buf[4]; @@ -468,9 +561,14 @@ } *p_color = eina_log_level_color_get(level); } +#endif #define DECLARE_LEVEL_NAME(level) const char *name; eina_log_print_level_name_get(level, &name) -#define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; eina_log_print_level_name_color_get(level, &name, &color) +#ifdef _WIN32 +# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; eina_log_print_level_name_color_get(level, &name, &color) +#else +# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; eina_log_print_level_name_color_get(level, &name, &color) +#endif /** No threads, No color */ static void @@ -499,26 +597,77 @@ eina_log_print_prefix_NOthreads_color_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line) { DECLARE_LEVEL_NAME_COLOR(level); +#ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " %s:%d ", file, line); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%s()", fnc); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " "); +#else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, file, line, fnc); +#endif } static void eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__) { DECLARE_LEVEL_NAME_COLOR(level); +#ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%s()", fnc); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " "); +#else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, fnc); +#endif } static void eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line) { DECLARE_LEVEL_NAME_COLOR(level); +#ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " %s:%d ", file, line); +#else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ", color, name, d->domain_str, file, line); +#endif } /** threads, No color */ @@ -573,15 +722,45 @@ pthread_t cur = pthread_self(); if (IS_OTHER(cur)) { +# ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s[T:", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "[T:"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%lu", (unsigned long)cur.p); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "] %s:%d ", file, line); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%s()", fnc); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " "); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:" EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, cur, file, line, fnc); +# endif return; } +# ifdef _WIN32 + eina_log_print_prefix_NOthreads_color_file_func(fp, d, level, file, fnc, line); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, file, line, fnc); +# endif } static void @@ -591,15 +770,42 @@ pthread_t cur = pthread_self(); if (IS_OTHER(cur)) { +# ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s[T:", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "[T:"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%lu", (unsigned long)cur.p); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%s()", fnc); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, " "); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:" EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, cur, fnc); +# endif return; } +# ifdef _WIN32 + eina_log_print_prefix_NOthreads_color_NOfile_func(fp, d, level, file, fnc, line); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s " EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ", color, name, d->domain_str, fnc); +# endif } static void @@ -609,13 +815,37 @@ pthread_t cur = pthread_self(); if (IS_OTHER(cur)) { +# ifdef _WIN32 + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + color); + fprintf(fp, "%s", name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, ":"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str)); + fprintf(fp, "%s[T:", d->name); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "[T:"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "%lu", (unsigned long)cur.p); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fprintf(fp, "] %s:%d ", file, line); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:" EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ", color, name, d->domain_str, cur, file, line); +# endif return; } +# ifdef _WIN32 + eina_log_print_prefix_NOthreads_color_file_NOfunc(fp, d, level, file, fnc, line); +# else fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ", color, name, d->domain_str, file, line); +# endif } #endif @@ -995,6 +1225,7 @@ if (color_disable == 1) _disable_color = EINA_TRUE; +#ifndef _WIN32 /* color was not explicitly disabled or enabled, guess it */ else if (color_disable == -1) { @@ -1015,6 +1246,7 @@ _disable_color = EINA_TRUE; } } +#endif if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1)) _disable_file = EINA_TRUE; |
From: Enlightenment S. <no-...@en...> - 2010-04-15 06:13:15
|
Log: include private headers after standard headers Author: caro Date: 2010-04-14 23:13:08 -0700 (Wed, 14 Apr 2010) New Revision: 48013 Modified: trunk/eina/src/lib/eina_strbuf.c Modified: trunk/eina/src/lib/eina_strbuf.c =================================================================== --- trunk/eina/src/lib/eina_strbuf.c 2010-04-15 06:03:37 UTC (rev 48012) +++ trunk/eina/src/lib/eina_strbuf.c 2010-04-15 06:13:08 UTC (rev 48013) @@ -8,6 +8,10 @@ # include "config.h" #endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "eina_private.h" #include "eina_str.h" #include "eina_magic.h" @@ -15,10 +19,6 @@ #include "eina_safety_checks.h" #include "eina_strbuf.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - /*============================================================================* * Local * *============================================================================*/ |
From: Enlightenment S. <no-...@en...> - 2010-04-15 06:17:06
|
Log: include Evil.h with vc++ for vasprintf Author: caro Date: 2010-04-14 23:16:59 -0700 (Wed, 14 Apr 2010) New Revision: 48014 Modified: trunk/eina/src/lib/eina_strbuf.c Modified: trunk/eina/src/lib/eina_strbuf.c =================================================================== --- trunk/eina/src/lib/eina_strbuf.c 2010-04-15 06:13:08 UTC (rev 48013) +++ trunk/eina/src/lib/eina_strbuf.c 2010-04-15 06:16:59 UTC (rev 48014) @@ -12,6 +12,10 @@ #include <stdlib.h> #include <string.h> +#ifdef _MSC_VER +# include <Evil.h> +#endif + #include "eina_private.h" #include "eina_str.h" #include "eina_magic.h" |