bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] question on engine abstraction


From: Øystein Johansen
Subject: Re: [Bug-gnubg] question on engine abstraction
Date: Sun, 19 Sep 2004 23:29:23 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jon Nall wrote:
|
| Øystein,
| that certainly sounds like a step in the right direction. it seems a
| clean engine abstraction could help lots of efforts (new clients, bots,
| etc).

It wasn't much. Here's the files. There wasn't much to change. I just
removed DumpPosition from eval.c -- that's all! Everything else is just
like the cvs repository code.

The Makefile with capital M, goes in the main directory, the makefile
with a small m goes in the lib directory.

config.h goes in the main directory of course.

The gnubg.def file lists the exported functions. Of course you can add
whichever functions you want.

This works for windows and Mingw. I have no idea how it works for Mac or
anything else. Also note the -mrtd compile option, you need this to be
able to call your dll from other things than Mingw compiled stuff.
Basically you should be able to call your dll from anything with the
compile option since it converts all function calls to stdcall (aka
PASCAL) calling convension.

I guess building a shared library of the engine on any system can be
done similar. Maybe you will need some other sources and do some tricks
of course, but basically it should be the same thing.

Good luck,
- -Øystein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBTfox6kDTFPhwyqYRAq1aAJ9y0C7EGyXCPgloebiURRab+NW8DACghr5t
uCAf2XwLsRiHaPwbE5sQK34=
=XqsY
-----END PGP SIGNATURE-----
#ifdef BUILD_DLL
// the dll exports
#define EXPORT __declspec(dllexport)
#else
// the exe imports
#define EXPORT __declspec(dllimport)
#endif

/* config.h.  Generated automatically by configure.  */
/* config.h.in.  Generated automatically from configure.in by autoheader.  */

/* Define if using alloca.c.  */
/* #undef C_ALLOCA */

/* Define to empty if the keyword does not work.  */
/* #undef const */

/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
   This function is required for alloca.c support on those systems.  */
/* #undef CRAY_STACKSEG_END */

/* Define if you have alloca, as a function or macro.  */
#define HAVE_ALLOCA 1 

/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
/* #undef HAVE_ALLOCA_H */

/* Define if you don't have vprintf but do have _doprnt.  */
/* #undef HAVE_DOPRNT */

/* Define if you have a working `mmap' system call.  */
/* #undef HAVE_MMAP */

/* Define if you have the vprintf function.  */
#define HAVE_VPRINTF 1

/* Define as __inline if that's what the C compiler calls it.  */
/* #undef inline */

/* Define as the return type of signal handlers (int or void).  */
#define RETSIGTYPE void

/* Define to `unsigned' if <sys/types.h> doesn't define.  */
/* #undef size_t */

/* If using the C implementation of alloca, define if you know the
   direction of stack growth for your system; otherwise it will be
   automatically deduced at run-time.
 STACK_DIRECTION > 0 => grows toward higher addresses
 STACK_DIRECTION < 0 => grows toward lower addresses
 STACK_DIRECTION = 0 => direction of growth unknown
 */
/* #undef STACK_DIRECTION */

/* Define if you have the ANSI C header files.  */
#define STDC_HEADERS 1

/* Define if you can safely include both <sys/time.h> and <time.h>.  */
#define TIME_WITH_SYS_TIME 1

/* Define if the X Window System is missing or not being used.  */
#define X_DISPLAY_MISSING 1

/* Installation directory (used to determine PKGDATADIR below). */
#define DATADIR "/usr/local/share"

/* Define if you have the gtkextra library (-lgtkextra).  */
/* #undef HAVE_LIBGTKEXTRA */

/* Define if you have the XCopyPlane function.  */
/* #undef HAVE_XCOPYPLANE */

/* Define if you have the acosf function.  */
#define HAVE_ACOSF 1

/* Define if you have the asinf function.  */
#define HAVE_ASINF 1

/* Define if you have the atanf function.  */
#define HAVE_ATANF 1

/* Define if you have the cosf function.  */
#define HAVE_COSF 1

/* Define if you have the fork function.  */
/* #undef HAVE_FORK 1 */

/* Define if you have the fstat function.  */
#define HAVE_FSTAT 1

/* Define if you have the getdtablesize function.  */
#define HAVE_GETDTABLESIZE 1

/* Define if you have the getlogin function.  */
/* #undef HAVE_GETLOGIN 1 */

/* Define if you have the getpagesize function.  */
#define HAVE_GETPAGESIZE 1

/* Define if you have the getpwuid function.  */
/* #undef HAVE_GETPWUID 1 */

/* Define if you have the gettimeofday function.  */
/* #undef HAVE_GETTIMEOFDAY 1 */

/* Define if you have the isatty function.  */
#define HAVE_ISATTY 1

/* Define if you have the lrint function.  */
#define HAVE_LRINT 1

/* Define if you have the random function.  */
/* #define HAVE_RANDOM 1 */

/* Define if you have the readv function.  */
#define HAVE_READV 1

/* Define if you have the select function.  */
/* #define HAVE_SELECT 1 */

/* Define if you have the setvbuf function.  */
#define HAVE_SETVBUF 1

/* Define if you have the sigaction function.  */
/* #undef HAVE_SIGACTION 1 */

/* Define if you have the sigblock function.  */
/* #undef HAVE_SIGBLOCK */

/* Define if you have the sigprocmask function.  */
#define HAVE_SIGPROCMASK 1

/* Define if you have the sigvec function.  */
/* #define HAVE_SIGVEC 1 */

/* Define if you have the sinf function.  */
#define HAVE_SINF 1

/* Define if you have the tanf function.  */
#define HAVE_TANF 1

/* Define if you have the <fcntl.h> header file.  */
#define HAVE_FCNTL_H 1 

/* Define if you have the <gdk/gdkx.h> header file.  */
/* #undef HAVE_GDK_GDKX_H */

/* Define if you have the <gtkextra/gtksheet.h> header file.  */
/* #undef HAVE_GTKEXTRA_GTKSHEET_H */

/* Define if you have the <limits.h> header file.  */
#define HAVE_LIMITS_H 1

/* Define if you have the <pwd.h> header file.  */
/* #undef HAVE_PWD_H 1 */

/* Define if you have the <stropts.h> header file.  */
/* #undef HAVE_STROPTS_H */

/* Define if you have the <sys/file.h> header file.  */
#define HAVE_SYS_FILE_H 1

/* Define if you have the <sys/ioctl.h> header file.  */
/* #undef HAVE_SYS_IOCTL_H 1 */

/* Define if you have the <sys/mman.h> header file.  */
/* #undef HAVE_SYS_MMAN_H 1 */

/* Define if you have the <sys/socket.h> header file.  */
/* #undef HAVE_SYS_SOCKET_H 1 */

/* Define if you have the <sys/stat.h> header file.  */
#define HAVE_SYS_STAT_H 1

/* Define if you have the <sys/time.h> header file.  */
#define HAVE_SYS_TIME_H 1

/* Define if you have the <sys/types.h> header file.  */
#define HAVE_SYS_TYPES_H 1

/* Define if you have the <sys/uio.h> header file.  */
#define HAVE_SYS_UIO_H 1

/* Define if you have the <sys/wait.h> header file.  */
/* #undef HAVE_SYS_WAIT_H 1 */

/* Define if you have the <unistd.h> header file.  */
#define HAVE_UNISTD_H 1

/* Define if you have the dl library (-ldl).  */
/* #undef HAVE_LIBDL */

/* Define if you have the gdbm library (-lgdbm).  */
/* #define HAVE_LIBGDBM 1 */

/* Define if you have gdbm_errno or _imp_gdbm_errno in your gdbm */
/* #undef HAVE_GDBM_ERRNO */ 
/* #define HAVE_IMP_GDBM_ERRNO 1 */  

/* Define if you have the m library (-lm).  */
#define HAVE_LIBM 1
#define HAVE_ERF 1

/* Define if you have the readline library (-lreadline).  */
/* #define HAVE_LIBREADLINE 1 */ 
/* #define HAVE_RL_COMPLETION_MATCHES 1 */ 
/* #define HAVE_STRING_H 1 */ 
#define HAVE_LIBXML2 1
/* Name of package */
#define PACKAGE "gnubg"

/* Version number of package */
#define VERSION "0.14-devel"

/* Define if you want to i18n support */
/* #define ENABLE_NLS 1 */

/* Define if you want to use the Guile extensibility language. */
/* #define USE_GUILE 1 */

/* Define if you have a signbit() macro faster than a compare to 0.0. */
#define HAVE_SIGNBIT 1

/* Define if the system supports AC_LOCAL sockets. */
/* #undef HAVE_SOCKETS 1 */

/* Define if you want to use the ext toolkit and widgets. */
/* #undef USE_EXT */

/* Define if you want to use the GTK toolkit and widgets. */
/* #define USE_GTK 1 */

/* Are we using either GUI (ext or GTK)? */
#if USE_EXT || USE_GTK
#define USE_GUI 1
#endif

/* does this gtk version have gtk_option_menu_get_history ? */
/* #define HAVE_GTK_OPTION_MENU_GET_HISTORY 1 */

/* The directory where the weights and databases will be stored. */
#define PKGDATADIR DATADIR "/" PACKAGE

/* Define the obvious signbit() if the C library doesn't. */
#if !HAVE_SIGNBIT
#define signbit(x) ( (x) < 0.0 )
#endif

/* Use the double versions of the math functions if the float ones aren't
   available. */
#if !HAVE_ACOSF
#define acosf acos
#endif

#if !HAVE_ASINF
#define asinf asin
#endif

#if !HAVE_ATANF
#define atanf atan
#endif

#if !HAVE_COSF
#define cosf cos
#endif

#if !HAVE_LRINT
#define lrint(x) ((long) ((x)+0.5))
#endif

#if !HAVE_SINF
#define sinf sin
#endif

#if !HAVE_TANF
#define tanf tan
#endif

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif


Index: eval.c
===================================================================
RCS file: /cvsroot/gnubg/gnubg/eval.c,v
retrieving revision 1.263
diff -u -r1.263 eval.c
--- eval.c      16 Sep 2004 07:44:26 -0000      1.263
+++ eval.c      19 Sep 2004 19:42:54 -0000
@@ -3923,6 +3923,7 @@
   DumpRace, DumpCrashed, DumpContact
 };
 
+#if !BUILD_DLL
 extern int
 DumpPosition( int anBoard[ 2 ][ 25 ], char* szOutput,
              const evalcontext* pec, cubeinfo* pci, int fOutputMWC,
@@ -4047,7 +4048,7 @@
 
   return 0;
 }
-
+#endif
 
 static void StatusHypergammon1( char *sz ) {
 
CC      = gcc
FC      = g77
#OPT     = -O3 -march=pentium -mcpu=pentium # -msse -mfpmath=sse -ffast-math
OPT     = -O3 -g 

# CFLAGS  = -fnative-struct -O2 -Wall $(DEFS) $(INCLUDE)
CFLAGS  = -mms-bitfields $(OPT) -Wall $(DEFS) $(INCLUDE)
#CFLAGS  = -O3 -Wall $(DEFS) $(INCLUDE)
FFLAGS  = $(OPT) -Wall
DEFS    = -DHAVE_CONFIG_H # -DADD_ -DHAVE_LIBATLAS=1
INCLUDE = -I. -I..
AR      = ar cr
RANLIB  = ranlib
TARGET  = libevent.a

SRCS = hash.c heap.c list.c neuralnet.c \
       dynarray.c isaac.c md5.c mt19937ar.c 
#       cblas_sgemv.c cblas_globals.c cblas_xerbla.c

OBJS = hash.o heap.o list.o neuralnet.o \
       dynarray.o isaac.o md5.o mt19937ar.o 
#       cblas_xerbla.o cblas_sgemv.o cblas_globals.o \
#       sgemv.o lsame.o xerbla.o

$(TARGET): $(OBJS)
        $(AR) $(TARGET) $(OBJS)
        $(RANLIB) $(TARGET)

clean:
        rm -f *.o libevent.a *~
CC       = gcc
CFLAGS   = -O3 -mrtd $(DEFS) $(INCLUDE)
DEFS     = -DBUILD_DLL -DHAVE_CONFIG_H -DLOCALEDIR=\"/mingw/lib/locale\"
INCLUDE  = -I. -I./lib -I/mingw/include/libxml2 
AR       = ar cr
LIBS     = $(LDFLAGS) $(LIBPATH) -levent -lxml2 -lm 
LIBPATH  = -L./lib
RM       = rm

TARGET   = gnubg.dll
CONFIG   = config.h
DEFFILE  = gnubg.def
LIBRARY  = libgnubg.a

SOURCE   = eval.c matchequity.c positionid.c matchid.c pub_eval.c osr.c \
           i18n.c bearoffgammon.c bearoff.c path.c mec.c simplelibgen.c

OBJECTS  = $(SOURCE:.c=.o)

LIBEVENT = lib/libevent.a

$(TARGET): $(LIBEVENT) $(OBJECTS) $(DEFFILE)
        dllwrap --output-lib=$(LIBRARY) --def=$(DEFFILE) \
        --dllname=$(TARGET) --driver-name=$(CC) $(OBJECTS) $(LIBS)

$(OBJECTS): $(SOURCE) $(CONFIG)

$(LIBEVENT): $(CONFIG)
        $(MAKE) -C lib

$(CONFIG):
        copy config-dll.h $(CONFIG)
        
clean: 
        $(RM) $(OBJECTS) *~ > nul
        $(MAKE) clean -C lib
        
EXPORTS
EvalInitialise
FindBestMove
GeneralCubeDecisionE
EvaluatePosition

reply via email to

[Prev in Thread] Current Thread [Next in Thread]