[PATCH] attribute "used"

Flavien Lebarbe <[email protected]> Fri, 13 May 2005 00:09:37 +0200
Newsgroups gmane.editors.qemacs.devel
Message-ID <[email protected]>
Hi,


I'm using qemacs on linux Fedora Core 3. Compiler is gcc 3.4.3.

Without the attached patch, qemacs compiles cleanly,  but  all  I
get is: "No suitable display found, exiting"

The reason is that the functions  defined  with  qe_module_init()
are never called. I found out I  need  to  add  "used"  attribute
here.

Pasting from the info of gcc 3.4.3 :
`used'
     This attribute, attached to a function, means that code must
     be emitted for the function even  if  it  appears  that  the
     function is not referenced. This  is  useful,  for  example,
     when the function is referenced only in inline assembly.

Given this, I'd say we need both "used" and "unused" !!!

Attached is a patch that implements this. I'm not sure if this is
the right fix or not. It  just  passes  the  "it  works  for  me"
test with gcc 3.4.3. It also compiles cleanly  with  egcs-2.91.66
(although I had to disable x11 support because of missing libs).


Flavien.

_______________________________________________
Qemacs-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemacs-devel
qemacs-attribute-used.patch (text/plain, 929 B)
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.19
diff -u -w -r1.19 qe.h
--- qe.h	11 May 2005 12:22:51 -0000	1.19
+++ qe.h	12 May 2005 21:39:47 -0000
@@ -627,9 +627,13 @@
 /* make sure that the keyword is not disabled by glibc (TINYC case) */
 #undef __attribute__ 
 
+#ifndef __attribute_used__
+#define __attribute_used__
+#endif
+
 /* same method as the linux kernel... */
-#define __init_call     __attribute__ ((unused,__section__ (".initcall.init")))
-#define __exit_call     __attribute__ ((unused,__section__ (".exitcall.exit")))
+#define __init_call     __attribute_used__ __attribute__ ((unused, __section__ (".initcall.init")))
+#define __exit_call     __attribute_used__ __attribute__ ((unused, __section__ (".exitcall.exit")))
 
 #define qe_module_init(fn) \
         static int (*__initcall_##fn)(void) __init_call = fn