00001 #include <stdio.h>
00002 #include <stdlib.h>
00003
00004 #define PAGE_SIZE (4096)
00005 #define STACK_PAGES_USED (9)
00006 #define STACK_ARRAY_ELEMS (PAGE_SIZE * STACK_PAGES_USED / sizeof(int))
00007 #define UNINIT_PAGES (9)
00008 #define UNINIT_ARRAY_ELEMS (PAGE_SIZE * UNINIT_PAGES / sizeof(int))
00009
00010 unsigned int uninit[UNINIT_ARRAY_ELEMS];
00011 unsigned int init[] = {
00012 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
00013 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
00014 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
00015 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
00016 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
00017 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
00018 };
00019
00020 #define INIT_ARRAY_ELEMS (sizeof(init) / sizeof(int))
00021
00022 int
00023 main()
00024 {
00025 unsigned int array[STACK_ARRAY_ELEMS];
00026 unsigned int i = 0;
00027
00028
00029 for (i=0; i<UNINIT_ARRAY_ELEMS; i++) {
00030 if (uninit[i] != 0) {
00031 printf("FAILED uninit[%d] = %u != %d\n", i, uninit[i], 0);
00032 exit(1);
00033 }
00034 }
00035
00036
00037 for (i=0; i<UNINIT_ARRAY_ELEMS; i++) {
00038 uninit[i] = i * 100;
00039 }
00040
00041
00042 for (i=0; i<STACK_ARRAY_ELEMS; i++) {
00043 array[i] = i * 1000;
00044 }
00045
00046
00047 for (i=0; i<STACK_ARRAY_ELEMS; i++) {
00048 if (array[i] != i * 1000) {
00049 printf("FAILED array[%d] = %u != %d\n", i, array[i], i);
00050 exit(1);
00051 }
00052 }
00053
00054
00055 for (i=0; i<UNINIT_ARRAY_ELEMS; i++) {
00056 if (uninit[i] != i * 100) {
00057 printf("FAILED uninit[%d] = %u != %d\n", i, uninit[i], i);
00058 exit(1);
00059 }
00060 }
00061
00062
00063 for (i=0; i<INIT_ARRAY_ELEMS; i++) {
00064 if (init[i] != i) {
00065 printf("FAILED init[%d] = %u != %d\n", i, init[i], i);
00066 exit(1);
00067 }
00068 }
00069
00070 printf("SUCCEEDED\n");
00071 exit(0);
00072 }