/* sys/endthrea.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */

#if defined (__MT__)

#define INCL_DOS
#include <os2emx.h>
#include <emx/syscalls.h>
#include "syscalls.h"

int __endthread (int tid)
{
  thread_data *tp;

  if (tid < MAX_THREADS && _sys_thread_table[tid] != NULL)
    {
      tp = _sys_thread_table[tid];
      if (tp->fd.find_handle != HDIR_CREATE)
        DosFindClose (tp->fd.find_handle);
      DosSubFreeMem (_sys_private_heap, tp, sizeof (thread_data));
      _sys_thread_table[tid] = NULL;
    }
  return 0;
}

#endif
