ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/utils/physmem.c
(Generate patch)

Comparing trunk/OOPSE-4/src/utils/physmem.c (file contents):
Revision 1996 by tim, Fri Feb 11 22:35:05 2005 UTC vs.
Revision 2759 by tim, Wed May 17 21:51:42 2006 UTC

# Line 75 | Line 75 | double
75   #endif
76  
77   /* Return the total amount of physical memory.  */
78 < double
78 > RealType
79   physmem_total ()
80   {
81   #if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
82    { /* This works on linux-gnu, solaris2 and cygwin.  */
83 <    double pages = sysconf (_SC_PHYS_PAGES);
84 <    double pagesize = sysconf (_SC_PAGESIZE);
83 >    RealType pages = sysconf (_SC_PHYS_PAGES);
84 >    RealType pagesize = sysconf (_SC_PAGESIZE);
85      if (0 <= pages && 0 <= pagesize)
86        return pages * pagesize;
87    }
# Line 92 | Line 92 | physmem_total ()
92      struct pst_static pss;
93      if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0))
94        {
95 <        double pages = pss.physical_memory;
96 <        double pagesize = pss.page_size;
95 >        RealType pages = pss.physical_memory;
96 >        RealType pagesize = pss.page_size;
97          if (0 <= pages && 0 <= pagesize)
98            return pages * pagesize;
99        }
# Line 105 | Line 105 | physmem_total ()
105      struct rminfo realmem;
106      if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0)
107        {
108 <        double pagesize = sysconf (_SC_PAGESIZE);
109 <        double pages = realmem.physmem;
108 >        RealType pagesize = sysconf (_SC_PAGESIZE);
109 >        RealType pages = realmem.physmem;
110          if (0 <= pages && 0 <= pagesize)
111            return pages * pagesize;
112        }
# Line 120 | Line 120 | physmem_total ()
120      if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem),
121                      NULL, NULL, NULL) == 1)
122        {
123 <        double kbytes = physmem;
123 >        RealType kbytes = physmem;
124  
125          if (0 <= kbytes)
126            return kbytes * 1024.0;
# Line 136 | Line 136 | physmem_total ()
136  
137      if (sysctl (mib, 2, &physmem, &len, NULL, 0) == 0
138          && len == sizeof (physmem))
139 <      return (double) physmem;
139 >      return (RealType) physmem;
140    }
141   #endif
142  
# Line 160 | Line 160 | physmem_total ()
160          lms_ex.dwLength = sizeof lms_ex;
161          if (!pfnex (&lms_ex))
162            return 0.0;
163 <        return (double) lms_ex.ullTotalPhys;
163 >        return (RealType) lms_ex.ullTotalPhys;
164        }
165  
166      /*  Fall back to GlobalMemoryStatus which is always available.
# Line 169 | Line 169 | physmem_total ()
169        {
170          MEMORYSTATUS ms;
171          GlobalMemoryStatus (&ms);
172 <        return (double) ms.dwTotalPhys;
172 >        return (RealType) ms.dwTotalPhys;
173        }
174    }
175   #endif
# Line 179 | Line 179 | double
179   }
180  
181   /* Return the amount of physical memory available.  */
182 < double
182 > RealType
183   physmem_available ()
184   {
185   #if defined _SC_AVPHYS_PAGES && defined _SC_PAGESIZE
186    { /* This works on linux-gnu, solaris2 and cygwin.  */
187 <    double pages = sysconf (_SC_AVPHYS_PAGES);
188 <    double pagesize = sysconf (_SC_PAGESIZE);
187 >    RealType pages = sysconf (_SC_AVPHYS_PAGES);
188 >    RealType pagesize = sysconf (_SC_PAGESIZE);
189      if (0 <= pages && 0 <= pagesize)
190        return pages * pagesize;
191    }
# Line 198 | Line 198 | physmem_available ()
198      if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)
199          && 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0))
200        {
201 <        double pages = psd.psd_free;
202 <        double pagesize = pss.page_size;
201 >        RealType pages = psd.psd_free;
202 >        RealType pagesize = pss.page_size;
203          if (0 <= pages && 0 <= pagesize)
204            return pages * pagesize;
205        }
# Line 211 | Line 211 | physmem_available ()
211      struct rminfo realmem;
212      if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0)
213        {
214 <        double pagesize = sysconf (_SC_PAGESIZE);
215 <        double pages = realmem.availrmem;
214 >        RealType pagesize = sysconf (_SC_PAGESIZE);
215 >        RealType pages = realmem.availrmem;
216          if (0 <= pages && 0 <= pagesize)
217            return pages * pagesize;
218        }
# Line 225 | Line 225 | physmem_available ()
225  
226      if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1)
227        {
228 <        double pages = vmstats.free_count;
229 <        double pagesize = vmstats.pagesize;
228 >        RealType pages = vmstats.free_count;
229 >        RealType pagesize = vmstats.pagesize;
230  
231          if (0 <= pages && 0 <= pagesize)
232            return pages * pagesize;
# Line 242 | Line 242 | physmem_available ()
242  
243      if (sysctl (mib, 2, &usermem, &len, NULL, 0) == 0
244          && len == sizeof (usermem))
245 <      return (double) usermem;
245 >      return (RealType) usermem;
246    }
247   #endif
248  
# Line 261 | Line 261 | physmem_available ()
261          lms_ex.dwLength = sizeof lms_ex;
262          if (!pfnex (&lms_ex))
263            return 0.0;
264 <        return (double) lms_ex.ullAvailPhys;
264 >        return (RealType) lms_ex.ullAvailPhys;
265        }
266  
267      /*  Fall back to GlobalMemoryStatus which is always available.
# Line 270 | Line 270 | physmem_available ()
270        {
271          MEMORYSTATUS ms;
272          GlobalMemoryStatus (&ms);
273 <        return (double) ms.dwAvailPhys;
273 >        return (RealType) ms.dwAvailPhys;
274        }
275    }
276   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines