Back to index

cell-binutils  2.17cvs20070401
main.c
Go to the documentation of this file.
00001 /* This is the main program for the shared library test.  */
00002 
00003 #include <stdio.h>
00004 
00005 int mainvar = 1;
00006 int overriddenvar = 2;
00007 extern int shlibvar1;
00008 
00009 extern int shlib_mainvar ();
00010 extern int shlib_overriddenvar ();
00011 extern int shlib_shlibvar1 ();
00012 extern int shlib_shlibvar2 ();
00013 extern int shlib_shlibcall ();
00014 extern int shlib_maincall ();
00015 extern int shlib_checkfunptr1 ();
00016 extern int shlib_checkfunptr2 ();
00017 extern int (*shlib_getfunptr1 ()) ();
00018 extern int (*shlib_getfunptr2 ()) ();
00019 extern int shlib_check ();
00020 extern int shlib_shlibcall2 ();
00021 
00022 /* This function is called by the shared library.  */
00023 
00024 int
00025 main_called ()
00026 {
00027   return 6;
00028 }
00029 
00030 /* This function overrides a function in the shared library.  */
00031 
00032 int
00033 shlib_overriddencall2 ()
00034 {
00035   return 8;
00036 }
00037 
00038 int
00039 main ()
00040 {
00041   int (*p) ();
00042 
00043   printf ("mainvar == %d\n", mainvar);
00044   printf ("overriddenvar == %d\n", overriddenvar);
00045   printf ("shlibvar1 == %d\n", shlibvar1);
00046 #ifndef XCOFF_TEST
00047   printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
00048   printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
00049 #endif
00050   printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
00051   printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
00052   printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
00053 #ifndef XCOFF_TEST
00054   printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ());
00055   printf ("shlib_maincall () == %d\n", shlib_maincall ());
00056 #endif
00057   printf ("main_called () == %d\n", main_called ());
00058 #ifndef SYMBOLIC_TEST
00059   printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
00060          shlib_checkfunptr1 (shlib_shlibvar1));
00061 #ifndef XCOFF_TEST
00062   printf ("shlib_checkfunptr2 (main_called) == %d\n",
00063          shlib_checkfunptr2 (main_called));
00064 #endif
00065   p = shlib_getfunptr1 ();
00066   printf ("shlib_getfunptr1 () ");
00067   if (p == shlib_shlibvar1)
00068     printf ("==");
00069   else
00070     printf ("!=");
00071   printf (" shlib_shlibvar1\n");
00072 #ifndef XCOFF_TEST
00073   p = shlib_getfunptr2 ();
00074   printf ("shlib_getfunptr2 () ");
00075   if (p == main_called)
00076     printf ("==");
00077   else
00078     printf ("!=");
00079   printf (" main_called\n");
00080 #endif
00081 #endif
00082   printf ("shlib_check () == %d\n", shlib_check ());
00083   return 0;
00084 }