ObjFW  Diff

Differences From Artifact [eefc937c4b]:

To Artifact [89698eef26]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

43





44

45
46
47
48
49
50
51
#include "config.h"

#import "macros.h"

bool
of_thread_attr_init(of_thread_attr_t *attr)
{
	attr->priority =
	    (float)(THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST) /
	    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
	attr->stackSize = 0;

	return true;
}

bool
of_thread_new(of_thread_t *thread, void (*function)(id), id object,
    const of_thread_attr_t *attr)
{
	size_t stackSize = 0;
	int priority = 0;

	if (attr != NULL) {
		if (attr->priority < 0 || attr->priority > 1)
			return false;


		priority = THREAD_PRIORITY_LOWEST + attr->priority *





		    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);

		stackSize = attr->stackSize;
	}

	*thread = CreateThread(NULL, stackSize,
	    (LPTHREAD_START_ROUTINE)function, (__bridge void*)object, 0, NULL);

	if (thread == NULL)







|
<
<













|


>
|
>
>
>
>
>
|
>







17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "config.h"

#import "macros.h"

bool
of_thread_attr_init(of_thread_attr_t *attr)
{
	attr->priority = 0;


	attr->stackSize = 0;

	return true;
}

bool
of_thread_new(of_thread_t *thread, void (*function)(id), id object,
    const of_thread_attr_t *attr)
{
	size_t stackSize = 0;
	int priority = 0;

	if (attr != NULL) {
		if (attr->priority < -1 || attr->priority > 1)
			return false;

		if (attr->priority < 0)
			priority = THREAD_PRIORITY_LOWEST +
			    (1.0 + attr->priority) *
			    (THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST);
		else
			priority = THREAD_PRIORITY_NORMAL +
			    attr->priority *
			    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_NORMAL);

		stackSize = attr->stackSize;
	}

	*thread = CreateThread(NULL, stackSize,
	    (LPTHREAD_START_ROUTINE)function, (__bridge void*)object, 0, NULL);

	if (thread == NULL)