Jelajahi Sumber

Prepared the project for mixing C++ code in

Jittapan Pluemsumran 8 tahun lalu
induk
melakukan
7749c18a06

+ 6 - 1
.travis.yml

@@ -1,7 +1,8 @@
-language: c
+language: cpp
 compiler:
   - clang
   - gcc
+dist: trusty
 
 before_script:
   - uname -a
@@ -24,6 +25,10 @@ before_script:
   - mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db2_re.sql || aborterror "Unable to import renewal monster skill 2 table."
   - mysql -u $DB_ROOT $DB_NAME < sql-files/roulette_default_data.sql || aborterror "Unable to import roulette table."
   - mysql -u $DB_ROOT -e "GRANT ALL ON *.* TO '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS';"
+  - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
+  - sudo apt-get update -q
+  - sudo apt-get install gcc-4.8 -y
+  - sudo apt-get install g++-4.8 -y
 
 script:
   - ./configure $CONFIGURE_FLAGS

File diff ditekan karena terlalu besar
+ 536 - 441
configure


+ 8 - 8
configure.in

@@ -433,9 +433,9 @@ AC_ARG_WITH(
 
 AC_PROG_MAKE_SET
 AC_PROG_CC
-AC_PROG_CPP
+AC_PROG_CXX
 AC_PATH_PROG(AR, ar)
-AC_LANG([C])
+AC_LANG([C++])
 
 
 CFLAGS="$CFLAGS -pipe -ffast-math -Wall"
@@ -700,12 +700,12 @@ AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
 AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
 AC_CHECK_COMPILER_WNOFLAG(clobbered)
 AC_CHECK_COMPILER_WFLAG(empty-body)
-AC_CHECK_COMPILER_WFLAG(newline-eof)
-AC_CHECK_COMPILER_WFLAG(int-conversion)
-AC_CHECK_COMPILER_WFLAG(enum-conversion)
-AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
-AC_CHECK_COMPILER_WFLAG(constant-conversion)
-AC_CHECK_COMPILER_WFLAG(bool-conversion)
+#AC_CHECK_COMPILER_WFLAG(newline-eof)
+#AC_CHECK_COMPILER_WFLAG(int-conversion)
+#AC_CHECK_COMPILER_WFLAG(enum-conversion)
+#AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
+#AC_CHECK_COMPILER_WFLAG(constant-conversion)
+#AC_CHECK_COMPILER_WFLAG(bool-conversion)
 AC_CHECK_COMPILER_WNOFLAG(switch)
 AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
 

+ 10 - 0
src/common/Makefile.in

@@ -23,6 +23,8 @@ else
 endif
 ALL_DEPENDS=server
 
+CXXFLAG =-std=c++11
+
 @SET_MAKE@
 
 #####################################################################
@@ -63,10 +65,18 @@ obj/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
 	@echo "	CC	$<"
 	@@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
 
+obj/%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+	@echo "	CXX	$<"
+	@@CXX@ $(CXXFLAG) @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+
 obj/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
 	@echo "	CC	$<"
 	@@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
 
+obj/mini%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+	@echo "	CXX	$<"
+	@@CXX@ $(CXXFLAG) @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+
 # missing object files
 $(MT19937AR_OBJ):
 	@$(MAKE) -C ../../3rdparty/mt19937ar

+ 16 - 15
src/common/core.c

@@ -2,6 +2,7 @@
 // For more information, see LICENCE in the main folder
 
 #include "mmo.h"
+#include "cbasetypes.h"
 #include "showmsg.h"
 #include "malloc.h"
 #include "core.h"
@@ -164,14 +165,14 @@ const char* get_svn_revision(void) {
 	// - ignores database file structure
 	// - assumes the data in NODES.dav_cache column ends with "!svn/ver/<revision>/<path>)"
 	// - since it's a cache column, the data might not even exist
-	if( (fp = fopen(".svn"PATHSEP_STR"wc.db", "rb")) != NULL || (fp = fopen(".."PATHSEP_STR".svn"PATHSEP_STR"wc.db", "rb")) != NULL )
+	if( (fp = fopen(".svn" PATHSEP_STR "wc.db", "rb")) != NULL || (fp = fopen(".." PATHSEP_STR ".svn" PATHSEP_STR "wc.db", "rb")) != NULL )
 	{
 	#ifndef SVNNODEPATH
 		//not sure how to handle branches, so i'll leave this overridable define until a better solution comes up
 		#define SVNNODEPATH trunk
 	#endif
 		const char* prefix = "!svn/ver/";
-		const char* postfix = "/"EXPAND_AND_QUOTE(SVNNODEPATH)")"; // there should exist only 1 entry like this
+		const char* postfix = "/" EXPAND_AND_QUOTE(SVNNODEPATH) ")"; // there should exist only 1 entry like this
 		size_t prefix_len = strlen(prefix);
 		size_t postfix_len = strlen(postfix);
 		size_t i,j,len;
@@ -257,7 +258,7 @@ const char *get_git_hash (void) {
 	if( GitHash[0] != '\0' )
 		return GitHash;
 
-	if( (fp = fopen(".git/"GIT_ORIGIN, "r")) != NULL ) {
+	if( (fp = fopen(".git/" GIT_ORIGIN, "r")) != NULL ) {
 		char line[64];
 		char *rev = (char*)malloc(sizeof(char) * 50);
 
@@ -286,21 +287,21 @@ static void display_title(void) {
 	const char* git = get_git_hash();
 
 	ShowMessage("\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"                                                                 "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"       "CL_BT_WHITE"            rAthena Development Team presents                  "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"                 ___   __  __                                    "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"           _____/   | / /_/ /_  ___  ____  ____ _                "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"          / ___/ /| |/ __/ __ \\/ _ \\/ __ \\/ __ `/                "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"         / /  / ___ / /_/ / / /  __/ / / / /_/ /                 "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"        /_/  /_/  |_\\__/_/ /_/\\___/_/ /_/\\__,_/                  "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"                                                                 "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"       "CL_GREEN"              http://rathena.org/board/                        "CL_PASS""CL_CLL""CL_NORMAL"\n");
-	ShowMessage(""CL_PASS"     "CL_BOLD"                                                                 "CL_PASS""CL_CLL""CL_NORMAL"\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "                                                                 " CL_PASS"" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "       " CL_BT_WHITE "            rAthena Development Team presents                  " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "                 ___   __  __                                    " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "           _____/   | / /_/ /_  ___  ____  ____ _                " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "          / ___/ /| |/ __/ __ \\/ _ \\/ __ \\/ __ `/                " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "         / /  / ___ / /_/ / / /  __/ / / / /_/ /                 " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "        /_/  /_/  |_\\__/_/ /_/\\___/_/ /_/\\__,_/                  " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "                                                                 " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "       " CL_GREEN "              http://rathena.org/board/                        " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
+	ShowMessage("" CL_PASS "     " CL_BOLD "                                                                 " CL_PASS "" CL_CLL "" CL_NORMAL "\n");
 
 	if( svn[0] != UNKNOWN_VERSION )
-		ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'\n", svn);
+		ShowInfo("SVN Revision: '" CL_WHITE "%s" CL_RESET "'\n", svn);
 	else if( git[0] != UNKNOWN_VERSION )
-		ShowInfo("Git Hash: '"CL_WHITE"%s"CL_RESET"'\n", git);
+		ShowInfo("Git Hash: '" CL_WHITE "%s" CL_RESET "'\n", git);
 }
 
 // Warning if executed as superuser (root)

+ 14 - 0
src/common/core.h

@@ -4,6 +4,10 @@
 #ifndef	_CORE_H_
 #define	_CORE_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* so that developers with --enable-debug can raise signals from any section of the code they'd like */
 #ifdef DEBUG
 	#include <signal.h>
@@ -34,12 +38,18 @@ enum {
 extern char SERVER_TYPE;
 
 extern int parse_console(const char* buf);
+#ifdef __cplusplus
+extern "C" {
+#endif
 const char *get_svn_revision(void);
 const char *get_git_hash(void);
 extern int do_init(int,char**);
 extern void set_server_type(void);
 extern void do_abort(void);
 extern void do_final(void);
+#ifdef __cplusplus
+}
+#endif
 
 /// The main loop continues until runflag is CORE_ST_STOP
 enum E_CORE_ST
@@ -53,4 +63,8 @@ enum E_CORE_ST
 /// If NULL, runflag is set to CORE_ST_STOP instead.
 extern void (*shutdown_callback)(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CORE_H_ */

+ 7 - 1
src/common/db.h

@@ -42,6 +42,10 @@
 #ifndef _DB_H_
 #define _DB_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 
 #include <stdarg.h>
@@ -1655,6 +1659,8 @@ void  linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
 /// @return negative if v1 is top, positive if v2 is top, 0 if equal
 #define BHEAP_MAXTOPCMP(v1,v2) ( v1 == v2 ? 0 : v1 > v2 ? -1 : 1 )
 
-
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _DB_H_ */

+ 8 - 0
src/common/ers.h

@@ -40,6 +40,10 @@
 #ifndef _ERS_H_
 #define _ERS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 
 /*****************************************************************************\
@@ -175,4 +179,8 @@ void ers_report(void);
 void ers_final(void);
 #endif /* DISABLE_ERS / not DISABLE_ERS */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _ERS_H_ */

+ 7 - 0
src/common/malloc.h

@@ -4,6 +4,9 @@
 #ifndef _MALLOC_H_
 #define _MALLOC_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #include "cbasetypes.h"
 
 #define ALC_MARK __FILE__, __LINE__, __func__
@@ -89,4 +92,8 @@ size_t malloc_usage (void);
 void malloc_init (void);
 void malloc_final (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _MALLOC_H_ */

+ 15 - 15
src/common/mempool.c

@@ -51,7 +51,7 @@ struct ra_align(16) node{
 
 // The Pointer to this struct is the base address of the segment itself.
 struct pool_segment{
-	mempool	pool; // pool, this segment belongs to
+	pMempool	pool; // pool, this segment belongs to
 	struct 	pool_segment *next;
 	int64	num_nodes_total;	
 	int64	num_bytes;
@@ -96,17 +96,17 @@ struct mempool{
 /// 
 // Implementation:
 //
-static void segment_allocate_add(mempool p,  uint64 count);
+static void segment_allocate_add(pMempool p,  uint64 count);
 
 static SPIN_LOCK l_mempoolListLock;
-static mempool 	l_mempoolList = NULL;
-static rAthread l_async_thread = NULL;
+static pMempool 	l_mempoolList = NULL;
+static prAthread l_async_thread = NULL;
 static ramutex	l_async_lock = NULL;
 static racond	l_async_cond = NULL;
 static volatile int32 l_async_terminate = 0;
 
 static void *mempool_async_allocator(void *x){
-	mempool p;
+	pMempool p;
 	
 	
 	while(1){
@@ -167,7 +167,7 @@ void mempool_init(){
 
 
 void mempool_final(){
-	mempool p, pn;
+	pMempool p, pn;
 	
 	if( rand()%2 + 1 )
 		return;
@@ -205,7 +205,7 @@ void mempool_final(){
 }//end: mempool_final()
 
 
-static void segment_allocate_add(mempool p,  uint64 count){
+static void segment_allocate_add(pMempool p,  uint64 count){
 	
 	// Required Memory:
 	//	sz( segment ) 
@@ -303,7 +303,7 @@ static void segment_allocate_add(mempool p,  uint64 count){
 }//end: segment_allocate_add()
 
 
-mempool mempool_create(const char *name,
+pMempool mempool_create(const char *name,
 						uint64 elem_size,
 						uint64 initial_count,
 						uint64 realloc_count,
@@ -311,8 +311,8 @@ mempool mempool_create(const char *name,
 						memPoolOnNodeDeallocationProc onNodeDealloc){
 	//..
 	uint64 realloc_thresh;
-	mempool pool;
-	pool = (mempool)aCalloc( 1,  sizeof(struct mempool) );
+	pMempool pool;
+	pool = (pMempool)aCalloc( 1,  sizeof(struct mempool) );
 	
 	if(pool == NULL){
 		ShowFatalError("mempool_create: Failed to allocate %u bytes memory.\n", sizeof(struct mempool) );
@@ -369,10 +369,10 @@ mempool mempool_create(const char *name,
 }//end: mempool_create()
 
 
-void mempool_destroy(mempool p){
+void mempool_destroy(pMempool p){
 	struct  pool_segment *seg, *segnext;
 	struct	node *niter;
-	mempool piter, pprev;
+	pMempool piter, pprev;
 	char *ptr;
 	int64 i;
 
@@ -472,7 +472,7 @@ void mempool_destroy(mempool p){
 }//end: mempool_destroy()
 
 
-void *mempool_node_get(mempool p){
+void *mempool_node_get(pMempool p){
 	struct node *node;
 	int64 num_used;
 	
@@ -511,7 +511,7 @@ void *mempool_node_get(mempool p){
 }//end: mempool_node_get()
 
 
-void mempool_node_put(mempool p, void *data){
+void mempool_node_put(pMempool p, void *data){
 	struct node *node;
 	
 	node = DATA_TO_NODE(data);
@@ -544,7 +544,7 @@ void mempool_node_put(mempool p, void *data){
 }//end: mempool_node_put()
 
 
-mempool_stats mempool_get_stats(mempool pool){
+mempool_stats mempool_get_stats(pMempool pool){
 	mempool_stats stats;
 	
 	// initialize all with zeros

+ 13 - 6
src/common/mempool.h

@@ -1,9 +1,13 @@
 #ifndef _rA_MEMPOOL_H_
 #define _rA_MEMPOOL_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 
-typedef struct mempool *mempool;
+typedef struct mempool *pMempool;
 
 typedef void (*memPoolOnNodeAllocationProc)(void *ptr);
 typedef void (*memPoolOnNodeDeallocationProc)(void *ptr);
@@ -45,7 +49,7 @@ void mempool_final();
  *
  * @return not NULL
  */
-mempool mempool_create(const char *name,
+pMempool mempool_create(const char *name,
 						uint64 elem_size,
 						uint64 initial_count,
 						uint64 realloc_count,
@@ -63,7 +67,7 @@ mempool mempool_create(const char *name,
  *	Everything gets deallocated, regardless if everything was freed properly!
  *	So you have to ensure that all references are cleared properly!
  */
-void mempool_destroy(mempool pool);
+void mempool_destroy(pMempool pool);
 
 
 /**
@@ -73,7 +77,7 @@ void mempool_destroy(mempool pool);
  *
  * @return Address of empty Node
  */
-void *mempool_node_get(mempool pool);
+void *mempool_node_get(pMempool pool);
 
 
 /**
@@ -82,7 +86,7 @@ void *mempool_node_get(mempool pool);
  * @param pool - the pool to put the node, to
  * @param node - the node to return 
  */
-void mempool_node_put(mempool pool, void *node);
+void mempool_node_put(pMempool pool, void *node);
 
 
 /** 
@@ -94,7 +98,10 @@ void mempool_node_put(mempool pool, void *node);
  *
  * @return stats struct
  */
-mempool_stats mempool_get_stats(mempool pool);
+mempool_stats mempool_get_stats(pMempool pool);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif

+ 8 - 0
src/common/showmsg.h

@@ -4,6 +4,10 @@
 #ifndef _SHOWMSG_H_
 #define _SHOWMSG_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "../../3rdparty/libconfig/libconfig.h"
 
 // for help with the console colors look here:
@@ -97,4 +101,8 @@ extern void ShowError(const char *, ...);
 extern void ShowFatalError(const char *, ...);
 extern void ShowConfigWarning(config_setting_t *config, const char *string, ...);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _SHOWMSG_H_ */

+ 8 - 0
src/common/socket.h

@@ -17,6 +17,10 @@
 
 #include <time.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FIFOSIZE_SERVERLINK 256*1024
 
 // socket I/O macros
@@ -182,4 +186,8 @@ void send_shortlist_add_fd(int fd);
 void send_shortlist_do_sends();
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _SOCKET_H_ */

+ 7 - 0
src/common/sql.h

@@ -4,6 +4,10 @@
 #ifndef _COMMON_SQL_H_
 #define _COMMON_SQL_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 #include <stdarg.h>// va_list
 
@@ -341,5 +345,8 @@ void SqlStmt_Free(SqlStmt* self);
 
 void Sql_Init(void);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _COMMON_SQL_H_ */

+ 14 - 0
src/common/strlib.h

@@ -4,12 +4,22 @@
 #ifndef _STRLIB_H_
 #define _STRLIB_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 #include <stdarg.h>
 
+#if !defined(__USE_GNU)
 #define __USE_GNU  // required to enable strnlen on some platforms
+#define __USED_GNU
+#endif
 #include <string.h>
+#if defined(__USED_GNU)
 #undef __USE_GNU
+#undef __USED_GNU
+#endif
 
 char* jstrescape (char* pt);
 char* jstrescapecpy (char* pt, const char* spt);
@@ -152,4 +162,8 @@ void StringBuf_Clear(StringBuf* self);
 void StringBuf_Destroy(StringBuf* self);
 void StringBuf_Free(StringBuf* self);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _STRLIB_H_ */

+ 14 - 14
src/common/thread.c

@@ -96,7 +96,7 @@ void rathread_final(){
 
 
 // gets called whenever a thread terminated ..
-static void rat_thread_terminated( rAthread handle ){
+static void rat_thread_terminated( prAthread handle ){
 
 	int id_backup = handle->myID;
 
@@ -117,7 +117,7 @@ static void *_raThreadMainRedirector( void *p ){
 	
 	// Update myID @ TLS to right id.
 #ifdef HAS_TLS
-	g_rathread_ID = ((rAthread)p)->myID; 
+	g_rathread_ID = ((prAthread)p)->myID; 
 #endif
 
 #ifndef WIN32
@@ -135,13 +135,13 @@ static void *_raThreadMainRedirector( void *p ){
 #endif
 
 
-	ret = ((rAthread)p)->proc( ((rAthread)p)->param ) ;
+	ret = ((prAthread)p)->proc( ((prAthread)p)->param ) ;
 
 #ifdef WIN32	
-	CloseHandle( ((rAthread)p)->hThread );
+	CloseHandle( ((prAthread)p)->hThread );
 #endif
 
-	rat_thread_terminated( (rAthread)p );
+	rat_thread_terminated( (prAthread)p );
 #ifdef WIN32
 	return (DWORD)ret;
 #else
@@ -156,18 +156,18 @@ static void *_raThreadMainRedirector( void *p ){
 ///
 /// API Level
 /// 
-rAthread rathread_create( rAthreadProc entryPoint,  void *param ){
+prAthread rathread_create( rAthreadProc entryPoint,  void *param ){
 	return rathread_createEx( entryPoint, param,  (1<<23) /*8MB*/,  RAT_PRIO_NORMAL );
 }//end: rathread_create()
 
 
-rAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szStack,  RATHREAD_PRIO prio ){
+prAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szStack,  RATHREAD_PRIO prio ){
 #ifndef WIN32
 	pthread_attr_t attr;
 #endif
 	size_t tmp;
 	unsigned int i;
-	rAthread handle = NULL;
+	prAthread handle = NULL;
 
 
 	// given stacksize aligned to systems pagesize?
@@ -214,7 +214,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szSta
 }//end: rathread_createEx
 
 
-void rathread_destroy ( rAthread handle ){
+void rathread_destroy ( prAthread handle ){
 #ifdef WIN32
 	if( TerminateThread(handle->hThread, 0) != FALSE){
 		CloseHandle(handle->hThread);
@@ -233,9 +233,9 @@ void rathread_destroy ( rAthread handle ){
 #endif
 }//end: rathread_destroy()
 
-rAthread rathread_self( ){
+prAthread rathread_self( ){
 #ifdef HAS_TLS
-	rAthread handle = &l_threads[g_rathread_ID];
+	prAthread handle = &l_threads[g_rathread_ID];
 	
 	if(handle->proc != NULL) // entry point set, so its used!	
 		return handle;
@@ -279,7 +279,7 @@ int rathread_get_tid(){
 }//end: rathread_get_tid()
 
 
-bool rathread_wait( rAthread handle,  void* *out_exitCode ){
+bool rathread_wait( prAthread handle,  void* *out_exitCode ){
 	
 	// Hint:
 	// no thread data cleanup routine call here!
@@ -297,13 +297,13 @@ bool rathread_wait( rAthread handle,  void* *out_exitCode ){
 }//end: rathread_wait()
 
 
-void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ){
+void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio ){
 	handle->prio = RAT_PRIO_NORMAL; 
 	//@TODO 
 }//end: rathread_prio_set()
 
 
-RATHREAD_PRIO rathread_prio_get( rAthread handle){
+RATHREAD_PRIO rathread_prio_get( prAthread handle){
 	return handle->prio;
 }//end: rathread_prio_get()
 

+ 15 - 8
src/common/thread.h

@@ -5,9 +5,13 @@
 #ifndef _rA_THREAD_H_
 #define _rA_THREAD_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 
-typedef struct rAthread *rAthread;
+typedef struct rAthread *prAthread;
 typedef void* (*rAthreadProc)(void*);
 
 typedef enum RATHREAD_PRIO {
@@ -25,7 +29,7 @@ typedef enum RATHREAD_PRIO {
  * 
  * @return not NULL if success
  */
-rAthread rathread_create( rAthreadProc entryPoint,  void *param );
+prAthread rathread_create( rAthreadProc entryPoint,  void *param );
 
 
 /** 
@@ -38,7 +42,7 @@ rAthread rathread_create( rAthreadProc entryPoint,  void *param );
  *
  * @return not NULL if success
  */
-rAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szStack,  RATHREAD_PRIO prio );
+prAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szStack,  RATHREAD_PRIO prio );
 
 
 /**
@@ -48,7 +52,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint,  void *param,  size_t szSta
  *
  * @param handle - thread to destroy.
  */
-void rathread_destroy ( rAthread handle );
+void rathread_destroy ( prAthread handle );
 
 
 /** 
@@ -59,7 +63,7 @@ void rathread_destroy ( rAthread handle );
  * 
  * @return not NULL if success
  */
-rAthread rathread_self( );
+prAthread rathread_self( );
 
 
 /**
@@ -81,7 +85,7 @@ int rathread_get_tid();
  * 
  * @return true - if the given thread has been terminated.
  */
-bool rathread_wait( rAthread handle,  void* *out_exitCode );
+bool rathread_wait( prAthread handle,  void* *out_exitCode );
 
 
 /** 
@@ -90,7 +94,7 @@ bool rathread_wait( rAthread handle,  void* *out_exitCode );
  * @param handle - thread to set prio for
  * @param rio - the priority (RAT_PRIO_LOW ... )
  */
-void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio );
+void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio );
 
 
 /** 
@@ -98,7 +102,7 @@ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio );
  *
  * @param handle - the thread to get the prio for.
  */
-RATHREAD_PRIO rathread_prio_get( rAthread handle);
+RATHREAD_PRIO rathread_prio_get( prAthread handle);
 
 
 /**
@@ -115,5 +119,8 @@ void rathread_yield();
 void rathread_init();
 void rathread_final();
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif

+ 8 - 0
src/common/timer.h

@@ -4,6 +4,10 @@
 #ifndef	_TIMER_H_
 #define	_TIMER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "cbasetypes.h"
 #include <time.h>
 
@@ -60,4 +64,8 @@ int do_timer(unsigned int tick);
 void timer_init(void);
 void timer_final(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _TIMER_H_ */

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini