[xiph-commits] r15794 - in trunk/ezstream: . src win32

moritz at svn.xiph.org moritz at svn.xiph.org
Wed Mar 18 02:10:29 PDT 2009


Author: moritz
Date: 2009-03-18 02:10:28 -0700 (Wed, 18 Mar 2009)
New Revision: 15794

Added:
   trunk/ezstream/src/ezstream.h
Removed:
   trunk/ezstream/src/compat.h
Modified:
   trunk/ezstream/configure.in
   trunk/ezstream/src/Makefile.am
   trunk/ezstream/src/compat.c
   trunk/ezstream/src/configfile.c
   trunk/ezstream/src/ezstream.c
   trunk/ezstream/src/getopt.c
   trunk/ezstream/src/metadata.c
   trunk/ezstream/src/playlist.c
   trunk/ezstream/src/util.c
   trunk/ezstream/src/xalloc.c
   trunk/ezstream/src/xalloc.h
   trunk/ezstream/win32/compat.h
Log:
Work towards cleaner portability goo, and remove some ununsed code while there.


Modified: trunk/ezstream/configure.in
===================================================================
--- trunk/ezstream/configure.in	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/configure.in	2009-03-18 09:10:28 UTC (rev 15794)
@@ -227,6 +227,7 @@
 
 AC_CHECK_FUNCS([ \
 	arc4random \
+	basename \
 	gettimeofday \
 	getopt \
 	nl_langinfo \

Modified: trunk/ezstream/src/Makefile.am
===================================================================
--- trunk/ezstream/src/Makefile.am	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/Makefile.am	2009-03-18 09:10:28 UTC (rev 15794)
@@ -19,8 +19,8 @@
 AM_LDFLAGS	 = @EZ_LDFLAGS@
 
 EXTRA_DIST	 = \
-	compat.h \
 	configfile.h \
+	ezstream.h \
 	metadata.h \
 	playlist.h \
 	strfctns.h \

Modified: trunk/ezstream/src/compat.c
===================================================================
--- trunk/ezstream/src/compat.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/compat.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -1,5 +1,48 @@
 /*	$Id$	*/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "ezstream.h"
+
+#if defined(HAVE_LIBGEN_H) && !defined(__linux__)
+# include <libgen.h>
+#endif /* HAVE_LIBGEN_H && !__linux__ */
+
+#ifndef PATH_MAX
+# define PATH_MAX		256
+#endif /* !PATH_MAX */
+
+#ifndef PATH_SEPARATORS
+# define PATH_SEPARATORS	"/"
+#endif /* !PATH_SEPARATORS */
+
+char *	local_basename(const char *);
+
+static const char	*path_separators = PATH_SEPARATORS;
+
+static inline int
+	is_separator(int);
+
+static inline int
+is_separator(int c)
+{
+	const char	*cp;
+
+	for (cp = path_separators; '\0' != *cp; cp++) {
+		if (*cp == c)
+			return (1);
+	}
+
+	return (0);
+}
+
 /*
+ * Modified basename() implementation from OpenBSD, based on:
+ * $OpenBSD: src/lib/libc/gen/basename.c,v 1.14 2005/08/08 08:05:33 espie Exp $
+ */
+/*
  * Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller at courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -14,27 +57,12 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <errno.h>
-#include <limits.h>
-#include <string.h>
-
-#include "compat.h"
-
-/*
- * Modified basename() implementation from OpenBSD, based on:
- * $OpenBSD: src/lib/libc/gen/basename.c,v 1.14 2005/08/08 08:05:33 espie Exp $
- */
 char *
 local_basename(const char *path)
 {
+#ifdef HAVE_BASENAME
+	return (basename(path));
+#else /* HAVE_BASENAME */
 	static char	 bname[PATH_MAX];
 	size_t		 len;
 	const char	*startp, *endp;
@@ -45,13 +73,16 @@
 		return (bname);
 	}
 
-	/* Strip any trailing slashes */
+	/* Strip any trailing path separators */
 	endp = path + strlen(path) - 1;
-	while (endp > path && *endp == PATH_SEPARATOR)
+	while (endp > path && is_separator(*endp))
 		endp--;
 
-	/* All slashes become "\" */
-	if (endp == path && *endp == PATH_SEPARATOR) {
+	/*
+	 * All path separators become a single one; pick the first in the
+	 * list as the default.
+	 */
+	if (endp == path && is_separator(*endp)) {
 		bname[0] = PATH_SEPARATOR;
 		bname[1] = '\0';
 		return (bname);
@@ -59,7 +90,7 @@
 
 	/* Find the start of the base */
 	startp = endp;
-	while (startp > path && *(startp - 1) != PATH_SEPARATOR)
+	while (startp > path && !is_separator(*(startp - 1)))
 		startp--;
 
 	len = endp - startp + 1;
@@ -71,4 +102,5 @@
 	bname[len] = '\0';
 
 	return (bname);
+#endif /* HAVE_BASENAME */
 }

Deleted: trunk/ezstream/src/compat.h
===================================================================
--- trunk/ezstream/src/compat.h	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/compat.h	2009-03-18 09:10:28 UTC (rev 15794)
@@ -1,95 +0,0 @@
-/*	$Id$	*/
-/*
- * Copyright (c) 2007, 2009 Moritz Grimm <mdgrimm at gmx.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef __COMPAT_H__
-#define __COMPAT_H__
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifndef PATH_SEPARATOR
-# ifdef WIN32
-#  define PATH_SEPARATOR	'\\'
-# else
-#  define PATH_SEPARATOR	'/'
-# endif /* WIN32 */
-#endif /* !PATH_SEPARATOR */
-
-#ifndef PATH_MAX
-# define PATH_MAX	256
-#endif /* !PATH_MAX */
-
-/* Sometimes defined through <limits.h>. */
-#ifndef SIZE_T_MAX
-# define SIZE_T_MAX	((size_t)-1)
-#endif /* !SIZE_T_MAX */
-
-#ifdef WIN32
-# include <windows.h>
-
-# define _PATH_DEVNULL	"nul"
-
-# define pclose 	_pclose
-# define popen		_popen
-# define snprintf	_snprintf
-# define stat		_stat
-# define strncasecmp	strnicmp
-# ifndef __GNUC__
-#  define strtoll	_strtoi64
-# endif /* !__GNUC__ */
-
-# define S_IRGRP	0
-# define S_IROTH	0
-# define S_IWGRP	0
-# define S_IWOTH	0
-# define S_IXGRP	0
-# define S_IXOTH	0
-
-# define basename	local_basename
-# define sleep(a)	Sleep((a) * 1000)
-#endif /* WIN32 */
-
-/* Usually defined in <sys/stat.h>. */
-#ifndef S_IEXEC
-# define S_IEXEC	S_IXUSR
-#endif /* !S_IEXEC */
-
-/* For Solaris, possibly others (usually defined in <paths.h>.) */
-#ifndef _PATH_DEVNULL
-# define _PATH_DEVNULL	"/dev/null"
-#endif /* !_PATH_DEVNULL */
-
-#ifndef HAVE_STRUCT_TIMEVAL
-struct timeval {
-	long	tv_sec;
-	long	tv_usec;
-};
-#endif
-
-extern int	 opterr;
-extern int	 optind;
-extern int	 optopt;
-extern int	 optreset;
-extern char	*optarg;
-
-extern int
-	local_getopt(int, char * const *, const char *);
-
-char *	local_basename(const char *);
-
-#endif /* __COMPAT_H__ */

Modified: trunk/ezstream/src/configfile.c
===================================================================
--- trunk/ezstream/src/configfile.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/configfile.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -22,12 +22,8 @@
 # include "config.h"
 #endif
 
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
+#include "ezstream.h"
 
-#include "compat.h"
 #include "configfile.h"
 #include "strfctns.h"
 #include "util.h"

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/ezstream.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -22,37 +22,14 @@
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef HAVE_LIBGEN_H
-# include <libgen.h>
-#endif
-#include <limits.h>
-#ifdef HAVE_PATHS_H
-# include <paths.h>
-#endif
+#include "ezstream.h"
+
 #ifdef HAVE_SIGNAL_H
 # include <signal.h>
 #endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+
 #include <shout/shout.h>
 
-#include "compat.h"
 #include "configfile.h"
 #include "metadata.h"
 #include "playlist.h"
@@ -833,7 +810,7 @@
 				if (pezConfig->fileNameIsProgram) {
 					char *tmp = xstrdup(pezConfig->fileName);
 					printf("  [%s]",
-					       basename(tmp));
+					       local_basename(tmp));
 					xfree(tmp);
 				} else
 					printf("  [%4lu/%-4lu]",

Copied: trunk/ezstream/src/ezstream.h (from rev 15793, trunk/ezstream/src/compat.h)
===================================================================
--- trunk/ezstream/src/ezstream.h	                        (rev 0)
+++ trunk/ezstream/src/ezstream.h	2009-03-18 09:10:28 UTC (rev 15794)
@@ -0,0 +1,104 @@
+/*	$Id$	*/
+/*
+ * Copyright (c) 2007, 2009 Moritz Grimm <mdgrimm at gmx.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef __COMPAT_H__
+#define __COMPAT_H__
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#else /* HAVE_SYS_TIME_H */
+# include <time.h>
+#endif /* HAVE_SYS_TIME_H */
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#ifdef HAVE_PATHS_H
+# include <paths.h>
+#endif /* HAVE_PATHS_H */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifndef _PATH_DEVNULL
+# ifdef WIN32
+#  define _PATH_DEVNULL 	"nul"
+# else /* WIN32 */
+#  define _PATH_DEVNULL 	"/dev/null"
+# endif /* WIN32 */
+#endif /* !_PATH_DEVNULL */
+
+#ifdef WIN32
+# include <windows.h>
+
+# define pclose 	_pclose
+# define popen		_popen
+# define snprintf	_snprintf
+# define stat		_stat
+# define strncasecmp	strnicmp
+# ifndef __GNUC__
+#  define strtoll	_strtoi64
+# endif /* !__GNUC__ */
+
+# define S_IRGRP	0
+# define S_IROTH	0
+# define S_IWGRP	0
+# define S_IWOTH	0
+# define S_IXGRP	0
+# define S_IXOTH	0
+
+# define sleep(a)	Sleep((a) * 1000)
+#endif /* WIN32 */
+
+#ifndef HAVE_STRUCT_TIMEVAL
+struct timeval {
+	long	tv_sec;
+	long	tv_usec;
+};
+#endif
+
+/*
+ * For compat.c and getopt.c:
+ */
+
+extern int	 opterr;
+extern int	 optind;
+extern int	 optopt;
+extern int	 optreset;
+extern char	*optarg;
+
+extern int
+	local_getopt(int, char * const *, const char *);
+extern char *
+	local_basename(const char *);
+
+#endif /* __COMPAT_H__ */

Modified: trunk/ezstream/src/getopt.c
===================================================================
--- trunk/ezstream/src/getopt.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/getopt.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -54,16 +54,8 @@
 # include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif /* HAVE_UNISTD_H */
+#include "ezstream.h"
 
-#include "compat.h"
-
 int	local_getopt(int, char * const *, const char *);
 
 #ifndef HAVE_GETOPT

Modified: trunk/ezstream/src/metadata.c
===================================================================
--- trunk/ezstream/src/metadata.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/metadata.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -19,20 +19,7 @@
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#include <ctype.h>
-#include <errno.h>
-#ifdef HAVE_LIBGEN_H
-# include <libgen.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "ezstream.h"
 
 #ifdef HAVE_TAGLIB
 # include <taglib/tag_c.h>
@@ -42,12 +29,16 @@
 #endif /* HAVE_VORBISFILE */
 #include <shout/shout.h>
 
-#include "compat.h"
 #include "metadata.h"
 #include "strfctns.h"
 #include "util.h"
 #include "xalloc.h"
 
+/* Usually defined in <sys/stat.h>. */
+#ifndef S_IEXEC
+# define S_IEXEC	S_IXUSR
+#endif /* !S_IEXEC */
+
 extern char		*__progname;
 extern int		 vFlag;
 
@@ -314,7 +305,7 @@
 		abort();
 	}
 
-	if ((p1 = basename(filename)) == NULL) {
+	if ((p1 = local_basename(filename)) == NULL) {
 		printf("%s: Internal error: basename() failed with '%s'\n",
 		       __progname, filename);
 		exit(1);

Modified: trunk/ezstream/src/playlist.c
===================================================================
--- trunk/ezstream/src/playlist.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/playlist.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -19,23 +19,16 @@
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include "ezstream.h"
 
-#include "compat.h"
 #include "playlist.h"
 #include "xalloc.h"
 
+/* Usually defined in <sys/stat.h>. */
+#ifndef S_IEXEC
+# define S_IEXEC	S_IXUSR
+#endif /* !S_IEXEC */
+
 extern char	*__progname;
 
 struct playlist {

Modified: trunk/ezstream/src/util.c
===================================================================
--- trunk/ezstream/src/util.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/util.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -27,32 +27,20 @@
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
+#include "ezstream.h"
 
-#include <ctype.h>
-#include <errno.h>
 #ifdef HAVE_LANGINFO_H
 # include <langinfo.h>
 #endif
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
 #endif
-#include <stdio.h>
-#include <string.h>
 
 #ifdef HAVE_ICONV
 # include <iconv.h>
 #endif
 #include <shout/shout.h>
 
-#include "compat.h"
 #include "util.h"
 #include "configfile.h"
 #include "xalloc.h"

Modified: trunk/ezstream/src/xalloc.c
===================================================================
--- trunk/ezstream/src/xalloc.c	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/xalloc.c	2009-03-18 09:10:28 UTC (rev 15794)
@@ -19,15 +19,7 @@
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "ezstream.h"
 
 #include "xalloc.h"
 
@@ -43,27 +35,6 @@
 # undef XALLOC_SILENT
 #endif /* XALLOC_DEBUG && XALLOC_SILENT */
 
-#ifdef THREAD_SAFE
-# include <pthread.h>
-static pthread_mutex_t	 xalloc_mutex;
-static pthread_mutex_t	 strerror_mutex;
-# define XALLOC_LOCK(mtx) do {						\
-	int error;							\
-	if ((error = pthread_mutex_lock(&mtx)) != 0)			\
-		_xalloc_error(error, "XALLOC: Internal error in %s:%u: pthread_mutex_lock()", \
-			      __FILE__, __LINE__);			\
-} while (0)
-# define XALLOC_UNLOCK(mtx) do {					\
-	int error;							\
-	if ((error = pthread_mutex_unlock(&mtx)) != 0)			\
-		_xalloc_error(error, "XALLOC: Internal error in %s:%u: pthread_mutex_unlock()", \
-			      __FILE__, __LINE__);			\
-} while (0)
-#else
-# define XALLOC_LOCK(mtx)	((void)0)
-# define XALLOC_UNLOCK(mtx)	((void)0)
-#endif /* THREAD_SAFE */
-
 #ifdef XALLOC_DEBUG
 # include <sys/tree.h>
 
@@ -170,13 +141,8 @@
 	va_start(ap, fmt);
 #ifndef XALLOC_SILENT
 	vfprintf(debug_output, fmt, ap);
-	if (errnum > 0) {
-		if (xalloc_initialized)
-			XALLOC_LOCK(strerror_mutex);
+	if (errnum > 0)
 		fprintf(debug_output, ": %s\n", strerror(errnum));
-		if (xalloc_initialized)
-			XALLOC_UNLOCK(strerror_mutex);
-	}
 	fflush(debug_output);
 #endif /* !XALLOC_SILENT */
 	va_end(ap);
@@ -292,10 +258,6 @@
 void
 xalloc_initialize_debug(unsigned int level, FILE *output)
 {
-#ifdef THREAD_SAFE
-	int	err;
-#endif /* THREAD_SAFE */
-
 	if (xalloc_initialized)
 		_xalloc_fatal("XALLOC: xalloc_initialize(): Xalloc library already initialized\n");
 
@@ -315,13 +277,6 @@
 	xalloc_peak = 0;
 	xalloc_freed = 0;
 
-#ifdef THREAD_SAFE
-	if ((err = pthread_mutex_init(&strerror_mutex, NULL)) != 0)
-		_xalloc_error(err, "XALLOC: xalloc_initialize(): Initializing xalloc_mutex");
-	if ((err = pthread_mutex_init(&xalloc_mutex, NULL)) != 0)
-		_xalloc_error(err, "XALLOC: xalloc_initialize(): Initializing strerror_mutex");
-#endif /* THREAD_SAFE */
-
 	xalloc_initialized = 1;
 }
 
@@ -339,12 +294,10 @@
 	    realloc_func == NULL)
 		_xalloc_fatal("XALLOC: xalloc_set_functions(): Bad argument(s)\n");
 
-	XALLOC_LOCK(xalloc_mutex);
 	real_malloc = malloc_func;
 	real_calloc = calloc_func;
 	real_realloc = realloc_func;
 	real_free = free_func;
-	XALLOC_UNLOCK(xalloc_mutex);
 }
 
 void
@@ -358,8 +311,6 @@
 		struct memory	*mem, *mem_next;
 		size_t		 leaked_bytes = 0;
 
-		XALLOC_LOCK(xalloc_mutex);
-
 		for (mem = RB_MIN(memory_tree, &memory_tree_head);
 		     mem != NULL;
 		     mem = mem_next) {
@@ -395,20 +346,9 @@
 				     (unsigned long)xalloc_peak,
 				     (unsigned long)xalloc_freed,
 				     (unsigned long)xalloc_total);
-
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 #endif /* XALLOC_DEBUG */
 
-#ifdef THREAD_SAFE
-	if (pthread_mutex_destroy(&xalloc_mutex) != 0)
-		_xalloc_fatal("XALLOC: Internal error: xalloc_shutdown(): xalloc_mutex %p cannot be destroyed\n",
-			      xalloc_mutex);
-	if (pthread_mutex_destroy(&strerror_mutex) != 0)
-		_xalloc_fatal("XALLOC: Internal error: xalloc_shutdown(): strerror_mutex %p cannot be destroyed\n",
-			      strerror_mutex);
-#endif /* THREAD_SAFE */
-
 	xalloc_initialized = 0;
 }
 
@@ -442,7 +382,6 @@
 		else
 			mem->allocated_by = unknown_file;
 		mem->allocated_in_line = line;
-		XALLOC_LOCK(xalloc_mutex);
 		mem->id = ++xalloc_next_id;
 		if ((mem_exists = RB_INSERT(memory_tree, &memory_tree_head, mem)) != NULL) {
 			/* Freed pointer is being reused: */
@@ -457,7 +396,6 @@
 		xalloc_total += size;
 		if (xalloc_allocated > xalloc_peak)
 			xalloc_peak = xalloc_allocated;
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 #endif /* XALLOC_DEBUG */
 
@@ -499,7 +437,6 @@
 		else
 			mem->allocated_by = unknown_file;
 		mem->allocated_in_line = line;
-		XALLOC_LOCK(xalloc_mutex);
 		mem->id = ++xalloc_next_id;
 		if ((mem_exists = RB_INSERT(memory_tree, &memory_tree_head, mem)) != NULL) {
 			/* Freed pointer is being reused: */
@@ -514,7 +451,6 @@
 		xalloc_total += nmemb * size;
 		if (xalloc_allocated > xalloc_peak)
 			xalloc_peak = xalloc_allocated;
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 #endif /* XALLOC_DEBUG */
 
@@ -549,9 +485,7 @@
 			if ((mem = real_calloc(1, sizeof(struct memory))) == NULL)
 				_xalloc_error(errno, "XALLOC: Internal error");
 			mem->ptr = ret;
-			XALLOC_LOCK(xalloc_mutex);
 			mem->id = ++xalloc_next_id;
-			XALLOC_UNLOCK(xalloc_mutex);
 			if (file)
 				mem->allocated_by = file;
 			else
@@ -563,7 +497,6 @@
 #ifdef XALLOC_DEBUG
 		struct memory	find_mem;
 
-		XALLOC_LOCK(xalloc_mutex);
 		if (debug_level > 0) {
 			find_mem.ptr = ptr;
 			if ((mem = RB_FIND(memory_tree, &memory_tree_head, &find_mem)) == NULL)
@@ -572,7 +505,6 @@
 					      line, ptr);
 			RB_REMOVE(memory_tree, &memory_tree_head, mem);
 		}
-		XALLOC_UNLOCK(xalloc_mutex);
 #endif /* XALLOC_DEBUG */
 		ret = real_realloc(ptr, nsiz);
 #ifdef XALLOC_DEBUG
@@ -597,7 +529,6 @@
 		struct memory	*mem_exists;
 		ssize_t 	 diff = (ssize_t)(nsiz - mem->size);
 
-		XALLOC_LOCK(xalloc_mutex);
 		xalloc_allocated += diff;
 		if (diff < 0)
 			xalloc_freed += -diff;
@@ -615,7 +546,6 @@
 			_memory_free(&mem_exists);
 			RB_INSERT(memory_tree, &memory_tree_head, mem);
 		}
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 #endif /* XALLOC_DEBUG */
 
@@ -659,7 +589,6 @@
 	if (debug_level > 0) {
 		struct memory	*mem = NULL, find_mem;
 
-		XALLOC_LOCK(xalloc_mutex);
 		find_mem.ptr = *ptr_p;
 		if ((mem = RB_FIND(memory_tree, &memory_tree_head, &find_mem)) == NULL)
 			_xalloc_fatal("XALLOC: xfree(): %s:%u: Junk pointer %p not accounted for\n",
@@ -696,7 +625,6 @@
 			RB_REMOVE(memory_tree, &memory_tree_head, mem);
 			_memory_free(&mem);
 		}
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 #endif /* XALLOC_DEBUG */
 
@@ -744,7 +672,6 @@
 		else
 			mem->allocated_by = unknown_file;
 		mem->allocated_in_line = line;
-		XALLOC_LOCK(xalloc_mutex);
 		mem->id = ++xalloc_next_id;
 		if ((mem_exists = RB_INSERT(memory_tree, &memory_tree_head, mem)) != NULL) {
 			/* Freed pointer is being reused: */
@@ -759,7 +686,6 @@
 		xalloc_total += strsiz;
 		if (xalloc_allocated > xalloc_peak)
 			xalloc_peak = xalloc_allocated;
-		XALLOC_UNLOCK(xalloc_mutex);
 	}
 # endif /* XALLOC_DEBUG */
 

Modified: trunk/ezstream/src/xalloc.h
===================================================================
--- trunk/ezstream/src/xalloc.h	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/src/xalloc.h	2009-03-18 09:10:28 UTC (rev 15794)
@@ -37,8 +37,7 @@
  *                over time!)
  *
  * Define XALLOC_SILENT to suppress all messages, which makes libxalloc
- * abort() and exit() silently. This has no effect when THREAD_DEBUG is
- * defined.
+ * abort() and exit() silently.
  *
  * Define XALLOC_WITH_XASPRINTF to expose the xasprintf() interface. Doing
  * so will require libxalloc to be compiled with a compiler that supports C99
@@ -55,11 +54,7 @@
 /* The default output stream for messages: */
 #define XALLOC_DEFAULT_OUTPUT	stderr
 
-#if (defined(_REENTRANT) || defined(_POSIX_THREADS)) && !defined(THREAD_SAFE)
-# define THREAD_SAFE		1
-#endif
 
-
 /*
  * Library initialization and shutdown.
  */

Modified: trunk/ezstream/win32/compat.h
===================================================================
--- trunk/ezstream/win32/compat.h	2009-03-17 22:25:47 UTC (rev 15793)
+++ trunk/ezstream/win32/compat.h	2009-03-18 09:10:28 UTC (rev 15794)
@@ -12,8 +12,11 @@
 #define popen			_popen
 #define pclose			_pclose
 #define snprintf		_snprintf
+#define stat			_stat
 #define strncasecmp		strnicmp
-#define stat			_stat
+#ifndef __GNUC__
+# define strtoll		_strtoi64
+#endif /* !__GNUC__ */
 
 #define sleep(a)		Sleep((a) * 1000)
 
@@ -25,11 +28,10 @@
 #define S_IWOTH 		0
 #define S_IXGRP 		0
 #define S_IXOTH 		0
-#define PATH_SEPARATOR		'\\'
-#define _PATH_DEVNULL		"nul"
+#define PATH_SEPARATORS 	"\\/"
 
 #ifndef ssize_t
-# define ssize_t	long
+# define ssize_t		long
 #endif /* !ssize_t */
 
 #endif /* __WIN32_COMPAT_H__ */
\ No newline at end of file



More information about the commits mailing list