Changeset 13375


Ignore:
Timestamp:
Jan 11, 2010, 7:33:29 PM (10 years ago)
Author:
rme
Message:

xFindSymbol, xGetSharedLibrary: delete some obsolete Darwin-specific
that has been #ifdef'd out for some time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r13352 r13375  
    20552055xGetSharedLibrary(char *path, int *resultType)
    20562056{
    2057 #if 0
    2058   NSObjectFileImageReturnCode code;
    2059   NSObjectFileImage              moduleImage;
    2060   NSModule                       module;
    2061   const struct mach_header *     header;
    2062   const char *                   error;
    2063   void *                         result;
    2064   /* not thread safe */
    2065   /*
    2066   static struct {
    2067     const struct mach_header  *header;
    2068     NSModule                  *module;
    2069     const char                *error;
    2070   } results;   
    2071   */
    2072   result = NULL;
    2073   error = NULL;
    2074 
    2075   /* first try to open this as a bundle */
    2076   code = NSCreateObjectFileImageFromFile(path,&moduleImage);
    2077   if (code != NSObjectFileImageSuccess &&
    2078       code != NSObjectFileImageInappropriateFile &&
    2079       code != NSObjectFileImageAccess)
    2080     {
    2081       /* compute error strings */
    2082       switch (code)
    2083         {
    2084         case NSObjectFileImageFailure:
    2085           error = "NSObjectFileImageFailure";
    2086           break;
    2087         case NSObjectFileImageArch:
    2088           error = "NSObjectFileImageArch";
    2089           break;
    2090         case NSObjectFileImageFormat:
    2091           error = "NSObjectFileImageFormat";
    2092           break;
    2093         case NSObjectFileImageAccess:
    2094           /* can't find the file */
    2095           error = "NSObjectFileImageAccess";
    2096           break;
    2097         default:
    2098           error = "unknown error";
    2099         }
    2100       *resultType = 0;
    2101       return (void *)error;
    2102     }
    2103   if (code == NSObjectFileImageInappropriateFile ||
    2104       code == NSObjectFileImageAccess ) {
    2105     /* the pathname might be a partial pathane (hence the access error)
    2106        or it might be something other than a bundle, if so perhaps
    2107        it is a .dylib so now try to open it as a .dylib */
    2108 
    2109     /* protect against redundant loads, Gary Byers noticed possible
    2110        heap corruption if this isn't done */
    2111     header = NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR |
    2112                         NSADDIMAGE_OPTION_WITH_SEARCHING |
    2113                         NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
    2114     if (!header)
    2115       header = NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR |
    2116                           NSADDIMAGE_OPTION_WITH_SEARCHING);
    2117     result = (void *)header;
    2118     *resultType = 1;
    2119   }
    2120   else if (code == NSObjectFileImageSuccess) {
    2121     /* we have a sucessful module image
    2122        try to link it, don't bind symbols privately */
    2123 
    2124     module = NSLinkModule(moduleImage, path,
    2125                           NSLINKMODULE_OPTION_RETURN_ON_ERROR | NSLINKMODULE_OPTION_BINDNOW);
    2126     NSDestroyObjectFileImage(moduleImage);     
    2127     result = (void *)module;
    2128     *resultType = 2;
    2129   }
    2130   if (!result)
    2131     {
    2132       /* compute error string */
    2133       NSLinkEditErrors ler;
    2134       int lerno;
    2135       const char* file;
    2136       NSLinkEditError(&ler,&lerno,&file,&error);
    2137       if (error) {
    2138         result = (void *)error;
    2139         *resultType = 0;
    2140       }
    2141     }
    2142   return result;
    2143 #else
    2144   const char *                   error;
    2145   void *                         result;
     2057  const char *error;
     2058  void *result;
    21462059
    21472060  result = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
     
    21542067  *resultType = 1;
    21552068  return result;
    2156 #endif
    21572069}
    21582070#endif
     
    23132225#endif
    23142226#ifdef DARWIN
    2315 #if 1
    23162227  void *result;
    23172228
     
    23242235  }
    23252236  return result;
    2326 #else
    2327   natural address = 0;
    2328 
    2329   if ((handle == NULL) ||
    2330       (handle == (void *)-1) ||
    2331       (handle == (void *)-2)){
    2332     if (NSIsSymbolNameDefined(name)) { /* Keep dyld_lookup from crashing */
    2333       _dyld_lookup_and_bind(name, (void *) &address, (void*) NULL);
    2334     }
    2335     return (void *)address;
    2336   }
    2337   Bug(NULL, "How did this happen ?");
    2338 #endif
    23392237#endif
    23402238#ifdef WINDOWS
Note: See TracChangeset for help on using the changeset viewer.