* src/mm/boehm-gc/BCC_MAKEFILE, src/mm/boehm-gc/digimars.mak: unix2dos'ed
[cacao.git] / src / threads / threads-common.c
1 /* src/threads/threads-common.c - machine independent thread functions
2
3    Copyright (C) 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #include "config.h"
27
28 #include <assert.h>
29 #include <stdint.h>
30 #include <unistd.h>
31
32 #include "vm/types.h"
33
34 #include "mm/memory.h"
35
36 #include "native/jni.h"
37 #include "native/llni.h"
38
39 #include "native/include/java_lang_Object.h"
40 #include "native/include/java_lang_String.h"
41 #include "native/include/java_lang_Thread.h"
42
43 #if defined(WITH_CLASSPATH_GNU)
44 # include "native/include/java_lang_Throwable.h"
45 # include "native/include/java_lang_VMThread.h"
46 #endif
47
48 #include "threads/critical.h"
49 #include "threads/lock-common.h"
50 #include "threads/threadlist.h"
51 #include "threads/threads-common.h"
52
53 #include "toolbox/list.h"
54
55 #include "vm/builtin.h"
56 #include "vm/stringlocal.h"
57 #include "vm/vm.h"
58
59 #include "vm/jit/stacktrace.h"
60
61 #include "vmcore/class.h"
62 #include "vmcore/options.h"
63
64 #if defined(ENABLE_STATISTICS)
65 # include "vmcore/statistics.h"
66 #endif
67
68 #include "vmcore/utf8.h"
69
70
71 /* global variables ***********************************************************/
72
73 #if defined(__LINUX__)
74 /* XXX Remove for exact-GC. */
75 bool threads_pthreads_implementation_nptl;
76 #endif
77
78
79 /* threads_preinit *************************************************************
80
81    Do some early initialization of stuff required.
82
83 *******************************************************************************/
84
85 void threads_preinit(void)
86 {
87         threadobject *mainthread;
88 #if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
89         char         *pathbuf;
90         size_t        len;
91 #endif
92
93         TRACESUBSYSTEMINITIALIZATION("threads_preinit");
94
95 #if defined(__LINUX__)
96         /* XXX Remove for exact-GC. */
97
98         /* On Linux we need to check the pthread implementation. */
99
100         /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */
101         /* If the glibc is a pre-2.3.2 version, we fall back to
102            linuxthreads. */
103
104 # if defined(_CS_GNU_LIBPTHREAD_VERSION)
105         len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
106
107         /* Some systems return as length 0 (maybe cross-compilation
108            related).  In this case we also fall back to linuxthreads. */
109
110         if (len > 0) {
111                 pathbuf = MNEW(char, len);
112
113                 (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len);
114
115                 if (strstr(pathbuf, "NPTL") != NULL)
116                         threads_pthreads_implementation_nptl = true;
117                 else
118                         threads_pthreads_implementation_nptl = false;
119         }
120         else
121                 threads_pthreads_implementation_nptl = false;
122 # else
123         threads_pthreads_implementation_nptl = false;
124 # endif
125 #endif
126
127         /* Initialize the threads implementation (sets the thinlock on the
128            main thread). */
129
130         threads_impl_preinit();
131
132         /* create internal thread data-structure for the main thread */
133
134         mainthread = threads_thread_new();
135
136         /* thread is a Java thread and running */
137
138         mainthread->flags |= THREAD_FLAG_JAVA;
139         mainthread->state = THREAD_STATE_RUNNABLE;
140
141         /* store the internal thread data-structure in the TSD */
142
143         threads_set_current_threadobject(mainthread);
144 }
145
146
147 /* threads_thread_new **********************************************************
148
149    Allocates and initializes an internal thread data-structure and
150    adds it to the threads list.
151
152 *******************************************************************************/
153
154 threadobject *threads_thread_new(void)
155 {
156         int32_t         index;
157         threadobject   *t;
158         
159         /* lock the threads-lists */
160
161         threads_list_lock();
162
163         index = threadlist_get_free_index();
164
165         /* Allocate a thread data structure. */
166
167         /* First, try to get one from the free-list. */
168
169         t = threadlist_free_first();
170
171         if (t != NULL) {
172                 /* Remove from free list. */
173
174                 threadlist_free_remove(t);
175
176                 /* Equivalent of MZERO on the else path */
177
178                 threads_impl_thread_clear(t);
179         }
180         else {
181 #if defined(ENABLE_GC_BOEHM)
182                 t = GCNEW_UNCOLLECTABLE(threadobject, 1);
183 #else
184                 t = NEW(threadobject);
185 #endif
186
187 #if defined(ENABLE_STATISTICS)
188                 if (opt_stat)
189                         size_threadobject += sizeof(threadobject);
190 #endif
191
192                 /* Clear memory. */
193
194                 MZERO(t, threadobject, 1);
195
196 #if defined(ENABLE_GC_CACAO)
197                 /* Register reference to java.lang.Thread with the GC. */
198                 /* FIXME is it ok to do this only once? */
199
200                 gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT);
201                 gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT);
202 #endif
203
204                 /* Initialize the implementation-specific bits. */
205
206                 threads_impl_thread_init(t);
207         }
208
209         /* Pre-compute the thinlock-word. */
210
211         assert(index != 0);
212
213         t->index     = index;
214         t->thinlock  = lock_pre_compute_thinlock(t->index);
215         t->flags     = 0;
216         t->state     = THREAD_STATE_NEW;
217
218 #if defined(ENABLE_GC_CACAO)
219         t->flags    |= THREAD_FLAG_IN_NATIVE; 
220 #endif
221
222         /* Initialize the implementation-specific bits. */
223
224         threads_impl_thread_reuse(t);
225
226         /* Add the thread to the thread list. */
227
228         threadlist_add(t);
229
230         /* Unlock the threads-lists. */
231
232         threads_list_unlock();
233
234         return t;
235 }
236
237
238 /* threads_thread_free *********************************************************
239
240    Remove the thread from the threads-list and free the internal
241    thread data structure.  The thread index is added to the
242    thread-index free-list.
243
244    IN:
245        t....thread data structure
246
247 *******************************************************************************/
248
249 void threads_thread_free(threadobject *t)
250 {
251         /* Lock the threads lists. */
252
253         threads_list_lock();
254
255         /* Remove the thread from the thread-list. */
256
257         threadlist_remove(t);
258
259         /* Add the thread index to the free list. */
260
261         threadlist_index_add(t->index);
262
263         /* Add the thread data structure to the free list. */
264
265         threads_thread_set_object(t, NULL);
266
267         threadlist_free_add(t);
268
269         /* Unlock the threads lists. */
270
271         threads_list_unlock();
272 }
273
274
275 /* threads_thread_start_internal ***********************************************
276
277    Start an internal thread in the JVM.  No Java thread objects exists
278    so far.
279
280    IN:
281       name.......UTF-8 name of the thread
282       f..........function pointer to C function to start
283
284 *******************************************************************************/
285
286 bool threads_thread_start_internal(utf *name, functionptr f)
287 {
288         threadobject       *t;
289         java_lang_Thread   *object;
290 #if defined(WITH_CLASSPATH_GNU)
291         java_lang_VMThread *vmt;
292 #endif
293
294         /* Enter the join-mutex, so if the main-thread is currently
295            waiting to join all threads, the number of non-daemon threads
296            is correct. */
297
298         threads_mutex_join_lock();
299
300         /* create internal thread data-structure */
301
302         t = threads_thread_new();
303
304         t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON;
305
306         /* The thread is flagged as (non-)daemon thread, we can leave the
307            mutex. */
308
309         threads_mutex_join_unlock();
310
311         /* create the java thread object */
312
313         object = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
314
315         /* XXX memory leak!!! */
316         if (object == NULL)
317                 return false;
318
319 #if defined(WITH_CLASSPATH_GNU)
320         vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
321
322         /* XXX memory leak!!! */
323         if (vmt == NULL)
324                 return false;
325
326         LLNI_field_set_ref(vmt, thread, object);
327         LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) t);
328
329         LLNI_field_set_ref(object, vmThread, vmt);
330 #elif defined(WITH_CLASSPATH_CLDC1_1)
331         LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t);
332 #endif
333
334         threads_thread_set_object(t, (java_handle_t *) object);
335
336         /* set java.lang.Thread fields */
337
338 #if defined(WITH_CLASSPATH_GNU)
339         LLNI_field_set_ref(object, name    , (java_lang_String *) javastring_new(name));
340 #elif defined(WITH_CLASSPATH_CLDC1_1)
341         /* FIXME: In cldc the name is a char[] */
342 /*      LLNI_field_set_ref(object, name    , (java_chararray *) javastring_new(name)); */
343         LLNI_field_set_ref(object, name    , NULL);
344 #endif
345
346 #if defined(ENABLE_JAVASE)
347         LLNI_field_set_val(object, daemon  , true);
348 #endif
349
350         LLNI_field_set_val(object, priority, NORM_PRIORITY);
351
352         /* start the thread */
353
354         threads_impl_thread_start(t, f);
355
356         /* everything's ok */
357
358         return true;
359 }
360
361
362 /* threads_thread_start ********************************************************
363
364    Start a Java thread in the JVM.  Only the java thread object exists
365    so far.
366
367    IN:
368       object.....the java thread object java.lang.Thread
369
370 *******************************************************************************/
371
372 void threads_thread_start(java_handle_t *object)
373 {
374         java_lang_Thread   *o;
375         threadobject       *thread;
376 #if defined(WITH_CLASSPATH_GNU)
377         java_lang_VMThread *vmt;
378 #endif
379
380         o = (java_lang_Thread *) object;
381
382         /* Enter the join-mutex, so if the main-thread is currently
383            waiting to join all threads, the number of non-daemon threads
384            is correct. */
385
386         threads_mutex_join_lock();
387
388         /* create internal thread data-structure */
389
390         thread = threads_thread_new();
391
392         /* this is a normal Java thread */
393
394         thread->flags |= THREAD_FLAG_JAVA;
395
396 #if defined(ENABLE_JAVASE)
397         /* is this a daemon thread? */
398
399         if (LLNI_field_direct(o, daemon) == true)
400                 thread->flags |= THREAD_FLAG_DAEMON;
401 #endif
402
403         /* The thread is flagged and (non-)daemon thread, we can leave the
404            mutex. */
405
406         threads_mutex_join_unlock();
407
408         /* link the two objects together */
409
410         threads_thread_set_object(thread, object);
411
412 #if defined(WITH_CLASSPATH_GNU)
413         LLNI_field_get_ref(o, vmThread, vmt);
414
415         assert(vmt);
416         assert(LLNI_field_direct(vmt, vmdata) == NULL);
417
418         LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) thread);
419 #elif defined(WITH_CLASSPATH_CLDC1_1)
420         LLNI_field_set_val(o, vm_thread, (java_lang_Object *) thread);
421 #endif
422
423         /* Start the thread.  Don't pass a function pointer (NULL) since
424            we want Thread.run()V here. */
425
426         threads_impl_thread_start(thread, NULL);
427 }
428
429
430 /* threads_thread_print_info ***************************************************
431
432    Print information of the passed thread.
433    
434 *******************************************************************************/
435
436 void threads_thread_print_info(threadobject *t)
437 {
438         java_lang_Thread *object;
439 #if defined(WITH_CLASSPATH_GNU)
440         java_lang_String *namestring;
441 #endif
442         utf              *name;
443
444         assert(t->state != THREAD_STATE_NEW);
445
446         /* the thread may be currently in initalization, don't print it */
447
448         object = (java_lang_Thread *) threads_thread_get_object(t);
449
450         if (object != NULL) {
451                 /* get thread name */
452
453 #if defined(WITH_CLASSPATH_GNU)
454                 LLNI_field_get_ref(object, name, namestring);
455                 name = javastring_toutf((java_handle_t *) namestring, false);
456 #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
457                 /* FIXME: In cldc the name is a char[] */
458 /*              name = object->name; */
459                 name = utf_null;
460 #else
461 # error unknown classpath configuration
462 #endif
463
464                 printf("\"");
465                 utf_display_printable_ascii(name);
466                 printf("\"");
467
468                 if (t->flags & THREAD_FLAG_DAEMON)
469                         printf(" daemon");
470
471                 printf(" prio=%d", LLNI_field_direct(object, priority));
472
473 #if SIZEOF_VOID_P == 8
474                 printf(" t=0x%016lx tid=0x%016lx (%ld)",
475                            (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
476 #else
477                 printf(" t=0x%08x tid=0x%08x (%d)",
478                            (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
479 #endif
480
481                 printf(" index=%d", t->index);
482
483                 /* print thread state */
484
485                 switch (t->state) {
486                 case THREAD_STATE_NEW:
487                         printf(" new");
488                         break;
489                 case THREAD_STATE_RUNNABLE:
490                         printf(" runnable");
491                         break;
492                 case THREAD_STATE_BLOCKED:
493                         printf(" blocked");
494                         break;
495                 case THREAD_STATE_WAITING:
496                         printf(" waiting");
497                         break;
498                 case THREAD_STATE_TIMED_WAITING:
499                         printf(" waiting on condition");
500                         break;
501                 case THREAD_STATE_TERMINATED:
502                         printf(" terminated");
503                         break;
504                 default:
505                         vm_abort("threads_thread_print_info: unknown thread state %d",
506                                          t->state);
507                 }
508         }
509 }
510
511
512 /* threads_get_current_tid *****************************************************
513
514    Return the tid of the current thread.
515    
516    RETURN VALUE:
517        the current tid
518
519 *******************************************************************************/
520
521 ptrint threads_get_current_tid(void)
522 {
523         threadobject *thread;
524
525         thread = THREADOBJECT;
526
527         /* this may happen during bootstrap */
528
529         if (thread == NULL)
530                 return 0;
531
532         return (ptrint) thread->tid;
533 }
534
535
536 /* threads_get_current_object **************************************************
537
538    Return the Java object of the current thread.
539    
540    RETURN VALUE:
541        the Java object
542
543 *******************************************************************************/
544
545 #include "native/include/java_lang_ThreadGroup.h"
546
547 java_object_t *threads_get_current_object(void)
548 {
549 #if defined(ENABLE_THREADS)
550         threadobject  *t;
551 # if defined(ENABLE_JAVASE)
552         java_lang_ThreadGroup *group;
553 # endif
554 #endif
555         java_lang_Thread *o;
556
557 #if defined(ENABLE_THREADS)
558         t = THREADOBJECT;
559         o = threads_thread_get_object(t);
560
561 # if defined(ENABLE_JAVASE)
562         /* TODO Do we really need this code?  Or should we check, when we
563            create the threads, that all of them have a group? */
564         /* TWISTI No, we don't need this code!  We need to allocate a
565            ThreadGroup before we initialize the main thread. */
566
567         LLNI_field_get_ref(o, group, group);
568
569         if (group == NULL) {
570                 /* ThreadGroup of currentThread is not initialized */
571
572                 group = (java_lang_ThreadGroup *)
573                         native_new_and_init(class_java_lang_ThreadGroup);
574
575                 if (group == NULL)
576                         vm_abort("unable to create ThreadGroup");
577
578                 LLNI_field_set_ref(o, group, group);
579         }
580 # endif
581 #else
582         /* We just return a fake java.lang.Thread object, otherwise we get
583            NullPointerException's in GNU Classpath. */
584
585         o = builtin_new(class_java_lang_Thread);
586 #endif
587
588         return o;
589 }
590
591
592 /* threads_thread_state_runnable ***********************************************
593
594    Set the current state of the given thread to THREAD_STATE_RUNNABLE.
595
596    NOTE: If the thread has already terminated, don't set the state.
597          This is important for threads_detach_thread.
598
599 *******************************************************************************/
600
601 void threads_thread_state_runnable(threadobject *t)
602 {
603         /* Set the state inside a lock. */
604
605         threads_list_lock();
606
607         if (t->state != THREAD_STATE_TERMINATED)
608                 t->state = THREAD_STATE_RUNNABLE;
609
610         DEBUGTHREADS("is RUNNABLE", t);
611
612         threads_list_unlock();
613 }
614
615
616 /* threads_thread_state_waiting ************************************************
617
618    Set the current state of the given thread to THREAD_STATE_WAITING.
619
620    NOTE: If the thread has already terminated, don't set the state.
621          This is important for threads_detach_thread.
622
623 *******************************************************************************/
624
625 void threads_thread_state_waiting(threadobject *t)
626 {
627         /* Set the state inside a lock. */
628
629         threads_list_lock();
630
631         if (t->state != THREAD_STATE_TERMINATED)
632                 t->state = THREAD_STATE_WAITING;
633
634         DEBUGTHREADS("is WAITING", t);
635
636         threads_list_unlock();
637 }
638
639
640 /* threads_thread_state_timed_waiting ******************************************
641
642    Set the current state of the given thread to
643    THREAD_STATE_TIMED_WAITING.
644
645    NOTE: If the thread has already terminated, don't set the state.
646          This is important for threads_detach_thread.
647
648 *******************************************************************************/
649
650 void threads_thread_state_timed_waiting(threadobject *t)
651 {
652         /* Set the state inside a lock. */
653
654         threads_list_lock();
655
656         if (t->state != THREAD_STATE_TERMINATED)
657                 t->state = THREAD_STATE_TIMED_WAITING;
658
659         DEBUGTHREADS("is TIMED_WAITING", t);
660
661         threads_list_unlock();
662 }
663
664
665 /* threads_thread_state_terminated *********************************************
666
667    Set the current state of the given thread to
668    THREAD_STATE_TERMINATED.
669
670 *******************************************************************************/
671
672 void threads_thread_state_terminated(threadobject *t)
673 {
674         /* set the state in the lock */
675
676         threads_list_lock();
677
678         t->state = THREAD_STATE_TERMINATED;
679
680         DEBUGTHREADS("is TERMINATED", t);
681
682         threads_list_unlock();
683 }
684
685
686 /* threads_thread_get_state ****************************************************
687
688    Returns the current state of the given thread.
689
690 *******************************************************************************/
691
692 utf *threads_thread_get_state(threadobject *t)
693 {
694         utf *u;
695
696         switch (t->state) {
697         case THREAD_STATE_NEW:
698                 u = utf_new_char("NEW");
699                 break;
700         case THREAD_STATE_RUNNABLE:
701                 u = utf_new_char("RUNNABLE");
702                 break;
703         case THREAD_STATE_BLOCKED:
704                 u = utf_new_char("BLOCKED");
705                 break;
706         case THREAD_STATE_WAITING:
707                 u = utf_new_char("WAITING");
708                 break;
709         case THREAD_STATE_TIMED_WAITING:
710                 u = utf_new_char("TIMED_WAITING");
711                 break;
712         case THREAD_STATE_TERMINATED:
713                 u = utf_new_char("TERMINATED");
714                 break;
715         default:
716                 vm_abort("threads_get_state: unknown thread state %d", t->state);
717
718                 /* keep compiler happy */
719
720                 u = NULL;
721         }
722
723         return u;
724 }
725
726
727 /* threads_thread_is_alive *****************************************************
728
729    Returns if the give thread is alive.
730
731 *******************************************************************************/
732
733 bool threads_thread_is_alive(threadobject *t)
734 {
735         switch (t->state) {
736         case THREAD_STATE_NEW:
737         case THREAD_STATE_TERMINATED:
738                 return false;
739
740         case THREAD_STATE_RUNNABLE:
741         case THREAD_STATE_BLOCKED:
742         case THREAD_STATE_WAITING:
743         case THREAD_STATE_TIMED_WAITING:
744                 return true;
745
746         default:
747                 vm_abort("threads_thread_is_alive: unknown thread state %d", t->state);
748         }
749
750         /* keep compiler happy */
751
752         return false;
753 }
754
755
756 /* threads_dump ****************************************************************
757
758    Dumps info for all threads running in the JVM.  This function is
759    called when SIGQUIT (<ctrl>-\) is sent to CACAO.
760
761 *******************************************************************************/
762
763 void threads_dump(void)
764 {
765         threadobject *t;
766
767         /* XXX we should stop the world here */
768
769         /* lock the threads lists */
770
771         threads_list_lock();
772
773         printf("Full thread dump CACAO "VERSION":\n");
774
775         /* iterate over all started threads */
776
777         for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
778                 /* ignore threads which are in state NEW */
779                 if (t->state == THREAD_STATE_NEW)
780                         continue;
781
782 #if defined(ENABLE_GC_CACAO)
783                 /* Suspend the thread. */
784                 /* XXX Is the suspend reason correct? */
785
786                 if (threads_suspend_thread(t, SUSPEND_REASON_JNI) == false)
787                         vm_abort("threads_dump: threads_suspend_thread failed");
788 #endif
789
790                 /* Print thread info. */
791
792                 printf("\n");
793                 threads_thread_print_info(t);
794                 printf("\n");
795
796                 /* Print trace of thread. */
797
798                 threads_thread_print_stacktrace(t);
799
800 #if defined(ENABLE_GC_CACAO)
801                 /* Resume the thread. */
802
803                 if (threads_resume_thread(t) == false)
804                         vm_abort("threads_dump: threads_resume_thread failed");
805 #endif
806         }
807
808         /* unlock the threads lists */
809
810         threads_list_unlock();
811 }
812
813
814 /* threads_thread_print_stacktrace *********************************************
815
816    Print the current stacktrace of the given thread.
817
818 *******************************************************************************/
819
820 void threads_thread_print_stacktrace(threadobject *thread)
821 {
822         stackframeinfo_t        *sfi;
823         java_handle_bytearray_t *ba;
824         stacktrace_t            *st;
825
826         /* Build a stacktrace for the passed thread. */
827
828         sfi = thread->_stackframeinfo;
829         ba  = stacktrace_get(sfi);
830         
831         if (ba != NULL) {
832                 /* We need a critical section here as we use the byte-array
833                    data pointer directly. */
834
835                 LLNI_CRITICAL_START;
836         
837                 st = (stacktrace_t *) LLNI_array_data(ba);
838
839                 /* Print stacktrace. */
840
841                 stacktrace_print(st);
842
843                 LLNI_CRITICAL_END;
844         }
845         else {
846                 puts("\t<<No stacktrace available>>");
847                 fflush(stdout);
848         }
849 }
850
851
852 /* threads_print_stacktrace ****************************************************
853
854    Print the current stacktrace of the current thread.
855
856 *******************************************************************************/
857
858 void threads_print_stacktrace(void)
859 {
860         threadobject *thread;
861
862         thread = THREADOBJECT;
863
864         threads_thread_print_stacktrace(thread);
865 }
866
867
868 /*
869  * These are local overrides for various environment variables in Emacs.
870  * Please do not remove this and leave it at the end of the file, where
871  * Emacs will automagically detect them.
872  * ---------------------------------------------------------------------
873  * Local variables:
874  * mode: c
875  * indent-tabs-mode: t
876  * c-basic-offset: 4
877  * tab-width: 4
878  * End:
879  * vim:noexpandtab:sw=4:ts=4:
880  */