Back to index

glibc  2.9
Defines | Functions
glrefmain.c File Reference
#include <dlfcn.h>
#include <error.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "../test-skeleton.c"

Go to the source code of this file.


#define TEST_FUNCTION   do_test ()


static void * load (const char *name)
int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 37 of file glrefmain.c.

Function Documentation

static int do_test ( void  )

Definition at line 41 of file glrefmain.c.

  void *d1;
  void *d2;
  int (*f) (void);

  d1 = load ("");
  d2 = load ("");

  f = dlsym (d2, "ref2");
  if (f == NULL)
    error (EXIT_FAILURE, errno, "cannot get pointer to `%s'", "ref2");

  if (f () != 42)
    error (EXIT_FAILURE, 0, "wrong result from `%s'", "ref2");

  puts ("Correct result in first call");
  fflush (stdout);

  /* Now unload the first file.  */
  dlclose (d1);

  puts ("About to call the second time");
  fflush (stdout);

  /* Try calling the function again.  */
  if (f () != 42)
    error (EXIT_FAILURE, 0, "wrong result from `%s' (second call)", "ref2");

  puts ("Second call succeeded!");
  fflush (stdout);

  dlclose (d2);

  puts ("glreflib2 also closed");
  fflush (stdout);

  return 0;
static void* load ( const char *  name) [static]

Definition at line 28 of file glrefmain.c.

  void *d = dlopen (name, RTLD_LAZY | RTLD_GLOBAL);
  if (d == NULL)
    error (EXIT_FAILURE, errno, "cannot load `%s'", name);
  return d;

Here is the call graph for this function:

Here is the caller graph for this function: