Cleaned up the use of thread types

The THREAD type was not used everywhere and pthread_t was used instead.
The thread creation function also returned the address of a stack allocated
value which isn't guaranteed to be usable.
This commit is contained in:
Markus Makela
2016-01-23 02:56:04 +02:00
parent da1a717dd8
commit 0111df3767
13 changed files with 79 additions and 43 deletions

View File

@ -16,7 +16,7 @@
* Copyright MariaDB Corporation Ab 2013-2014
*/
#include <thread.h>
#include <pthread.h>
/**
* @file thread.c - Implementation of thread related operations
*
@ -33,20 +33,18 @@
/**
* Start a polling thread
*
* @param entry The entry point to call
* @param arg The argument to pass the thread entry point
* @return The thread handle
* @param thd Pointer to the THREAD object
* @param entry The entry point to call
* @param arg The argument to pass the thread entry point
* @return The thread handle or NULL if an error occurred
*/
void *
thread_start(void (*entry)(void *), void *arg)
THREAD *thread_start(THREAD *thd, void (*entry)(void *), void *arg)
{
pthread_t thd;
if (pthread_create(&thd, NULL, (void *(*)(void *))entry, arg) != 0)
if (pthread_create(thd, NULL, (void *(*)(void *))entry, arg) != 0)
{
return NULL;
}
return (void *)thd;
return thd;
}
/**
@ -55,7 +53,7 @@ thread_start(void (*entry)(void *), void *arg)
* @param thd The thread handle
*/
void
thread_wait(void *thd)
thread_wait(THREAD thd)
{
void *rval;
@ -71,7 +69,6 @@ void
thread_millisleep(int ms)
{
struct timespec req;
req.tv_sec = ms / 1000;
req.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&req, NULL);