Closed
Bug 292899
Opened 19 years ago
Closed 19 years ago
API for determining the amount of system memory
Categories
(NSPR :: NSPR, enhancement)
NSPR
NSPR
Tracking
(Not tracked)
RESOLVED
FIXED
4.6
People
(Reporter: bryner, Assigned: bryner)
References
Details
Attachments
(4 files, 1 obsolete file)
6.13 KB,
patch
|
wtc
:
review+
brendan
:
approval-aviary1.1a1+
brendan
:
approval1.8b2+
|
Details | Diff | Splinter Review |
2.36 KB,
patch
|
wtc
:
review+
|
Details | Diff | Splinter Review |
872 bytes,
patch
|
wtc
:
review+
|
Details | Diff | Splinter Review |
643 bytes,
patch
|
Details | Diff | Splinter Review |
We currently have code in mozilla/netwerk/cache/src/nsCacheService.cpp that determines the amont of RAM in the system. This should be moved into NSPR so that it's easier to use from other places.
Assignee | ||
Comment 1•19 years ago
|
||
Attachment #182616 -
Flags: review?(wtchang)
Comment 2•19 years ago
|
||
Comment on attachment 182616 [details] [diff] [review] patch (against NSPRPUB_PRE_4_2_CLIENT_BRANCH) This patch is basically OK. The indentation level needs to be changed to 4 to follow NSPR's coding style. I also suggest we change SystemMemory to PhysicalMemory because "physical memory" seems to be the more common term. I'm wondering if the function should return the signed PRInt64 type so that it can return -1 on failure. (By the way, the function needs to have a #else case to call PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0).) I don't think we will ever have a computer with more than 2^63 bytes of memory. Microsoft documentation says we need to use GlobalMemoryStatusEx instead on computers with more than 4 GB of memory. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/me morystatus_str.asp
Attachment #182616 -
Flags: review?(wtchang) → review-
Assignee | ||
Comment 3•19 years ago
|
||
(In reply to comment #2) > (From update of attachment 182616 [details] [diff] [review] [edit]) > This patch is basically OK. The indentation level > needs to be changed to 4 to follow NSPR's coding style. Hm, why does the emacs modeline have c-basic-offset: 2? > I also suggest we change SystemMemory to PhysicalMemory > because "physical memory" seems to be the more common > term. > I'll do that. > I'm wondering if the function should return the signed > PRInt64 type so that it can return -1 on failure. > (By the way, the function needs to have a #else case to call > PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0).) I don't think > we will ever have a computer with more than 2^63 bytes of > memory. Perhaps not, but 0 seems like a fine error return to me, and that way we're sure we can return any amount of memory addressable by a 64-bit architecture. > > Microsoft documentation says we need to use GlobalMemoryStatusEx > instead on computers with more than 4 GB of memory. > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/me > morystatus_str.asp > Yeah, see the fixme comment in the windows code. Since this function is only present on Windows 2000 and newer, I think we'll have to dynamically look up the function and fall back to GlobalMemoryStatus if it's not present. I'll go ahead and code that up.
Assignee | ||
Comment 4•19 years ago
|
||
I didn't change the return type, but I addressed all of the other comments. I changed to use GlobalMemoryStatusEx on win2k+ with a fallback for win95/8. I also added this to the prsystem test.
Assignee | ||
Updated•19 years ago
|
Attachment #182616 -
Attachment is obsolete: true
Attachment #182621 -
Flags: review?(wtchang)
Comment 5•19 years ago
|
||
Comment on attachment 182621 [details] [diff] [review] revised patch r=wtc. Thank you for adding a test for the new function. >-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ This line was imposed on NSPR when the Mozilla code was open sourced in 1998. Since none of the NSPR developers used emacs, it's just a comment to us. We probably need to add the newly included system headers to nsprpub/config/system-headers. >+#if defined(LINUX) || defined(SUN) We use SOLARIS instead of SUN in NSPR. Can this patch wait until after Aviary 1.1? I'm defining NSPR 4.6 to be the NSPR in Aviary 1.1, so I don't want to add new functions to NSPR now unless Aviary 1.1 needs them or you can obtain drivers' aviary1.1 approval for them. This function also needs to be added to nsprpub/pr/src/nspr.def and nsprpub/pr/src/nspr_symvec.opt. See attachment 177691 [details] [diff] [review] for an example (look at changes to plc.def and plc_symvec.opt). But we need to know which NSPR version this new function will go in.
Attachment #182621 -
Flags: review?(wtchang) → review+
Assignee | ||
Comment 6•19 years ago
|
||
Actually, I was planning to use this for bug 274784 which we are hoping to have enabled in Firefox 1.1. So this needs to be something we can use on the trunk now. Should I go ahead and label this for version 4.6? (In reply to comment #5) > (From update of attachment 182621 [details] [diff] [review] [edit]) > r=wtc. Thank you for adding a test for the new function. > > >-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ > > This line was imposed on NSPR when the Mozilla code was > open sourced in 1998. Since none of the NSPR developers > used emacs, it's just a comment to us. > > We probably need to add the newly included system headers > to nsprpub/config/system-headers. > > >+#if defined(LINUX) || defined(SUN) > > We use SOLARIS instead of SUN in NSPR. > > Can this patch wait until after Aviary 1.1? I'm defining > NSPR 4.6 to be the NSPR in Aviary 1.1, so I don't want to > add new functions to NSPR now unless Aviary 1.1 needs them > or you can obtain drivers' aviary1.1 approval for them. > > This function also needs to be added to nsprpub/pr/src/nspr.def > and nsprpub/pr/src/nspr_symvec.opt. See attachment 177691 [details] [diff] [review] [edit] > for an example (look at changes to plc.def and plc_symvec.opt). > But we need to know which NSPR version this new function will > go in. >
Assignee | ||
Comment 7•19 years ago
|
||
These are the changes to system_headers, nspr.def, and nspr_symvec.opt to add this function to NSPR 4.6. I wasn't really sure about how nspr_symvec.opt works, so hopefully this is ok.
Attachment #182692 -
Flags: review?(wtchang)
Comment 8•19 years ago
|
||
Comment on attachment 182692 [details] [diff] [review] additional changes r=wtc.
Attachment #182692 -
Flags: review?(wtchang) → review+
Assignee | ||
Comment 9•19 years ago
|
||
Comment on attachment 182621 [details] [diff] [review] revised patch Requesting approval to land... this only adds a new API so there is no risk to any current code paths.
Attachment #182621 -
Flags: approval-aviary1.1a?
Comment 10•19 years ago
|
||
Comment on attachment 182621 [details] [diff] [review] revised patch 1.1a for front-end firefox code is 1.8b2 for back-end, and using both will get you a special prize... a=me. /be
Attachment #182621 -
Flags: approval1.8b2+
Attachment #182621 -
Flags: approval-aviary1.1a?
Attachment #182621 -
Flags: approval-aviary1.1a+
Assignee | ||
Comment 11•19 years ago
|
||
Checked in on trunk and nspr client branch.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 12•19 years ago
|
||
This will be in NSPR 4.6 and Mozilla 1.8 Beta 2.
Severity: normal → enhancement
Target Milestone: --- → 4.6
Assignee | ||
Comment 13•19 years ago
|
||
The new library functions we call require libodl and libcfg.
Attachment #182827 -
Flags: review?(wtchang)
Comment 14•19 years ago
|
||
Comment on attachment 182827 [details] [diff] [review] fix AIX build It would be a good idea to ask Philip Warren of IBM whether the linking order between -lodm -lcfg and -lpthreads is important. On many platforms, the pthread library must appear before all other system libraries in the linking order.
Attachment #182827 -
Flags: review?(wtchang) → review+
Comment 15•19 years ago
|
||
This change added a newline at the end of nspr.def, and caused my OS/2 build to fail as follows : gcc -Zomf -Zdll -Zmap -o nspr4.dll ./nspr4.def ./prvrsion.o io/./prfdcach.o io/./prmwait.o io/./prmapopt.o io/./priometh.o io/./pripv6.o io/./prlayer.o io/./prlog.o io/./prmmap.o io/./prpolevt.o io/./prprf.o io/./prscanf.o io/./prstdio.o threads/./prcmon.o threads/./prrwlock.o threads/./prtpd.o linking/./prlink.o malloc/./prmem.o md/./prosdep.o memory/./prshm.o memory/./prshma.o memory/./prseg.o misc/./pralarm.o misc/./pratom.o misc/./prcountr.o misc/./prdtoa.o misc/./prenv.o misc/./prerr.o misc/./prerror.o misc/./prerrortable.o misc/./prinit.o misc/./prinrval.o misc/./pripc.o misc/./prlog2.o misc/./prlong.o misc/./prnetdb.o misc/./prolock.o misc/./prrng.o misc/./prsystem.o misc/./prthinfo.o misc/./prtpool.o misc/./prtrace.o misc/./prtime.o malloc/./prmalloc.o io/./prdir.o io/./prfile.o io/./prio.o io/./prsocket.o misc/./pripcsem.o threads/./prcthr.o threads/./prdump.o threads/./prmon.o threads/./prsem.o threads/combined/./prucpu.o threads/combined/./prucv.o threads/combined/./prulock.o threads/combined/./prustack.o threads/combined/./pruthr.o md/os2/./os2io.o md/os2/./os2sock.o md/os2/./os2thred.o md/os2/./os2cv.o md/os2/./os2gc.o md/os2/./os2misc.o md/os2/./os2inrval.o md/os2/./os2sem.o md/os2/./os2_errors.o md/os2/./os2poll.o md/os2/./os2rng.o md/os2/./os2emx.o md/os2/./os2vaclegacy.o -ldl -lsocket weakld: error: Unresolved symbol (UNDEF EXPORT) '_'. weakld: info: The symbol is referenced by: ./nspr4.def Ignoring unresolved externals reported from weak prelinker. ILink : error LNK2022: _ (alias _) : export undefined There was 1 error detected make.exe[3]: *** [nspr4.dll] Error 1 make.exe[3]: Leaving directory `E:/dev/nss/tip/mozilla/nsprpub/OS22.45_gcc_DBG.OBJ/pr/src' Please remove the newline.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 16•19 years ago
|
||
I'd rather fix rules.mk so this doesn't happen... http://lxr.mozilla.org/seamonkey/source/nsprpub/config/rules.mk#390
Comment 17•19 years ago
|
||
Check for empty lines in rules.mk I don't like this patch - I'd rather do it in sed - suggestions welcome.
Comment 18•19 years ago
|
||
*** Bug 293400 has been marked as a duplicate of this bug. ***
Comment 19•19 years ago
|
||
Sorry about that. I've checked in a fix (attachment 182975 [details] [diff] [review] in bug 293400). I agree we should enhance our makefile rules to ignore blank lines, but let's do that as an NSS bug because NSPR copies NSS's rules for processing *.def files on various platforms.
Status: REOPENED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•