Instead of hardcoding the function name.
Reported-by: checkpatch(1)
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
static void
func1(void)
{
- printf("func1: started\en");
- printf("func1: swapcontext(&uctx_func1, &uctx_func2)\en");
+ printf("%s: started\en", __func__);
+ printf("%s: swapcontext(&uctx_func1, &uctx_func2)\en", __func__);
if (swapcontext(&uctx_func1, &uctx_func2) == \-1)
handle_error("swapcontext");
- printf("func1: returning\en");
+ printf("%s: returning\en", __func__);
}
static void
func2(void)
{
- printf("func2: started\en");
- printf("func2: swapcontext(&uctx_func2, &uctx_func1)\en");
+ printf("%s: started\en", __func__);
+ printf("%s: swapcontext(&uctx_func2, &uctx_func1)\en", __func__);
if (swapcontext(&uctx_func2, &uctx_func1) == \-1)
handle_error("swapcontext");
- printf("func2: returning\en");
+ printf("%s: returning\en", __func__);
}
int
uctx_func2.uc_link = (argc > 1) ? NULL : &uctx_func1;
makecontext(&uctx_func2, func2, 0);
- printf("main: swapcontext(&uctx_main, &uctx_func2)\en");
+ printf("%s: swapcontext(&uctx_main, &uctx_func2)\en", __func__);
if (swapcontext(&uctx_main, &uctx_func2) == \-1)
handle_error("swapcontext");
- printf("main: exiting\en");
+ printf("%s: exiting\en", __func__);
exit(EXIT_SUCCESS);
}
.EE
}
free(p);
- printf("main(): returned from first free() call\en");
+ printf("%s(): returned from first free() call\en", __func__);
free(p);
- printf("main(): returned from second free() call\en");
+ printf("%s(): returned from second free() call\en", __func__);
exit(EXIT_SUCCESS);
}
if (s != 0)
handle_error_en(s, "pthread_setcancelstate");
- printf("thread_func(): started; cancelation disabled\en");
+ printf("%s(): started; cancelation disabled\en", __func__);
sleep(5);
- printf("thread_func(): about to enable cancelation\en");
+ printf("%s(): about to enable cancelation\en", __func__);
s = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
if (s != 0)
/* Should never get here. */
- printf("thread_func(): not canceled!\en");
+ printf("%s(): not canceled!\en", __func__);
return NULL;
}
sleep(2); /* Give thread a chance to get started */
- printf("main(): sending cancelation request\en");
+ printf("%s(): sending cancelation request\en", __func__);
s = pthread_cancel(thr);
if (s != 0)
handle_error_en(s, "pthread_cancel");
handle_error_en(s, "pthread_join");
if (res == PTHREAD_CANCELED)
- printf("main(): thread was canceled\en");
+ printf("%s(): thread was canceled\en", __func__);
else
- printf("main(): thread wasn\(aqt canceled (shouldn\(aqt happen!)\en");
+ printf("%s(): thread wasn\(aqt canceled (shouldn\(aqt happen!)\en",
+ __func__);
exit(EXIT_SUCCESS);
}
.EE
ts.tv_sec += atoi(argv[2]);
- printf("main() about to call sem_timedwait()\en");
+ printf("%s() about to call sem_timedwait()\en", __func__);
while ((s = sem_timedwait(&sem, &ts)) == \-1 && errno == EINTR)
continue; /* Restart if interrupted by handler. */