Skip to content

Commit

Permalink
Support building in cygwin.
Browse files Browse the repository at this point in the history
Revised the compiler platform macros. Building goes like
$ AMDAPPSDKROOT= CPPFLAGS=-I/usr/include/ncurses ./configure
  • Loading branch information
markuspeloquin committed Feb 8, 2014
1 parent 4ce8a3e commit bf8e37c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 43 deletions.
30 changes: 15 additions & 15 deletions adl.c
Expand Up @@ -9,32 +9,32 @@

#include "config.h"

#if defined(HAVE_ADL) && (defined(__linux) || defined (WIN32))
#if defined(HAVE_ADL) && (defined(__unix__) || defined (WIN32))

#include <stdio.h>
#include <string.h>
#include <math.h>

#ifdef HAVE_CURSES
#include <curses.h>
# include <curses.h>
#endif

#include "miner.h"
#include "ADL_SDK/adl_sdk.h"
#include "compat.h"

#if defined (__linux)
#include <dlfcn.h>
#include <stdlib.h>
#include <unistd.h>
#if defined (__unix__)
# include <dlfcn.h>
# include <stdlib.h>
# include <unistd.h>
#else /* WIN32 */
#include <windows.h>
#include <tchar.h>
# include <windows.h>
# include <tchar.h>
#endif
#include "adl_functions.h"

#ifndef HAVE_CURSES
#define wlogprint(...) applog(LOG_WARNING, __VA_ARGS__)
# define wlogprint(...) applog(LOG_WARNING, __VA_ARGS__)
#endif

bool adl_active;
Expand Down Expand Up @@ -69,7 +69,7 @@ static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
}
}

#if defined (LINUX)
#if defined (UNIX)
// equivalent functions in linux
static void *GetProcAddress(void *pLibrary, const char *name)
{
Expand Down Expand Up @@ -114,7 +114,7 @@ static ADL_OVERDRIVE6_FANSPEED_SET ADL_Overdrive6_FanSpeed_Set;
static ADL_OVERDRIVE6_STATE_SET ADL_Overdrive6_State_Set;
static ADL_OVERDRIVE6_POWERCONTROL_SET ADL_Overdrive6_PowerControl_Set;

#if defined (LINUX)
#if defined (UNIX)
static void *hDLL; // Handle to .so library
#else
HINSTANCE hDLL; // Handle to DLL
Expand Down Expand Up @@ -266,7 +266,7 @@ static bool prepare_adl(void)
{
int result;

#if defined (LINUX)
#if defined (UNIX)
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
#else
hDLL = LoadLibrary("atiadlxx.dll");
Expand Down Expand Up @@ -397,7 +397,7 @@ void init_adl(int nDevs)
"strUDID:%s "
"iBusNumber:%d "
"iDeviceNumber:%d "
#if defined(__linux)
#if defined(__linux__)
"iDrvIndex:%d "
#endif
"iFunctionNumber:%d "
Expand All @@ -409,7 +409,7 @@ void init_adl(int nDevs)
lpInfo[i].strUDID,
lpInfo[i].iBusNumber,
lpInfo[i].iDeviceNumber,
#if defined(__linux)
#if defined(__linux__)
lpInfo[i].iDrvIndex,
#endif
lpInfo[i].iFunctionNumber,
Expand Down Expand Up @@ -1584,7 +1584,7 @@ static void free_adl(void)
{
ADL_Main_Memory_Free ((void **)&lpInfo);
ADL_Main_Control_Destroy ();
#if defined (LINUX)
#if defined (UNIX)
dlclose(hDLL);
#else
FreeLibrary(hDLL);
Expand Down
14 changes: 7 additions & 7 deletions adl_functions.h
Expand Up @@ -29,13 +29,13 @@
// AMD ADL function types from Version 3.0
// ------------------------------------------------------------------------------------------------------------

#if defined (linux)
#include <dlfcn.h> //dyopen, dlsym, dlclose
#include <stdlib.h>
#include <string.h> //memeset
#if defined (__unix__)
# include <dlfcn.h> //dyopen, dlsym, dlclose
# include <stdlib.h>
# include <string.h> //memeset
#else
#include <windows.h>
#include <tchar.h>
# include <windows.h>
# include <tchar.h>
#endif

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

// ------------------------------------------------------------------------------------------------------------

#ifdef LINUX
#ifdef __linux__
// ADL Linux
typedef int ( *ADL_ADAPTER_MEMORYINFO_GET ) (int iAdapterIndex, ADLMemoryInfo *lpMemoryInfo);
typedef int ( *ADL_CONTROLLER_COLOR_SET ) (int iAdapterIndex, int iControllerIndex, ADLGamma adlGamma);
Expand Down
16 changes: 6 additions & 10 deletions api.c
Expand Up @@ -152,23 +152,19 @@ static const char *SCRYPTSTR = "scrypt";
static const char *DEVICECODE = "GPU ";

static const char *OSINFO =
#if defined(__linux)
#if defined(__linux__)
"Linux";
#else
#if defined(__APPLE__)
#elif defined(__APPLE__)
"Apple";
#else
#if defined (WIN32)
#elif defined(WIN32)
"Windows";
#else
#if defined(unix)
#elif defined(__CYGWIN__)
"Cygwin";
#elif defined(__unix__)
"Unix";
#else
"Unknown";
#endif
#endif
#endif
#endif

#define _DEVS "DEVS"
#define _POOLS "POOLS"
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Expand Up @@ -297,10 +297,10 @@ AM_CONDITIONAL(USE_GIT_VERSION, [test x$usegitver = xyes])
#check execv signature
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <process.h>
int execv(const char*, const char*const*);
int execv(const char*, char *const*);
])],
AC_DEFINE([EXECV_2ND_ARG_TYPE], [const char* const*], [int execv(const char*, const char*const*);]),
AC_DEFINE([EXECV_2ND_ARG_TYPE], [char* const*], [int execv(const char*, char*const*);]))
AC_DEFINE([EXECV_2ND_ARG_TYPE], [char* const*], [int execv(const char*, char*const*);]),
AC_DEFINE([EXECV_2ND_ARG_TYPE], [const char* const*], [int execv(const char*, const char*const*);]))

dnl CCAN wants to know a lot of vars.
# All the configuration checks. Regrettably, the __attribute__ checks will
Expand Down
9 changes: 5 additions & 4 deletions miner.h
Expand Up @@ -84,10 +84,11 @@ static inline int fsync (int fd)
#endif
#endif /* __MINGW32__ */

#if defined (__linux)
#ifndef LINUX
#define LINUX
#endif
#if defined (__unix__) && !defined(UNIX)
# define UNIX
#endif
#if defined (__linux__) && !defined(LINUX)
# define LINUX
#endif

#ifdef WIN32
Expand Down
9 changes: 5 additions & 4 deletions util.c
Expand Up @@ -25,7 +25,7 @@
#include <sys/types.h>
#ifndef WIN32
#include <fcntl.h>
# ifdef __linux
# ifdef __linux__
# include <sys/prctl.h>
# endif
# include <sys/socket.h>
Expand Down Expand Up @@ -63,15 +63,16 @@ static void keep_sockalive(SOCKETTYPE fd)
#endif

setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const void *)&tcp_one, sizeof(tcp_one));
#ifndef __linux__
if (!opt_delaynet)
#ifndef __linux
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
#else /* __linux */
#else /* __linux__ */
if (!opt_delaynet)
setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one));
setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle));
setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl));
#endif /* __linux */
#endif /* __linux__ */

#ifdef __APPLE_CC__
setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &tcp_keepintvl, sizeof(tcp_keepintvl));
Expand Down

0 comments on commit bf8e37c

Please sign in to comment.