Changeset f9dc520 in git


Ignore:
Timestamp:
May 19, 2011, 12:48:24 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b52fc4b2495505785981d640dcf7eb3e456778ef')
Children:
2e91854ee11f07858653eb6c3ebda2393a158a47
Parents:
8d1a1ab92a3fa4bf30daf110a860313ccf3ef58c
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-05-19 12:48:24+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:36:12+01:00
Message:
ADD: search for dynamic modules within the usual search pathes
ADD: minor improvements to dynamic module loading routines
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/templates/mod_raw.cc

    r8d1a1ab rf9dc520  
    2121#include <misc/auxiliary.h>
    2222
    23 // #include <kernel/mod2.h>
    24 // #include <Singular/static.h>
     23#include <omalloc/omalloc.h>
    2524
    2625#include <reporter/reporter.h>
     
    131130  if (bin_dir != NULL)
    132131  {
    133     char path_name[MAXPATHLEN];
    134     sprintf(path_name, "%s%s%s.%s", bin_dir, DIR_SEPP, binary_name,
    135             DL_TAIL);
    136     handle = dynl_open(path_name);
    137     if (handle == NULL && ! warn_handle)
    138     {
    139       Warn("Could not open dynamic library: %s", path_name);
     132    const int binary_name_so_length = 3 + strlen(DL_TAIL) + strlen(binary_name) + strlen(DIR_SEPP) + strlen(bin_dir);
     133    char* binary_name_so = (char *)omAlloc0( binary_name_so_length * sizeof(char) );
     134    snprintf(binary_name_so, binary_name_so_length, "%s%s%s.%s", bin_dir, DIR_SEPP, binary_name, DL_TAIL);
     135    handle = dynl_open(binary_name_so);
     136    omFreeSize((ADDRESS)binary_name_so, binary_name_so_length * sizeof(char) );
     137  }
     138
     139  if (handle == NULL )
     140  {
     141    const int binary_name_so_length = 3 + strlen(DL_TAIL) + strlen(binary_name);
     142    char* binary_name_so = (char *)omAlloc0( binary_name_so_length * sizeof(char) );
     143    snprintf(binary_name_so, binary_name_so_length, "%s.%s", binary_name, DL_TAIL);
     144
     145    char* pp = (char *)omAlloc0( MAXPATHLEN * sizeof(char) );
     146    lib_types type = type_of_LIB( binary_name_so, pp );
     147    omFreeSize((ADDRESS)binary_name_so, binary_name_so_length * sizeof(char) );
     148
     149    if( type == LT_ELF || type == LT_HPUX || type == LT_MACH_O )
     150      handle = dynl_open(pp);
     151
     152    omFreeSize((ADDRESS)pp, MAXPATHLEN * sizeof(char) );
     153  }
     154
     155  if (handle == NULL && ! warn_handle)
     156  {
     157      Warn("Could not find dynamic library: %s.%s", binary_name, DL_TAIL);
    140158      Warn("Error message from system: %s", dynl_error());
    141159      if (msg != NULL) Warn("%s", msg);
    142160      Warn("See the INSTALL section in the Singular manual for details.");
    143161      warn_handle = TRUE;
    144     }
    145   }
     162  }
     163
    146164  return  handle;
    147165}
Note: See TracChangeset for help on using the changeset viewer.