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