Ticket #2298: MoveFileEx.dpatch

File MoveFileEx.dpatch, 20.4 KB (added by duncan, 7 years ago)

patch to simplify renameFile impl on windows

Line 
1
2New patches:
3
4[Simplify implementation of __hscore_renameFile to be NT+ only
5Duncan Coutts <[email protected]>**20080520172055
6 Remove a bunch of hacky workarounds for Win9x systems.
7 There is also a behaviour change for NT systems: previously the
8 code also tried a workaround even on NT systems if calling
9 MoveFileEx() failed. It would instead try to delete the target
10 file and have another go at renaming. This seems most unwise as
11 it looses any atomicity guarantee that MoveFileEx() provides.
12] {
13hunk ./cbits/dirUtils.c 79
14- * the target if it exists (the MS CRT implementation of rename() returns
15- * an error
16+ * the target if it exists. The MS CRT implementation of rename() returns
17+ * an error if the target file exists so we have to use MoveFileEx().
18hunk ./cbits/dirUtils.c 87
19-    static int forNT = -1;
20-   
21-    /* ToDo: propagate error codes back */
22-    if (MoveFileA(src, dest)) {
23+    if (MoveFileExA(src, dest, MOVEFILE_REPLACE_EXISTING)) {
24hunk ./cbits/dirUtils.c 90
25-       ;
26-    }
27-   
28-    /* Failed...it could be because the target already existed. */
29-    if ( !GetFileAttributes(dest) ) {
30-       /* No, it's not there - just fail. */
31-       maperrno();
32-       return (-1);
33-    }
34-
35-    if (forNT == -1) {
36-       OSVERSIONINFO ovi;
37-       ovi.dwOSVersionInfoSize = sizeof(ovi);
38-       if ( !GetVersionEx(&ovi) ) {
39-           maperrno();
40-           return (-1);
41-       }
42-       forNT = ((ovi.dwPlatformId & VER_PLATFORM_WIN32_NT) != 0);
43-    }
44-   
45-    if (forNT) {
46-       /* Easy, go for MoveFileEx() */
47-       if ( MoveFileExA(src, dest, MOVEFILE_REPLACE_EXISTING) ) {
48-           return 0;
49-       } else {
50-           maperrno();
51-           return (-1);
52-       }
53-    }
54-
55-    /* No MoveFileEx() for Win9x, try deleting the target. */
56-    /* Similarly, if the MoveFile*() ops didn't work out under NT */
57-    if (DeleteFileA(dest)) {
58-       if (MoveFileA(src,dest)) {
59-           return 0;
60-       } else {
61-           maperrno();
62-           return (-1);
63-       }
64-    } else {
65}
66
67Context:
68
69[Avoid calling varargs functions using the FFI
70Simon Marlow <[email protected]>**20080509145334
71 Calling varargs functions is explicitly deprecated according to the
72 FFI specification.  It used to work, just about, but it broke with the
73 recent changes to the via-C backend to not use header files.
74]
75[Add comments about why rotate has an INLINE
76[email protected]**20080502074137]
77[Inline Data.Bits.rotate@Int, enables rotate to be constant folded
78Don Stewart <[email protected]>**20080501230152
79 
80 All other Bits instances seem to inline well enough on their own
81 to enable constant folding, e.g.
82 
83     sumU . mapU (`shift` 3) . replicateU 10000000 $ (7 :: Int)
84 
85 goes to:
86 
87     Main.$wfold =
88       \ (ww_sOb :: Int#) (ww1_sOf :: Int#) ->
89         case ww1_sOf of wild_XM {
90           __DEFAULT -> Main.$wfold (+# ww_sOb 56) (+# wild_XM 1);
91           10000000 -> ww_sOb
92         }
93 
94 With this patch, rotate gets inlined and folded too,
95 
96     sumU . mapU (`rotate` 3) . replicateU 10000000 $ (7 :: Int)
97 
98 to:
99 
100   Main.$wfold =
101     \ (ww_sO7 :: Int#) (ww1_sOb :: Int#) ->
102       case ww1_sOb of wild_XM {
103         __DEFAULT -> Main.$wfold (+# ww_sO7 56) (+# wild_XM 1);
104         10000000 -> ww_sO7
105 
106 Whereas it was left as a call to $wrotate before.
107     
108 
109]
110[Moved def. of emptyP
111[email protected]**20080501024223]
112[emptyP def to gHC.PArr
113[email protected]**20080501012547]
114[Reexport (>>>) and (<<<) from Control.Arrow. Preserves API compatibility
115Don Stewart <[email protected]>**20080430231055]
116[Add realToFrac RULE comments from patch message into the source code
117[email protected]**20080430214355]
118[Add RULES for realToFrac from Int.
119Don Stewart <[email protected]>**20080430174126
120 
121     {-# RULES
122     "realToFrac/Int->Double"    realToFrac   = int2Double
123     "realToFrac/Int->Float"     realToFrac   = int2Float
124       #-}
125 
126 Note that this only matters for realToFrac. If you've been using
127 fromIntegral to promote Int to Doubles, things should be fine as they are.
128 
129 The following program, using stream fusion to eliminate arrays:
130 
131     import Data.Array.Vector
132 
133     n = 40000000
134 
135     main = do
136           let c = replicateU n (2::Double)
137               a = mapU realToFrac (enumFromToU 0 (n-1) ) :: UArr Double
138           print (sumU (zipWithU (*) c a))
139 
140 Yields this loop body without the RULE:
141 
142     case $wtoRational sc_sY4 of ww_aM7 { (# ww1_aM9, ww2_aMa #) ->
143     case $wfromRat ww1_aM9 ww2_aMa of tpl_X1P { D# ipv_sW3 ->
144     Main.$s$wfold
145       (+# sc_sY4 1)
146       (+# wild_X1i 1)
147       (+## sc2_sY6 (*## 2.0 ipv_sW3))
148 
149 And with the rule:
150 
151    Main.$s$wfold
152       (+# sc_sXT 1)
153       (+# wild_X1h 1)
154       (+## sc2_sXV (*## 2.0 (int2Double# sc_sXT)))
155 
156 The running time of the program goes from 120 seconds to 0.198 seconds
157 with the native backend, and 0.143 seconds with the C backend.
158 
159 
160 And just so I don't forget, here's the difference in resulting
161 assembly (x86_64), between the native code generator, and the
162 C backend.
163 
164 -fasm
165 
166     Main_zdszdwfold_info:
167       movq %rdi,%rax
168       cmpq $40000000,%rax
169       jne .LcZK
170       jmp *(%rbp)
171     .LcZK:
172       cmpq $39999999,%rsi
173       jg .LcZN
174       cvtsi2sdq %rsi,%xmm0
175       mulsd .LnZP(%rip),%xmm0
176       movsd %xmm5,%xmm7
177       addsd %xmm0,%xmm7
178       incq %rax
179       incq %rsi
180       movq %rax,%rdi
181       movsd %xmm7,%xmm5
182       jmp Main_zdszdwfold_info
183 
184 With the C backend we get the even better assembly, (-fvia-C -optc-O3)
185 
186     Main_zdszdwfold_info:
187         cmpq    $40000000, %rdi
188         je  .L9
189     .L5:
190         cmpq    $39999999, %rsi
191         jg  .L9
192         cvtsi2sdq   %rsi, %xmm0
193         leaq    1(%rdi), %rdi
194         addq    $1, %rsi
195         addsd   %xmm0, %xmm0
196         addsd   %xmm0, %xmm5
197         jmp Main_zdszdwfold_info
198     .L9:
199         jmp *(%rbp)
200 
201 So might make a useful test once the native codegen project starts up.
202 
203 
204]
205[Just (-0/1) is now printed as Just (-0.0), not Just -0.0; trac #2036
206Ian Lynagh <[email protected]>**20080427133230]
207[record [email protected] as maintainer
208Ross Paterson <[email protected]>**20080425095200]
209[Added emptyP def
210[email protected]**20080424021403]
211[don't set O_NONBLOCK on FDs passed to fdToHandle
212Simon Marlow <[email protected]>**20080422204719]
213[Improve docs for unsafeCoerce
214[email protected]**20080422130547
215 Make it clear that compilers differ.  Point to GHC docs in GHC.Base, and
216 add a short description of nhc98's representation-safe conversions.
217]
218[Spelling only
219[email protected]**20080422082033]
220[In docs for unsafeCoerce, point to unsafeCoerce#
221[email protected]**20080421152251]
222[Turn off the gcd/lcm optimisations for Integer for now
223Ian Lynagh <[email protected]>**20080418190238
224 This makes it easier to experiment with other implementations
225]
226[Ordering has now moved to ghc-prim
227Ian Lynagh <[email protected]>**20080412100741]
228[fix types for __hscore_st_dev() and __hscore_st_ino()
229Simon Marlow <[email protected]>**20080319174101]
230[give an absolute path to 'harch'
231[email protected]**20080327142912]
232[Move Word64/Int64/Word32/Int32 primitives into ghc-prim
233Ian Lynagh <[email protected]>**20080325202634]
234[Update .darcs-boring
235Ian Lynagh <[email protected]>**20080324205808
236 GHC/Prim.hs, GHC/PrimopWrappers.hs are no longer generated in this package
237]
238[Remove GHC.PrimopWrappers from base's exposed modules list
239Ian Lynagh <[email protected]>**20080324205734]
240[base now uses build-type: Configure
241Ian Lynagh <[email protected]>**20080323191146]
242[Move Integer out into its own package
243Ian Lynagh <[email protected]>**20080323181342
244 We now depend on the new integer package.
245 We also depend on a new ghc-prim package, which has GHC.Prim,
246 GHC.PrimopWrappers, and new modules GHC.Bool and GHC.Generics,
247 containing Bool and Unit/Inl/Inr respectively.
248]
249[List extensions used rather than using the -fglasgow-exts hammer
250Ian Lynagh <[email protected]>**20080322133622]
251[Remove a gratuitous pattern type sig
252Ian Lynagh <[email protected]>**20080321011356]
253[An even better definition for (^) (trac #1687)
254Ian Lynagh <[email protected]>**20080320003957]
255[Replace (^) with a faster variant (from trac #1687)
256Ian Lynagh <[email protected]>**20080318003017]
257[Add partitionEithers, lefts, and rights.
258Ian Lynagh <[email protected]>**20080314193037
259 Patch from Russell O'Connor, trac proposal #974.
260]
261[System.Console.GetOpt mistakenly rejects options as ambiguous.
262[email protected]**20080312111047
263 From "Eelis van der Weegen" <[email protected]>.
264 Testcase:
265 
266 > import System.Console.GetOpt
267 >
268 > type Color = String
269 >
270 > optsDesc :: [OptDescr Color]
271 > optsDesc = [Option "" ["color", "colour"]
272 >                    (ReqArg id "color") "Foreground color"]
273 >
274 > main = do
275 >   let args = ["--col=blue"]
276 >   case getOpt RequireOrder optsDesc args of
277 >     (_, _, err:_) -> putStrLn err
278 >     _ -> return ()
279 
280 Output:
281   option `--col' is ambiguous; could be one of:
282       --color=color, --colour=color  Foreground color
283       --color=color, --colour=color  Foreground color
284 
285 This error is silly, because the two alternatives listed are the same
286 option.  The problem is caused by incorrect use of a generator in a list
287 comprehension.
288]
289[untabify
290Don Stewart <[email protected]>**20080310005455]
291[untabify
292Don Stewart <[email protected]>**20080308014256]
293[untabify
294Don Stewart <[email protected]>**20080308014129]
295[untabify
296Don Stewart <[email protected]>**20080308014040]
297[untabify
298Don Stewart <[email protected]>**20080308013556]
299[untabify
300Don Stewart <[email protected]>**20080308012457]
301[untabify
302Don Stewart <[email protected]>**20080308012059]
303[untabify
304Don Stewart <[email protected]>**20080307192727]
305[untabify
306Don Stewart <[email protected]>**20080305033712]
307[untabify
308Don Stewart <[email protected]>**20080305015827]
309[untabify
310Don Stewart <[email protected]>**20080305012530]
311[untabify
312Don Stewart <[email protected]>**20080305010343]
313[untabify
314Don Stewart <[email protected]>**20080305010255]
315[untabify
316Don Stewart <[email protected]>**20080305005041]
317[untabify
318Don Stewart <[email protected]>**20080305005025]
319[untabify
320Don Stewart <[email protected]>**20080304235330]
321[untabify
322Don Stewart <[email protected]>**20080304225120]
323[untabify
324Don Stewart <[email protected]>**20080304174827]
325[untabify
326Don Stewart <[email protected]>**20080303195109]
327[untabify
328Don Stewart <[email protected]>**20080303195002]
329[untabify
330Don Stewart <[email protected]>**20080303194454]
331[untabify
332Don Stewart <[email protected]>**20080228234443]
333[untabify
334Don Stewart <[email protected]>**20080228185409]
335[untabify
336Don Stewart <[email protected]>**20080228185356]
337[untabify
338Don Stewart <[email protected]>**20080228185331]
339[export MVar, TVar, and STM non-abstractly
340Simon Marlow <[email protected]>**20080228113035
341 As requested by Sterling Clover on ghc-users
342]
343[Added Down class and improved groupWith fusion
344Max Bolingbroke <[email protected]>**20080213212246]
345[untabify
346Don Stewart <[email protected]>**20080227062836]
347[untabify
348Don Stewart <[email protected]>**20080226070630]
349[mention explicitly that hIsEOF may block
350Simon Marlow <[email protected]>**20080220141209]
351[untabify
352Don Stewart <[email protected]>**20080219233644]
353[untabify
354Don Stewart <[email protected]>**20080219233047]
355[untabify
356Don Stewart <[email protected]>**20080219232910]
357[untabify
358Don Stewart <[email protected]>**20080219225437]
359[untabify
360Don Stewart <[email protected]>**20080219061513]
361[Add exitSuccess :: IO a. For symmetry with exitFailure
362Don Stewart <[email protected]>**20080213222644]
363[untabify
364Don Stewart <[email protected]>**20080218075732]
365[untabify
366Don Stewart <[email protected]>**20080218065411]
367[untabify
368Don Stewart <[email protected]>**20080215005543]
369[FIX dynamic001, dynamic002: further fixes to tuple printing
370Simon Marlow <[email protected]>**20080211101908]
371[untabify
372Don Stewart <[email protected]>**20080213221950]
373[untabify only
374Don Stewart <[email protected]>**20080213221856]
375[whitespace only
376Don Stewart <[email protected]>**20080207191939]
377[Whitespace only
378Don Stewart <[email protected]>**20080207183954]
379[FIX dynamic001 dynamic002: isTupleTyCon had rotted
380Simon Marlow <[email protected]>**20080205103904
381 In the patch "Tuple tycons have parens around their names", the names
382 of the tuple tycons were changed to include parens, but isTupleTyCon
383 was not updated to match, which made tuple types show as "(,) a b"
384 rather than "(a,b)"
385]
386[deforestation rules for enumFromThenTo; based on a patch from Robin Houston
387Ian Lynagh <[email protected]>**20080203152755]
388[Generalise type of forever :: (Monad m) => m a -> m b
389Don Stewart <[email protected]>**20080129191940]
390[FIX #1936: hGetBufNonBlocking was blocking on stdin/stdout/stderr
391Simon Marlow <[email protected]>**20080124092203]
392[The default uncaught exception handler was adding an extra \n
393Simon Marlow <[email protected]>**20080124091216]
394[add comment about lack of _chsize_s()
395Simon Marlow <[email protected]>**20080123131248]
396[Windows: large file support for hFileSize and hSeek (#1771)
397Simon Marlow <[email protected]>**20080123102904
398 
399 
400]
401[Export topHandler, topHandlerFastExit from GHC.TopHandler
402Ian Lynagh <[email protected]>**20080120182429
403 We now use one of these in ghc when running with ghc -e
404]
405[haddock attributes for haddock-2.0
406Ross Paterson <[email protected]>**20080120022308]
407[Data.List.sort: force elements from start to end.
408Bertram Felgenhauer <[email protected]>**20071121101458
409 this prevents a stack overflow on  sort (take 10^6 [1..])
410]
411[Fix comment on GHC.Ptr.minusPtr
412[email protected]**20080109114736]
413[Remove redundant imports of GHC.Err
414[email protected]**20080104091314
415 
416 GHC.Base SOURCE-imports GHC.Err, and re-exports 'error'.  So
417 other modules need only import GHC.Base.
418 
419 This doesn't change the fact that these other modules are all compiled
420 before GHC.Err, so they are all part of the module loop that starts with
421 GHC.Base and finishes with GHC.Err.  But it does reduce the occurrence
422 of those SOURCE imports.
423 
424]
425[Tuple tycons have parens around their names
426simonpj@microsoft**20071220171812
427 
428 The name of the pair TyCon, in the Typeable instance,
429 should be "(,)" not ",".
430 
431 Don't merge to 6.8; it's a minor API change.
432 
433]
434[Add groupWith, sortWith, the, to support generalised list comprehensions
435[email protected]**20071220111929
436 
437   This the base-library patch to support the main compiler patch
438      Implement generalised list comprehensions
439   
440   It just adds three functions to GHC.Exts.
441 
442]
443[Add GHC.Prim to exposedModules in the Haddock 0.x hook
444David Waern <[email protected]>*-20071209173931
445 
446 Please merge to the stable branch
447]
448[Add GHC.Prim to exposedModules in the Haddock 0.x hook
449David Waern <[email protected]>**20071209173931
450 
451 Please merge to the stable branch
452]
453[Simplify the GHC.Prim hack in base.cabal/Setup.hs
454Ian Lynagh <[email protected]>**20071202215758]
455[Implement 'openTempFile' for nhc98.
456[email protected]**20071207133335]
457[docs: describe the changes to forkIO, and document forkOnIO
458Simon Marlow <[email protected]>**20071205091423]
459[doc only: use realToFrac instead of fromRational.toRational
460Simon Marlow <[email protected]>**20071205091334]
461[Add singletonP to GHC.PArr
462Roman Leshchinskiy <[email protected]>**20071205220859]
463[FIX #1621: bug in Windows code for getCPUTime
464Simon Marlow <[email protected]>**20071205120118
465 We were reading the components of FILETIME as CLong, when they should
466 be unsigned.  Word32 seems to be the correct type here.
467]
468[protect console handler against concurrent access (#1922)
469Simon Marlow <[email protected]>**20071204153940]
470[protect against concurrent access to the signal handlers (#1922)
471Simon Marlow <[email protected]>**20071204110817]
472[restore fdToHandle' to avoid breaking clients (#1109)
473Simon Marlow <simonmar@microsoft.com>**20071130135122
474 
475]
476[note about how to convert CTime (aka EpochTime) to UTCTime
477Simon Marlow <simonmar@microsoft.com>**20071130101648]
478[Fix some URLs
479Ian Lynagh <igloo@earth.li>**20071126214213]
480[Fix some links in haddock docs
481Ian Lynagh <igloo@earth.li>**20071126184428]
482[Don't try to make haddock links to the mtl package as we don't depend on it
483Ian Lynagh <igloo@earth.li>**20071126170631]
484[Escape some special characters in haddock docs
485Ian Lynagh <igloo@earth.li>**20071126163443]
486[FIX BUILD: maybeUpdateFile: ignore failures when removing the target
487Simon Marlow <simonmar@microsoft.com>**20071123092219]
488[FIX #1753
489Simon Marlow <simonmar@microsoft.com>**20071122094207
490 hClose should close the Handle and unlock the file even if calling
491 close() fails for some reason.
492]
493[remove lockFile.h from install-includes
494Simon Marlow <simonmar@microsoft.com>**20071121102248]
495[oops, we forgot to export traceShow
496Simon Marlow <simonmar@microsoft.com>**20071121094300]
497[Fix compilation with GHC 6.2.x
498Simon Marlow <simonmar@microsoft.com>**20071121084341]
499[Move file locking into the RTS, fixing #629, #1109
500Simon Marlow <simonmar@microsoft.com>**20071120121053
501 File locking (of the Haskell 98 variety) was previously done using a
502 static table with linear search, which had two problems: the array had
503 a fixed size and was sometimes too small (#1109), and performance of
504 lockFile/unlockFile was suboptimal due to the linear search.
505 Also the algorithm failed to count readers as required by Haskell 98
506 (#629).
507 
508 Now it's done using a hash table (provided by the RTS).  Furthermore I
509 avoided the extra fstat() for every open file by passing the dev_t and
510 ino_t into lockFile.  This and the improvements to the locking
511 algorithm result in a healthy 20% or so performance increase for
512 opening/closing files (see openFile008 test).
513]
514[Only overwrite GHC/Prim.hs and GHC/Primopwrappers.hs if they change
515Simon Marlow <simonmar@microsoft.com>**20071120102042
516 This avoids make doing unnecessary work after 'setup makefile'.
517]
518[fix comment
519Simon Marlow <simonmar@microsoft.com>**20071116091227]
520[Fix ` characters in elem's haddock docs
521Ian Lynagh <igloo@earth.li>**20071110173052]
522[Filter out GHC.Prim also for the Haddock step
523David Waern <david.waern@gmail.com>**20071109000806
524 Please merge to the GHC 6.8.2 branch
525]
526[Add module of special magic GHC desugaring helper functions
527Simon Marlow <simonmar@microsoft.com>**20071102160054
528 Currently containing only one such helper: (>>>) for arrow desugaring
529]
530[add Control.Category to the nhc98 build
531Malcolm.Wallace@cs.york.ac.uk**20071030120459]
532[fix nhc98 build: need a qualified Prelude import
533Malcolm.Wallace@cs.york.ac.uk**20071030120410]
534[Fix performance regression: re-instate -funbox-strict-fields
535Simon Marlow <simonmar@microsoft.com>**20071029150730
536 Yikes!  While investigating the increase in code size with GHC 6.8
537 relative to 6.6, I noticed that in the transition to Cabal for the
538 libraries we lost -funbox-strict-fields, which is more or less
539 depended on by the IO library for performance.  I'm astonished that we
540 didn't notice this earlier!
541 
542 To reduce the chances of this happening again, I put
543 -funbox-strict-fields in the OPTIONS_GHC pragma of the modules that
544 need it.  {-# UNPACK #-} pragmas would be better, though.
545]
546[FIX BUILD: Haddock 1.x fails to parse (Prelude..)
547Simon Marlow <simonmar@microsoft.com>**20071029131921]
548[new Control.Category, ghc ticket #1773
549Ashley Yakeley <ashley@semantic.org>**20071029022526]
550[new Control.Compositor module
551Ashley Yakeley <ashley@semantic.org>**20071013074851
552 
553 The Compositor class is a superclass of Arrow.
554]
555[Fix doc building with Haddock 0.9
556Simon Marlow <simonmar@microsoft.com>**20071024090947
557 I was using a recent build here, which is more tolerant.
558]
559[FIX #1258: document that openTempFile is secure(ish)
560Simon Marlow <simonmar@microsoft.com>**20071023130928
561 Also change the mode from 0666 to 0600, which seems like a more
562 sensible value and matches what C's mkstemp() does.
563]
564[Clean up .cabal file a bit
565Duncan Coutts <duncan@haskell.org>**20071022132708
566 specify build-type and cabal-version >= 1.2
567 put extra-tmp-files in the right place
568 use os(windows) rather than os(mingw32)
569]
570[base in 6.8 and head branch should be version 3.0
571Don Stewart <dons@galois.com>**20071007150408]
572[FIX #1652: openTempFile should accept an empty string for the directory
573Simon Marlow <simonmar@microsoft.com>**20071018122345]
574[clean up duplicate code
575Simon Marlow <simonmar@microsoft.com>**20071017141311]
576[expose the value of +RTS -N as GHC.Conc.numCapabilities (see #1733)
577Simon Marlow <simonmar@microsoft.com>**20071009132042]
578[typo
579Simon Marlow <simonmar@microsoft.com>**20070917130703]
580[put extra-tmp-files field in the right place
581Simon Marlow <simonmar@microsoft.com>**20070914140812]
582[Add more entries to boring file
583Ian Lynagh <igloo@earth.li>**20070913210500]
584[Add a boring file
585Ian Lynagh <igloo@earth.li>**20070913204641]
586[TAG 2007-09-13
587Ian Lynagh <igloo@earth.li>**20070913215720]
588Patch bundle hash:
5893a528267f25f2781d8a633e99cc6731e37dae8d2