Просмотр исходного кода

2006-08-17 Miguel de Icaza <[email protected]>

	* src/glib.h: A handful of extra macros

	* configure.in, src/eglib-config.h.in: Set some system-specific
	settings that are probed at configure time.



svn path=/trunk/mono/; revision=63949
Miguel de Icaza 19 лет назад
Родитель
Сommit
7c2de2e3a9
5 измененных файлов с 65 добавлено и 23 удалено
  1. 7 0
      eglib/ChangeLog
  2. 0 12
      eglib/TODO
  3. 36 0
      eglib/configure.in
  4. 10 7
      eglib/src/Makefile.am
  5. 12 4
      eglib/src/glib.h

+ 7 - 0
eglib/ChangeLog

@@ -1,3 +1,10 @@
+2006-08-17  Miguel de Icaza  <[email protected]>
+
+	* src/glib.h: A handful of extra macros
+
+	* configure.in, src/eglib-config.h.in: Set some system-specific
+	settings that are probed at configure time.
+
 2006-08-17  Aaron Bockover  <[email protected]>
 
 	* src/gptrarray.c: Added beginnings of GPtrArray (alloc, free, add, iterate)

+ 0 - 12
eglib/TODO

@@ -140,35 +140,23 @@ Routines missing from eglib, by count number:
       1 g_get_prgname
       1 g_get_charset
       1 g_filename_from_utf8
-      1 g_bit_nth_msf
       1 g_ascii_strdown
       1 g_ascii_isprint
       1 g_array_remove_index
 
 Macros:
-    124 G_GNUC_PRETTY_FUNCTION
      40 G_GSIZE_FORMAT
-     40 G_GNUC_UNUSED
-     20 G_LITTLE_ENDIAN
-     16 G_DIR_SEPARATOR_S
-     12 G_BREAKPOINT
-     10 G_STMT_START
-     10 G_STMT_END
       9 G_GUINT64_FORMAT
       7 G_FILE_TEST_IS_DIR
       6 G_UNLIKELY
       6 G_HASH_TABLE_RESIZE
-      6 G_DIR_SEPARATOR
       5 G_UNLOCK
       5 G_LOCK
       4 G_LIKELY
-      4 G_GNUC_NORETURN
       4 G_FILE_TEST_IS_REGULAR
-      3 G_SEARCHPATH_SEPARATOR_S
       2 G_USEC_PER_SEC
       2 G_STRLOC
       2 G_IO_NVAL
-      2 G_BIG_ENDIAN
       1 G_SPAWN_SEARCH_PATH
       1 G_IO_PRI
       1 G_ALLOC_ONLY

+ 36 - 0
eglib/configure.in

@@ -10,8 +10,44 @@ AM_PROG_LIBTOOL
 CFLAGS='-g -O0'
 AC_SUBST(CFLAGS)
 
+GNUC_PRETTY=
+GNUC_UNUSED=
+BREAKPOINT=
+if test x$GCC = xyes; then
+   GNUC_PRETTY=__PRETTY_FUNCTION__
+   GNUC_UNUSED='__attribute__((__unused__))'
+   GNUC_NORETURN='__attribute__((__noreturn__))'
+   case $target in
+     i[3456]86-*)
+       BREAKPOINT="G_STMT_START { __asm__ ("int $03"); } G_STMT_END"
+     ;;
+   esac
+fi
+AC_SUBST(GNUC_PRETTY)
+AC_SUBST(GNUC_UNUSED)
+AC_SUBST(GNUC_NORETURN)
+AC_SUBST(BREAKPOINT)
+
+AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
+AC_SUBST(ORDER)
+
+case $host in
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+    PATHSEP='\\'
+    SEARCHSEP=';'
+    ;;
+*)
+    PATHSEP='/'
+    SEARCHSEP=':'
+    ;;
+esac
+
+AC_SUBST(PATHSEP)
+AC_SUBST(SEARCHSEP)
+
 AC_OUTPUT([
 Makefile
 src/Makefile
+src/eglib-config.h
 test/Makefile
 ])

+ 10 - 7
eglib/src/Makefile.am

@@ -1,13 +1,15 @@
 noinst_LTLIBRARIES = libeglib.la
 
 libeglib_la_SOURCES = \
-	ghashtable.c \
-	gmem.c       \
-	gmodule.c    \
-	goutput.c    \
-	gstr.c       \
-	gslist.c     \
-	gstring.c    \
+	eglib-config.h	\
+	glib.h	     	\	
+	ghashtable.c 	\
+	gmem.c       	\
+	gmodule.c    	\
+	goutput.c    	\
+	gstr.c       	\
+	gslist.c     	\
+	gstring.c    	\
 	gptrarray.c
 
 libeglib_la_CFLAGS = -Wall -Werror -D_FORTIFY_SOURCE=2
@@ -18,3 +20,4 @@ libeglib_la_LIBADD = -lm
 
 MAINTAINERCLEANFILES = Makefile.in
 
+EXTRA_DIST = eglib-config.h.in

+ 12 - 4
eglib/src/glib.h

@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <eglib-config.h>
 
 /*
  * Basic data types
@@ -38,9 +39,16 @@ typedef unsigned char  guchar;
 #define GINT_TO_POINTER(v)     ((gpointer) (v))
 #define GUINT_TO_POINTER(v)    ((gpointer) (v))
 
+#define G_GSIZE_FORMAT "u"
+#define G_LITTLE_ENDIAN 1234
+#define G_BIG_ENDIAN    4321
+#define G_STMT_START    do 
+#define G_STMT_END      while (0)
+
 #define G_STRUCT_OFFSET(p_type,field) \
         ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
 
+
 /*
  * Allocation
  */
@@ -66,8 +74,8 @@ gpointer g_memdup (gconstpointer mem, guint byte_size);
 /*
  * Precondition macros
  */
-#define g_return_if_fail(x)  do { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return; } } while (0) ;
-#define g_return_val_if_fail(x,e)  do { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return (e); } } while (0) ;
+#define g_return_if_fail(x)  G_STMT_START { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
+#define g_return_val_if_fail(x,e)  G_STMT_START { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
 
 /*
  * Hashtables
@@ -103,8 +111,8 @@ guint    g_int_hash     (gconstpointer v1);
 gboolean g_str_equal    (gconstpointer v1, gconstpointer v2);
 guint    g_str_hash     (gconstpointer v1);
 
-#define  g_assert(x)     do { if (!(x)) g_error ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); } while (0)
-#define  g_assert_not_reached() do { g_error ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } while (0)
+#define  g_assert(x)     G_STMT_START { if (!(x)) g_error ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x);  } G_STMT_END
+#define  g_assert_not_reached() G_STMT_START { g_error ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } G_STMT_END
 
 /*
  * Strings utility