Changeset 10946


Ignore:
Timestamp:
Oct 3, 2008, 2:29:38 PM (11 years ago)
Author:
gb
Message:

Some math library functions may be statically linked; if we can't
find a symbol's address via dynamic shared library lookup, look
in a table that maps math function names to their addresses.

File:
1 edited

Legend:

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

    r10917 r10946  
    2727#undef __argv
    2828#include <stdio.h>
    29 
     29#include <math.h>
    3030
    3131#ifndef WIN_32
     
    457457}
    458458
     459typedef struct {
     460  char *name;
     461  void *addr;
     462} math_fn_entry;
     463
     464
     465math_fn_entry math_fn_entries [] = {
     466  {"acos",acos},
     467  {"acosf",acosf},
     468  {"acosh",acosh},
     469  {"acoshf",acoshf},
     470  {"asin",asin},
     471  {"asinf",asinf},
     472  {"asinh",asinh},
     473  {"asinhf",asinhf},
     474  {"atan",atan},
     475  {"atan2",atan2},
     476  {"atan2f",atan2f},
     477  {"atanf",atanf},
     478  {"atanh",atanh},
     479  {"atanhf",atanhf},
     480  {"cos",cos},
     481  {"cosf",cosf},
     482  {"cosh",cosh},
     483  {"coshf",coshf},
     484  {"exp",exp},
     485  {"expf",expf},
     486  {"log",log},
     487  {"logf",logf},
     488  {"pow",pow},
     489  {"powf",powf},
     490  {"sin",sin},
     491  {"sinf",sinf},
     492  {"sinh",sinh},
     493  {"sinhf",sinhf},
     494  {"tan",tan},
     495  {"tanf",tanf},
     496  {"tanh",tanh},
     497  {"tanhf",tanhf},
     498  {NULL, 0}};
     499
     500void *
     501lookup_math_fn(char *name)
     502{
     503  math_fn_entry *p = math_fn_entries;
     504  char *entry_name;
     505 
     506  while ((entry_name = p->name) != NULL) {
     507    if (!strcmp(name, entry_name)) {
     508      return p->addr;
     509    }
     510    p++;
     511  }
     512  return NULL;
     513}
    459514
    460515HMODULE *modules = NULL;
     
    465520windows_find_symbol(void *handle, char *name)
    466521{
     522  void *addr;
     523
    467524  if ((handle == ((void *)-2L)) ||
    468525      (handle == ((void *)-1L))) {
     
    470527  }
    471528  if (handle != NULL) {
    472     return GetProcAddress(handle, name);
     529    addr = GetProcAddress(handle, name);
    473530  } else {
    474531    DWORD cbneeded,  have, i;
     
    491548
    492549    for (i = 0; i < have; i++) {
    493       void *addr = GetProcAddress(modules[i],name);
     550      addr = GetProcAddress(modules[i],name);
    494551
    495552      if (addr) {
    496         ReleaseMutex(find_symbol_lock);
    497         return addr;
     553        break;
    498554      }
    499555    }
    500556    ReleaseMutex(find_symbol_lock);
    501     return NULL;
     557    if (addr) {
     558      return addr;
     559    }
     560    return lookup_math_fn(name);
    502561  }
    503562}
Note: See TracChangeset for help on using the changeset viewer.