8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ use container:: Container ;
12
+ use iterator:: IteratorUtil ;
11
13
use libc;
14
+ use str:: StrSlice ;
12
15
13
16
/// Get the number of cores available
14
17
pub fn num_cpus ( ) -> uint {
@@ -21,6 +24,64 @@ pub fn num_cpus() -> uint {
21
24
}
22
25
}
23
26
24
- pub fn abort ( ) -> ! {
27
+ pub fn dumb_println ( s : & str ) {
28
+ use io:: WriterUtil ;
29
+ let dbg = :: libc:: STDERR_FILENO as :: io:: fd_t ;
30
+ dbg. write_str ( s) ;
31
+ dbg. write_str ( "\n " ) ;
32
+ }
33
+
34
+ pub fn abort ( msg : & str ) -> ! {
35
+ let msg = if !msg. is_empty ( ) { msg } else { "aborted" } ;
36
+ let hash = msg. iter ( ) . fold ( 0 , |accum, val| accum + ( val as uint ) ) ;
37
+ let quote = match hash % 10 {
38
+ 0 => "
39
+ It was from the artists and poets that the pertinent answers came, and I
40
+ know that panic would have broken loose had they been able to compare notes.
41
+ As it was, lacking their original letters, I half suspected the compiler of
42
+ having asked leading questions, or of having edited the correspondence in
43
+ corroboration of what he had latently resolved to see." ,
44
+ 1 => "
45
+ There are not many persons who know what wonders are opened to them in the
46
+ stories and visions of their youth; for when as children we listen and dream,
47
+ we think but half-formed thoughts, and when as men we try to remember, we are
48
+ dulled and prosaic with the poison of life. But some of us awake in the night
49
+ with strange phantasms of enchanted hills and gardens, of fountains that sing
50
+ in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
51
+ down to sleeping cities of bronze and stone, and of shadowy companies of heroes
52
+ that ride caparisoned white horses along the edges of thick forests; and then
53
+ we know that we have looked back through the ivory gates into that world of
54
+ wonder which was ours before we were wise and unhappy." ,
55
+ 2 => "
56
+ Instead of the poems I had hoped for, there came only a shuddering blackness
57
+ and ineffable loneliness; and I saw at last a fearful truth which no one had
58
+ ever dared to breathe before — the unwhisperable secret of secrets — The fact
59
+ that this city of stone and stridor is not a sentient perpetuation of Old New
60
+ York as London is of Old London and Paris of Old Paris, but that it is in fact
61
+ quite dead, its sprawling body imperfectly embalmed and infested with queer
62
+ animate things which have nothing to do with it as it was in life." ,
63
+ 3 => "
64
+ The ocean ate the last of the land and poured into the smoking gulf, thereby
65
+ giving up all it had ever conquered. From the new-flooded lands it flowed
66
+ again, uncovering death and decay; and from its ancient and immemorial bed it
67
+ trickled loathsomely, uncovering nighted secrets of the years when Time was
68
+ young and the gods unborn. Above the waves rose weedy remembered spires. The
69
+ moon laid pale lilies of light on dead London, and Paris stood up from its damp
70
+ grave to be sanctified with star-dust. Then rose spires and monoliths that were
71
+ weedy but not remembered; terrible spires and monoliths of lands that men never
72
+ knew were lands..." ,
73
+ 4 => "
74
+ There was a night when winds from unknown spaces whirled us irresistibly into
75
+ limitless vacum beyond all thought and entity. Perceptions of the most
76
+ maddeningly untransmissible sort thronged upon us; perceptions of infinity
77
+ which at the time convulsed us with joy, yet which are now partly lost to my
78
+ memory and partly incapable of presentation to others." ,
79
+ _ => "You've met with a terrible fate, haven't you?"
80
+ } ;
81
+ rterrln ! ( "%s" , "" ) ;
82
+ rterrln ! ( "%s" , quote) ;
83
+ rterrln ! ( "%s" , "" ) ;
84
+ rterrln ! ( "fatal runtime error: %s" , msg) ;
85
+
25
86
unsafe { libc:: abort ( ) ; }
26
- }
87
+ }
0 commit comments