patch-ad: fix an #endif versus #else error patch-cc: adds NetBSD bswap* to interface/utils.h as per utils.h patch-ci: fix a crash on big-endian machinesdiff -r1.4 -r1.5 pkgsrc/audio/cdparanoia/patches/patch-ad
(jdc)
@@ -1,60 +1,62 @@ | @@ -1,60 +1,62 @@ | |||
1 | $NetBSD: patch-ad,v 1.4 2006/09/03 17:13:30 ben Exp $ | 1 | $NetBSD: patch-ad,v 1.5 2010/03/26 16:38:32 jdc Exp $ | |
2 | 2 | |||
3 | --- utils.h.orig 2000-04-19 15:41:04.000000000 -0700 | 3 | --- utils.h.orig 2008-08-22 09:39:06.000000000 +0000 | |
4 | +++ utils.h | 4 | +++ utils.h 2010-03-24 11:10:19.000000000 +0000 | |
5 | @@ -1,5 +1,20 @@ | 5 | @@ -1,5 +1,20 @@ | |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> | |
7 | +#ifdef __linux__ | 7 | +#ifdef __linux__ | |
8 | #include <endian.h> | 8 | #include <endian.h> | |
9 | +#endif | 9 | +#endif | |
10 | +#ifdef __NetBSD__ | 10 | +#ifdef __NetBSD__ | |
11 | +#include <sys/param.h> | 11 | +#include <sys/param.h> | |
12 | +#if __NetBSD_Version__ >= 104010000 | 12 | +#if __NetBSD_Version__ >= 104010000 | |
13 | +#include <sys/endian.h> | 13 | +#include <sys/endian.h> | |
14 | +#else | 14 | +#else | |
15 | +#include <machine/endian.h> | 15 | +#include <machine/endian.h> | |
16 | +#include <machine/bswap.h> | 16 | +#include <machine/bswap.h> | |
17 | +#endif | 17 | +#endif | |
18 | +#endif | 18 | +#endif | |
19 | +#if defined(__APPLE__) && defined(__MACH__) | 19 | +#if defined(__APPLE__) && defined(__MACH__) | |
20 | +#include <stdint.h> | 20 | +#include <stdint.h> | |
21 | +#include <machine/endian.h> | 21 | +#include <machine/endian.h> | |
22 | +#endif | 22 | +#endif | |
23 | #include <stdio.h> | 23 | #include <stdio.h> | |
24 | #include <errno.h> | 24 | #include <errno.h> | |
25 | #include <string.h> | 25 | #include <string.h> | |
26 | @@ -19,15 +34,34 @@ static inline int bigendianp(void){ | 26 | @@ -18,15 +33,35 @@ | |
27 | } | 27 | } | |
28 | 28 | |||
29 | static inline int32_t swap32(int32_t x){ | 29 | static inline int32_t swap32(int32_t x){ | |
30 | +#ifdef __NetBSD__ | 30 | +#ifdef __NetBSD__ | |
31 | + return bswap32(x); | 31 | + return bswap32(x); | |
32 | +#else | 32 | +#else | |
33 | +#if defined(__APPLE__) && defined(__MACH__) | 33 | +#if defined(__APPLE__) && defined(__MACH__) | |
34 | + return((((uint32_t)x & 0x000000ffU) << 24) | | 34 | + return((((uint32_t)x & 0x000000ffU) << 24) | | |
35 | + (((uint32_t)x & 0x0000ff00U) << 8) | | 35 | + (((uint32_t)x & 0x0000ff00U) << 8) | | |
36 | + (((uint32_t)x & 0x00ff0000U) >> 8) | | 36 | + (((uint32_t)x & 0x00ff0000U) >> 8) | | |
37 | + (((uint32_t)x & 0xff000000U) >> 24)); | 37 | + (((uint32_t)x & 0xff000000U) >> 24)); | |
38 | +#else | 38 | +#else | |
39 | return((((u_int32_t)x & 0x000000ffU) << 24) | | 39 | return((((u_int32_t)x & 0x000000ffU) << 24) | | |
40 | (((u_int32_t)x & 0x0000ff00U) << 8) | | 40 | (((u_int32_t)x & 0x0000ff00U) << 8) | | |
41 | (((u_int32_t)x & 0x00ff0000U) >> 8) | | 41 | (((u_int32_t)x & 0x00ff0000U) >> 8) | | |
42 | (((u_int32_t)x & 0xff000000U) >> 24)); | 42 | (((u_int32_t)x & 0xff000000U) >> 24)); | |
43 | +#endif | 43 | +#endif | |
44 | +#endif | 44 | +#endif | |
45 | } | 45 | } | |
46 | 46 | |||
47 | static inline int16_t swap16(int16_t x){ | 47 | -static inline int16_t swap16(int16_t x){ | |
48 | +static inline int16_t swap16(int16_t x){ | |||
48 | +#ifdef __NetBSD__ | 49 | +#ifdef __NetBSD__ | |
49 | + return bswap16(x); | 50 | + return bswap16(x); | |
50 | +#else | 51 | +#else | |
51 | +#if defined(__APPLE__) && defined(__MACH__) | 52 | +#if defined(__APPLE__) && defined(__MACH__) | |
52 | + return((((uint16_t)x & 0x00ffU) << 8) | | 53 | + return((((uint16_t)x & 0x00ffU) << 8) | | |
53 | + (((uint16_t)x & 0xff00U) >> 8)); | 54 | + (((uint16_t)x & 0xff00U) >> 8)); | |
54 | +#endif | 55 | +#else | |
55 | return((((u_int16_t)x & 0x00ffU) << 8) | | 56 | return((((u_int16_t)x & 0x00ffU) << 8) | | |
56 | (((u_int16_t)x & 0xff00U) >> 8)); | 57 | (((u_int16_t)x & 0xff00U) >> 8)); | |
57 | +#endif | 58 | +#endif | |
59 | +#endif | |||
58 | } | 60 | } | |
59 | 61 | |||
60 | #if BYTE_ORDER == LITTLE_ENDIAN | 62 | #if BYTE_ORDER == LITTLE_ENDIAN |
@@ -1,56 +1,64 @@ | @@ -1,56 +1,64 @@ | |||
1 | $NetBSD: patch-cc,v 1.7 2009/08/09 16:00:53 drochner Exp $ | 1 | $NetBSD: patch-cc,v 1.8 2010/03/26 16:38:32 jdc Exp $ | |
2 | 2 | |||
3 | --- interface/utils.h.orig 2008-08-14 15:56:20.000000000 +0200 | 3 | --- interface/utils.h.orig 2008-08-14 13:56:20.000000000 +0000 | |
4 | +++ interface/utils.h | 4 | +++ interface/utils.h 2010-03-24 10:55:09.000000000 +0000 | |
5 | @@ -1,4 +1,23 @@ | 5 | @@ -1,4 +1,23 @@ | |
6 | +#ifdef __linux__ | 6 | +#ifdef __linux__ | |
7 | #include <endian.h> | 7 | #include <endian.h> | |
8 | +#endif | 8 | +#endif | |
9 | +#ifdef __NetBSD__ | 9 | +#ifdef __NetBSD__ | |
10 | +#include <sys/param.h> | 10 | +#include <sys/param.h> | |
11 | +#if __NetBSD_Version__ >= 104010000 | 11 | +#if __NetBSD_Version__ >= 104010000 | |
12 | +#include <sys/endian.h> | 12 | +#include <sys/endian.h> | |
13 | +#else | 13 | +#else | |
14 | +#include <machine/endian.h> | 14 | +#include <machine/endian.h> | |
15 | +#include <machine/bswap.h> | 15 | +#include <machine/bswap.h> | |
16 | +#endif | 16 | +#endif | |
17 | +#include <err.h> /* XXX */ | 17 | +#include <err.h> /* XXX */ | |
18 | +#elif defined(__FreeBSD__) || defined(__DragonFly__) | 18 | +#elif defined(__FreeBSD__) || defined(__DragonFly__) | |
19 | +#include <machine/endian.h> | 19 | +#include <machine/endian.h> | |
20 | +#endif | 20 | +#endif | |
21 | +#if defined(__APPLE__) && defined(__MACH__) | 21 | +#if defined(__APPLE__) && defined(__MACH__) | |
22 | +#include <stdint.h> | 22 | +#include <stdint.h> | |
23 | +#include <machine/endian.h> | 23 | +#include <machine/endian.h> | |
24 | +#define STDERR_FILENO 2 | 24 | +#define STDERR_FILENO 2 | |
25 | +#endif | 25 | +#endif | |
26 | #include <stdio.h> | 26 | #include <stdio.h> | |
27 | #include <errno.h> | 27 | #include <errno.h> | |
28 | #include <string.h> | 28 | #include <string.h> | |
29 | @@ -14,15 +33,27 @@ static inline int bigendianp(void){ | 29 | @@ -14,15 +33,35 @@ | |
30 | } | 30 | } | |
31 | 31 | |||
32 | static inline int32_t swap32(int32_t x){ | 32 | static inline int32_t swap32(int32_t x){ | |
33 | +#ifdef __NetBSD__ | |||
34 | + return bswap32(x); | |||
35 | +#else | |||
33 | +#if defined(__APPLE__) && defined(__MACH__) | 36 | +#if defined(__APPLE__) && defined(__MACH__) | |
34 | + return((((uint32_t)x & 0x000000ffU) << 24) | | 37 | + return((((uint32_t)x & 0x000000ffU) << 24) | | |
35 | + (((uint32_t)x & 0x0000ff00U) << 8) | | 38 | + (((uint32_t)x & 0x0000ff00U) << 8) | | |
36 | + (((uint32_t)x & 0x00ff0000U) >> 8) | | 39 | + (((uint32_t)x & 0x00ff0000U) >> 8) | | |
37 | + (((uint32_t)x & 0xff000000U) >> 24)); | 40 | + (((uint32_t)x & 0xff000000U) >> 24)); | |
38 | +#else | 41 | +#else | |
39 | return((((u_int32_t)x & 0x000000ffU) << 24) | | 42 | return((((u_int32_t)x & 0x000000ffU) << 24) | | |
40 | (((u_int32_t)x & 0x0000ff00U) << 8) | | 43 | (((u_int32_t)x & 0x0000ff00U) << 8) | | |
41 | (((u_int32_t)x & 0x00ff0000U) >> 8) | | 44 | (((u_int32_t)x & 0x00ff0000U) >> 8) | | |
42 | (((u_int32_t)x & 0xff000000U) >> 24)); | 45 | (((u_int32_t)x & 0xff000000U) >> 24)); | |
43 | +#endif | 46 | +#endif | |
47 | +#endif | |||
44 | } | 48 | } | |
45 | 49 | |||
46 | static inline int16_t swap16(int16_t x){ | 50 | static inline int16_t swap16(int16_t x){ | |
51 | +#ifdef __NetBSD__ | |||
52 | + return bswap16(x); | |||
53 | +#else | |||
47 | +#if defined(__APPLE__) && defined(__MACH__) | 54 | +#if defined(__APPLE__) && defined(__MACH__) | |
48 | + return((((uint16_t)x & 0x00ffU) << 8) | | 55 | + return((((uint16_t)x & 0x00ffU) << 8) | | |
49 | + (((uint16_t)x & 0xff00U) >> 8)); | 56 | + (((uint16_t)x & 0xff00U) >> 8)); | |
50 | +#else | 57 | +#else | |
51 | return((((u_int16_t)x & 0x00ffU) << 8) | | 58 | return((((u_int16_t)x & 0x00ffU) << 8) | | |
52 | (((u_int16_t)x & 0xff00U) >> 8)); | 59 | (((u_int16_t)x & 0xff00U) >> 8)); | |
53 | +#endif | 60 | +#endif | |
61 | +#endif | |||
54 | } | 62 | } | |
55 | 63 | |||
56 | #if BYTE_ORDER == LITTLE_ENDIAN | 64 | #if BYTE_ORDER == LITTLE_ENDIAN |
@@ -1,49 +1,49 @@ | @@ -1,49 +1,49 @@ | |||
1 | $NetBSD: patch-ci,v 1.7 2009/08/29 04:54:52 hasso Exp $ | 1 | $NetBSD: patch-ci,v 1.8 2010/03/26 16:38:32 jdc Exp $ | |
2 | 2 | |||
3 | --- interface/interface.c.orig 2008-09-11 13:43:52 +0300 | 3 | --- interface/interface.c.orig 2008-09-11 10:43:52.000000000 +0000 | |
4 | +++ interface/interface.c 2009-08-26 09:57:44 +0300 | 4 | +++ interface/interface.c 2010-03-24 13:57:38.000000000 +0000 | |
5 | @@ -35,6 +35,10 @@ int cdda_close(cdrom_drive *d){ | 5 | @@ -35,6 +35,10 @@ | |
6 | 6 | |||
7 | _clean_messages(d); | 7 | _clean_messages(d); | |
8 | if(d->cdda_device_name)free(d->cdda_device_name); | 8 | if(d->cdda_device_name)free(d->cdda_device_name); | |
9 | +#if !defined(__FreeBSD__) | 9 | +#if !defined(__FreeBSD__) | |
10 | +#if defined(__APPLE__) && defined(__MACH__) | 10 | +#if defined(__APPLE__) && defined(__MACH__) | |
11 | + if(d->fd != -1) close(d->fd); | 11 | + if(d->fd != -1) close(d->fd); | |
12 | +#else | 12 | +#else | |
13 | if(d->ioctl_device_name)free(d->ioctl_device_name); | 13 | if(d->ioctl_device_name)free(d->ioctl_device_name); | |
14 | if(d->drive_model)free(d->drive_model); | 14 | if(d->drive_model)free(d->drive_model); | |
15 | if(d->cdda_fd!=-1)close(d->cdda_fd); | 15 | if(d->cdda_fd!=-1)close(d->cdda_fd); | |
16 | @@ -43,6 +47,19 @@ int cdda_close(cdrom_drive *d){ | 16 | @@ -43,6 +47,19 @@ | |
17 | if(d->private->sg_hd)free(d->private->sg_hd); | 17 | if(d->private->sg_hd)free(d->private->sg_hd); | |
18 | free(d->private); | 18 | free(d->private); | |
19 | } | 19 | } | |
20 | +#endif | 20 | +#endif | |
21 | +#else | 21 | +#else | |
22 | + if(d->drive_model) | 22 | + if(d->drive_model) | |
23 | + free(d->drive_model); | 23 | + free(d->drive_model); | |
24 | + if(d->ccb) | 24 | + if(d->ccb) | |
25 | + cam_freeccb(d->ccb); | 25 | + cam_freeccb(d->ccb); | |
26 | + if(d->dev) | 26 | + if(d->dev) | |
27 | + cam_close_device(d->dev); | 27 | + cam_close_device(d->dev); | |
28 | + if(d->private->sg_buffer) | 28 | + if(d->private->sg_buffer) | |
29 | + free(d->private->sg_buffer); | 29 | + free(d->private->sg_buffer); | |
30 | + if(d->ioctl_fd != -1) | 30 | + if(d->ioctl_fd != -1) | |
31 | + close(d->ioctl_fd); | 31 | + close(d->ioctl_fd); | |
32 | +#endif | 32 | +#endif | |
33 | 33 | |||
34 | free(d); | 34 | free(d); | |
35 | } | 35 | } | |
36 | @@ -55,22 +72,31 @@ int cdda_open(cdrom_drive *d){ | 36 | @@ -55,22 +72,31 @@ | |
37 | if(d->opened)return(0); | 37 | if(d->opened)return(0); | |
38 | 38 | |||
39 | switch(d->interface){ | 39 | switch(d->interface){ | |
40 | +#if defined(__APPLE__) && defined(__MACH__) | 40 | +#if defined(__APPLE__) && defined(__MACH__) | |
41 | + case OSX_IOKIT: | 41 | + case OSX_IOKIT: | |
42 | + if((ret=osx_open_device(d))) | 42 | + if((ret=osx_open_device(d))) | |
43 | + return ret; | 43 | + return ret; | |
44 | + break; | 44 | + break; | |
45 | +#else | 45 | +#else | |
46 | case SGIO_SCSI_BUGGY1: | 46 | case SGIO_SCSI_BUGGY1: | |
47 | case SGIO_SCSI: | 47 | case SGIO_SCSI: | |
48 | case GENERIC_SCSI: | 48 | case GENERIC_SCSI: | |
49 | if((ret=scsi_init_drive(d))) | 49 | if((ret=scsi_init_drive(d))) | |
@@ -55,13 +55,22 @@ $NetBSD: patch-ci,v 1.7 2009/08/29 04:54 | @@ -55,13 +55,22 @@ $NetBSD: patch-ci,v 1.7 2009/08/29 04:54 | |||
55 | return(ret); | 55 | return(ret); | |
56 | break; | 56 | break; | |
57 | +#endif | 57 | +#endif | |
58 | #ifdef CDDA_TEST | 58 | #ifdef CDDA_TEST | |
59 | case TEST_INTERFACE: | 59 | case TEST_INTERFACE: | |
60 | if((ret=test_init_drive(d))) | 60 | if((ret=test_init_drive(d))) | |
61 | return(ret); | 61 | return(ret); | |
62 | break; | 62 | break; | |
63 | #endif | 63 | #endif | |
64 | +#endif | 64 | +#endif | |
65 | default: | 65 | default: | |
66 | cderror(d,"100: Interface not supported\n"); | 66 | cderror(d,"100: Interface not supported\n"); | |
67 | return(-100); | 67 | return(-100); | |
68 | @@ -113,7 +139,7 @@ | |||
69 | if(sectors>0){ | |||
70 | sectors=d->read_audio(d,buffer,beginsector,sectors); | |||
71 | ||||
72 | - if(sectors>0){ | |||
73 | + if(sectors>0 && buffer != NULL){ | |||
74 | /* byteswap? */ | |||
75 | if(d->bigendianp==-1) /* not determined yet */ | |||
76 | d->bigendianp=data_bigendianp(d); |