Skip to content

Commit bf8e37c

Browse files
Support building in cygwin.
Revised the compiler platform macros. Building goes like $ AMDAPPSDKROOT= CPPFLAGS=-I/usr/include/ncurses ./configure
1 parent 4ce8a3e commit bf8e37c

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

adl.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99

1010
#include "config.h"
1111

12-
#if defined(HAVE_ADL) && (defined(__linux) || defined (WIN32))
12+
#if defined(HAVE_ADL) && (defined(__unix__) || defined (WIN32))
1313

1414
#include <stdio.h>
1515
#include <string.h>
1616
#include <math.h>
1717

1818
#ifdef HAVE_CURSES
19-
#include <curses.h>
19+
# include <curses.h>
2020
#endif
2121

2222
#include "miner.h"
2323
#include "ADL_SDK/adl_sdk.h"
2424
#include "compat.h"
2525

26-
#if defined (__linux)
27-
#include <dlfcn.h>
28-
#include <stdlib.h>
29-
#include <unistd.h>
26+
#if defined (__unix__)
27+
# include <dlfcn.h>
28+
# include <stdlib.h>
29+
# include <unistd.h>
3030
#else /* WIN32 */
31-
#include <windows.h>
32-
#include <tchar.h>
31+
# include <windows.h>
32+
# include <tchar.h>
3333
#endif
3434
#include "adl_functions.h"
3535

3636
#ifndef HAVE_CURSES
37-
#define wlogprint(...) applog(LOG_WARNING, __VA_ARGS__)
37+
# define wlogprint(...) applog(LOG_WARNING, __VA_ARGS__)
3838
#endif
3939

4040
bool adl_active;
@@ -69,7 +69,7 @@ static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
6969
}
7070
}
7171

72-
#if defined (LINUX)
72+
#if defined (UNIX)
7373
// equivalent functions in linux
7474
static void *GetProcAddress(void *pLibrary, const char *name)
7575
{
@@ -114,7 +114,7 @@ static ADL_OVERDRIVE6_FANSPEED_SET ADL_Overdrive6_FanSpeed_Set;
114114
static ADL_OVERDRIVE6_STATE_SET ADL_Overdrive6_State_Set;
115115
static ADL_OVERDRIVE6_POWERCONTROL_SET ADL_Overdrive6_PowerControl_Set;
116116

117-
#if defined (LINUX)
117+
#if defined (UNIX)
118118
static void *hDLL; // Handle to .so library
119119
#else
120120
HINSTANCE hDLL; // Handle to DLL
@@ -266,7 +266,7 @@ static bool prepare_adl(void)
266266
{
267267
int result;
268268

269-
#if defined (LINUX)
269+
#if defined (UNIX)
270270
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
271271
#else
272272
hDLL = LoadLibrary("atiadlxx.dll");
@@ -397,7 +397,7 @@ void init_adl(int nDevs)
397397
"strUDID:%s "
398398
"iBusNumber:%d "
399399
"iDeviceNumber:%d "
400-
#if defined(__linux)
400+
#if defined(__linux__)
401401
"iDrvIndex:%d "
402402
#endif
403403
"iFunctionNumber:%d "
@@ -409,7 +409,7 @@ void init_adl(int nDevs)
409409
lpInfo[i].strUDID,
410410
lpInfo[i].iBusNumber,
411411
lpInfo[i].iDeviceNumber,
412-
#if defined(__linux)
412+
#if defined(__linux__)
413413
lpInfo[i].iDrvIndex,
414414
#endif
415415
lpInfo[i].iFunctionNumber,
@@ -1584,7 +1584,7 @@ static void free_adl(void)
15841584
{
15851585
ADL_Main_Memory_Free ((void **)&lpInfo);
15861586
ADL_Main_Control_Destroy ();
1587-
#if defined (LINUX)
1587+
#if defined (UNIX)
15881588
dlclose(hDLL);
15891589
#else
15901590
FreeLibrary(hDLL);

adl_functions.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
// AMD ADL function types from Version 3.0
3030
// ------------------------------------------------------------------------------------------------------------
3131

32-
#if defined (linux)
33-
#include <dlfcn.h> //dyopen, dlsym, dlclose
34-
#include <stdlib.h>
35-
#include <string.h> //memeset
32+
#if defined (__unix__)
33+
# include <dlfcn.h> //dyopen, dlsym, dlclose
34+
# include <stdlib.h>
35+
# include <string.h> //memeset
3636
#else
37-
#include <windows.h>
38-
#include <tchar.h>
37+
# include <windows.h>
38+
# include <tchar.h>
3939
#endif
4040

4141
#include "ADL_SDK/adl_sdk.h"
@@ -267,7 +267,7 @@ typedef int ( *ADL_WORKSTATION_LOADBALANCING_CAPS ) (int iAdapterIndex, int *lpR
267267

268268
// ------------------------------------------------------------------------------------------------------------
269269

270-
#ifdef LINUX
270+
#ifdef __linux__
271271
// ADL Linux
272272
typedef int ( *ADL_ADAPTER_MEMORYINFO_GET ) (int iAdapterIndex, ADLMemoryInfo *lpMemoryInfo);
273273
typedef int ( *ADL_CONTROLLER_COLOR_SET ) (int iAdapterIndex, int iControllerIndex, ADLGamma adlGamma);

api.c

+6-10
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,19 @@ static const char *SCRYPTSTR = "scrypt";
152152
static const char *DEVICECODE = "GPU ";
153153

154154
static const char *OSINFO =
155-
#if defined(__linux)
155+
#if defined(__linux__)
156156
"Linux";
157-
#else
158-
#if defined(__APPLE__)
157+
#elif defined(__APPLE__)
159158
"Apple";
160-
#else
161-
#if defined (WIN32)
159+
#elif defined(WIN32)
162160
"Windows";
163-
#else
164-
#if defined(unix)
161+
#elif defined(__CYGWIN__)
162+
"Cygwin";
163+
#elif defined(__unix__)
165164
"Unix";
166165
#else
167166
"Unknown";
168167
#endif
169-
#endif
170-
#endif
171-
#endif
172168

173169
#define _DEVS "DEVS"
174170
#define _POOLS "POOLS"

configure.ac

+3-3
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ AM_CONDITIONAL(USE_GIT_VERSION, [test x$usegitver = xyes])
297297
#check execv signature
298298
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
299299
#include <process.h>
300-
int execv(const char*, const char*const*);
300+
int execv(const char*, char *const*);
301301
])],
302-
AC_DEFINE([EXECV_2ND_ARG_TYPE], [const char* const*], [int execv(const char*, const char*const*);]),
303-
AC_DEFINE([EXECV_2ND_ARG_TYPE], [char* const*], [int execv(const char*, char*const*);]))
302+
AC_DEFINE([EXECV_2ND_ARG_TYPE], [char* const*], [int execv(const char*, char*const*);]),
303+
AC_DEFINE([EXECV_2ND_ARG_TYPE], [const char* const*], [int execv(const char*, const char*const*);]))
304304

305305
dnl CCAN wants to know a lot of vars.
306306
# All the configuration checks. Regrettably, the __attribute__ checks will

miner.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ static inline int fsync (int fd)
8484
#endif
8585
#endif /* __MINGW32__ */
8686

87-
#if defined (__linux)
88-
#ifndef LINUX
89-
#define LINUX
90-
#endif
87+
#if defined (__unix__) && !defined(UNIX)
88+
# define UNIX
89+
#endif
90+
#if defined (__linux__) && !defined(LINUX)
91+
# define LINUX
9192
#endif
9293

9394
#ifdef WIN32

util.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <sys/types.h>
2626
#ifndef WIN32
2727
#include <fcntl.h>
28-
# ifdef __linux
28+
# ifdef __linux__
2929
# include <sys/prctl.h>
3030
# endif
3131
# include <sys/socket.h>
@@ -63,15 +63,16 @@ static void keep_sockalive(SOCKETTYPE fd)
6363
#endif
6464

6565
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const void *)&tcp_one, sizeof(tcp_one));
66+
#ifndef __linux__
6667
if (!opt_delaynet)
67-
#ifndef __linux
6868
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
69-
#else /* __linux */
69+
#else /* __linux__ */
70+
if (!opt_delaynet)
7071
setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
7172
setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one));
7273
setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle));
7374
setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl));
74-
#endif /* __linux */
75+
#endif /* __linux__ */
7576

7677
#ifdef __APPLE_CC__
7778
setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &tcp_keepintvl, sizeof(tcp_keepintvl));

0 commit comments

Comments
 (0)