summaryrefslogtreecommitdiff
path: root/src/xine-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-utils')
-rw-r--r--src/xine-utils/Makefile.am43
-rw-r--r--src/xine-utils/attributes.h24
-rw-r--r--src/xine-utils/cpu_accel.c34
-rw-r--r--src/xine-utils/memcpy.c6
-rw-r--r--src/xine-utils/monitor.c11
-rw-r--r--src/xine-utils/utils.c57
-rw-r--r--src/xine-utils/xineutils.h10
7 files changed, 110 insertions, 75 deletions
diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am
index 95de06b9e..10f1714f9 100644
--- a/src/xine-utils/Makefile.am
+++ b/src/xine-utils/Makefile.am
@@ -1,19 +1,33 @@
include $(top_srcdir)/misc/Makefile.common
-LIBTOOL = $(SHELL) $(top_builddir)/libtool
-noinst_LTLIBRARIES = libxineutils.la
+AM_CFLAGS = $(DEFAULT_OCFLAGS) $(X_CFLAGS) $(VISIBILITY_FLAG)
+AM_CPPFLAGS = -DXINE_LIBRARY_COMPILE
EXTRA_DIST = ppcasm_string.S ppc_asm.tmpl
-if PPC_ARCH
+noinst_HEADERS = ppcasm_string.h xine_check.h
+
+xineinclude_HEADERS = \
+ attributes.h \
+ compat.h \
+ xine_buffer.h \
+ xineutils.h \
+ xmllexer.h \
+ xmlparser.h \
+ list.h \
+ array.h \
+ sorted_array.h \
+ pool.h \
+ ring_buffer.h
+
+noinst_LTLIBRARIES = libxineutils.la
+
+if ARCH_PPC
if !HOST_OS_DARWIN
pppc_files = ppcasm_string.S
endif
endif
-AM_CFLAGS = $(X_CFLAGS) $(VISIBILITY_FLAG)
-AM_CPPFLAGS=-DXINE_LIBRARY_COMPILE
-
libxineutils_la_SOURCES = $(pppc_files) \
cpu_accel.c \
color.c \
@@ -31,20 +45,3 @@ libxineutils_la_SOURCES = $(pppc_files) \
sorted_array.c \
pool.c \
ring_buffer.c
-
-xineinclude_HEADERS = \
- attributes.h \
- compat.h \
- xine_buffer.h \
- xineutils.h \
- xmllexer.h \
- xmlparser.h \
- list.h \
- array.h \
- sorted_array.h \
- pool.h \
- ring_buffer.h
-
-
-noinst_HEADERS = ppcasm_string.h xine_check.h
-
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h
index f7f5a111c..a9be4792f 100644
--- a/src/xine-utils/attributes.h
+++ b/src/xine-utils/attributes.h
@@ -32,18 +32,6 @@
#define ATTR_ALIGN(align)
#endif
-/* disable GNU __attribute__ extension, when not compiling with GNU C */
-#if defined(__GNUC__) || defined (__ICC)
-#ifndef ATTRIBUTE_PACKED
-#define ATTRIBUTE_PACKED 1
-#endif
-#else
-#undef ATTRIBUTE_PACKED
-#ifndef __attribute__
-#define __attribute__(x) /**/
-#endif /* __attribute __*/
-#endif
-
#ifdef XINE_COMPILE
# include "configure.h"
#endif
@@ -83,4 +71,16 @@
# define XINE_FORMAT_PRINTF_ARG(fmt)
#endif
+#ifdef SUPPORT_ATTRIBUTE_PACKED
+# define XINE_PACKED __attribute__((packed))
+#else
+# define XINE_PACKED
+#endif
+
+#ifdef SUPPORT_ATTRIBUTE_MALLOC
+# define XINE_MALLOC __attribute__((__malloc__))
+#else
+# define XINE_MALLOC
+#endif
+
#endif /* ATTRIBUTE_H_ */
diff --git a/src/xine-utils/cpu_accel.c b/src/xine-utils/cpu_accel.c
index b32733fba..06ee90cd3 100644
--- a/src/xine-utils/cpu_accel.c
+++ b/src/xine-utils/cpu_accel.c
@@ -24,9 +24,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
-#include <signal.h>
-#include <setjmp.h>
+
+#if defined(HAVE_MLIB) && defined(MLIB_LAZYLOAD)
#include <dlfcn.h>
+#endif
#if defined (__SVR4) && defined (__sun)
#include <sys/systeminfo.h>
@@ -40,22 +41,32 @@
#include "xineutils.h"
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if defined(__i386__) || defined(__x86_64__)
+
+#ifndef __x86_64__
+#include <signal.h>
+#include <setjmp.h>
static jmp_buf sigill_return;
static void sigill_handler (int n) {
longjmp(sigill_return, 1);
}
+#endif
static uint32_t arch_accel (void)
{
uint32_t caps;
-#ifdef __x86_64__
+#if defined(__x86_64__) || \
+ ( defined(__SSE__) && defined(__SSE2__) && defined(__MMX__) )
/* No need to test for this on AMD64, we know what the
platform has. */
- caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_SSE | MM_ACCEL_X86_MMXEXT | MM_ACCEL_X86_SSE2;
+ caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_SSE | MM_ACCEL_X86_MMXEXT | MM_ACCEL_X86_SSE2
+# if defined(__3dNOW__)
+ | MM_ACCEL_X86_3DNOW
+# endif
+ ;
#else
#ifndef _MSC_VER
@@ -148,6 +159,9 @@ static uint32_t arch_accel (void)
caps = 0;
#endif /* _MSC_VER */
+#endif /* x86_64 or built-in options */
+
+#ifndef __x86_64__
/* test OS support for SSE */
if (caps & MM_ACCEL_X86_SSE) {
void (*old_sigill_handler)(int);
@@ -169,9 +183,12 @@ static uint32_t arch_accel (void)
return caps;
}
-#endif /* ARCH_X86 */
+#endif /* i386 or x86_64 */
#if defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)
+#include <signal.h>
+#include <setjmp.h>
+
static sigjmp_buf jmpbuf;
static volatile sig_atomic_t canjump = 0;
@@ -256,6 +273,9 @@ static uint32_t arch_accel (void)
return flags;
}
#else
+#include <signal.h>
+#include <setjmp.h>
+
static sigjmp_buf jmpbuf;
static volatile sig_atomic_t canjump = 0;
@@ -326,7 +346,7 @@ uint32_t xine_mm_accel (void)
#endif
#endif
-#if defined(ARCH_X86) || defined(ARCH_X86_64) || (defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)) || (defined(ARCH_SPARC) && defined(ENABLE_VIS))
+#if defined(__i386__) || defined(__x86_64__) || (defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)) || (defined(ARCH_SPARC) && defined(ENABLE_VIS))
accel |= arch_accel();
#endif
diff --git a/src/xine-utils/memcpy.c b/src/xine-utils/memcpy.c
index 539f4c8dd..67645081e 100644
--- a/src/xine-utils/memcpy.c
+++ b/src/xine-utils/memcpy.c
@@ -383,8 +383,8 @@ static void *linux_kernel_memcpy(void *to, const void *from, size_t len) {
#endif /* ARCH_X86 */
static struct {
- char *name;
- void *(* function)(void *to, const void *from, size_t len);
+ char *const name;
+ void *(*const function)(void *to, const void *from, size_t len);
uint64_t time; /* This type could be used for non-MSC build too! */
@@ -461,7 +461,7 @@ void xine_probe_fast_memcpy(xine_t *xine)
char *buf1, *buf2;
int i, j, best;
int config_flags = -1;
- static const char *memcpy_methods[] = {
+ static const char *const memcpy_methods[] = {
"probe", "libc",
#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined(_MSC_VER)
"kernel", "mmx", "mmxext", "sse",
diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c
index c0cfd6179..b19195065 100644
--- a/src/xine-utils/monitor.c
+++ b/src/xine-utils/monitor.c
@@ -41,13 +41,10 @@ static long profiler_calls[MAX_ID] ;
static const char *profiler_label[MAX_ID] ;
void xine_profiler_init () {
- int i;
- for (i=0; i<MAX_ID; i++) {
- profiler_times[i] = 0;
- profiler_start[i] = 0;
- profiler_calls[i] = 0;
- profiler_label[i] = NULL;
- }
+ memset(profiler_times, 0, sizeof(profiler_times));
+ memset(profiler_start, 0, sizeof(profiler_start));
+ memset(profiler_calls, 0, sizeof(profiler_calls));
+ memset(profiler_label, 0, sizeof(profiler_label));
}
int xine_profiler_allocate_slot (const char *label) {
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index fa0c11dbe..f79d2ebce 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -256,6 +256,27 @@ void *xine_xmalloc(size_t size) {
return ptr;
}
+/**
+ * @brief Wrapper around calloc() function.
+ * @param nmemb Number of elements to allocate
+ * @param size Size of each element to allocate
+ *
+ * This is a simple wrapper around calloc(), the only thing
+ * it does more than calloc() is outputting an error if
+ * the calloc fails (returning NULL).
+ */
+void *xine_xcalloc(size_t nmemb, size_t size) {
+ void *ptr;
+
+ if((ptr = calloc(nmemb, size)) == NULL) {
+ fprintf(stderr, "%s: calloc() failed: %s.\n",
+ __XINE_FUNCTION__, strerror(errno));
+ return NULL;
+ }
+
+ return ptr;
+}
+
void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) {
char *ptr;
@@ -453,38 +474,40 @@ void xine_usec_sleep(unsigned usec) {
/* print a hexdump of length bytes from the data given in buf */
-void xine_hexdump (const char *buf, int length) {
- int i,j;
- unsigned char c;
+void xine_hexdump (const void *buf_gen, int length) {
+ static const char separator[70] = "---------------------------------------------------------------------";
+
+ const uint8_t *const buf = (const uint8_t*)buf;
+ int j = 0;
/* printf ("Hexdump: %i Bytes\n", length);*/
- for(j=0; j<69; j++)
- printf ("-");
- printf ("\n");
+ puts(separator);
- j=0;
while(j<length) {
+ int i;
+ const int imax = (j+16 < length) ? (j+16) : length;
+
printf ("%04X ",j);
for (i=j; i<j+16; i++) {
if( i<length )
- printf ("%02X ", (unsigned char) buf[i]);
+ printf ("%02X ", buf[i]);
else
printf(" ");
}
- for (i=j;i<(j+16<length?j+16:length);i++) {
- c=buf[i];
+
+ for (i=j; i < imax; i++) {
+ uint8_t c = buf[i];
if ((c>=32) && (c<127))
- printf ("%c", c);
- else
- printf (".");
+ c = '.';
+
+ fputc(c, stdout);
}
j=i;
- printf("\n");
+
+ fputc('\n', stdout);
}
- for(j=0; j<69; j++)
- printf("-");
- printf("\n");
+ puts(separator);
}
diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h
index 03c5f689a..980586b7d 100644
--- a/src/xine-utils/xineutils.h
+++ b/src/xine-utils/xineutils.h
@@ -624,11 +624,9 @@ void xine_profiler_print_results (void) XINE_PROTECTED;
* Allocate and clean memory size_t 'size', then return the pointer
* to the allocated memory.
*/
-#if !defined(__GNUC__) || __GNUC__ < 3
-void *xine_xmalloc(size_t size) XINE_PROTECTED;
-#else
-void *xine_xmalloc(size_t size) __attribute__ ((__malloc__)) XINE_PROTECTED;
-#endif
+void *xine_xmalloc(size_t size) XINE_MALLOC XINE_PROTECTED;
+
+void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED;
/*
* Same as above, but memory is aligned to 'alignement'.
@@ -786,7 +784,7 @@ extern void yuy2_to_yuy2
int width, int height) XINE_PROTECTED;
/* print a hexdump of the given data */
-void xine_hexdump (const char *buf, int length) XINE_PROTECTED;
+void xine_hexdump (const void *buf, int length) XINE_PROTECTED;
/*
* Optimization macros for conditions