]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/matchbox-panel/matchbox-panel-0.9.2/kernel2.6.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / matchbox-panel / matchbox-panel-0.9.2 / kernel2.6.patch
1 --- matchbox-panel-0.9.2/applets/mb-applet-system-monitor.c.old 2005-03-20 18:43:31.000000000 +0100
2 +++ matchbox-panel-0.9.2/applets/mb-applet-system-monitor.c     2005-12-21 10:24:18.000000000 +0100
3 @@ -37,6 +37,11 @@
4  # define _(text) (text)
5  #endif
6  
7 +#include <linux/version.h>
8 +#ifndef KERNEL_VERSION
9 +#define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))
10 +#endif
11 +
12  #ifdef MB_HAVE_PNG
13  #define IMG_EXT "png"
14  #else
15 @@ -112,71 +117,148 @@
16  
17  int system_memory(void)
18  {
19 -    u_int64_t my_mem_used, my_mem_max;
20 -    u_int64_t my_swap_max;
21 -
22 -    static int mem_delay = 0;
23 -    FILE *mem;
24 -    static u_int64_t total, used, mfree, shared, buffers, cached,
25 -      cache_total, cache_used;
26 -
27 -    /* put this in permanent storage instead of stack */
28 -    static char not_needed[2048];
29 -
30 -    if (mem_delay-- <= 0) {
31 -      if ((mem = fopen("/proc/meminfo", "r")) == NULL)
32 -       {
33 -         fprintf(stderr, "mb-applet-system-monitor: failed to open /proc/meminfo. Exiting.\n");
34 -         exit(1);
35 -      }
36 -
37 -
38 -
39 -       fgets(not_needed, 2048, mem);
40 -       
41 -       /* 
42 -           total:    used:    free:  shared: buffers:  cached:
43 -       */
44 -
45 -       fscanf(mem, "%*s %Ld %Ld %Ld %Ld %Ld %Ld", &total, &used, &mfree,
46 -              &shared, &buffers, &cached);
47 -
48 -       fscanf(mem, "%*s %Ld %Ld", &cache_total, &cache_used);
49 -
50 -       fclose(mem);
51 -       mem_delay = 25;
52 -
53 -       /* calculate it */
54 -       my_mem_max = total;
55 -       my_swap_max = cache_total;
56 -
57 -       my_mem_used = cache_used + used - cached - buffers;
58 -
59 -       /* No swap on ipaq 
60 -       if (my_mem_used > my_mem_max) {
61 -          my_swap_used = my_mem_used - my_mem_max;
62 -           my_mem_used = my_mem_max;
63 -       } else {
64 -          my_swap_used = 0;
65 -       }
66 -       */
67 -       
68 -       msd.mem_used = my_mem_used;
69 -       msd.mem_max = my_mem_max;
70 -       //msd.swap_used = my_swap_used;
71 -       //msd.swap_max = my_swap_max;
72 -
73 -       msd.mem_percent = (100 * msd.mem_used) / msd.mem_max;
74 -       //msd.swap_percent = (100 * msd.swap_used) / msd.swap_max;
75 -
76 -       /* memory info changed - update things */
77 -       return 1;
78 -       }
79 -    /* nothing new */
80 -    return 0;
81 +    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
82 +        u_int64_t  total, mfree, buffers, cached, used, shared,
83 +        cache_total, cache_free, cache_used;
84 +
85 +        u_int64_t my_mem_used, my_mem_max;
86 +        u_int64_t my_swap_max;
87 +
88 +        static int mem_delay = 0;
89 +        FILE *mem;
90 +
91 +        /* put this in permanent storage instead of stack */
92 +        static char not_needed[2048];
93 +
94 +        if (mem_delay-- <= 0) {
95 +            if ((mem = fopen("/proc/meminfo", "r")) == NULL) {
96 +                fprintf(stderr, "mb-applet-system-monitor: failed to open /proc/meminfo. Exiting.\n");
97 +                exit(1);
98 +        }
99 +
100 +        fgets(not_needed, 2048, mem);
101 +
102 +        rewind (mem);
103 +
104 +        fscanf (mem, "%*s %Ld %*s", &total);
105 +        fscanf (mem, "%*s %Ld %*s", &mfree);
106 +        fscanf (mem, "%*s %Ld %*s", &buffers);
107 +        fscanf (mem, "%*s %Ld %*s", &cached);
108 +        fscanf (mem, "%*s %Ld %*s", &shared);
109 +        fscanf (mem, "%*s %Ld %*s", &used);
110 +        fscanf (mem, "%*s %*Ld %*s");
111 +        fscanf (mem, "%*s %*Ld %*s");
112 +        fscanf (mem, "%*s %*Ld %*s");
113 +        fscanf (mem, "%*s %*Ld %*s");
114 +        fscanf (mem, "%*s %*Ld %*s");
115 +        fscanf (mem, "%*s %Ld %*s", &cache_total);
116 +        fscanf (mem, "%*s %Ld %*s", &cache_free);
117 +
118 +        fclose (mem);
119 +
120 +        total = total * 1024;
121 +        mfree = mfree * 1024;
122 +        buffers = buffers * 1024;
123 +        cached = cached * 1024;
124 +        used = used * 1024;
125 +        shared = shared * 1024;
126 +        cache_total = cache_total * 1024;
127 +        cache_used = cache_total - (cache_free * 1024);
128 +
129 +        mem_delay = 25;
130 +
131 +        /* calculate it */
132 +        my_mem_max = total;
133 +        my_swap_max = cache_total;
134 +
135 +        my_mem_used = cache_used + used - cached - buffers;
136 +
137 +        /* No swap on ipaq
138 +        if (my_mem_used > my_mem_max) {
139 +        my_swap_used = my_mem_used - my_mem_max;
140 +        my_mem_used = my_mem_max;
141 +        } else {
142 +        my_swap_used = 0;
143 +        }
144 +        */
145 +
146 +        msd.mem_used = my_mem_used;
147 +        msd.mem_max = my_mem_max;
148 +        //msd.swap_used = my_swap_used;
149 +        //msd.swap_max = my_swap_max;
150 +
151 +        msd.mem_percent = (100 * msd.mem_used) / msd.mem_max;
152 +        //msd.swap_percent = (100 * msd.swap_used) / msd.swap_max;
153 +
154 +        /* memory info changed - update things */
155 +        return 1;
156 +        }
157 +        /* nothing new */
158 +        return 0;
159 +    #else
160 +        static u_int64_t total, used, mfree, shared, buffers, cached,
161 +            cache_total, cache_used;
162 +
163 +        u_int64_t my_mem_used, my_mem_max;
164 +        u_int64_t my_swap_max;
165 +
166 +        static int mem_delay = 0;
167 +        FILE *mem;
168 +
169 +        /* put this in permanent storage instead of stack */
170 +        static char not_needed[2048];
171 +
172 +        if (mem_delay-- <= 0) {
173 +            if ((mem = fopen("/proc/meminfo", "r")) == NULL) {
174 +                fprintf(stderr, "mb-applet-system-monitor: failed to open /proc/meminfo. Exiting.\n");
175 +                exit(1);
176 +            }
177 +
178 +            fgets(not_needed, 2048, mem);
179 +
180 +            /*
181 +            total:    used:    free:  shared: buffers:  cached:
182 +            */
183 +            fscanf(mem, "%*s %Ld %Ld %Ld %Ld %Ld %Ld", &total, &used, &mfree,
184 +                &shared, &buffers, &cached);
185 +
186 +            fscanf(mem, "%*s %Ld %Ld", &cache_total, &cache_used);
187 +
188 +            fclose(mem);
189 +
190 +            mem_delay = 25;
191 +
192 +            /* calculate it */
193 +            my_mem_max = total;
194 +            my_swap_max = cache_total;
195 +
196 +            my_mem_used = cache_used + used - cached - buffers;
197 +
198 +            /* No swap on ipaq
199 +                if (my_mem_used > my_mem_max) {
200 +                my_swap_used = my_mem_used - my_mem_max;
201 +                my_mem_used = my_mem_max;
202 +            } else {
203 +                my_swap_used = 0;
204 +            }
205 +            */
206 +
207 +            msd.mem_used = my_mem_used;
208 +            msd.mem_max = my_mem_max;
209 +            //msd.swap_used = my_swap_used;
210 +            //msd.swap_max = my_swap_max;
211 +
212 +            msd.mem_percent = (100 * msd.mem_used) / msd.mem_max;
213 +            //msd.swap_percent = (100 * msd.swap_used) / msd.swap_max;
214 +
215 +            /* memory info changed - update things */
216 +            return 1;
217 +        }
218 +        /* nothing new */
219 +        return 0;
220 +    #endif
221  }
222  
223 -
224  void
225  paint_callback (MBTrayApp *app, Drawable drw )
226  {