/* 120 us - 90 us = 33 us */ void PrintC(char Char) { GIE_CHECK(); GET_MUTEX(); if (Char >= ASCII_BEGIN && Char <= ASCII_END) WRITE_UART(Char); GIVE_MUTEX(); }
/* 120 us - 90 us = 33 us */ void PrintC(char Char) { GIE_CHECK(); GET_MUTEX(); WRITE_UART(Char); GIVE_MUTEX(); }
/* 120 us - 90 us = 33 us */ void PrintCharacter(char Character) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer((tString *)&Character); GIVE_MUTEX(); }
void PrintStringAndThreeDecimals(tString * const pString1, unsigned int Value1, tString * const pString2, unsigned int Value2, tString * const pString3, unsigned int Value3) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString1); ToDecimalString(Value1,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(SPACE); WriteTxBuffer(pString2); ToDecimalString(Value2,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(SPACE); WriteTxBuffer(pString3); ToDecimalString(Value3,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(CR); GIVE_MUTEX(); }
void PrintW(const char *pString) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString); GIVE_MUTEX(); }
void PrintR(void) { GIE_CHECK(); GET_MUTEX(); WRITE_UART(CR); WRITE_UART(LN); GIVE_MUTEX(); }
void PrintString(const tString * pString) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString); GIVE_MUTEX(); }
NITFAPI(NITF_BOOL) nitf_PluginRegistry_loadDir(const char *dirName, nitf_Error * error) { NITF_BOOL status; /* first, get the registry */ nitf_PluginRegistry *reg = nitf_PluginRegistry_getInstance(error); /* must be thread safe */ nitf_Mutex_lock( GET_MUTEX() ); status = nitf_PluginRegistry_internalLoadDir(reg, dirName, error); /* unlock */ nitf_Mutex_unlock( GET_MUTEX() ); return status; }
void PrintString2(const tString * pString1, const tString * pString2) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString1); WriteTxBuffer(pString2); GIVE_MUTEX(); }
void PrintS(const char *pString) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString); WRITE_UART(CR); WRITE_UART(LN); GIVE_MUTEX(); }
void PrintDecimal(unsigned int Value) { GIE_CHECK(); GET_MUTEX(); ToDecimalString(Value,ConversionString); WriteTxBuffer(ConversionString); GIVE_MUTEX(); }
void PrintTimeStamp(void) { GIE_CHECK(); GET_MUTEX(); IntToHexString(RTCPS,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(SPACE); GIVE_MUTEX(); }
void PrintHex(unsigned char Value) { GIE_CHECK(); GET_MUTEX(); ByteToHexString(Value,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(SPACE); GIVE_MUTEX(); }
void PrintStringAndHexByte(tString * const pString,unsigned char Value) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString); ByteToHexString(Value,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(CR); GIVE_MUTEX(); }
void PrintStringAndDecimal(const tString * pString, unsigned int Value) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString); ToDecimalString(Value,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(CR); GIVE_MUTEX(); }
/* * pmemobj_mutex_trylock -- trylock a pmem resident mutex * * Atomically initializes and trylocks a PMEMmutex, otherwise behaves as its * POSIX counterpart. */ int pmemobj_mutex_trylock(PMEMobjpool *pop, PMEMmutex *mutexp) { LOG(3, "pop %p mutex %p", pop, mutexp); pthread_mutex_t *mutex = GET_MUTEX(pop, mutexp); if (mutex == NULL) return EINVAL; return pthread_mutex_trylock(mutex); }
/* * pmemobj_mutex_unlock -- unlock a pmem resident mutex */ int pmemobj_mutex_unlock(PMEMobjpool *pop, PMEMmutex *mutexp) { LOG(3, "pop %p mutex %p", pop, mutexp); /* XXX potential performance improvement - move GET to debug version */ pthread_mutex_t *mutex = GET_MUTEX(pop, mutexp); if (mutex == NULL) return EINVAL; return pthread_mutex_unlock(mutex); }
nitf_PluginRegistry_getInstance(nitf_Error * error) { static nitf_PluginRegistry *theInstance = NULL; /*nitf_Mutex mutex = GET_MUTEX();*/ /*nitf_Mutex_lock(&mutex);*/ if (theInstance == NULL) { nitf_Mutex_lock( GET_MUTEX()); /* If this call below fails, the error will have been */ /* constructed */ if (theInstance == NULL) { theInstance = implicitConstruct(error); /* If this succeeded... */ if (theInstance) { const NITF_BOOL loadedOK = nitf_PluginRegistry_load(theInstance, error); if (loadedOK) { atexit(exitListener); } else { /* Sorry, no go... */ implicitDestruct(&theInstance); } } } nitf_Mutex_unlock( GET_MUTEX()); } return theInstance; }
nitf_PluginRegistry_TREHandlerExists(const char* ident) { NITF_BOOL exists; nitf_Error error; /* first, get the registry */ nitf_PluginRegistry* const reg = nitf_PluginRegistry_getInstance(&error); if (reg == NULL) { return NITF_FAILURE; } /* must be thread safe */ nitf_Mutex_lock(GET_MUTEX()); exists = nitf_PluginRegistry_internalTREHandlerExists(reg, ident); /* unlock */ nitf_Mutex_unlock(GET_MUTEX()); return exists; }
void PrintH(unsigned char Value) { unsigned char MSB = Value >> 4; unsigned char LSB = Value & 0x0F; MSB += MSB > 9 ? 'A' - 10 : '0'; LSB += LSB > 9 ? 'A' - 10 : '0'; GIE_CHECK(); GET_MUTEX(); WRITE_UART(MSB); WRITE_UART(LSB); WRITE_UART(SPACE); GIVE_MUTEX(); }
void PrintSignedDecimalAndNewline(signed int Value) { GIE_CHECK(); GET_MUTEX(); if ( Value < 0 ) { Value = ~Value + 1; WriteTxBuffer("-"); } ToDecimalString(Value,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(CR); GIVE_MUTEX(); }
/* * This function is a garbage-collector. * It is called at exit time. In the event that the singleton * is properly returned, it destructs it. * * Since this function is only registered in the getInstance() * call in the first place, it is presumed to exist already, and * thereby need destruction. * */ NITFPRIV(void) exitListener(void) { nitf_Error error; nitf_Mutex* mutex = GET_MUTEX(); nitf_PluginRegistry *single = nitf_PluginRegistry_getInstance(&error); if (single) { int unloadRet = nitf_PluginRegistry_unload(single, &error); if (unloadRet) { implicitDestruct(&single); } } nitf_Mutex_delete(mutex); }
void PrintStringSpaceAndTwoDecimals(tString * const pString1, unsigned int Value1, unsigned int Value2) { GIE_CHECK(); GET_MUTEX(); WriteTxBuffer(pString1); WriteTxBuffer(SPACE); ToDecimalString(Value1,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(SPACE); ToDecimalString(Value2,ConversionString); WriteTxBuffer(ConversionString); WriteTxBuffer(CR); GIVE_MUTEX(); }
/* * pmemobj_mutex_assert_locked -- checks whether mutex is locked. * * Returns 0 when mutex is locked. */ int pmemobj_mutex_assert_locked(PMEMobjpool *pop, PMEMmutex *mutexp) { LOG(3, "pop %p mutex %p", pop, mutexp); pthread_mutex_t *mutex = GET_MUTEX(pop, mutexp); if (mutex == NULL) return EINVAL; int ret = pthread_mutex_trylock(mutex); if (ret == EBUSY) return 0; if (ret == 0) { util_mutex_unlock(mutex); /* * There's no good error code for this case. EINVAL is used for * something else here. */ return ENODEV; } return ret; }
static int QueryDNSListenUDP(void *ID){ socklen_t AddrLen; CompatibleAddr ClientAddr; int State; ThreadContext Context; char RequestEntity[1024]; InitContext(&Context, RequestEntity); /* Listen and accept requests */ while(TRUE) { memset(&ClientAddr, 0, sizeof(ClientAddr)); GET_MUTEX(ListenMutex); if( Family == AF_INET ) { AddrLen = sizeof(struct sockaddr); State = recvfrom(ListenSocketUDP, RequestEntity, sizeof(RequestEntity), 0, (struct sockaddr *)&(ClientAddr.Addr4), &AddrLen ); } else { AddrLen = sizeof(struct sockaddr_in6); State = recvfrom(ListenSocketUDP, RequestEntity, sizeof(RequestEntity), 0, (struct sockaddr *)&(ClientAddr.Addr6), &AddrLen ); } RELEASE_MUTEX(ListenMutex); if(State < 1) { if( ErrorMessages == TRUE ) { int ErrorNum = GET_LAST_ERROR(); char ErrorMessage[320]; ErrorMessage[0] ='\0'; GetErrorMsg(ErrorNum, ErrorMessage, sizeof(ErrorMessage)); if( Family == AF_INET ) { printf("An error occured while receiving from %s : %d : %s .\n", inet_ntoa(ClientAddr.Addr4.sin_addr), ErrorNum, ErrorMessage ); } else { char Addr[LENGTH_OF_IPV6_ADDRESS_ASCII] = {0}; IPv6AddressToAsc(&(ClientAddr.Addr6.sin6_addr), Addr); printf("An error occured while receiving from %s : %d : %s .\n", Addr, ErrorNum, ErrorMessage ); } } continue; } Context.RequestLength = State; Query(&Context, &ClientAddr); ExtendableBuffer_Reset(Context.ResponseBuffer); } return 0; }