 |
Changeset 3886
- Timestamp:
- 08/18/08 14:39:49
(4 months ago)
- Author:
- keinfarbton
- Message:
merged from trunk -r 3716:3830
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3724 |
r3886 |
|
| 11 | 11 | $DSSS_BUILD -obj -explicit lib/common/tango/core/Exception.d -fintfc-file=tango/core/Exception.di ; \ |
|---|
| 12 | 12 | $DSSS_BUILD -obj -explicit lib/common/tango/core/Memory.d -fintfc-file=tango/core/Memory.di ; \ |
|---|
| 13 | | $DSSS_BUILD -obj -explicit lib/common/tango/core/Runtime.d -fintfc-file=tango/core/Runtime.di ; \ |
|---|
| 14 | | $DSSS_BUILD -obj -explicit lib/common/tango/core/Thread.d -fintfc-file=tango/core/Thread.di ; |
|---|
| | 13 | $DSSS_BUILD -obj -explicit lib/common/tango/core/Runtime.d -fintfc-file=tango/core/Runtime.di ; |
|---|
| 15 | 14 | } else version (DigitalMars) { |
|---|
| 16 | 15 | prebuild = $DSSS_BUILD -obj -explicit lib/common/tango/core/BitManip.d -Hftango/core/BitManip.di ; \ |
|---|
| … | … | |
| 33 | 32 | |
|---|
| 34 | 33 | [tango/sys] |
|---|
| 35 | | exclude = tango/sys/linux/* tango/sys/darwin/* tango/sys/win32/* tango/sys/freebsd/* |
|---|
| | 34 | exclude = tango/sys/linux/* tango/sys/darwin/* tango/sys/freebsd/* |
|---|
| 36 | 35 | exclude += tango/sys/TimeConverter.d |
|---|
| | 36 | exclude += tango/sys/win32/Type.di |
|---|
| | 37 | exclude += tango/sys/win32/UserGdi.di |
|---|
| | 38 | exclude += tango/sys/win32/Process.di |
|---|
| | 39 | exclude += tango/sys/win32/Macros.di |
|---|
| | 40 | version(!Windows) { |
|---|
| | 41 | exclude += tango/sys/win32/CodePage.d |
|---|
| | 42 | } |
|---|
| 37 | 43 | |
|---|
| 38 | 44 | version (linux) { |
|---|
| … | … | |
| 70 | 76 | [tango/time] |
|---|
| 71 | 77 | |
|---|
| 72 | | [tango/group] |
|---|
| | 78 | [+std] |
|---|
| | 79 | preinstall = install std/intrinsic.di $INCLUDE_PREFIX/std ; \ |
|---|
| | 80 | install std/stdarg.di $INCLUDE_PREFIX/std ; \ |
|---|
| | 81 | install std/c/stdarg.di $INCLUDE_PREFIX/std/c |
|---|
| 73 | 82 | |
|---|
| 74 | | [+std] |
|---|
| 75 | | preinstall = installdir std $INCLUDE_PREFIX/std |
|---|
| r3724 |
r3886 |
|
| 33 | 33 | [networking/sockethello.d] |
|---|
| 34 | 34 | [networking/socketserver.d] |
|---|
| 35 | | [system/arguments.d] |
|---|
| | 35 | #[system/arguments.d] |
|---|
| 36 | 36 | [system/localtime.d] |
|---|
| 37 | 37 | [system/normpath.d] |
|---|
| … | … | |
| 41 | 41 | [text/formatspec.d] |
|---|
| 42 | 42 | [text/localetime.d] |
|---|
| 43 | | [text/properties.d] |
|---|
| 44 | 43 | [text/token.d] |
|---|
| 45 | 44 | [text/xmldom.d] |
|---|
| r2854 |
r3886 |
|
| 63 | 63 | text/formatspec \ |
|---|
| 64 | 64 | text/localetime \ |
|---|
| 65 | | text/properties \ |
|---|
| 66 | 65 | text/token |
|---|
| 67 | 66 | |
|---|
| r3724 |
r3886 |
|
| 26 | 26 | { |
|---|
| 27 | 27 | if(useMessageBoxes) |
|---|
| 28 | | MessageBoxA(null, cast(ubyte*) toStringz(msg), cast(ubyte*) "Tango Switch utility\0", 0); |
|---|
| | 28 | MessageBoxA(null, toStringz(msg), "Tango Switch utility\0", 0); |
|---|
| 29 | 29 | else |
|---|
| 30 | 30 | printf("%s\n", toStringz(msg)); |
|---|
| … | … | |
| 94 | 94 | } |
|---|
| 95 | 95 | |
|---|
| 96 | | MoveFileA(cast(ubyte*) toStringz(targetConf), cast(ubyte*) toStringz(tangoConf)); // backup the Tango Build config |
|---|
| 97 | | MoveFileA(cast(ubyte*) toStringz(phobosConf), cast(ubyte*) toStringz(targetConf)); // put Phobos's Build config in place |
|---|
| | 96 | MoveFileA(toStringz(targetConf), toStringz(tangoConf)); // backup the Tango Build config |
|---|
| | 97 | MoveFileA(toStringz(phobosConf), toStringz(targetConf)); // put Phobos's Build config in place |
|---|
| 98 | 98 | |
|---|
| 99 | | if (!CopyFileA(cast(ubyte*) toStringz(phobosLib), cast(ubyte*) toStringz(targetLib), false)) |
|---|
| | 99 | if (!CopyFileA(toStringz(phobosLib), toStringz(targetLib), false)) |
|---|
| 100 | 100 | showMessage("Error: Could not find " ~ phobosLib); |
|---|
| 101 | 101 | else |
|---|
| … | … | |
| 111 | 111 | } |
|---|
| 112 | 112 | |
|---|
| 113 | | MoveFileA(cast(ubyte*) toStringz(targetConf), cast(ubyte*) toStringz(phobosConf)); // backup the Phobos Build config |
|---|
| 114 | | MoveFileA(cast(ubyte*) toStringz(tangoConf), cast(ubyte*) toStringz(targetConf)); // put Tango's Build config in place |
|---|
| | 113 | MoveFileA(toStringz(targetConf), toStringz(phobosConf)); // backup the Phobos Build config |
|---|
| | 114 | MoveFileA(toStringz(tangoConf), toStringz(targetConf)); // put Tango's Build config in place |
|---|
| 115 | 115 | |
|---|
| 116 | | if (!CopyFileA(cast(ubyte*) toStringz(tangoLib), cast(ubyte*) toStringz(targetLib), false)) |
|---|
| | 116 | if (!CopyFileA(toStringz(tangoLib), toStringz(targetLib), false)) |
|---|
| 117 | 117 | showMessage("Error: Could not find " ~ tangoLib); |
|---|
| 118 | 118 | else |
|---|
| r3725 |
r3886 |
|
| 494 | 494 | if( m_sz && pthread_attr_setstacksize( &attr, m_sz ) ) |
|---|
| 495 | 495 | throw new ThreadException( "Error initializing thread stack size" ); |
|---|
| | 496 | if( pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ) ) |
|---|
| | 497 | throw new ThreadException( "Error setting thread joinable" ); |
|---|
| 496 | 498 | } |
|---|
| 497 | 499 | |
|---|
| … | … | |
| 534 | 536 | * ThreadException if the operation fails. |
|---|
| 535 | 537 | * Any exception not handled by the joined thread. |
|---|
| 536 | | */ |
|---|
| 537 | | final void join( bool rethrow = true ) |
|---|
| | 538 | * |
|---|
| | 539 | * Returns: |
|---|
| | 540 | * Any exception not handled by this thread if rethrow = false, null |
|---|
| | 541 | * otherwise. |
|---|
| | 542 | */ |
|---|
| | 543 | final Object join( bool rethrow = true ) |
|---|
| 538 | 544 | { |
|---|
| 539 | 545 | version( Win32 ) |
|---|
| … | … | |
| 558 | 564 | /+volatile+/ m_addr = m_addr.init; |
|---|
| 559 | 565 | } |
|---|
| 560 | | if( rethrow && m_unhandled ) |
|---|
| 561 | | { |
|---|
| 562 | | throw m_unhandled; |
|---|
| 563 | | } |
|---|
| | 566 | if( m_unhandled ) |
|---|
| | 567 | { |
|---|
| | 568 | if( rethrow ) |
|---|
| | 569 | throw m_unhandled; |
|---|
| | 570 | return m_unhandled; |
|---|
| | 571 | } |
|---|
| | 572 | return null; |
|---|
| 564 | 573 | } |
|---|
| 565 | 574 | |
|---|
| … | … | |
| 601 | 610 | |
|---|
| 602 | 611 | /** |
|---|
| 603 | | * Gets the daemon status for this thread. |
|---|
| | 612 | * Gets the daemon status for this thread. While the runtime will wait for |
|---|
| | 613 | * all normal threads to complete before tearing down the process, daemon |
|---|
| | 614 | * threads are effectively ignored and thus will not prevent the process |
|---|
| | 615 | * from terminating. In effect, daemon threads will be terminated |
|---|
| | 616 | * automatically by the OS when the process exits. |
|---|
| 604 | 617 | * |
|---|
| 605 | 618 | * Returns: |
|---|
| … | … | |
| 616 | 629 | |
|---|
| 617 | 630 | /** |
|---|
| 618 | | * Sets the daemon status for this thread. |
|---|
| | 631 | * Sets the daemon status for this thread. While the runtime will wait for |
|---|
| | 632 | * all normal threads to complete before tearing down the process, daemon |
|---|
| | 633 | * threads are effectively ignored and thus will not prevent the process |
|---|
| | 634 | * from terminating. In effect, daemon threads will be terminated |
|---|
| | 635 | * automatically by the OS when the process exits. |
|---|
| 619 | 636 | * |
|---|
| 620 | 637 | * Params: |
|---|
| … | … | |
| 2113 | 2130 | |
|---|
| 2114 | 2131 | t.start(); |
|---|
| 2115 | | synchronized |
|---|
| | 2132 | synchronized( this ) |
|---|
| 2116 | 2133 | { |
|---|
| 2117 | 2134 | m_all[t] = t; |
|---|
| … | … | |
| 2136 | 2153 | |
|---|
| 2137 | 2154 | t.start(); |
|---|
| 2138 | | synchronized |
|---|
| | 2155 | synchronized( this ) |
|---|
| 2139 | 2156 | { |
|---|
| 2140 | 2157 | m_all[t] = t; |
|---|
| … | … | |
| 2160 | 2177 | body |
|---|
| 2161 | 2178 | { |
|---|
| 2162 | | synchronized |
|---|
| | 2179 | synchronized( this ) |
|---|
| 2163 | 2180 | { |
|---|
| 2164 | 2181 | m_all[t] = t; |
|---|
| … | … | |
| 2184 | 2201 | body |
|---|
| 2185 | 2202 | { |
|---|
| 2186 | | synchronized |
|---|
| | 2203 | synchronized( this ) |
|---|
| 2187 | 2204 | { |
|---|
| 2188 | 2205 | m_all.remove( t ); |
|---|
| … | … | |
| 2196 | 2213 | final int opApply( int delegate( Thread ) dg ) |
|---|
| 2197 | 2214 | { |
|---|
| 2198 | | synchronized |
|---|
| | 2215 | synchronized( this ) |
|---|
| 2199 | 2216 | { |
|---|
| 2200 | 2217 | int ret = 0; |
|---|
| … | … | |
| 2226 | 2243 | final void joinAll( bool rethrow = true ) |
|---|
| 2227 | 2244 | { |
|---|
| 2228 | | synchronized |
|---|
| | 2245 | synchronized( this ) |
|---|
| 2229 | 2246 | { |
|---|
| 2230 | 2247 | // NOTE: This loop relies on the knowledge that m_all uses the |
|---|
| … | … | |
| 2605 | 2622 | * Throws: |
|---|
| 2606 | 2623 | * Any exception not handled by the joined thread. |
|---|
| 2607 | | */ |
|---|
| 2608 | | final void call( bool rethrow = true ) |
|---|
| | 2624 | * |
|---|
| | 2625 | * Returns: |
|---|
| | 2626 | * Any exception not handled by this fiber if rethrow = false, null |
|---|
| | 2627 | * otherwise. |
|---|
| | 2628 | */ |
|---|
| | 2629 | final Object call( bool rethrow = true ) |
|---|
| 2609 | 2630 | in |
|---|
| 2610 | 2631 | { |
|---|
| … | … | |
| 2641 | 2662 | m_unhandled = null; |
|---|
| 2642 | 2663 | if( rethrow ) |
|---|
| 2643 | | { |
|---|
| 2644 | 2664 | throw obj; |
|---|
| 2645 | | } |
|---|
| 2646 | | } |
|---|
| | 2665 | return obj; |
|---|
| | 2666 | } |
|---|
| | 2667 | return null; |
|---|
| 2647 | 2668 | } |
|---|
| 2648 | 2669 | |
|---|
| r3724 |
r3886 |
|
| 374 | 374 | /*************************************** |
|---|
| 375 | 375 | * Support for array equality test. |
|---|
| | 376 | * Returns: |
|---|
| | 377 | * 1 equal |
|---|
| | 378 | * 0 not equal |
|---|
| 376 | 379 | */ |
|---|
| 377 | 380 | |
|---|
| 378 | 381 | extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) |
|---|
| 379 | 382 | { |
|---|
| 380 | | /+ |
|---|
| 381 | | + TODO: Re-enable once the correct TypeInfo is passed: |
|---|
| 382 | | + http://d.puremagic.com/issues/show_bug.cgi?id=2161 |
|---|
| 383 | | + |
|---|
| 384 | | debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); |
|---|
| 385 | | |
|---|
| 386 | | if (a1.length != a2.length) |
|---|
| 387 | | return 0; // not equal |
|---|
| 388 | | if (a1.ptr == a2.ptr) |
|---|
| 389 | | return 1; // equal |
|---|
| 390 | | |
|---|
| 391 | | // We should really have a ti.isPOD() check for this |
|---|
| 392 | | if (ti.tsize() != 1) |
|---|
| 393 | | return ti.equals(&a1, &a2); |
|---|
| 394 | | return memcmp(a1.ptr, a2.ptr, a1.length) == 0; |
|---|
| 395 | | +/ |
|---|
| 396 | 383 | debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); |
|---|
| 397 | 384 | if (a1.length != a2.length) |
|---|
| … | … | |
| 413 | 400 | } |
|---|
| 414 | 401 | |
|---|
| | 402 | extern (C) int _adEq2(Array a1, Array a2, TypeInfo ti) |
|---|
| | 403 | { |
|---|
| | 404 | debug(adi) printf("_adEq2(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); |
|---|
| | 405 | if (a1.length != a2.length) |
|---|
| | 406 | return 0; // not equal |
|---|
| | 407 | if (!ti.equals(&a1, &a2)) |
|---|
| | 408 | return 0; |
|---|
| | 409 | return 1; |
|---|
| | 410 | } |
|---|
| 415 | 411 | unittest |
|---|
| 416 | 412 | { |
|---|
| … | … | |
| 432 | 428 | extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti) |
|---|
| 433 | 429 | { |
|---|
| 434 | | /+ |
|---|
| 435 | | + TODO: Re-enable once the correct TypeInfo is passed: |
|---|
| 436 | | + http://d.puremagic.com/issues/show_bug.cgi?id=2161 |
|---|
| 437 | | + |
|---|
| 438 | | debug(adi) printf("adCmp()\n"); |
|---|
| 439 | | |
|---|
| 440 | | if (a1.ptr == a2.ptr && |
|---|
| 441 | | a1.length == a2.length) |
|---|
| 442 | | return 0; |
|---|
| 443 | | |
|---|
| 444 | | auto len = a1.length; |
|---|
| 445 | | if (a2.length < len) |
|---|
| 446 | | len = a2.length; |
|---|
| 447 | | |
|---|
| 448 | | // We should really have a ti.isPOD() check for this |
|---|
| 449 | | if (ti.tsize() != 1) |
|---|
| 450 | | return ti.compare(&a1, &a2); |
|---|
| 451 | | auto c = memcmp(a1.ptr, a2.ptr, len); |
|---|
| 452 | | if (c) |
|---|
| 453 | | return c; |
|---|
| 454 | | if (a1.length == a2.length) |
|---|
| 455 | | return 0; |
|---|
| 456 | | return a1.length > a2.length ? 1 : -1; |
|---|
| 457 | | +/ |
|---|
| 458 | 430 | debug(adi) printf("adCmp()\n"); |
|---|
| 459 | 431 | auto len = a1.length; |
|---|
| … | … | |
| 484 | 456 | } |
|---|
| 485 | 457 | |
|---|
| | 458 | extern (C) int _adCmp2(Array a1, Array a2, TypeInfo ti) |
|---|
| | 459 | { |
|---|
| | 460 | debug(adi) printf("_adCmp2(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); |
|---|
| | 461 | return ti.compare(&a1, &a2); |
|---|
| | 462 | } |
|---|
| 486 | 463 | unittest |
|---|
| 487 | 464 | { |
|---|
| r3724 |
r3886 |
|
| 70 | 70 | arraycast.o \ |
|---|
| 71 | 71 | arraycat.o \ |
|---|
| | 72 | arraydouble.o \ |
|---|
| | 73 | arrayfloat.o \ |
|---|
| | 74 | arrayreal.o \ |
|---|
| 72 | 75 | cast.o \ |
|---|
| 73 | 76 | cmath2.o \ |
|---|
| … | … | |
| 96 | 99 | OBJ_UTIL= \ |
|---|
| 97 | 100 | util/console.o \ |
|---|
| | 101 | util/cpuid.o \ |
|---|
| 98 | 102 | util/ctype.o \ |
|---|
| 99 | 103 | util/string.o \ |
|---|
| r3724 |
r3886 |
|
| 66 | 66 | arraycast.obj \ |
|---|
| 67 | 67 | arraycat.obj \ |
|---|
| | 68 | arraydouble.obj \ |
|---|
| | 69 | arrayfloat.obj \ |
|---|
| | 70 | arrayreal.obj \ |
|---|
| 68 | 71 | cast.obj \ |
|---|
| 69 | 72 | complex.obj \ |
|---|
| … | … | |
| 89 | 92 | OBJ_UTIL= \ |
|---|
| 90 | 93 | util\console.obj \ |
|---|
| | 94 | util\cpuid.obj \ |
|---|
| 91 | 95 | util\ctype.obj \ |
|---|
| 92 | 96 | util\string.obj \ |
|---|
| r3724 |
r3886 |
|
| 38 | 38 | fi |
|---|
| 39 | 39 | |
|---|
| 40 | | if [ "$DMDVERSIONMIN" -gt "31" ] |
|---|
| | 40 | if [ "$DMDVERSIONMIN" = "32" ] |
|---|
| | 41 | then |
|---|
| | 42 | echo ">> DMD 1.032 is not supported by Tango. You are most likely going" |
|---|
| | 43 | echo " >> to experience problems." |
|---|
| | 44 | fi |
|---|
| | 45 | |
|---|
| | 46 | if [ "$DMDVERSIONMIN" -gt "33" ] |
|---|
| 41 | 47 | then |
|---|
| 42 | 48 | echo ">> This version has not been tested with Tango prior to this release," |
|---|
| 43 | | echo " >> so if you experience any problems, try reverting to DMD 1.031" |
|---|
| | 49 | echo " >> so if you experience any problems, try reverting to DMD 1.033" |
|---|
| 44 | 50 | echo " >> or earlier." |
|---|
| 45 | 51 | fi |
|---|
| r3724 |
r3886 |
|
| 1695 | 1695 | * |
|---|
| 1696 | 1696 | * Returns: |
|---|
| 1697 | | * The number of unique elements in buf. |
|---|
| 1698 | | */ |
|---|
| 1699 | | size_t unique( Elem[] buf, Pred2E pred = Pred2E.init ); |
|---|
| | 1697 | * The number of distinct sub-sequences in buf. |
|---|
| | 1698 | */ |
|---|
| | 1699 | size_t distinct( Elem[] buf, Pred2E pred = Pred2E.init ); |
|---|
| 1700 | 1700 | } |
|---|
| 1701 | 1701 | else |
|---|
| 1702 | 1702 | { |
|---|
| 1703 | | template unique_( Elem, Pred = IsEqual!(Elem) ) |
|---|
| | 1703 | template distinct_( Elem, Pred = IsEqual!(Elem) ) |
|---|
| 1704 | 1704 | { |
|---|
| 1705 | 1705 | static assert( isCallableType!(Pred) ); |
|---|
| … | … | |
| 1738 | 1738 | |
|---|
| 1739 | 1739 | |
|---|
| 1740 | | template unique( Buf ) |
|---|
| 1741 | | { |
|---|
| 1742 | | size_t unique( Buf buf ) |
|---|
| 1743 | | { |
|---|
| 1744 | | return unique_!(ElemTypeOf!(Buf)).fn( buf ); |
|---|
| 1745 | | } |
|---|
| 1746 | | } |
|---|
| 1747 | | |
|---|
| 1748 | | |
|---|
| 1749 | | template unique( Buf, Pred ) |
|---|
| 1750 | | { |
|---|
| 1751 | | size_t unique( Buf buf, Pred pred ) |
|---|
| 1752 | | { |
|---|
| 1753 | | return unique_!(ElemTypeOf!(Buf), Pred).fn( buf, pred ); |
|---|
| | 1740 | template distinct( Buf ) |
|---|
| | 1741 | { |
|---|
| | 1742 | size_t distinct( Buf buf ) |
|---|
| | 1743 | { |
|---|
| | 1744 | return distinct_!(ElemTypeOf!(Buf)).fn( buf ); |
|---|
| | 1745 | } |
|---|
| | 1746 | } |
|---|
| | 1747 | |
|---|
| | 1748 | |
|---|
| | 1749 | template distinct( Buf, Pred ) |
|---|
| | 1750 | { |
|---|
| | 1751 | size_t distinct( Buf buf, Pred pred ) |
|---|
| | 1752 | { |
|---|
| | 1753 | return distinct_!(ElemTypeOf!(Buf), Pred).fn( buf, pred ); |
|---|
| 1754 | 1754 | } |
|---|
| 1755 | 1755 | } |
|---|
| … | … | |
| 1762 | 1762 | void test( char[] buf, Cutf8 pat ) |
|---|
| 1763 | 1763 | { |
|---|
| 1764 | | assert( unique( buf ) == pat.length ); |
|---|
| | 1764 | assert( distinct( buf ) == pat.length ); |
|---|
| 1765 | 1765 | foreach( pos, cur; pat ) |
|---|
| 1766 | 1766 | { |
|---|
| r3724 |
r3886 |
|
| 118 | 118 | } |
|---|
| 119 | 119 | |
|---|
| 120 | | debug(UnitTest) { |
|---|
| 121 | | |
|---|
| 122 | | unittest { |
|---|
| 123 | | |
|---|
| 124 | | assert(isPointerType!(void*)); |
|---|
| 125 | | assert(!isPointerType!(char[])); |
|---|
| 126 | | assert(isPointerType!(char[]*)); |
|---|
| 127 | | assert(!isPointerType!(char*[])); |
|---|
| 128 | | assert(isPointerType!(real*)); |
|---|
| 129 | | assert(!isPointerType!(uint)); |
|---|
| 130 | | |
|---|
| | 120 | debug( UnitTest ) |
|---|
| | 121 | { |
|---|
| | 122 | unittest |
|---|
| | 123 | { |
|---|
| | 124 | assert( isPointerType!(void*) ); |
|---|
| | 125 | assert( !isPointerType!(char[]) ); |
|---|
| | 126 | assert( isPointerType!(char[]*) ); |
|---|
| | 127 | assert( !isPointerType!(char*[]) ); |
|---|
| | 128 | assert( isPointerType!(real*) ); |
|---|
| | 129 | assert( !isPointerType!(uint) ); |
|---|
| | 130 | |
|---|
| 131 | 131 | class Ham |
|---|
| 132 | 132 | { |
|---|
| 133 | 133 | void* a; |
|---|
| 134 | 134 | } |
|---|
| 135 | | |
|---|
| 136 | | assert(!isPointerType!(Ham)); |
|---|
| 137 | | |
|---|
| | 135 | |
|---|
| | 136 | assert( !isPointerType!(Ham) ); |
|---|
| | 137 | |
|---|
| 138 | 138 | union Eggs |
|---|
| 139 | 139 | { |
|---|
| 140 | 140 | void* a; |
|---|
| 141 | | uint b; |
|---|
| | 141 | uint b; |
|---|
| 142 | 142 | }; |
|---|
| 143 | | |
|---|
| 144 | | assert(!isPointerType!(Eggs)); |
|---|
| 145 | | assert(isPointerType!(Eggs*)); |
|---|
| 146 | | |
|---|
| | 143 | |
|---|
| | 144 | assert( !isPointerType!(Eggs) ); |
|---|
| | 145 | assert( isPointerType!(Eggs*) ); |
|---|
| | 146 | |
|---|
| 147 | 147 | struct Bacon {}; |
|---|
| 148 | | |
|---|
| 149 | | assert(!isPointerType!(Bacon)); |
|---|
| | 148 | |
|---|
| | 149 | assert( !isPointerType!(Bacon) ); |
|---|
| 150 | 150 | |
|---|
| 151 | 151 | } |
|---|
| … | … | |
| 173 | 173 | } |
|---|
| 174 | 174 | |
|---|
| 175 | | |
|---|
| 176 | | private template isStaticArrayTypeInst( T ) |
|---|
| 177 | | { |
|---|
| 178 | | const T isStaticArrayTypeInst = void; |
|---|
| 179 | | } |
|---|
| 180 | | |
|---|
| 181 | | |
|---|
| 182 | 175 | /** |
|---|
| 183 | 176 | * Evaluates to true if T is a static array type. |
|---|
| 184 | 177 | */ |
|---|
| 185 | | template isStaticArrayType( T ) |
|---|
| 186 | | { |
|---|
| 187 | | static if( is( typeof(T.length) ) && !is( typeof(T) == typeof(T.init) ) ) |
|---|
| 188 | | { |
|---|
| 189 | | const bool isStaticArrayType = is( T == typeof(T[0])[isStaticArrayTypeInst!(T).length] ); |
|---|
| 190 | | } |
|---|
| 191 | | else |
|---|
| | 178 | version( GNU ) |
|---|
| | 179 | { |
|---|
| | 180 | // GDC should also be able to use the other version, but it probably |
|---|
| | 181 | // relies on a frontend fix in one of the latest DMD versions - will |
|---|
| | 182 | // remove this when GDC is ready. For now, this code pass the unittests. |
|---|
| | 183 | private template isStaticArrayTypeInst( T ) |
|---|
| | 184 | { |
|---|
| | 185 | const T isStaticArrayTypeInst = void; |
|---|
| | 186 | } |
|---|
| | 187 | |
|---|
| | 188 | template isStaticArrayType( T ) |
|---|
| | 189 | { |
|---|
| | 190 | static if( is( typeof(T.length) ) && !is( typeof(T) == typeof(T.init) ) ) |
|---|
| | 191 | { |
|---|
| | 192 | const bool isStaticArrayType = is( T == typeof(T[0])[isStaticArrayTypeInst!(T).length] ); |
|---|
| | 193 | } |
|---|
| | 194 | else |
|---|
| | 195 | { |
|---|
| | 196 | const bool isStaticArrayType = false; |
|---|
| | 197 | } |
|---|
| | 198 | } |
|---|
| | 199 | } |
|---|
| | 200 | else |
|---|
| | 201 | { |
|---|
| | 202 | template isStaticArrayType( T : T[U], size_t U ) |
|---|
| | 203 | { |
|---|
| | 204 | const bool isStaticArrayType = true; |
|---|
| | 205 | } |
|---|
| | 206 | |
|---|
| | 207 | template isStaticArrayType( T ) |
|---|
| 192 | 208 | { |
|---|
| 193 | 209 | const bool isStaticArrayType = false; |
|---|
| … | … | |
| 195 | 211 | } |
|---|
| 196 | 212 | |
|---|
| | 213 | debug( UnitTest ) |
|---|
| | 214 | { |
|---|
| | 215 | unittest |
|---|
| | 216 | { |
|---|
| | 217 | assert( isStaticArrayType!(char[5][2]) ); |
|---|
| | 218 | assert( !isDynamicArrayType!(char[5][2]) ); |
|---|
| | 219 | |
|---|
| | 220 | assert( isStaticArrayType!(char[15]) ); |
|---|
| | 221 | assert( !isStaticArrayType!(char[]) ); |
|---|
| | 222 | |
|---|
| | 223 | assert( isDynamicArrayType!(char[]) ); |
|---|
| | 224 | assert( !isDynamicArrayType!(char[15]) ); |
|---|
| | 225 | } |
|---|
| | 226 | } |
|---|
| 197 | 227 | |
|---|
| 198 | 228 | /** |
|---|
| r1918 |
r3886 |
|
| 24 | 24 | |
|---|
| 25 | 25 | |
|---|
| 26 | | template va_start( T ) |
|---|
| | 26 | /** |
|---|
| | 27 | * This function initializes the supplied argument pointer for subsequent |
|---|
| | 28 | * use by va_arg and va_end. |
|---|
| | 29 | * |
|---|
| | 30 | * Params: |
|---|
| | 31 | * ap = The argument pointer to initialize. |
|---|
| | 32 | * paramn = The identifier of the rightmost parameter in the function |
|---|
| | 33 | * parameter list. |
|---|
| | 34 | */ |
|---|
| | 35 | void va_start(T) ( out va_list ap, inout T parmn ) |
|---|
| 27 | 36 | { |
|---|
| 28 | | /** |
|---|
| 29 | | * This function initializes the supplied argument pointer for subsequent |
|---|
| 30 | | * use by va_arg and va_end. |
|---|
| 31 | | * |
|---|
| 32 | | * Params: |
|---|
| 33 | | * ap = The argument pointer to initialize. |
|---|
| 34 | | * paramn = The identifier of the rightmost parameter in the function |
|---|
| 35 | | * parameter list. |
|---|
| 36 | | */ |
|---|
| 37 | | void va_start( out va_list ap, inout T parmn ) |
|---|
| 38 | | { |
|---|
| 39 | | ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); |
|---|
| 40 | | } |
|---|
| | 37 | ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); |
|---|
| 41 | 38 | } |
|---|
| 42 | 39 | |
|---|
| 43 | | |
|---|
| 44 | | template va_arg( T ) |
|---|
| | 40 | /** |
|---|
| | 41 | * This function returns the next argument in the sequence referenced by |
|---|
| | 42 | * the supplied argument pointer. The argument pointer will be adjusted |
|---|
| | 43 | * to point to the next arggument in the sequence. |
|---|
| | 44 | * |
|---|
| | 45 | * Params: |
|---|
| | 46 | * ap = The argument pointer. |
|---|
| | 47 | * |
|---|
| | 48 | * Returns: |
|---|
| | 49 | * The next argument in the sequence. The result is undefined if ap |
|---|
| | 50 | * does not point to a valid argument. |
|---|
| | 51 | */ |
|---|
| | 52 | T va_arg(T) ( inout va_list ap ) |
|---|
| 45 | 53 | { |
|---|
| 46 | | /** |
|---|
| 47 | | * This function returns the next argument in the sequence referenced by |
|---|
| 48 | | * the supplied argument pointer. The argument pointer will be adjusted |
|---|
| 49 | | * to point to the next arggument in the sequence. |
|---|
| 50 | | * |
|---|
| 51 | | * Params: |
|---|
| 52 | | * ap = The argument pointer. |
|---|
| 53 | | * |
|---|
| 54 | | * Returns: |
|---|
| 55 | | * The next argument in the sequence. The result is undefined if ap |
|---|
| 56 | | * does not point to a valid argument. |
|---|
| 57 | | */ |
|---|
| 58 | | T va_arg( inout va_list ap ) |
|---|
| 59 | | { |
|---|
| 60 | | T arg = *cast(T*) ap; |
|---|
| 61 | | ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); |
|---|
| 62 | | return arg; |
|---|
| 63 | | } |
|---|
| | 54 | T arg = *cast(T*) ap; |
|---|
| | 55 | ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); |
|---|
| | 56 | return arg; |
|---|
| 64 | 57 | } |
|---|
| 65 | | |
|---|
| 66 | 58 | |
|---|
| 67 | 59 | /** |
|---|
| r3724 |
r3886 |
|
| 95 | 95 | } |
|---|
| 96 | 96 | |
|---|
| | 97 | template isInterface(T) |
|---|
| | 98 | { |
|---|
| | 99 | static if( is( T == interface ) ) |
|---|
| | 100 | const isInterface = true; |
|---|
| | 101 | else |
|---|
| | 102 | const isInterface = false; |
|---|
| | 103 | } |
|---|
| | 104 | |
|---|
| 97 | 105 | template isStaticArray(T) |
|---|
| 98 | 106 | { |
|---|
| … | … | |
| 292 | 300 | this.value.obj = value; |
|---|
| 293 | 301 | } |
|---|
| | 302 | else static if( isInterface!(T) ) |
|---|
| | 303 | { |
|---|
| | 304 | this.value.obj = cast(Object) value; |
|---|
| | 305 | } |
|---|
| 294 | 306 | else |
|---|
| 295 | 307 | { |
|---|
| … | … | |
| 379 | 391 | // Let D do runtime check itself |
|---|
| 380 | 392 | && !isObject!(T) |
|---|
| | 393 | && !isInterface!(T) |
|---|
| 381 | 394 | // Allow implicit upcasts |
|---|
| 382 | 395 | && !canImplicitCastTo!(T)(type) |
|---|
| … | … | |
| 426 | 439 | } |
|---|
| 427 | 440 | else static if( isObject!(T) ) |
|---|
| | 441 | { |
|---|
| | 442 | return cast(T)this.value.obj; |
|---|
| | 443 | } |
|---|
| | 444 | else static if( isInterface!(T) ) |
|---|
| 428 | 445 | { |
|---|
| 429 | 446 | return cast(T)this.value.obj; |
|---|
| … | … | |
| 629 | 646 | } |
|---|
| 630 | 647 | |
|---|
| | 648 | // Test interface support |
|---|
| | 649 | { |
|---|
| | 650 | interface A {} |
|---|
| | 651 | interface B : A {} |
|---|
| | 652 | class C : B {} |
|---|
| | 653 | class D : C {} |
|---|
| | 654 | |
|---|
| | 655 | A a = new D; |
|---|
| | 656 | Variant v = a; |
|---|
| | 657 | B b = v.get!(B); |
|---|
| | 658 | C c = v.get!(C); |
|---|
| | 659 | D d = v.get!(D); |
|---|
| | 660 | } |
|---|
| | 661 | |
|---|
| 631 | 662 | // Test doubles and implicit casting |
|---|
| 632 | 663 | v = 3.1413; |
|---|
| … | … | |
| 719 | 750 | } |
|---|
| 720 | 751 | } |
|---|
| 721 | | |
|---|
| r2810 |
r3886 |
|
| 414 | 414 | maxReaders = numReaders; |
|---|
| 415 | 415 | } |
|---|
| 416 | | Thread.yield(); |
|---|
| | 416 | Thread.sleep( 0.001 ); |
|---|
| 417 | 417 | synchronized( synInfo ) |
|---|
| 418 | 418 | { |
|---|
| … | … | |
| 455 | 455 | maxReaders = numReaders; |
|---|
| 456 | 456 | } |
|---|
| 457 | | Thread.yield(); |
|---|
| | 457 | Thread.sleep( 0.001 ); |
|---|
| 458 | 458 | synchronized( synInfo ) |
|---|
| 459 | 459 | { |
|---|
| … | … | |
| 475 | 475 | maxWriters = numWriters; |
|---|
| 476 | 476 | } |
|---|
| 477 | | Thread.yield(); |
|---|
| | 477 | Thread.sleep( 0.001 ); |
|---|
| 478 | 478 | synchronized( synInfo ) |
|---|
| 479 | 479 | { |
|---|
| r3724 |
r3886 |
|
| 326 | 326 | } |
|---|
| 327 | 327 | |
|---|
| 328 | | for( int i = numConsumers * 10; i > 0; --i ) |
|---|
| | 328 | for( int i = numConsumers * 1000; i > 0; --i ) |
|---|
| 329 | 329 | { |
|---|
| 330 | 330 | synchronized( synComplete ) |
|---|
| … | … | |
| 333 | 333 | break; |
|---|
| 334 | 334 | } |
|---|
| | 335 | Thread.yield(); |
|---|
| 335 | 336 | } |
|---|
| 336 | 337 | |
|---|
| … | … | |
| 339 | 340 | assert( numComplete == numConsumers ); |
|---|
| 340 | 341 | } |
|---|
| 341 | | assert( numConsumed == numToProduce ); |
|---|
| | 342 | |
|---|
| | 343 | synchronized( synConsumed ) |
|---|
| | 344 | { |
|---|
| | 345 | assert( numConsumed == numToProduce ); |
|---|
| | 346 | } |
|---|
| 342 | 347 | |
|---|
| 343 | 348 | assert( !semaphore.tryWait() ); |
|---|
| r3727 |
r3886 |
|
| 1357 | 1357 | assert (fp.isChild); |
|---|
| 1358 | 1358 | |
|---|
| 1359 | | fp = new FilePath(r"C:\foo\bar\test.bar"); |
|---|
| | 1359 | fp = new FilePath(r"C:/foo/bar/test.bar"); |
|---|
| 1360 | 1360 | assert (fp.path == "C:/foo/bar/"); |
|---|
| 1361 | 1361 | fp = new FilePath(r"C:/foo/bar/test.bar"); |
|---|
| r3724 |
r3886 |
|
| 170 | 170 | { |
|---|
| 171 | 171 | dir[len-1] = '/'; |
|---|
| 172 | | path = dir; |
|---|
| | 172 | path = standard (dir); |
|---|
| 173 | 173 | } |
|---|
| 174 | 174 | else |
|---|
|