Gentoo Archives: gentoo-commits

From: Austin English <wizardedit@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: games-emulation/dosbox/files/, games-emulation/dosbox/
Date: Tue, 28 Jun 2016 08:23:08
Message-Id: 1467101809.143e036505e2b27b1aa5037d52a5f999391b4168.wizardedit@gentoo
1 commit: 143e036505e2b27b1aa5037d52a5f999391b4168
2 Author: Austin English <wizardedit <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 3 04:03:24 2016 +0000
4 Commit: Austin English <wizardedit <AT> gentoo <DOT> org>
5 CommitDate: Tue Jun 28 08:16:49 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=143e0365
7
8 games-emulation/dosbox: fix compiling with clang (#449060)
9
10 Also apply two patches needed by Wine using DOSBox (#586650)
11
12 Gentoo-Bug: https://bugs.gentoo.org/449060
13 Gentoo-Bug: https://bugs.gentoo.org/586650
14
15 Upstream-Bug: https://bugs.winehq.org/show_bug.cgi?id=18118
16 Upstream-Bug: https://bugs.winehq.org/show_bug.cgi?id=25887
17 Upstream-Bug: https://bugs.winehq.org/show_bug.cgi?id=26423
18
19 Package-Manager: portage-2.2.26
20
21 games-emulation/dosbox/dosbox-0.74-r1.ebuild | 51 +++++++
22 .../dosbox/files/dosbox-0.74-clang.patch | 48 +++++++
23 .../dosbox/files/dosbox-0.74-gcc46.patch | 4 +-
24 .../dosbox/files/dosbox-0.74-wine-drive-z.patch | 151 +++++++++++++++++++++
25 .../dosbox/files/dosbox-0.74-wine-filenames.patch | 89 ++++++++++++
26 5 files changed, 341 insertions(+), 2 deletions(-)
27
28 diff --git a/games-emulation/dosbox/dosbox-0.74-r1.ebuild b/games-emulation/dosbox/dosbox-0.74-r1.ebuild
29 new file mode 100644
30 index 0000000..80989ea
31 --- /dev/null
32 +++ b/games-emulation/dosbox/dosbox-0.74-r1.ebuild
33 @@ -0,0 +1,51 @@
34 +# Copyright 1999-2016 Gentoo Foundation
35 +# Distributed under the terms of the GNU General Public License v2
36 +# $Id$
37 +
38 +EAPI=5
39 +inherit eutils games
40 +
41 +DESCRIPTION="DOS emulator"
42 +HOMEPAGE="http://dosbox.sourceforge.net/"
43 +SRC_URI="mirror://sourceforge/dosbox/${P}.tar.gz"
44 +
45 +LICENSE="GPL-2"
46 +SLOT="0"
47 +KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~sparc ~x86"
48 +IUSE="alsa debug hardened opengl"
49 +
50 +DEPEND="alsa? ( media-libs/alsa-lib )
51 + debug? ( sys-libs/ncurses:0 )
52 + opengl? ( virtual/glu virtual/opengl )
53 + media-libs/libpng:0
54 + media-libs/libsdl[joystick,video,X]
55 + media-libs/sdl-net
56 + media-libs/sdl-sound"
57 +RDEPEND=${DEPEND}
58 +
59 +PATCHES=(
60 + "${FILESDIR}"/${P}-clang.patch
61 + "${FILESDIR}"/${P}-gcc46.patch
62 + "${FILESDIR}"/${P}-wine-drive-z.patch
63 + "${FILESDIR}"/${P}-wine-filenames.patch
64 +)
65 +
66 +src_prepare() {
67 + epatch -p1 "${PATCHES[@]}"
68 +}
69 +
70 +src_configure() {
71 + egamesconf \
72 + $(use_enable alsa alsa-midi) \
73 + $(use_enable !hardened dynamic-core) \
74 + $(use_enable !hardened dynamic-x86) \
75 + $(use_enable debug) \
76 + $(use_enable opengl)
77 +}
78 +
79 +src_install() {
80 + default
81 + make_desktop_entry dosbox DOSBox /usr/share/pixmaps/dosbox.ico
82 + doicon src/dosbox.ico
83 + prepgamesdirs
84 +}
85
86 diff --git a/games-emulation/dosbox/files/dosbox-0.74-clang.patch b/games-emulation/dosbox/files/dosbox-0.74-clang.patch
87 new file mode 100644
88 index 0000000..df2923f
89 --- /dev/null
90 +++ b/games-emulation/dosbox/files/dosbox-0.74-clang.patch
91 @@ -0,0 +1,48 @@
92 +Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=449060
93 +
94 +Two backports from Dosbox SVN needed for clang support:
95 +src/fpu/fpu_instructions_x86.h changes are revision 3841
96 +src/cpu/core_dynrec/risc_x64.h changes are revision 3894
97 +
98 +Index: src/fpu/fpu_instructions_x86.h
99 +===================================================================
100 +--- a/src/fpu/fpu_instructions_x86.h (revision 3840)
101 ++++ b/src/fpu/fpu_instructions_x86.h (revision 3841)
102 +@@ -1161,12 +1161,12 @@
103 +
104 + static void FPU_FLD_I16(PhysPt addr,Bitu store_to) {
105 + fpu.p_regs[8].m1 = (Bit32u)mem_readw(addr);
106 +- FPUD_LOAD(fild,WORD,)
107 ++ FPUD_LOAD(fild,WORD,s)
108 + }
109 +
110 + static void FPU_FLD_I16_EA(PhysPt addr) {
111 + fpu.p_regs[8].m1 = (Bit32u)mem_readw(addr);
112 +- FPUD_LOAD_EA(fild,WORD,)
113 ++ FPUD_LOAD_EA(fild,WORD,s)
114 + }
115 +
116 + static void FPU_FLD_I32(PhysPt addr,Bitu store_to) {
117 +@@ -1211,7 +1211,7 @@
118 + }
119 +
120 + static void FPU_FST_I16(PhysPt addr) {
121 +- FPUD_STORE(fistp,WORD,)
122 ++ FPUD_STORE(fistp,WORD,s)
123 + mem_writew(addr,(Bit16u)fpu.p_regs[8].m1);
124 + }
125 +
126 +Index: src/cpu/core_dynrec/risc_x64.h
127 +===================================================================
128 +--- a/src/cpu/core_dynrec/risc_x64.h (revision 3893)
129 ++++ b/src/cpu/core_dynrec/risc_x64.h (revision 3894)
130 +@@ -85,7 +85,8 @@
131 +
132 + static INLINE void gen_reg_memaddr(HostReg reg,void* data) {
133 + Bit64s diff = (Bit64s)data-((Bit64s)cache.pos+5);
134 +- if ((diff<0x80000000LL) && (diff>-0x80000000LL)) {
135 ++// if ((diff<0x80000000LL) && (diff>-0x80000000LL)) { //clang messes itself up on this...
136 ++ if ( (diff>>63) == (diff>>31) ) { //signed bit extend, test to see if value fits in a Bit32s
137 + cache_addb(0x05+(reg<<3));
138 + // RIP-relative addressing is offset after the instruction
139 + cache_addd((Bit32u)(((Bit64u)diff)&0xffffffffLL));
140
141 diff --git a/games-emulation/dosbox/files/dosbox-0.74-gcc46.patch b/games-emulation/dosbox/files/dosbox-0.74-gcc46.patch
142 index 16811d4..54cd51b 100644
143 --- a/games-emulation/dosbox/files/dosbox-0.74-gcc46.patch
144 +++ b/games-emulation/dosbox/files/dosbox-0.74-gcc46.patch
145 @@ -1,5 +1,5 @@
146 ---- include/dos_inc.h.old 2011-04-28 08:46:04.505011354 +0200
147 -+++ include/dos_inc.h 2011-04-28 08:46:27.104408178 +0200
148 +--- a/include/dos_inc.h.old 2011-04-28 08:46:04.505011354 +0200
149 ++++ b/include/dos_inc.h 2011-04-28 08:46:27.104408178 +0200
150 @@ -21,6 +21,7 @@
151 #ifndef DOSBOX_DOS_INC_H
152 #define DOSBOX_DOS_INC_H
153
154 diff --git a/games-emulation/dosbox/files/dosbox-0.74-wine-drive-z.patch b/games-emulation/dosbox/files/dosbox-0.74-wine-drive-z.patch
155 new file mode 100644
156 index 0000000..848d3e7
157 --- /dev/null
158 +++ b/games-emulation/dosbox/files/dosbox-0.74-wine-drive-z.patch
159 @@ -0,0 +1,151 @@
160 +From Debian (which backported the patch):
161 +https://packages.debian.org/sid/dosbox
162 +
163 +Description: Rewrite mount without arguments to display volume label as well.
164 + Some refactoring of the code.
165 + Add mount -z X, where X is the new virtual drive for the Wine Team.
166 +Origin: upstream, http://sourceforge.net/p/dosbox/code-0/3736/
167 +Author: Peter Veenstra <qbix79@×××××××××××××××××.net>
168 +Last-Update: 2011-07-23
169 +--- a/src/dos/dos_programs.cpp
170 ++++ b/src/dos/dos_programs.cpp
171 +@@ -49,27 +49,55 @@
172 + #endif
173 +
174 + void MSCDEX_SetCDInterface(int intNr, int forceCD);
175 +-
176 ++static Bitu ZDRIVE_NUM = 25;
177 +
178 + class MOUNT : public Program {
179 + public:
180 +- void Run(void)
181 +- {
182 ++ void ListMounts(void) {
183 ++ char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u date;Bit16u time;Bit8u attr;
184 ++ /* Command uses dta so set it to our internal dta */
185 ++ RealPt save_dta = dos.dta();
186 ++ dos.dta(dos.tables.tempdta);
187 ++ DOS_DTA dta(dos.dta());
188 ++
189 ++ WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
190 ++ WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_FORMAT"),"Drive","Type","Label");
191 ++ for(int p = 0;p < 8;p++) WriteOut("----------");
192 ++
193 ++ for (int d = 0;d < DOS_DRIVES;d++) {
194 ++ if (!Drives[d]) continue;
195 ++
196 ++ char root[4] = {'A'+d,':','\\',0};
197 ++ bool ret = DOS_FindFirst(root,DOS_ATTR_VOLUME);
198 ++ if (ret) {
199 ++ dta.GetResult(name,size,date,time,attr);
200 ++ DOS_FindNext(); //Mark entry as invalid
201 ++ } else name[0] = 0;
202 ++
203 ++ /* Change 8.3 to 11.0 */
204 ++ char* dot = strchr(name,'.');
205 ++ if(dot && (dot - name == 8) ) {
206 ++ name[8] = name[9];name[9] = name[10];name[10] = name[11];name[11] = 0;
207 ++ }
208 ++
209 ++ root[1] = 0; //This way, the format string can be reused.
210 ++ WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_FORMAT"),root, Drives[d]->GetInfo(),name);
211 ++ }
212 ++ dos.dta(save_dta);
213 ++ }
214 ++
215 ++ void Run(void) {
216 + DOS_Drive * newdrive;char drive;
217 + std::string label;
218 + std::string umount;
219 ++ std::string newz;
220 +
221 + //Hack To allow long commandlines
222 + ChangeToLongCmd();
223 + /* Parse the command line */
224 + /* if the command line is empty show current mounts */
225 + if (!cmd->GetCount()) {
226 +- WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
227 +- for (int d=0;d<DOS_DRIVES;d++) {
228 +- if (Drives[d]) {
229 +- WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),d+'A',Drives[d]->GetInfo());
230 +- }
231 +- }
232 ++ ListMounts();
233 + return;
234 + }
235 +
236 +@@ -84,12 +112,12 @@
237 + if (cmd->FindString("-u",umount,false)) {
238 + umount[0] = toupper(umount[0]);
239 + int i_drive = umount[0]-'A';
240 +- if(i_drive < DOS_DRIVES && i_drive >= 0 && Drives[i_drive]) {
241 ++ if (i_drive < DOS_DRIVES && i_drive >= 0 && Drives[i_drive]) {
242 + switch (DriveManager::UnmountDrive(i_drive)) {
243 + case 0:
244 + Drives[i_drive] = 0;
245 + if(i_drive == DOS_GetDefaultDrive())
246 +- DOS_SetDrive(toupper('Z') - 'A');
247 ++ DOS_SetDrive(ZDRIVE_NUM);
248 + WriteOut(MSG_Get("PROGRAM_MOUNT_UMOUNT_SUCCESS"),umount[0]);
249 + break;
250 + case 1:
251 +@@ -104,8 +132,46 @@
252 + }
253 + return;
254 + }
255 +-
256 +- // Show list of cdroms
257 ++
258 ++ /* Check for moving Z: */
259 ++ /* Only allowing moving it once. It is merely a convenience added for the wine team */
260 ++ if (ZDRIVE_NUM == 25 && cmd->FindString("-z", newz,false)) {
261 ++ newz[0] = toupper(newz[0]);
262 ++ int i_newz = newz[0] - 'A';
263 ++ if (i_newz >= 0 && i_newz < DOS_DRIVES-1 && !Drives[i_newz]) {
264 ++ ZDRIVE_NUM = i_newz;
265 ++ /* remap drives */
266 ++ Drives[i_newz] = Drives[25];
267 ++ Drives[25] = 0;
268 ++ DOS_Shell *fs = static_cast<DOS_Shell *>(first_shell); //dynamic ?
269 ++ /* Update environment */
270 ++ std::string line = "";
271 ++ char ppp[2] = {newz[0],0};
272 ++ std::string tempenv = ppp; tempenv += ":\\";
273 ++ if (fs->GetEnvStr("PATH",line)){
274 ++ std::string::size_type idx = line.find('=');
275 ++ std::string value = line.substr(idx +1 , std::string::npos);
276 ++ while ( (idx = value.find("Z:\\")) != std::string::npos ||
277 ++ (idx = value.find("z:\\")) != std::string::npos )
278 ++ value.replace(idx,3,tempenv);
279 ++ line = value;
280 ++ }
281 ++ if (!line.size()) line = tempenv;
282 ++ fs->SetEnv("PATH",line.c_str());
283 ++ tempenv += "COMMAND.COM";
284 ++ fs->SetEnv("COMSPEC",tempenv.c_str());
285 ++
286 ++ /* Update batch file if running from Z: (very likely: autoexec) */
287 ++ if(fs->bf) {
288 ++ std::string &name = fs->bf->filename;
289 ++ if(name.length() >2 && name[0] == 'Z' && name[1] == ':') name[0] = newz[0];
290 ++ }
291 ++ /* Change the active drive */
292 ++ if (DOS_GetDefaultDrive() == 25) DOS_SetDrive(i_newz);
293 ++ }
294 ++ return;
295 ++ }
296 ++ /* Show list of cdroms */
297 + if (cmd->FindExist("-cd",false)) {
298 + int num = SDL_CDNumDrives();
299 + WriteOut(MSG_Get("PROGRAM_MOUNT_CDROMS_FOUND"),num);
300 +@@ -1347,8 +1413,9 @@
301 + /*Add Messages */
302 +
303 + MSG_Add("PROGRAM_MOUNT_CDROMS_FOUND","CDROMs found: %d\n");
304 ++ MSG_Add("PROGRAM_MOUNT_STATUS_FORMAT","%-5s %-58s %-12s\n");
305 + MSG_Add("PROGRAM_MOUNT_STATUS_2","Drive %c is mounted as %s\n");
306 +- MSG_Add("PROGRAM_MOUNT_STATUS_1","Current mounted drives are:\n");
307 ++ MSG_Add("PROGRAM_MOUNT_STATUS_1","The currently mounted drives are:\n");
308 + MSG_Add("PROGRAM_MOUNT_ERROR_1","Directory %s doesn't exist.\n");
309 + MSG_Add("PROGRAM_MOUNT_ERROR_2","%s isn't a directory\n");
310 + MSG_Add("PROGRAM_MOUNT_ILL_TYPE","Illegal type %s\n");
311
312 diff --git a/games-emulation/dosbox/files/dosbox-0.74-wine-filenames.patch b/games-emulation/dosbox/files/dosbox-0.74-wine-filenames.patch
313 new file mode 100644
314 index 0000000..89e2433
315 --- /dev/null
316 +++ b/games-emulation/dosbox/files/dosbox-0.74-wine-filenames.patch
317 @@ -0,0 +1,89 @@
318 +Description: Be friendly for other open source projects: work with WINE style namemangling.
319 + Patch 3382938 from Andre_H (modified).
320 +Origin: upstream, http://sourceforge.net/p/dosbox/code-0/3743/
321 +Author: Peter Veenstra <qbix79@×××××××××××××××××.net>
322 +Last-Update: 2011-08-30
323 +--- a/src/dos/drive_cache.cpp
324 ++++ b/src/dos/drive_cache.cpp
325 +@@ -370,6 +370,60 @@
326 + return false;
327 + }
328 +
329 ++#define WINE_DRIVE_SUPPORT 1
330 ++#if WINE_DRIVE_SUPPORT
331 ++//Changes to interact with WINE by supporting their namemangling.
332 ++//The code is rather slow, because orglist is unordered, so it needs to be avoided if possible.
333 ++//Hence the tests in GetLongFileName
334 ++
335 ++
336 ++// From the Wine project
337 ++static Bits wine_hash_short_file_name( char* name, char* buffer )
338 ++{
339 ++ static const char hash_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
340 ++ static const char invalid_chars[] = { '*','?','<','>','|','"','+','=',',',';','[',']',' ','\345','~','.',0 };
341 ++ char* p;
342 ++ char* ext;
343 ++ char* end = name + strlen(name);
344 ++ char* dst;
345 ++ unsigned short hash;
346 ++ int i;
347 ++
348 ++ // Compute the hash code of the file name
349 ++ for (p = name, hash = 0xbeef; p < end - 1; p++)
350 ++ hash = (hash<<3) ^ (hash>>5) ^ tolower(*p) ^ (tolower(p[1]) << 8);
351 ++ hash = (hash<<3) ^ (hash>>5) ^ tolower(*p); // Last character
352 ++
353 ++
354 ++ // Find last dot for start of the extension
355 ++ for (p = name + 1, ext = NULL; p < end - 1; p++) if (*p == '.') ext = p;
356 ++
357 ++ // Copy first 4 chars, replacing invalid chars with '_'
358 ++ for (i = 4, p = name, dst = buffer; i > 0; i--, p++)
359 ++ {
360 ++ if (p == end || p == ext) break;
361 ++ *dst++ = (*p < 0 || strchr( invalid_chars, *p ) != NULL) ? '_' : toupper(*p);
362 ++ }
363 ++ // Pad to 5 chars with '~'
364 ++ while (i-- >= 0) *dst++ = '~';
365 ++
366 ++ // Insert hash code converted to 3 ASCII chars
367 ++ *dst++ = hash_chars[(hash >> 10) & 0x1f];
368 ++ *dst++ = hash_chars[(hash >> 5) & 0x1f];
369 ++ *dst++ = hash_chars[hash & 0x1f];
370 ++
371 ++ // Copy the first 3 chars of the extension (if any)
372 ++ if (ext)
373 ++ {
374 ++ *dst++ = '.';
375 ++ for (i = 3, ext++; (i > 0) && ext < end; i--, ext++)
376 ++ *dst++ = (*ext < 0 || strchr( invalid_chars, *ext ) != NULL) ? '_' : toupper(*ext);
377 ++ }
378 ++
379 ++ return dst - buffer;
380 ++}
381 ++#endif
382 ++
383 + Bits DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName) {
384 + std::vector<CFileInfo*>::size_type filelist_size = curDir->fileList.size();
385 + if (GCC_UNLIKELY(filelist_size<=0)) return -1;
386 +@@ -390,6 +444,20 @@
387 + return mid;
388 + };
389 + }
390 ++#ifdef WINE_DRIVE_SUPPORT
391 ++ if (strlen(shortName) < 8 || shortName[4] != '~' || shortName[5] == '.' || shortName[6] == '.' || shortName[7] == '.') return -1; // not available
392 ++ // else it's most likely a Wine style short name ABCD~###, # = not dot (length at least 8)
393 ++ // The above test is rather strict as the following loop can be really slow if filelist_size is large.
394 ++ char buff[CROSS_LEN];
395 ++ for (Bits i = 0; i < filelist_size; i++) {
396 ++ res = wine_hash_short_file_name(curDir->fileList[i]->orgname,buff);
397 ++ if (!strncmp(shortName,buff,res))
398 ++ { // Found
399 ++ strcpy(shortName,curDir->fileList[i]->orgname);
400 ++ return i;
401 ++ };
402 ++ }
403 ++#endif
404 + // not available
405 + return -1;
406 + }