hid/gtk (GL): I think the polygon renderer works in mask mode now
[geda-pcb/pcjc2.git] / src / compat.c
blob24e6625c064840b7844598ccc3be7e241b75d380
1 /*!
2 * \file src/compat.c
4 * \brief .
6 * <hr>
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 2004, 2006 Dan McMahill
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
33 #include <math.h>
34 #include "compat.h"
35 #include "global.h"
37 #ifdef HAVE_LIBDMALLOC
38 #include <dmalloc.h>
39 #endif
41 #ifndef HAVE_EXPF
42 float
43 expf (float x)
45 return (float) exp ((double) x);
47 #endif
49 #ifndef HAVE_LOGF
50 float
51 logf (float x)
53 return (float) log ((double) x);
55 #endif
57 #ifndef HAVE_RANDOM
58 long
59 random (void)
61 return (long) rand ();
63 #endif
65 #if !defined(HAVE_DLFCN_H) && defined(WIN32)
66 #include <windows.h>
68 void *
69 dlopen (const char * f, int ATTRIBUTE_UNUSED flag)
71 return LoadLibrary (f);
74 void
75 dlclose (void * h)
77 FreeLibrary ((HINSTANCE) h);
80 char *
81 dlerror ()
83 static LPVOID lpMsgBuf = NULL;
84 DWORD dw;
86 /* free the error message buffer */
87 if (lpMsgBuf)
88 LocalFree (lpMsgBuf);
90 /* get the error code */
91 dw = GetLastError();
93 /* get the corresponding error message */
94 FormatMessage (
95 FORMAT_MESSAGE_ALLOCATE_BUFFER |
96 FORMAT_MESSAGE_FROM_SYSTEM |
97 FORMAT_MESSAGE_IGNORE_INSERTS,
98 NULL,
99 dw,
100 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
101 (LPTSTR) &lpMsgBuf,
102 0, NULL);
104 return (char *) lpMsgBuf;
107 void *
108 dlsym (void *handle, const char *symbol)
110 return (void *) GetProcAddress((HMODULE) handle, symbol);
114 #endif