genode/repos/libports/src/lib/pthread/thread_create.cc
Norman Feske ca971bbfd8 Move repositories to 'repos/' subdirectory
This patch changes the top-level directory layout as a preparatory
step for improving the tools for managing 3rd-party source codes.
The rationale is described in the issue referenced below.

Issue #1082
2014-05-14 16:08:00 +02:00

44 lines
984 B
C++

/*
* \brief pthread_create implementation
* \author Christian Prochaska
* \date 2012-03-12
*
* Purpose of a single file for pthread_create is that other application may
* easily replace this implementation with another one.
*/
/*
* Copyright (C) 2012-2014 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#include <base/env.h>
#include <errno.h>
#include <pthread.h>
#include "thread.h"
extern "C"
{
enum { STACK_SIZE=64*1024 };
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
pthread_t thread_obj = new (Genode::env()->heap())
pthread(attr ? *attr : 0, start_routine,
arg, STACK_SIZE, "pthread", nullptr);
if (!thread_obj)
return EAGAIN;
*thread = thread_obj;
thread_obj->start();
return 0;
}
}