harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r504061 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c
Date Tue, 06 Feb 2007 10:12:05 GMT
Author: hindessm
Date: Tue Feb  6 02:12:04 2007
New Revision: 504061

URL: http://svn.apache.org/viewvc?view=rev&rev=504061
Log:
Fix isLittleEndianImpl to do a proper test so it can return the right answer
on BigEndian platforms.
Minor fix for compiling on Aix where PAGE_SIZE is already defined.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c?view=diff&rev=504061&r1=504060&r2=504061
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSMemoryLinux32.c
Tue Feb  6 02:12:04 2007
@@ -31,7 +31,9 @@
 
 JNIEXPORT jboolean JNICALL Java_org_apache_harmony_luni_platform_OSMemory_isLittleEndianImpl(JNIEnv
* env, jclass clazz)
 {
-  return JNI_TRUE;
+  long l = 0x01020304;
+  unsigned char* c = (unsigned char*)&l;
+  return (*c == 0x04) ? JNI_TRUE : JNI_FALSE;
 }
 
 JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSMemory_getPointerSizeImpl
(JNIEnv * env, jclass clazz)
@@ -54,10 +56,10 @@
 
 int getPageSize()
 {
-	static int PAGE_SIZE = 0;
-	if(PAGE_SIZE==0)
-		PAGE_SIZE=getpagesize();
-	return PAGE_SIZE;
+	static int page_size = 0;
+	if(page_size==0)
+		page_size=getpagesize();
+	return page_size;
 }
 
 JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSMemory_loadImpl
@@ -79,13 +81,13 @@
 	  PORT_ACCESS_FROM_ENV (env);
   	  jboolean result = 0;
   	  IDATA m_addr = (IDATA)addr;
-	  int PAGE_SIZE = getPageSize();
+	  int page_size = getPageSize();
 	  char* vec = NULL;
 	  int page_count = 0;
-	  int align_offset = m_addr%PAGE_SIZE;//addr should align with the boundary of a page.
+	  int align_offset = m_addr%page_size;//addr should align with the boundary of a page.
 	  m_addr -= align_offset;
 	  size   += align_offset;
-	  page_count = (size+PAGE_SIZE-1)/PAGE_SIZE;
+	  page_count = (size+page_size-1)/page_size;
 	  vec = (char *) hymem_allocate_memory(page_count*sizeof(char));
 	  if(mincore((void *)m_addr, size , (unsigned char *)vec)==0) //or else there is error about
the mincore and return false;
 	  {



Mime
View raw message