diff --git a/graphics/libdvdread/Makefile b/graphics/libdvdread/Makefile index 352e0d2c3b38..78d1f211a6c8 100644 --- a/graphics/libdvdread/Makefile +++ b/graphics/libdvdread/Makefile @@ -46,4 +46,25 @@ post-install: .endfor .endif -.include +.include + +# FreeBSD byteswap optimized routines +.if ${ARCH} == "i386" +. if (defined(MACHINE_CPU) && ${MACHINE_CPU:Mi486} == "i486") +WITH_OPTIMIZED_BYTESWAP=yes +. endif + +. if defined(WITH_OPTIMIZED_BYTESWAP) +EXTRA_PATCHES= ${FILESDIR}/extra-patch-dvdread::bswap.h +. endif +.endif + +pre-everything:: +.ifndef(WITH_OPTIMIZED_BYTESWAP) + @${ECHO_MSG} '===>' + @${ECHO_MSG} '===> Define WITH_OPTIMIZED_BYTESWAP to use optimized byteswap' + @${ECHO_MSG} '===> routines. This works only in the i386 architecture, and' + @${ECHO_MSG} '===> only with 486 processors and above.' +.endif + +.include diff --git a/graphics/libdvdread/files/extra-patch-dvdread::bswap.h b/graphics/libdvdread/files/extra-patch-dvdread::bswap.h new file mode 100644 index 000000000000..91f08856dd37 --- /dev/null +++ b/graphics/libdvdread/files/extra-patch-dvdread::bswap.h @@ -0,0 +1,17 @@ +--- dvdread/bswap.h.orig Sat Nov 23 18:53:53 2002 ++++ dvdread/bswap.h Sat Nov 23 18:57:27 2002 +@@ -54,6 +54,14 @@ + * functionality! + */ + ++#elif defined(__FreeBSD__) ++# define _KERNEL ++# define I486_CPU /* Will crash unless 486+ */ ++# include ++# undef _KERNEL ++# undef I486_CPU ++# define FROM_BE_32(x) (ntohl(x)) ++ + #elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) + #define B2N_16(x) \ + x = ((((x) & 0xff00) >> 8) | \ diff --git a/graphics/libdvdread/files/patch-dvdread::bswap.h b/graphics/libdvdread/files/patch-dvdread::bswap.h new file mode 100644 index 000000000000..ad7f78b04ea8 --- /dev/null +++ b/graphics/libdvdread/files/patch-dvdread::bswap.h @@ -0,0 +1,34 @@ +--- dvdread/bswap.h.orig Sat Nov 23 18:53:53 2002 ++++ dvdread/bswap.h Sat Nov 23 18:56:21 2002 +@@ -22,6 +22,10 @@ + + #include + ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif ++ + #if defined(WORDS_BIGENDIAN) + /* All bigendian systems are fine, just ignore the swaps. */ + #define B2N_16(x) (void)(x) +@@ -53,6 +57,20 @@ + * FreeBSD and Solaris don't have or any other such + * functionality! + */ ++ ++#elif defined(__FreeBSD__) && __FreeBSD_version >= 470000 ++#include ++#define B2N_16(x) x = (be16toh(x)) ++#define B2N_32(x) x = (be32toh(x)) ++#define B2N_64(x) \ ++ x = ((((x) & 0xff00000000000000) >> 56) | \ ++ (((x) & 0x00ff000000000000) >> 40) | \ ++ (((x) & 0x0000ff0000000000) >> 24) | \ ++ (((x) & 0x000000ff00000000) >> 8) | \ ++ (((x) & 0x00000000ff000000) << 8) | \ ++ (((x) & 0x0000000000ff0000) << 24) | \ ++ (((x) & 0x000000000000ff00) << 40) | \ ++ (((x) & 0x00000000000000ff) << 56)) + + #elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) + #define B2N_16(x) \ diff --git a/multimedia/libdvdread/Makefile b/multimedia/libdvdread/Makefile index 352e0d2c3b38..78d1f211a6c8 100644 --- a/multimedia/libdvdread/Makefile +++ b/multimedia/libdvdread/Makefile @@ -46,4 +46,25 @@ post-install: .endfor .endif -.include +.include + +# FreeBSD byteswap optimized routines +.if ${ARCH} == "i386" +. if (defined(MACHINE_CPU) && ${MACHINE_CPU:Mi486} == "i486") +WITH_OPTIMIZED_BYTESWAP=yes +. endif + +. if defined(WITH_OPTIMIZED_BYTESWAP) +EXTRA_PATCHES= ${FILESDIR}/extra-patch-dvdread::bswap.h +. endif +.endif + +pre-everything:: +.ifndef(WITH_OPTIMIZED_BYTESWAP) + @${ECHO_MSG} '===>' + @${ECHO_MSG} '===> Define WITH_OPTIMIZED_BYTESWAP to use optimized byteswap' + @${ECHO_MSG} '===> routines. This works only in the i386 architecture, and' + @${ECHO_MSG} '===> only with 486 processors and above.' +.endif + +.include diff --git a/multimedia/libdvdread/files/extra-patch-dvdread::bswap.h b/multimedia/libdvdread/files/extra-patch-dvdread::bswap.h new file mode 100644 index 000000000000..91f08856dd37 --- /dev/null +++ b/multimedia/libdvdread/files/extra-patch-dvdread::bswap.h @@ -0,0 +1,17 @@ +--- dvdread/bswap.h.orig Sat Nov 23 18:53:53 2002 ++++ dvdread/bswap.h Sat Nov 23 18:57:27 2002 +@@ -54,6 +54,14 @@ + * functionality! + */ + ++#elif defined(__FreeBSD__) ++# define _KERNEL ++# define I486_CPU /* Will crash unless 486+ */ ++# include ++# undef _KERNEL ++# undef I486_CPU ++# define FROM_BE_32(x) (ntohl(x)) ++ + #elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) + #define B2N_16(x) \ + x = ((((x) & 0xff00) >> 8) | \ diff --git a/multimedia/libdvdread/files/patch-dvdread::bswap.h b/multimedia/libdvdread/files/patch-dvdread::bswap.h new file mode 100644 index 000000000000..ad7f78b04ea8 --- /dev/null +++ b/multimedia/libdvdread/files/patch-dvdread::bswap.h @@ -0,0 +1,34 @@ +--- dvdread/bswap.h.orig Sat Nov 23 18:53:53 2002 ++++ dvdread/bswap.h Sat Nov 23 18:56:21 2002 +@@ -22,6 +22,10 @@ + + #include + ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif ++ + #if defined(WORDS_BIGENDIAN) + /* All bigendian systems are fine, just ignore the swaps. */ + #define B2N_16(x) (void)(x) +@@ -53,6 +57,20 @@ + * FreeBSD and Solaris don't have or any other such + * functionality! + */ ++ ++#elif defined(__FreeBSD__) && __FreeBSD_version >= 470000 ++#include ++#define B2N_16(x) x = (be16toh(x)) ++#define B2N_32(x) x = (be32toh(x)) ++#define B2N_64(x) \ ++ x = ((((x) & 0xff00000000000000) >> 56) | \ ++ (((x) & 0x00ff000000000000) >> 40) | \ ++ (((x) & 0x0000ff0000000000) >> 24) | \ ++ (((x) & 0x000000ff00000000) >> 8) | \ ++ (((x) & 0x00000000ff000000) << 8) | \ ++ (((x) & 0x0000000000ff0000) << 24) | \ ++ (((x) & 0x000000000000ff00) << 40) | \ ++ (((x) & 0x00000000000000ff) << 56)) + + #elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) + #define B2N_16(x) \