hid/gtk: Clean up ghid_pan_fixup ()
[geda-pcb/pcjc2.git] / src / compat.c
blobe3acf2f0b6842b92c7df2034a519b28d96862539
1 /* $Id$ */
3 /*
4 * COPYRIGHT
6 * PCB, interactive printed circuit board design
7 * Copyright (C) 2004, 2006 Dan McMahill
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
29 #include <math.h>
30 #include "compat.h"
31 #include "global.h"
33 #ifdef HAVE_LIBDMALLOC
34 #include <dmalloc.h>
35 #endif
37 RCSID ("$Id$");
39 #ifndef HAVE_EXPF
40 float
41 expf (float x)
43 return (float) exp ((double) x);
45 #endif
47 #ifndef HAVE_LOGF
48 float
49 logf (float x)
51 return (float) log ((double) x);
53 #endif
55 #ifndef HAVE_RANDOM
56 long
57 random (void)
59 return (long) rand ();
61 #endif
63 #if !defined(HAVE_DLFCN_H) && defined(WIN32)
64 #include <windows.h>
66 void *
67 dlopen (const char * f, int ATTRIBUTE_UNUSED flag)
69 return LoadLibrary (f);
72 void
73 dlclose (void * h)
75 FreeLibrary ((HINSTANCE) h);
78 char *
79 dlerror ()
81 static LPVOID lpMsgBuf = NULL;
82 DWORD dw;
84 /* free the error message buffer */
85 if (lpMsgBuf)
86 LocalFree (lpMsgBuf);
88 /* get the error code */
89 dw = GetLastError();
91 /* get the corresponding error message */
92 FormatMessage (
93 FORMAT_MESSAGE_ALLOCATE_BUFFER |
94 FORMAT_MESSAGE_FROM_SYSTEM |
95 FORMAT_MESSAGE_IGNORE_INSERTS,
96 NULL,
97 dw,
98 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
99 (LPTSTR) &lpMsgBuf,
100 0, NULL);
102 return (char *) lpMsgBuf;
105 void *
106 dlsym (void *handle, const char *symbol)
108 return (void *) GetProcAddress((HMODULE) handle, symbol);
112 #endif