[Sablevm-developer] Fully automatic configuration (for Linux at least) - first try
Brought to you by:
egagnon
From: Grzegorz P. <gr...@se...> - 2002-10-12 22:47:21
|
Hi! Below is my patch for having fully automatic configuration on Linux (and probably other GNU-based) systems. I don't think it's 100% suitable for new release. I'd like to hear your comments on this. But IMO it's the right direction. I compiled the version for i386 and it worked. Do you have any "cons" why I should _not_ upload such modified version to Debian (to let it be tested on autobuilders for all 12 architectures and so on) ? Any comments? GBP PS: I removed some #if (defined (__GNUC__)) - I am not against having such #ifs in future, when we support sth. more than __GNUC__, but now - it's only bloat IMHO. I tried to keep the number if #ifs as low as possible. In fact - there are some #if (defined __i386__) or __alpha__ that could be removed too, but if we'd like to support systems w/o asm/system.h in future - it may be good to keep it as it's now. (almost) Probably first non-Linux port (besides *BSD family) can be MS Windows, so keeping at least i386 and ia64 seems resonable. PSS: My approach with testing this code would be to just to upload it to unstable and let the autobuilders do the rest. Then uplaod fixed version and so on. After second try we should have all basic problems solved. Then I could request testing on different arches at debian-java, or maybe better - installation of the packages on all the machines by deb...@de.... --- ./sablevm-1.0.4/configure.ac 2002-08-24 17:48:32.000000000 +0200 +++ ./sablevm-1.0.4-fullauto/configure.ac 2002-10-12 23:53:54.000000000 +0200 @@ -165,6 +165,10 @@ fi fi +dnl By GBP + +AC_CHECK_DECLS(cmpxchg,,,[#include <asm/system.h>] ) + +dnl By GBP - dnl -Wid-clash-LEN -Wlarger-than-LEN -Wredundant-decls -Wconversion -Wcast-qual dnl -Wmissing-noreturn -Wtraditional -Waggregate-return -ansi -pedantic -Wunreachable-code @@ -175,4 +179,147 @@ src/libsablevm/include/Makefile src/sablevm/Makefile]) +dnl Automagically check sizes of certain types +AC_CHECK_SIZEOF(void*) +AC_CHECK_SIZEOF(unsigned char) +AC_CHECK_SIZEOF(signed char) +AC_CHECK_SIZEOF(unsigned short) +AC_CHECK_SIZEOF(signed short) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(signed int) +AC_CHECK_SIZEOF(unsigned long long) +AC_CHECK_SIZEOF(signed long long) +AC_CHECK_SIZEOF(float) +AC_CHECK_SIZEOF(double) + +if test "$ac_cv_sizeof_unsigned_char" -eq 1; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_U8, unsigned char, "Autodetected 1byte/8bit unsigned int") + if test "$ac_cv_sizeof_unsigned_char" -eq "$ac_cv_sizeof_voidp"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD, unsigned char, "Autodetected unsinged int of void* size") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_SIZE, 1) + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_BIT_COUNT, 8) + fi +else + AC_MSG_ERROR("Unable to find 1byte/8bit unsigned int for this architecture") +fi + +if test "$ac_cv_sizeof_signed_char" -eq 1; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_S8, signed char, "Autodetected 1byte/8bit signed int") +else + AC_MSG_ERROR("Unable to find 1byte/8bit signed int for this architecture") +fi + +if test "$ac_cv_sizeof_unsigned_short" -eq 2; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_U16, unsigned short, "Autodetected 1byte/16bit unsigned int") + if test "$ac_cv_sizeof_unsigned_short" -eq "$ac_cv_sizeof_voidp"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD, unsigned int, "Autodetected unsinged int of void* size") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_SIZE, 2, "sizeof(void*)") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_BIT_COUNT, 16, "sizeof(void*) in bits") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT, AUTO_SVMT_WORD_SIZE, "alignment for this processor") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT_POWER, 1, "alignment for this processor expressed in power of 2") + fi +else + AC_MSG_ERROR("Unable to find 2byte/16bit unsigned int for this architecture") +fi + +if test "$ac_cv_sizeof_signed_short" -eq 2; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_S16, signed short, "Autodetected 2byte/16bit signed int") +else + AC_MSG_ERROR("Unable to find 2byte/16bit signed int for this architecture") +fi + +if test "$ac_cv_sizeof_unsigned_int" -eq 4; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_U32, unsigned int, "Autodetected 4byte/32bit unsigned int") + if test "$ac_cv_sizeof_unsigned_int" -eq "$ac_cv_sizeof_voidp"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD, unsigned int, "Autodetected unsinged int of void* size") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_SIZE, 4, "sizeof(void*)") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_BIT_COUNT, 32, "sizeof(void*) in bits") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT, AUTO_SVMT_WORD_SIZE, "alignment for this processor") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT_POWER, 2, "alignment for this processor expressed in power of 2") + fi +else + AC_MSG_ERROR("Unable to find 4byte/32bit unsigned int for this architecture") +fi + +if test "$ac_cv_sizeof_signed_int" -eq 4; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_S32, signed int, "Autodetected 4byte/32bit signed int") +else + AC_MSG_ERROR("Unable to find 4byte/32bit signed int for this architecture") +fi + +if test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_U64, unsigned long long, "Autodetected 8byte/64bit unsigned int") + if test "$ac_cv_sizeof_unsigned_long_long" -eq "$ac_cv_sizeof_voidp"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD, unsigned long long, "Autodetected unsinged int of void* size") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_SIZE, 8, "sizeof(void*)") + AC_DEFINE_UNQUOTED(AUTO_SVMT_WORD_BIT_COUNT, 64, "sizeof(void*) in bits") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT, AUTO_SVMT_WORD_SIZE, "alignment for this processor") + AC_DEFINE_UNQUOTED(AUTO_SVMT_ALIGNMENT_POWER, 3, "alignment for this processor expressed in power of 2") + fi +else + AC_MSG_ERROR("Unable to find 8byte/64bit unsigned int for this architecture") +fi + +if test "$ac_cv_sizeof_signed_long_long" -eq 8; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_S64, signed long long, "Autodetected 8byte/64bit signed int") +else + AC_MSG_ERROR("Unable to find 8byte/64bit signed int for this architecture") +fi + +if test "$ac_cv_sizeof_float" -eq "4"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_F32, float, "Autodetected 4byte/32bit float") +else + AC_MSG_ERROR("Unable to find 4byte/32bit float for this architecture") +fi + +if test "$ac_cv_sizeof_double" -eq "8"; then + AC_DEFINE_UNQUOTED(AUTO_SVMT_D64, double, "Autodetected 8byte/64bit double") +else + AC_MSG_ERROR("Unable to find 8byte/64bit double for this architecture") +fi + +dnl Check if we can use cmpxchg from asm/system.h + +dnl AC_CHECK_DECLS (cmpxchg,,,[#include <asm/system.h>]) +AC_CHECK_DECLS(cmpxchg,,,[#include <asm/system.h>] ) + +dnl Check if we can use getpagesize and get it's result +dnl sorry, this can't be crosscompiled +if test "$ac_cv_func_getpagesize" = "yes"; then + echo -n "getpagesize found, checking result... " >&5 + echo -n "getpagesize found, checking result... " >&6 + cat >conftest.$ac_ext <<_ACEOF +#include <unistd.h> +int main() { + int result; + result = getpagesize(); + printf("%i", result); + return 1; +} +_ACEOF + rm -f conftest.$ac_objext conftest$ac_exeext + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_result=`./conftest$ac_exeext` + echo "$ac_result" >&5 + echo "$ac_result" >&6 + AC_DEFINE_UNQUOTED(GETPAGESIZE_RESULT, $ac_result, "getpagesize result (0 if nonavail)") + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$as_ac_var=no" + AC_DEFINE_UNQUOTED(GETPAGESIZE_RESULT, 0, "getpagesize result (0 if nonavail)") + fi +else + AC_DEFINE_UNQUOTED(GETPAGESIZE_RESULT, 0, "getpagesize result (0 if nonavail)") +fi + AC_OUTPUT --- ./sablevm-1.0.4/src/libsablevm/include/jni_system_specific.h 2002-08-15 07:29:54.000000000 +0200 +++ ./sablevm-1.0.4-fullauto/src/libsablevm/include/jni_system_specific.h 2002-10-12 20:09:45.000000000 +0200 @@ -13,28 +13,21 @@ 8,16,32,64 = 8 bits, 16 bits, ... So, "u8" means an 8 bits unsigned integer. */ -/* alpha and i386 are identical here */ - -#if ((defined (__alpha__) || defined (__i386__)) && defined (__GNUC__)) - #define JNICALL #define JNIEXPORT -typedef unsigned char _svmt_u8; -typedef signed char _svmt_s8; -typedef unsigned short _svmt_u16; -typedef signed short _svmt_s16; -typedef unsigned int _svmt_u32; -typedef signed int _svmt_s32; -__extension__ typedef unsigned long long _svmt_u64; -__extension__ typedef signed long long _svmt_s64; -typedef float _svmt_f32; -typedef double _svmt_d64; - -#else +/* the AUTO_SVMT_* defines are detected at ./configure stage */ -#error "unknown system" +typedef AUTO_SVMT_U8 _svmt_u8; +typedef AUTO_SVMT_S8 _svmt_s8; +typedef AUTO_SVMT_U16 _svmt_u16; +typedef AUTO_SVMT_S16 _svmt_s16; +typedef AUTO_SVMT_U32 _svmt_u32; +typedef AUTO_SVMT_S32 _svmt_s32; +__extension__ typedef AUTO_SVMT_U64 _svmt_u64; +__extension__ typedef AUTO_SVMT_S64 _svmt_s64; +typedef AUTO_SVMT_F32 _svmt_f32; +typedef AUTO_SVMT_D64 _svmt_d64; -#endif #endif /* NOT SVM_JNI_SYSTEM_SPECIFIC_H */ --- ./sablevm-1.0.4/src/libsablevm/system.c 2002-08-19 07:16:06.000000000 +0200 +++ ./sablevm-1.0.4-fullauto/src/libsablevm/system.c 2002-10-13 00:26:45.000000000 +0200 @@ -5,8 +5,6 @@ * modification of SableVM. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#if ((defined (__alpha__) || defined (__i386__)) && defined (__GNUC__)) - /* ---------------------------------------------------------------------- _svmf_iflush @@ -29,7 +27,9 @@ #elif defined(__i386__) /* do nothing */ #else -#error + /* just do nothing by default, as we're on the safe side of threading kind by default + BTW: can we issue a #warning here somehow? + #error */ #endif } @@ -61,8 +61,12 @@ { /* Yes, some inline assembly source code... Unfortunaltely, this cannot be expressed in C. */ +#if HAVE_DECL_CMPXCHG +#include <asm/system.h> + int result; + result = (cmpxchg((pword), (old_value), (new_value)) == (old_value)); -#if defined (__i386__) +#elif defined (__i386__) /* On the ia32, cmpxchgl has a side effect. When swapping fails, the following variable contains the value that is currently in *pword (presumably different from old_value). */ @@ -77,9 +81,7 @@ :"r" (new_value), "m" (*pword), "a" (old_value) :"memory"); /* *INDENT-ON* */ -#endif - -#if (defined (__alpha__)) +#elif (defined (__alpha__)) register _svmt_word result, tmp; /* *INDENT-OFF* */ @@ -645,5 +647,3 @@ #endif } - -#endif /* (defined (__i386__) && defined (__GNUC__)) */ --- ./sablevm-1.0.4/src/libsablevm/system.h 2002-08-15 07:29:54.000000000 +0200 +++ ./sablevm-1.0.4-fullauto/src/libsablevm/system.h 2002-10-13 00:25:39.000000000 +0200 @@ -48,7 +48,7 @@ */ -#if ((defined (__alpha__) || defined (__i386__)) && defined (__GNUC__)) +#if (defined (__GNUC__)) /* "inline" is now an official keyword since the latest C standard (1999). So, it is a reasonable assuption to expect a target compiler to @@ -64,7 +64,18 @@ * I guess that on most architectures, an "unsigned int" is a "word". */ -#if defined (__i386) +#if ( GETPAGESIZE_RESULT && AUTO_SVMT_WORD_SIZE && AUTO_SVMT_WORD_BIT_COUNT \ + && AUTO_SVMT_ALIGNMENT && AUTO_SVMT_ALIGNMENT_POWER ) + +typedef AUTO_SVMT_WORD _svmt_word; +#define SVM_WORD_SIZE AUTO_SVMT_WORD_SIZE +#define SVM_WORD_BIT_COUNT AUTO_SVMT_WORD_BIT_COUNT + +#define SVM_ALIGNMENT AUTO_SVMT_ALIGNMENT +#define SVM_ALIGNMENT_POWER AUTO_SVMT_ALIGNMENT_POWER +#define SMV_PAGE_SIZE GETPAGESIZE_RESULT + +#elif defined (__i386__) typedef _svmt_u32 _svmt_word; |