pcb 4.1.1
An interactive printed circuit board layout editor.

compat.c

Go to the documentation of this file.
00001 
00029 #ifdef HAVE_CONFIG_H
00030 #include "config.h"
00031 #endif
00032 
00033 #include <math.h>
00034 #include "compat.h"
00035 #include "global.h"
00036 
00037 #ifdef HAVE_LIBDMALLOC
00038 #include <dmalloc.h>
00039 #endif
00040 
00041 #ifndef HAVE_EXPF
00042 float
00043 expf (float x)
00044 {
00045   return (float) exp ((double) x);
00046 }
00047 #endif
00048 
00049 #ifndef HAVE_LOGF
00050 float
00051 logf (float x)
00052 {
00053   return (float) log ((double) x);
00054 }
00055 #endif
00056 
00057 #ifndef HAVE_RANDOM
00058 long
00059 random (void)
00060 {
00061   return (long) rand ();
00062 }
00063 #endif
00064 
00065 #if !defined(HAVE_DLFCN_H) && defined(WIN32)
00066 #define WIN32_LEAN_AND_MEAN
00067 #include <windows.h>
00068 
00069 void *
00070 dlopen (const char * f, int ATTRIBUTE_UNUSED flag)
00071 {
00072   return LoadLibrary (f);
00073 }
00074 
00075 void
00076 dlclose (void * h)
00077 {
00078   FreeLibrary ((HINSTANCE) h);
00079 }
00080 
00081 char *
00082 dlerror ()
00083 {
00084   static LPVOID lpMsgBuf = NULL;
00085   DWORD dw;
00086 
00087   /* free the error message buffer */
00088   if (lpMsgBuf)
00089     LocalFree (lpMsgBuf);
00090 
00091   /* get the error code */
00092   dw = GetLastError();
00093 
00094   /* get the corresponding error message */
00095   FormatMessage (
00096                 FORMAT_MESSAGE_ALLOCATE_BUFFER |
00097                 FORMAT_MESSAGE_FROM_SYSTEM |
00098                 FORMAT_MESSAGE_IGNORE_INSERTS,
00099                 NULL,
00100                 dw,
00101                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00102                 (LPTSTR) &lpMsgBuf,
00103                 0, NULL);
00104 
00105   return (char *) lpMsgBuf;
00106 }
00107 
00108 void *
00109 dlsym (void *handle, const char *symbol)
00110 {
00111   return (void *) GetProcAddress((HMODULE) handle, symbol);
00112 }
00113 
00114 
00115 #endif
00116 
00117