/home/dko/projects/mobilec/trunk/src/include/macros.h File Reference

#include <pthread.h>
#include <semaphore.h>
#include "config.h"

Go to the source code of this file.


Defines

#define GET_THREAD_MODE(a, b) ( (a & (1<<b)) / (1<<b) )
#define SET_THREAD_ON(a, b) a = (a | (1<<b))
#define SET_THREAD_OFF(a, b) a = (a & (~(1<<b)))
#define STRUCT(name, members)
#define PTHREAD_STACK_SIZE 131072
#define THREAD_T pthread_t
#define THREAD_CREATE(thread_handle, function, arg)
#define THREAD_CANCEL(thread_handle) pthread_cancel( thread_handle )
#define THREAD_JOIN(thread_handle) pthread_join( thread_handle, NULL )
#define MUTEX_T pthread_mutex_t
#define MUTEX_INIT(mutex) pthread_mutex_init(mutex, NULL)
#define MUTEX_DESTROY(mutex) pthread_mutex_destroy(mutex)
#define MUTEX_LOCK(mutex)
#define MUTEX_UNLOCK(mutex) pthread_mutex_unlock( mutex )
#define MUTEX_NEW(mutex)
#define COND_T pthread_cond_t
#define COND_INIT(cond) pthread_cond_init(cond, NULL)
#define COND_DESTROY(cond) pthread_cond_destroy(cond)
#define COND_WAIT(cond, mutex) pthread_cond_wait(cond, mutex )
#define COND_SLEEP(cond, mutex, test)
#define COND_RESET(cond, mutex) pthread_mutex_unlock( mutex );
#define COND_SLEEP_ACTION(cond, mutex, action)
#define SIGNAL(cond, mutex, action)
#define COND_BROADCAST(cond) pthread_cond_broadcast( cond )
#define COND_SIGNAL(cond) pthread_cond_signal( cond )
#define SEMAPHORE_T sem_t
#define SEMAPHORE_INIT(sem) sem_init(sem, 0, 0)
#define SEMAPHORE_DESTROY(sem) sem_destroy(sem)
#define SEMAPHORE_WAIT(sem) sem_wait(sem)
#define SEMAPHORE_POST(sem) sem_post(sem)
#define RWLOCK_INIT(rwlock) mc_rwlock_init(rwlock)
#define RWLOCK_DESTROY(rwlock) mc_rwlock_destroy(rwlock)
#define RWLOCK_RDLOCK(rwlock) mc_rwlock_rdlock(rwlock)
#define RWLOCK_RDUNLOCK(rwlock) mc_rwlock_rdunlock(rwlock)
#define RWLOCK_WRLOCK(rwlock) mc_rwlock_wrlock(rwlock)
#define RWLOCK_WRUNLOCK(rwlock) mc_rwlock_wrunlock(rwlock)
#define WAKE_QUEUE(queue, action)
#define SLEEP_QUEUE(queue)
#define SLEEP_RESET(queue) pthread_mutex_unlock( queue->thread_mutex )
#define CHECK_NULL(var, action)
#define WARN(message)
#define CH_DATATYPE_SIZE(type, size)
#define CH_DATATYPE_STRING(type, string)
#define CH_DATATYPE_VALUE_STRING(type, string, p)
#define CH_STRING_DATATYPE(string, type)
#define CH_DATATYPE_STR_TO_VAL(type, string, val)

Define Documentation

#define CH_DATATYPE_SIZE ( type,
size )

Value:

switch(type) { \
 case CH_CHARTYPE: \
 size = sizeof(char); \
 break; \
 case CH_INTTYPE: \
 size = sizeof(int); \
 break; \
 case CH_UINTTYPE: \
 size = sizeof(unsigned int); \
 break; \
 case CH_SHORTTYPE: \
 size = sizeof(short); \
 break; \
 case CH_USHORTTYPE: \
 size = sizeof(unsigned short); \
 break; \
 case CH_FLOATTYPE: \
 size = sizeof(float); \
 break; \
 case CH_DOUBLETYPE: \
 size = sizeof(double); \
 break; \
 default: \
 fprintf(stderr, "Unknown data type: %d at %s:%d", \
 type, __FILE__, __LINE__); \
 size=0; \
 }

Definition at line 460 of file macros.h.

Referenced by agent_AddPersistentVariable(), agent_xml_compose__create_row_nodes(), agent_xml_parse__data(), agent_xml_parse__fill_row_data(), agent_xml_parse__row(), interpreter_variable_data_Initialize(), interpreter_variable_data_InitializeFromAgent(), and MC_GetAgentReturnData().

#define CH_DATATYPE_STR_TO_VAL ( type,
string,
val )

Value:

switch (type) { \
 case CH_INTTYPE: \
 *(int*)val = atoi(string); \
 break; \
 case CH_UINTTYPE: \
 *(unsigned int*)val = atoi(string); \
 break; \
 case CH_SHORTTYPE: \
 *(short*)val = (short)atoi(string); /*FIXME*/ \
 break; \
 case CH_USHORTTYPE: \
 *(unsigned short*)val = (unsigned short)atoi(string); /*FIXME*/ \
 break; \
 case CH_FLOATTYPE: \
 *(float*)val = strtof(string, NULL); \
 break; \
 case CH_DOUBLETYPE: \
 *(double*)val = strtod(string, NULL); \
 break; \
 default: \
 fprintf(stderr, \
 "Unsupported data type: %d %s:%d\n", \
 type, __FILE__, __LINE__ ); \
 }

Definition at line 574 of file macros.h.

Referenced by agent_xml_parse__data().

#define CH_DATATYPE_STRING ( type,
string )

Value:

switch(type) { \
 case CH_CHARTYPE: \
 strcpy(string, "char"); \
 break; \
 case CH_INTTYPE: \
 strcpy(string, "int"); \
 break; \
 case CH_UINTTYPE: \
 strcpy(string, "unsigned int"); \
 break; \
 case CH_SHORTTYPE: \
 strcpy(string, "short"); \
 break; \
 case CH_USHORTTYPE: \
 strcpy(string, "unsigned short"); \
 break; \
 case CH_FLOATTYPE: \
 strcpy(string, "float"); \
 break; \
 case CH_DOUBLETYPE: \
 strcpy(string, "double"); \
 break; \
 default: \
 fprintf(stderr, \
 "Unsupported data type: %d %s:%d\n", \
 type, __FILE__, __LINE__ ); \
 }

Definition at line 491 of file macros.h.

Referenced by agent_xml_compose__data().

#define CH_DATATYPE_VALUE_STRING ( type,
string,
p )

Value:

switch(type) { \
 case CH_CHARTYPE: \
 sprintf(string, "%c", *((char*)p)); \
 break; \
 case CH_INTTYPE: \
 sprintf(string, "%d", *((int*)p)); \
 break; \
 case CH_UINTTYPE: \
 sprintf(string, "%d", *((unsigned int*)p)); \
 break; \
 case CH_SHORTTYPE: \
 sprintf(string, "%d", *((short*)p)); \
 break; \
 case CH_USHORTTYPE: \
 sprintf(string, "%d", *((unsigned short*)p)); \
 break; \
 case CH_FLOATTYPE: \
 sprintf(string, "%f", *((float*)p)); \
 break; \
 case CH_DOUBLETYPE: \
 sprintf(string, "%f", *((double*)p)); \
 break; \
 default: \
 fprintf(stderr, \
 "Unsupported data type: %d %s:%d\n", \
 type, __FILE__, __LINE__); \
 }

Definition at line 523 of file macros.h.

Referenced by agent_xml_compose__create_row_nodes(), and agent_xml_compose__data().

#define CH_STRING_DATATYPE ( string,
type )

Value:

if (!strcmp(string, "int")) { \
 type = CH_INTTYPE; \
 } else if (!strcmp(string, "float")) { \
 type = CH_FLOATTYPE; \
 } else if (!strcmp(string, "double")) { \
 type = CH_DOUBLETYPE; \
 } else if (!strcmp(string, "unsigned int")) { \
 type = CH_UINTTYPE; \
 } else if (!strcmp(string, "short")) { \
 type = CH_SHORTTYPE; \
 } else if (!strcmp(string, "unsigned short")) { \
 type = CH_USHORTTYPE; \
 } else if (!strcmp(string, "char")) { \
 type = CH_CHARTYPE; \
 } else { \
 fprintf(stderr, \
 "Unsupported data type: %d %s:%d\n", \
 type, __FILE__, __LINE__ ); \
 }

Definition at line 552 of file macros.h.

Referenced by agent_xml_parse__data().

#define CHECK_NULL ( var,
action )

Value:

if ( var == NULL ) { \
 fprintf(stderr, "Pointer var is null: expected otherwise.\n"); \
 fprintf(stderr, "Error occured at %s:%d", __FILE__, __LINE__); \
 action; \
 }

Definition at line 443 of file macros.h.

Referenced by agent_AddPersistentVariable(), agent_datastate_New(), agent_xml_parse__home(), agent_xml_parse__name(), agent_xml_parse__owner(), agent_xml_parse__task(), ams_Initialize(), barrier_node_Initialize(), barrier_queue_New(), df_request_list_New(), df_request_list_node_New(), df_request_search_New(), fipa_agent_identifier_Parse(), fipa_word_Parse(), http_ParseExpression(), interpreter_variable_data_Initialize(), interpreter_variable_data_InitializeFromAgent(), interpreter_variable_data_New(), listen_Thread(), MC_AclSend_chdl(), MC_AddAgent_chdl(), MC_Barrier_chdl(), MC_BarrierDelete_chdl(), MC_BarrierInit_chdl(), MC_CondBroadcast_chdl(), MC_CondReset_chdl(), MC_CondSignal_chdl(), MC_CondWait_chdl(), MC_DeleteAgent(), MC_DeregisterService_chdl(), MC_End_chdl(), MC_FindAgentByID_chdl(), MC_FindAgentByName_chdl(), MC_HaltAgency_chdl(), MC_Initialize(), MC_MutexLock_chdl(), MC_MutexUnlock_chdl(), mc_platform_Initialize(), MC_RegisterService(), MC_RegisterService_chdl(), MC_ResumeAgency_chdl(), MC_RetrieveAgent_chdl(), mc_rwlock_init(), MC_SearchForService(), MC_SearchForService_chdl(), MC_SemaphorePost_chdl(), MC_SemaphoreWait_chdl(), MC_SendAgentMigrationMessage_chdl(), MC_SendSteerCommand_chdl(), MC_SetDefaultAgentStatus_chdl(), MC_SyncDelete_chdl(), MC_SyncInit_chdl(), message_InitializeFromAgent(), message_InitializeFromConnection(), message_InitializeFromString(), message_New(), message_queue_SendOutgoing(), message_Send(), message_xml_parse__message(), mtp_http_InitializeFromConnection(), mtp_http_New(), syncListNodeInit(), syncListNodeNew(), xml_get_cdata(), xml_get_text(), and xml_new_cdata().

#define COND_BROADCAST ( cond ) pthread_cond_broadcast( cond )

#define COND_RESET ( cond,
mutex ) pthread_mutex_unlock( mutex );

Definition at line 194 of file macros.h.

#define COND_SLEEP ( cond,
mutex,
test )

Value:

if (pthread_mutex_lock( mutex )) \
printf("pthread lock error: %s:%d\n", __FILE__, __LINE__); \
if (!test) { \
 pthread_cond_wait( cond, mutex ); \
}

Definition at line 188 of file macros.h.

#define COND_SLEEP_ACTION ( cond,
mutex,
action )

Value:

if (pthread_mutex_lock( mutex )) \
printf("pthread lock error: %s:%d\n", __FILE__, __LINE__); \
action; \
pthread_cond_wait( cond, mutex );

Definition at line 196 of file macros.h.

Referenced by MC_SearchForService().

#define GET_THREAD_MODE ( a,
b ) ( (a & (1<<b)) / (1<<b) )

Definition at line 111 of file macros.h.

Referenced by MC_End(), and mc_platform_Initialize().

#define MUTEX_LOCK ( mutex )

Value:

if (pthread_mutex_lock( mutex )) \
fprintf(stderr, "pthread lock error: %s:%d\n", __FILE__, __LINE__)

Definition at line 163 of file macros.h.

Referenced by acc_MessageHandlerThread(), acc_Thread(), agent_Copy(), agent_Destroy(), agent_mailbox_WaitRetrieve(), agent_RunChScriptThread(), ams_ManageAgentList(), ams_Print(), ams_Thread(), AP_QUEUE_SEARCH_TEMPLATE(), AP_QUEUE_STD_DEFN_TEMPLATE(), df_Destroy(), df_node_Destroy(), df_request_list_Pop(), df_SearchForService(), df_Thread(), interpreter_variable_data_Initialize(), listen_Thread(), MC_AddAgent(), MC_Barrier(), MC_CallAgentFunc(), MC_CallAgentFuncArg(), MC_CallAgentFuncV(), MC_CallAgentFuncVar(), MC_CondBroadcast(), MC_CondReset(), MC_CondSignal(), MC_CondWait(), MC_End(), MC_GetAgentName(), MC_GetAgentStatus(), MC_GetAllAgents(), MC_HaltAgency(), MC_MutexLock(), mc_platform_Initialize(), MC_PrintAgentCode(), MC_ResetSignal(), MC_ResumeAgency(), MC_RetrieveAgent(), MC_RetrieveAgentCode(), mc_rwlock_rdlock(), mc_rwlock_rdunlock(), mc_rwlock_wrlock(), mc_rwlock_wrunlock(), MC_SendSteerCommand(), MC_SetAgentStatus(), MC_Steer(), MC_SteerControl(), MC_SyncDelete(), MC_SyncInit(), MC_WaitAgent(), MC_WaitRetrieveAgent(), MC_WaitSignal(), message_queue_SendOutgoing(), and request_handler_DEREGISTER().

#define MUTEX_NEW ( mutex )

Value:

mutex = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t)); \
 if (mutex == NULL) \
 fprintf(stderr, "Memory Error. %s:%d\n", __FILE__,__LINE__); \

Definition at line 168 of file macros.h.

Referenced by agent_New().

#define MUTEX_UNLOCK ( mutex ) pthread_mutex_unlock( mutex )

Definition at line 166 of file macros.h.

Referenced by acc_MessageHandlerThread(), acc_Thread(), agent_mailbox_WaitRetrieve(), agent_RunChScriptThread(), ams_ManageAgentList(), ams_Print(), ams_Thread(), AP_QUEUE_SEARCH_TEMPLATE(), AP_QUEUE_STD_DEFN_TEMPLATE(), df_request_list_Pop(), df_SearchForService(), df_Thread(), interpreter_variable_data_Initialize(), listen_Thread(), MC_AddAgent(), MC_Barrier(), MC_CallAgentFunc(), MC_CallAgentFuncArg(), MC_CallAgentFuncV(), MC_CallAgentFuncVar(), MC_CondBroadcast(), MC_CondReset(), MC_CondSignal(), MC_CondWait(), MC_End(), MC_GetAgentName(), MC_GetAgentStatus(), MC_GetAllAgents(), MC_HaltAgency(), MC_MutexUnlock(), mc_platform_Initialize(), MC_PrintAgentCode(), MC_ResetSignal(), MC_ResumeAgency(), MC_RetrieveAgent(), MC_RetrieveAgentCode(), mc_rwlock_rdlock(), mc_rwlock_rdunlock(), mc_rwlock_wrlock(), mc_rwlock_wrunlock(), MC_SendSteerCommand(), MC_SetAgentStatus(), MC_Steer(), MC_SteerControl(), MC_SyncDelete(), MC_SyncInit(), MC_WaitAgent(), MC_WaitRetrieveAgent(), MC_WaitSignal(), message_queue_SendOutgoing(), and request_handler_DEREGISTER().

#define PTHREAD_STACK_SIZE 131072

Definition at line 134 of file macros.h.

#define RWLOCK_DESTROY ( rwlock ) mc_rwlock_destroy(rwlock)

Definition at line 250 of file macros.h.

Referenced by barrier_queue_Destroy().

#define RWLOCK_INIT ( rwlock ) mc_rwlock_init(rwlock)

Definition at line 242 of file macros.h.

Referenced by barrier_queue_New(), and syncListInit().

#define RWLOCK_RDLOCK ( rwlock ) mc_rwlock_rdlock(rwlock)

Definition at line 268 of file macros.h.

Referenced by barrier_queue_Get(), and syncListFind().

#define RWLOCK_RDUNLOCK ( rwlock ) mc_rwlock_rdunlock(rwlock)

Definition at line 270 of file macros.h.

Referenced by barrier_queue_Get(), and syncListFind().

#define RWLOCK_T mc_rwlock_t

Definition at line 235 of file macros.h.

Referenced by barrier_queue_New(), and syncListInit().

#define RWLOCK_WRLOCK ( rwlock ) mc_rwlock_wrlock(rwlock)

#define RWLOCK_WRUNLOCK ( rwlock ) mc_rwlock_wrunlock(rwlock)

#define SEMAPHORE_DESTROY ( sem ) sem_destroy(sem)

Definition at line 220 of file macros.h.

Referenced by syncListNodeDestroy().

#define SEMAPHORE_INIT ( sem ) sem_init(sem, 0, 0)

Definition at line 217 of file macros.h.

Referenced by syncListNodeInit(), and syncListNodeNew().

#define SEMAPHORE_POST ( sem ) sem_post(sem)

Definition at line 225 of file macros.h.

Referenced by MC_SemaphorePost().

#define SEMAPHORE_T sem_t

Definition at line 215 of file macros.h.

Referenced by syncListNodeInit(), and syncListNodeNew().

#define SEMAPHORE_WAIT ( sem ) sem_wait(sem)

Definition at line 223 of file macros.h.

Referenced by MC_SemaphoreWait().

#define SET_THREAD_OFF ( a,
b ) a = (a & (~(1<<b)))

Definition at line 115 of file macros.h.

Referenced by MC_SetThreadOff(), and MC_SetThreadsAllOff().

#define SET_THREAD_ON ( a,
b ) a = (a | (1<<b))

Definition at line 114 of file macros.h.

Referenced by MC_SetThreadOn(), and MC_SetThreadsAllOn().

#define SIGNAL ( cond,
mutex,
action )

Value:

pthread_mutex_lock( mutex ); \
action; \
pthread_cond_signal( cond ); \
pthread_mutex_unlock( mutex )

Definition at line 201 of file macros.h.

Referenced by agent_RunChScriptThread(), df_Add(), df_AddRequest(), and request_handler_SEARCH().

#define SLEEP_QUEUE ( queue )

Value:

if (pthread_mutex_lock( queue->thread_mutex )) \
printf("pthread lock error: %s:%d\n", __FILE__, __LINE__); \
pthread_cond_wait( queue->touched_signal, queue->thread_mutex )

Definition at line 288 of file macros.h.

#define SLEEP_RESET ( queue ) pthread_mutex_unlock( queue->thread_mutex )

Definition at line 292 of file macros.h.

#define STRUCT ( name,
members )

Value:

typedef struct name##_s { \
 members \
 } name##_t; \
typedef name##_t* name##_p;

Definition at line 119 of file macros.h.

#define THREAD_CANCEL ( thread_handle ) pthread_cancel( thread_handle )

Definition at line 144 of file macros.h.

Referenced by MC_End().

#define THREAD_CREATE ( thread_handle,
function,
arg )

Value:

pthread_create( \
 thread_handle, \
 &attr, \
 function, \
 (void*) arg \
 )

Definition at line 136 of file macros.h.

Referenced by acc_Start(), agent_RunChScript(), ams_Start(), cmd_prompt_Start(), and df_Start().

#define THREAD_JOIN ( thread_handle ) pthread_join( thread_handle, NULL )

Definition at line 147 of file macros.h.

Referenced by MC_End().

#define THREAD_T pthread_t

Definition at line 135 of file macros.h.

Referenced by agent_RunChScript().

#define WAKE_QUEUE ( queue,
action )

Value:

if (pthread_mutex_trylock( queue->lock ) == 0) { \
 action; \
 pthread_cond_signal( queue->cond); \
 pthread_mutex_unlock( queue->lock); \
 }

Definition at line 282 of file macros.h.

#define WARN ( message )

Value:

fprintf(stderr, "WARNING: "); \
 fprintf(stderr, message ); \
 fprintf(stderr, " %s:%d\n", __FILE__, __LINE__ )

Definition at line 450 of file macros.h.

Referenced by acc_MessageHandlerThread(), acc_Thread(), and message_InitializeFromAgent().


Generated on Tue Oct 28 17:03:23 2008 for Mobile-C by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /