Skip to content

Commit

Permalink
mac os : fix build error
Browse files Browse the repository at this point in the history
Signed-off-by:  Junyong Sim <junyong.sim@samsung.com>
  • Loading branch information
ejunu committed May 11, 2023
1 parent d7e5ff7 commit 72b4434
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/posix/ot_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static bool getRadioURL(char *comPort)
return false;
}

static int getInterface()
static int getInterface(void)
{
struct stat st;
int i = 0;
Expand Down Expand Up @@ -284,31 +284,33 @@ void otGetInstance(otInstance **instance, pthread_t *instanceId, const char *com

*instance = gInstance;
*instanceId = gThreadId;
#if defined(__linux)
otLogInfoPlat("After otThread : gThreadId[%ld]", gThreadId);
#endif

pthread_mutex_unlock(&gLock);

return;
}

void otWait()
void otWait(void)
{
otLogInfoPlat("otWait");
pthread_join(gThreadId, NULL);
}

void otLock()
void otLock(void)
{
otLogInfoPlat("otLock");
pthread_mutex_lock(&gLock);
}

void otUnlock()
void otUnlock(void)
{
otLogInfoPlat("otUnlock");
pthread_mutex_unlock(&gLock);
}
void otDestroyInstance()
void otDestroyInstance(void)
{
otLogInfoPlat("otDestroyInstance");
gTerminate = true;
Expand Down
12 changes: 12 additions & 0 deletions src/posix/platform/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,26 @@ OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const
nowtm = localtime(&nowtime);
strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm);

#if defined(__APPLE__)
int ret = snprintf(buf, sizeof buf, "%s.%06d", tmbuf, tv.tv_usec);
#else
int ret = snprintf(buf, sizeof buf, "%s.%06ld", tmbuf, tv.tv_usec);
#endif
if (ret < 0)
{
#if defined(__APPLE__)
printf("[%s][%d] openthread: %s\n", buf, getpid(), "failed to make log");
#else
printf("[%s][%d:%d] openthread: %s\n", buf, getpid(), gettid(), "failed to make log");
#endif
}
else
{
#if defined(__APPLE__)
printf("[%s][%d] openthread: %s\n", buf, getpid(), buffer);
#else
printf("[%s][%d:%d] openthread: %s\n", buf, getpid(), gettid(), buffer);
#endif
}
}
#else
Expand Down

0 comments on commit 72b4434

Please sign in to comment.