File openjdk-6-src-b09-s390-size_t-fixes.patch of Package java-1_6_0-openjdk

- 31-bit S/390 does not like MAX2 and MIN2 in some situations
- 31-bit S/390 does not accept these casts from size_t* to uintptr_t*

Signed-Off-By: Bernhard Kaindl <bk@suse.de>

--- openjdk/hotspot/src/share/vm/utilities/globalDefinitions.hpp
+++ openjdk/hotspot/src/share/vm/utilities/globalDefinitions.hpp
@@ -829,8 +829,17 @@
 // and 64-bit overloaded functions, which does not work, and having
 // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L)
 // will be even more error-prone than macros.
+#if defined(__s390__) && !defined(__s390x__)
+# ifndef MIN2
+#  define MIN2(a, b) (((a) < (b)) ? (a) : (b))
+# endif
+# ifndef MAX2
+#  define MAX2(a, b) (((a) < (b)) ? (b) : (a))
+# endif
+#else
 template<class T> inline T MAX2(T a, T b)           { return (a > b) ? a : b; }
 template<class T> inline T MIN2(T a, T b)           { return (a < b) ? a : b; }
+#endif
 template<class T> inline T MAX3(T a, T b, T c)      { return MAX2(MAX2(a, b), c); }
 template<class T> inline T MIN3(T a, T b, T c)      { return MIN2(MIN2(a, b), c); }
 template<class T> inline T MAX4(T a, T b, T c, T d) { return MAX2(MAX3(a, b, c), d); }
--- openjdk/hotspot/src/share/vm/utilities/bitMap.cpp
+++ openjdk/hotspot/src/share/vm/utilities/bitMap.cpp
@@ -43,7 +43,7 @@
 void BitMap::resize(idx_t size_in_bits) {
   assert(size_in_bits >= 0, "just checking");
   size_t old_size_in_words = size_in_words();
-  uintptr_t* old_map = map();
+  size_t* old_map = map();
   _size = size_in_bits;
   size_t new_size_in_words = size_in_words();
   _map = NEW_RESOURCE_ARRAY(idx_t, new_size_in_words);
@@ -282,8 +282,8 @@
 
 bool BitMap::contains(const BitMap other) const {
   assert(size() == other.size(), "must have same size");
-  uintptr_t* dest_map = map();
-  uintptr_t* other_map = other.map();
+  size_t* dest_map = map();
+  size_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     uintptr_t word_union = dest_map[index] | other_map[index];
@@ -296,8 +296,8 @@
 
 bool BitMap::intersects(const BitMap other) const {
   assert(size() == other.size(), "must have same size");
-  uintptr_t* dest_map = map();
-  uintptr_t* other_map = other.map();
+  size_t* dest_map = map();
+  size_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size_in_words(); index++) {
     if ((dest_map[index] & other_map[index]) != 0) return true;
@@ -408,7 +408,7 @@
 }
 
 bool BitMap::is_full() const {
-  uintptr_t* word = map();
+  size_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
     if (*word != (uintptr_t) AllBits) return false;
@@ -419,7 +419,7 @@
 
 
 bool BitMap::is_empty() const {
-  uintptr_t* word = map();
+  size_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
     if (*word != (uintptr_t) NoBits) return false;
@@ -558,7 +558,7 @@
 #endif
 
 
-BitMap2D::BitMap2D(uintptr_t* map, idx_t size_in_slots, idx_t bits_per_slot)
+BitMap2D::BitMap2D(size_t* map, idx_t size_in_slots, idx_t bits_per_slot)
   : _bits_per_slot(bits_per_slot)
   , _map(map, size_in_slots * bits_per_slot)
 {
--- openjdk/hotspot/src/share/vm/utilities/bitMap.hpp
+++ openjdk/hotspot/src/share/vm/utilities/bitMap.hpp
@@ -314,7 +314,7 @@
 
  public:
   // Construction. bits_per_slot must be greater than 0.
-  BitMap2D(uintptr_t* map, idx_t size_in_slots, idx_t bits_per_slot);
+  BitMap2D(size_t* map, idx_t size_in_slots, idx_t bits_per_slot);
 
   // Allocates necessary data structure in resource area. bits_per_slot must be greater than 0.
   BitMap2D(idx_t size_in_slots, idx_t bits_per_slot);
@@ -367,13 +367,13 @@
 
 
 inline void BitMap::set_range_of_words(idx_t beg, idx_t end) {
-  uintptr_t* map = _map;
+  size_t* map = _map;
   for (idx_t i = beg; i < end; ++i) map[i] = ~(uintptr_t)0;
 }
 
 
 inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) {
-  uintptr_t* map = _map;
+  size_t* map = _map;
   for (idx_t i = beg; i < end; ++i) map[i] = 0;
 }
 
--- openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+++ openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
@@ -6141,7 +6141,7 @@
   }
   assert(_virtual_space.committed_size() == brs.size(),
          "didn't reserve backing store for all of CMS bit map?");
-  _bm.set_map((uintptr_t*)_virtual_space.low());
+  _bm.set_map((size_t*)_virtual_space.low());
   assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >=
          _bmWordSize, "inconsistency in bit map sizing");
   _bm.set_size(_bmWordSize >> _shifter);

For some reason, the gcc-4.3 on s390 does not like the MAX2/MIN2 templates

--- openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
+++ openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
@@ -371,8 +371,8 @@
   _gc_points = 0;
   _bb_count  = 0;
   int size = binsToHold(method()->code_size());
-  _bb_hdr_bits = NEW_RESOURCE_ARRAY(uintptr_t,size);
-  memset(_bb_hdr_bits, 0, size*sizeof(uintptr_t));
+  _bb_hdr_bits = NEW_RESOURCE_ARRAY(size_t,size);
+  memset(_bb_hdr_bits, 0, size*sizeof(size_t));
 }
 
 void GenerateOopMap ::set_bbmark_bit(int bci) {
@@ -1024,7 +1024,7 @@
          "new method size is too small");
   int newWords = binsToHold(new_method_size);
 
-  uintptr_t * new_bb_hdr_bits = NEW_RESOURCE_ARRAY(uintptr_t, newWords);
+  size_t* new_bb_hdr_bits = NEW_RESOURCE_ARRAY(size_t, newWords);
 
   BitMap bb_bits(new_bb_hdr_bits, new_method_size);
   bb_bits.clear();
--- openjdk/hotspot/src/share/vm/oops/generateOopMap.hpp
+++ openjdk/hotspot/src/share/vm/oops/generateOopMap.hpp
@@ -341,7 +341,7 @@
   BasicBlock *    _basic_blocks;             // Array of basicblock info
   int             _gc_points;
   int             _bb_count;
-  uintptr_t *     _bb_hdr_bits;
+  size_t *        _bb_hdr_bits;
 
   // Basicblocks methods
   void          initialize_bb               ();
--- openjdk/hotspot/src/share/vm/compiler/methodLiveness.cpp
+++ openjdk/hotspot/src/share/vm/compiler/methodLiveness.cpp
@@ -566,15 +566,15 @@
 
 
 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
-         _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
+         _gen((size_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
                          analyzer->bit_map_size_bits()),
-         _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
+         _kill((size_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
                          analyzer->bit_map_size_bits()),
-         _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
+         _entry((size_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
                          analyzer->bit_map_size_bits()),
-         _normal_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
+         _normal_exit((size_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
                          analyzer->bit_map_size_bits()),
-         _exception_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
+         _exception_exit((size_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
                          analyzer->bit_map_size_bits()),
          _last_bci(-1) {
   _analyzer = analyzer;
@@ -991,7 +991,7 @@
 }
 
 MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) {
-  MethodLivenessResult answer(NEW_RESOURCE_ARRAY(uintptr_t, _analyzer->bit_map_size_words()),
+  MethodLivenessResult answer(NEW_RESOURCE_ARRAY(size_t, _analyzer->bit_map_size_words()),
                 _analyzer->bit_map_size_bits());
   answer.set_is_valid();
 
--- /usr/src/packages/BUILD/icedtea6-1.2/openjdk/hotspot/src/share/vm/compiler/methodLiveness.hpp
+++ /usr/src/packages/BUILD/icedtea6-1.2/openjdk/hotspot/src/share/vm/compiler/methodLiveness.hpp
@@ -29,7 +29,7 @@
   bool _is_valid;
 
  public:
-  MethodLivenessResult(uintptr_t* map, idx_t size_in_bits)
+  MethodLivenessResult(size_t* map, idx_t size_in_bits)
     : BitMap(map, size_in_bits)
     , _is_valid(false)
   {}
/usr/bin/gcc  -O3    -fno-strict-aliasing -fPIC -W -Wall  -Wno-unused -Wno-parentheses -m31 -g   -Ds390 -DARCH='"s390"' -DLINUX
 -DRELEASE='"1.6.0"' -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT -I. -I/usr/src/packages/BUILD/icedtea6-1.2/openjdk/contro
l/build/linux-s390/tmp/java/hpi/native_threads/CClassHeaders -I../../../../src/solaris/javavm/export -I../../../../src/share/ja
vavm/export -I../../../../src/share/javavm/include -I../../../../src/solaris/javavm/include -I../../../../src/solaris/hpi/nativ
e_threads/include -I../../../../src/solaris/hpi/include -I../../../../src/solaris/hpi/export -I../../../../src/share/hpi/includ
e -I../../../../src/share/hpi/export -D_REENTRANT -DNATIVE -DUSE_PTHREADS -DMOOT_PRIORITIES -DNO_INTERRUPTIBLE_IO    -c -o /usr
/src/packages/BUILD/icedtea6-1.2/openjdk/control/build/linux-s390/tmp/java/hpi/native_threads/obj/linker_md.o  ../../../../src/
solaris/hpi/src/linker_md.c
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c:384: error: conflicting types for ‘sysRecv’
../../../../src/share/hpi/include/hpi_impl.h:153: error: previous declaration of ‘sysRecv’ was here
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c:389: error: conflicting types for ‘sysSend’
../../../../src/share/hpi/include/hpi_impl.h:154: error: previous declaration of ‘sysSend’ was here
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c: In function ‘sysGetSockOpt’:
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c:567: warning: pointer targets in passing argument 5 of ‘getsockopt’
 differ in signedness
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c: At top level:
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c:599: error: conflicting types for ‘sysSendTo’
../../../../src/share/hpi/include/hpi_impl.h:149: error: previous declaration of ‘sysSendTo’ was here
../../../../src/solaris/hpi/native_threads/src/sys_api_td.c:605: error: conflicting types for ‘sysRecvFrom’
../../../../src/share/hpi/include/hpi_impl.h:151: error: previous declaration of ‘sysRecvFrom’ was here
make[6]: *** [/usr/src/packages/BUILD/icedtea6-1.2/openjdk/control/build/linux-s390/tmp/java/hpi/native_threads/obj/sys_api_td.
o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[6]: Leaving directory `/usr/src/packages/BUILD/icedtea6-1.2/openjdk/jdk/make/java/hpi/native'
make[5]: *** [library_parallel_compile] Error 2
make[5]: Leaving directory `/usr/src/packages/BUILD/icedtea6-1.2/openjdk/jdk/make/java/hpi/native'

Declaring things which return sizes does not make sense to define conditionally as int / size_t,
because on non-64bit, size_t is just an int anyway.

--- openjdk/jdk/src/share/hpi/include/hpi_impl.h	2008/04/22 15:10:11	1.1
+++ openjdk/jdk/src/share/hpi/include/hpi_impl.h	2008/04/22 16:00:54
@@ -138,21 +138,12 @@
 int sysBind(int fd, struct sockaddr *him, int len);
 int sysAccept(int fd, struct sockaddr *him, int *len);
 int sysGetSockName(int fd, struct sockaddr *him, int *len);
-#ifdef _LP64
 ssize_t sysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to,
               int tolen);
 ssize_t sysRecvFrom(int fd, char *buf, int nbytes, int flags,
                 struct sockaddr *from, int *fromlen);
 ssize_t sysRecv(int fd, char *buf, int nBytes, int flags);
 ssize_t sysSend(int fd, char *buf, int nBytes, int flags);
-#else
-int sysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to,
-              int tolen);
-int sysRecvFrom(int fd, char *buf, int nbytes, int flags,
-                struct sockaddr *from, int *fromlen);
-int sysRecv(int fd, char *buf, int nBytes, int flags);
-int sysSend(int fd, char *buf, int nBytes, int flags);
-#endif
 int sysListen(int fd, int count);
 int sysTimeout(int fd, long timeout);
 int sysGetHostName(char* name, int namelen);
openSUSE Build Service is sponsored by