[tools] build fixes for squashfs4 on cygwin
[openwrt/svn-archive/archive.git] / tools / squashfs4 / patches / 120-cygwin_fixes.patch
1 diff -urN squashfs4.0/squashfs-tools/global.h squashfs4.0.new/squashfs-tools/global.h
2 --- squashfs4.0/squashfs-tools/global.h 2009-08-27 21:33:03.000000000 +0200
3 +++ squashfs4.0.new/squashfs-tools/global.h 2009-08-27 21:36:38.000000000 +0200
4 @@ -44,6 +44,11 @@
5 typedef squashfs_inode_t squashfs_inode;
6 typedef squashfs_block_t squashfs_block;
7
8 +#ifdef __CYGWIN__
9 +#include <sys/termios.h>
10 +#define FNM_EXTMATCH (1 << 5)
11 +#endif
12 +
13 #ifndef FNM_EXTMATCH
14 #define FNM_EXTMATCH 0
15 #endif
16 diff -urN squashfs4.0/squashfs-tools/mksquashfs.c squashfs4.0.new/squashfs-tools/mksquashfs.c
17 --- squashfs4.0/squashfs-tools/mksquashfs.c 2009-08-27 21:33:06.000000000 +0200
18 +++ squashfs4.0.new/squashfs-tools/mksquashfs.c 2009-08-27 21:37:22.000000000 +0200
19 @@ -49,10 +49,12 @@
20 #include <fnmatch.h>
21
22 #ifndef linux
23 +#ifndef __CYGWIN__
24 #define __BYTE_ORDER BYTE_ORDER
25 #define __BIG_ENDIAN BIG_ENDIAN
26 #define __LITTLE_ENDIAN LITTLE_ENDIAN
27 #include <sys/sysctl.h>
28 +#endif /* __CYGWIN__ */
29 #else
30 #include <endian.h>
31 #include <sys/sysinfo.h>
32 @@ -825,6 +827,7 @@
33
34 void sigwinch_handler()
35 {
36 +#ifndef __CYGWIN__
37 struct winsize winsize;
38
39 if(ioctl(1, TIOCGWINSZ, &winsize) == -1) {
40 @@ -834,6 +837,9 @@
41 columns = 80;
42 } else
43 columns = winsize.ws_col;
44 +#else
45 + columns = 80;
46 +#endif
47 }
48
49
50 @@ -3753,7 +3759,9 @@
51 BAD_ERROR("Failed to set signal mask in intialise_threads\n");
52
53 signal(SIGUSR1, sigusr1_handler);
54 -
55 +#ifdef __CYGWIN__
56 + processors = atoi(getenv("NUMBER_OF_PROCESSORS"));
57 +#else
58 if(processors == -1) {
59 #ifndef linux
60 int mib[2];
61 @@ -3775,6 +3783,7 @@
62 processors = get_nprocs();
63 #endif
64 }
65 +#endif /* __CYGWIN__ */
66
67 if((thread = malloc((2 + processors * 2) * sizeof(pthread_t))) == NULL)
68 BAD_ERROR("Out of memory allocating thread descriptors\n");
69 diff -urN squashfs4.0/squashfs-tools/read_fs.c squashfs4.0.new/squashfs-tools/read_fs.c
70 --- squashfs4.0/squashfs-tools/read_fs.c 2009-08-27 21:33:06.000000000 +0200
71 +++ squashfs4.0.new/squashfs-tools/read_fs.c 2009-08-27 21:41:54.000000000 +0200
72 @@ -40,9 +40,11 @@
73 #include <sys/mman.h>
74
75 #ifndef linux
76 +#ifndef __CYGWIN__
77 #define __BYTE_ORDER BYTE_ORDER
78 #define __BIG_ENDIAN BIG_ENDIAN
79 #define __LITTLE_ENDIAN LITTLE_ENDIAN
80 +#endif
81 #else
82 #include <endian.h>
83 #endif
84 diff -urN squashfs4.0/squashfs-tools/swap.c squashfs4.0.new/squashfs-tools/swap.c
85 --- squashfs4.0/squashfs-tools/swap.c 2009-03-26 05:40:16.000000000 +0100
86 +++ squashfs4.0.new/squashfs-tools/swap.c 2009-08-27 21:44:52.000000000 +0200
87 @@ -20,9 +20,11 @@
88 */
89
90 #ifndef linux
91 +#ifndef __CYGWIN__
92 #define __BYTE_ORDER BYTE_ORDER
93 #define __BIG_ENDIAN BIG_ENDIAN
94 #define __LITTLE_ENDIAN LITTLE_ENDIAN
95 +#endif
96 #else
97 #include <endian.h>
98 #endif
99 diff -urN squashfs4.0/squashfs-tools/unsquashfs.c squashfs4.0.new/squashfs-tools/unsquashfs.c
100 --- squashfs4.0/squashfs-tools/unsquashfs.c 2009-08-27 21:33:06.000000000 +0200
101 +++ squashfs4.0.new/squashfs-tools/unsquashfs.c 2009-08-27 21:41:38.000000000 +0200
102 @@ -111,6 +111,7 @@
103
104 void sigwinch_handler()
105 {
106 +#ifndef __CYGWIN__
107 struct winsize winsize;
108
109 if(ioctl(1, TIOCGWINSZ, &winsize) == -1) {
110 @@ -120,6 +121,9 @@
111 columns = 80;
112 } else
113 columns = winsize.ws_col;
114 +#else
115 + columns = 80;
116 +#endif
117 }
118
119
120 @@ -1794,7 +1798,9 @@
121 if(sigprocmask(SIG_BLOCK, &sigmask, &old_mask) == -1)
122 EXIT_UNSQUASH("Failed to set signal mask in intialise_threads"
123 "\n");
124 -
125 +#ifdef __CYGWIN__
126 + processors = atoi(getenv("NUMBER_OF_PROCESSORS"));
127 +#else
128 if(processors == -1) {
129 #ifndef linux
130 int mib[2];
131 @@ -1816,6 +1822,7 @@
132 processors = get_nprocs();
133 #endif
134 }
135 +#endif /* __CYGWIN__ */
136
137 if((thread = malloc((3 + processors) * sizeof(pthread_t))) == NULL)
138 EXIT_UNSQUASH("Out of memory allocating thread descriptors\n");
139 diff -urN squashfs4.0/squashfs-tools/unsquashfs.h squashfs4.0.new/squashfs-tools/unsquashfs.h
140 --- squashfs4.0/squashfs-tools/unsquashfs.h 2009-08-27 21:33:03.000000000 +0200
141 +++ squashfs4.0.new/squashfs-tools/unsquashfs.h 2009-08-27 21:44:17.000000000 +0200
142 @@ -46,10 +46,12 @@
143 #include <sys/time.h>
144
145 #ifndef linux
146 +#ifndef __CYGWIN__
147 #define __BYTE_ORDER BYTE_ORDER
148 #define __BIG_ENDIAN BIG_ENDIAN
149 #define __LITTLE_ENDIAN LITTLE_ENDIAN
150 #include <sys/sysctl.h>
151 +#endif /* __CYGWIN__ */
152 #else
153 #include <endian.h>
154 #include <sys/sysinfo.h>