Fix check for object pointer depending on alignment requirement.

This commit is contained in:
rfm 2025-02-27 12:15:15 +00:00
parent 3a0bb73131
commit 956eb5b303
4 changed files with 59 additions and 11 deletions

View file

@ -9,6 +9,9 @@
/* The normal alignment of `gs_mutex_t', in bytes. */
#undef ALIGNOF_GS_MUTEX_T
/* The normal alignment of `objc_object', in bytes. */
#undef ALIGNOF_OBJC_OBJECT
/* The normal alignment of `pthread_cond_t', in bytes. */
#undef ALIGNOF_PTHREAD_COND_T

View file

@ -30,26 +30,21 @@ isPersistentObject(id obj)
return YES;
}
/* Disabled check for addresses not matching alignment rules below.
* The test is broken for the s390x (which is a Debiam supported machine)
* and shouldn't actually be needed anyway.
*/
#if 0
/* If the alignment of the object does not match that needed for a
* pointer (to the class of the object) then the object must be a
* special one of some sort and we assume it's persistent.
*/
#if GS_SIZEOF_VOIDP == 8
if ((intptr_t)obj & 15)
{
return YES;
}
#else
#if ALIGNOF_OBJC_OBJECT == 8
if ((intptr_t)obj & 7)
{
return YES;
}
#endif
#if ALIGNOF_OBJC_OBJECT == 4
if ((intptr_t)obj & 3)
{
return YES;
}
#endif
c = object_getClass(obj);

41
configure vendored
View file

@ -7382,6 +7382,47 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
#--------------------------------------------------------------------
# Check alignment of an object in memory
#--------------------------------------------------------------------
# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking alignment of objc_object" >&5
printf %s "checking alignment of objc_object... " >&6; }
if test ${ac_cv_alignof_objc_object+y}
then :
printf %s "(cached) " >&6
else $as_nop
if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_objc_object" "$ac_includes_default
typedef struct { void *isa; } objc_object;
typedef struct { char x; objc_object y; } ac__type_alignof_;"
then :
else $as_nop
if test "$ac_cv_type_objc_object" = yes; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute alignment of objc_object
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_alignof_objc_object=0
fi
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_objc_object" >&5
printf "%s\n" "$ac_cv_alignof_objc_object" >&6; }
printf "%s\n" "#define ALIGNOF_OBJC_OBJECT $ac_cv_alignof_objc_object" >>confdefs.h
if test $ac_cv_alignof_objc_object = 0 ; then
as_fn_error $? "Unable to find align of object (required)." "$LINENO" 5
fi
#--------------------------------------------------------------------
# Setup dynamic linking
#--------------------------------------------------------------------

View file

@ -1681,6 +1681,15 @@ AC_COMPILE_IFELSE(
AC_SUBST(BUGGY_PTR_LIMITS)
AC_LANG_POP(C)
#--------------------------------------------------------------------
# Check alignment of an object in memory
#--------------------------------------------------------------------
AC_CHECK_ALIGNOF(objc_object,[AC_INCLUDES_DEFAULT
typedef struct { void *isa; } objc_object;])
if test $ac_cv_alignof_objc_object = 0 ; then
AC_MSG_ERROR([Unable to find align of object (required).])
fi
#--------------------------------------------------------------------
# Setup dynamic linking
#--------------------------------------------------------------------