aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-12-24 18:41:05 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-12-24 18:41:05 +0000
commit410644c41a1b10798a0fe442c66f9bf582ecf067 (patch)
tree7562e7cd285a7a06e30ffabe52c2cf473a57ab9c /gcc
parent5750872c618185a2f1161d24510ad2be8669338a (diff)
downloadgcc-410644c41a1b10798a0fe442c66f9bf582ecf067.zip
gcc-410644c41a1b10798a0fe442c66f9bf582ecf067.tar.gz
gcc-410644c41a1b10798a0fe442c66f9bf582ecf067.tar.bz2
In libobjc/: 2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/: 2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com> * objc/runtime.h (class_addIvar): Updated documentation. The alignment is actually the log_2 of the alignment in bytes. * ivars.c (class_addIvar): Corresponding change to the implementation. In gcc/testsuite/: 2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/gnu-api-2-class.m: Updated test to pass log_2 of the alignment to class_addIvar, instead of the alignment itself. * obj-c++.dg/gnu-api-2-class.mm: Same change. From-SVN: r168230
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm26
-rw-r--r--gcc/testsuite/objc.dg/gnu-api-2-class.m26
3 files changed, 50 insertions, 8 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0140ced..2e68afa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
+ * objc.dg/gnu-api-2-class.m: Updated test to pass log_2 of the
+ alignment to class_addIvar, instead of the alignment itself.
+ * obj-c++.dg/gnu-api-2-class.mm: Same change.
+
+2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
+
* objc.dg/gnu-api-2-sel.m: Updated for renaming of sel_getType to
sel_getTypeEncoding. Test that sel_getTypeEncoding returns NULL
when called with a NULL argument. Added test for
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
index b86396f..18c3393 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
@@ -62,6 +62,24 @@
- (id) mySelf;
@end
+/* Hack to calculate the log2 of a byte alignment. */
+unsigned char
+log_2_of (unsigned int x)
+{
+ unsigned char result = 0;
+
+ /* We count how many times we need to divide by 2 before we reach 1.
+ This algorithm is good enough for the small numbers (such as 8,
+ 16 or 64) that we have to deal with. */
+ while (x > 1)
+ {
+ x = x / 2;
+ result++;
+ }
+
+ return result;
+}
+
int main ()
{
/* Functions are tested in alphabetical order. */
@@ -74,15 +92,15 @@ int main ()
abort ();
if (! class_addIvar (new_class, "variable2_ivar", sizeof (id),
- __alignof__ (id), @encode (id)))
+ log_2_of (__alignof__ (id)), @encode (id)))
abort ();
if (! class_addIvar (new_class, "variable3_ivar", sizeof (unsigned char),
- __alignof__ (unsigned char), @encode (unsigned char)))
+ log_2_of (__alignof__ (unsigned char)), @encode (unsigned char)))
abort ();
if (! class_addIvar (new_class, "variable4_ivar", sizeof (unsigned long),
- __alignof__ (unsigned long), @encode (unsigned long)))
+ log_2_of (__alignof__ (unsigned long)), @encode (unsigned long)))
abort ();
objc_registerClassPair (new_class);
@@ -135,7 +153,7 @@ int main ()
abort ();
if (! class_addIvar (new_class, "variable_ivar", sizeof (id),
- __alignof__ (id), @encode (id)))
+ log_2_of (__alignof__ (id)), @encode (id)))
abort ();
if (! class_addMethod (new_class, @selector (setVariable:), method_getImplementation (method1),
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class.m b/gcc/testsuite/objc.dg/gnu-api-2-class.m
index ff04259..3302fcc 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-class.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-class.m
@@ -62,6 +62,24 @@
- (id) mySelf;
@end
+/* Hack to calculate the log2 of a byte alignment. */
+unsigned char
+log_2_of (unsigned int x)
+{
+ unsigned char result = 0;
+
+ /* We count how many times we need to divide by 2 before we reach 1.
+ This algorithm is good enough for the small numbers (such as 8,
+ 16 or 64) that we have to deal with. */
+ while (x > 1)
+ {
+ x = x / 2;
+ result++;
+ }
+
+ return result;
+}
+
int main(int argc, void **args)
{
/* Functions are tested in alphabetical order. */
@@ -74,15 +92,15 @@ int main(int argc, void **args)
abort ();
if (! class_addIvar (new_class, "variable2_ivar", sizeof (id),
- __alignof__ (id), @encode (id)))
+ log_2_of (__alignof__ (id)), @encode (id)))
abort ();
if (! class_addIvar (new_class, "variable3_ivar", sizeof (unsigned char),
- __alignof__ (unsigned char), @encode (unsigned char)))
+ log_2_of (__alignof__ (unsigned char)), @encode (unsigned char)))
abort ();
if (! class_addIvar (new_class, "variable4_ivar", sizeof (unsigned long),
- __alignof__ (unsigned long), @encode (unsigned long)))
+ log_2_of (__alignof__ (unsigned long)), @encode (unsigned long)))
abort ();
objc_registerClassPair (new_class);
@@ -135,7 +153,7 @@ int main(int argc, void **args)
abort ();
if (! class_addIvar (new_class, "variable_ivar", sizeof (id),
- __alignof__ (id), @encode (id)))
+ log_2_of (__alignof__ (id)), @encode (id)))
abort ();
if (! class_addMethod (new_class, @selector (setVariable:), method_getImplementation (method1),