Default STEP export to board only
[geda-pcb/pcjc2/v2.git] / src / compat.c
blobd58887b0eee1e5ddb4856490d1ddf2736006bb32
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 #define WIN32_LEAN_AND_MEAN
67 #include <windows.h>
69 void *
70 dlopen (const char * f, int ATTRIBUTE_UNUSED flag)
72 return LoadLibrary (f);
75 void
76 dlclose (void * h)
78 FreeLibrary ((HINSTANCE) h);
81 char *
82 dlerror ()
84 static LPVOID lpMsgBuf = NULL;
85 DWORD dw;
87 /* free the error message buffer */
88 if (lpMsgBuf)
89 LocalFree (lpMsgBuf);
91 /* get the error code */
92 dw = GetLastError();
94 /* get the corresponding error message */
95 FormatMessage (
96 FORMAT_MESSAGE_ALLOCATE_BUFFER |
97 FORMAT_MESSAGE_FROM_SYSTEM |
98 FORMAT_MESSAGE_IGNORE_INSERTS,
99 NULL,
101 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
102 (LPTSTR) &lpMsgBuf,
103 0, NULL);
105 return (char *) lpMsgBuf;
108 void *
109 dlsym (void *handle, const char *symbol)
111 return (void *) GetProcAddress((HMODULE) handle, symbol);
115 #endif