Commit Graph

46 Commits

Author SHA1 Message Date
Jeroen van Rijn
a70ea6579d Silence -vet. 2022-09-05 18:55:33 +02:00
Jeroen van Rijn
426f02906b [sys/info] Add OpenBSD detection support. 2022-09-04 20:37:38 +02:00
Jeroen van Rijn
3f3f4fafff [sys/info] Move FreeBSD sysctl to sys/unix. 2022-09-03 16:53:03 +02:00
Jeroen van Rijn
4eafb0ce7f [sys/info] Move macOS sysctl to sys/unix. 2022-09-03 16:30:31 +02:00
Jeroen van Rijn
0171c276f0 [sys/info] Support FreeBSD 13 2022-09-03 02:33:36 +02:00
gingerBill
cb9e16f4df Correct syscalls for linux_i386 2022-08-24 12:37:56 +01:00
gingerBill
2908923db9 Fix #1972 2022-08-24 12:18:42 +01:00
jason
fff23e2bbb merge from upstream and convert to ^File types 2022-05-16 13:49:57 -04:00
gingerBill
33895b6d92 Convert all uses of *_from_slice to *_from_bytes where appropriate 2022-05-16 01:43:43 +01:00
gingerBill
2dd181e663 Remove duplication 2022-05-12 15:48:27 +01:00
gingerBill
f002857edc Clean up core:time to be consistent across all platforms 2022-05-12 15:47:24 +01:00
Jeroen van Rijn
8fb718245a Implement pthread_cancel. 2022-05-11 15:52:04 +02:00
gingerBill
be8de4a1ff Update arch enum 2022-05-01 23:52:55 +01:00
CiD-
5bc8164274 add mremap + flags 2022-04-26 17:11:30 -04:00
CiD-
1a2c36e482 whoops 2022-04-08 13:52:36 -04:00
CiD-
9ae566adcc commit before fetching upstream/master 2022-04-08 13:45:19 -04:00
CiD-
88de3a1c06 add _chtimes 2022-04-01 22:41:35 -04:00
CiD-
b21e7e4518 rewrite mkdir_all 2022-03-14 15:44:34 -04:00
CiD-
1f4e5e919f merge upstream/master 2022-03-14 13:36:22 -04:00
CiD-
c293e88f2e commit to merge upstream/master 2022-03-14 13:34:06 -04:00
gingerBill
633157f4f8 Merge pull request #1613 from semarie/linux_arm64
fix Linux arm64 support
2022-03-14 11:37:45 +00:00
Sébastien Marie
ca67cf032c freebsd_amd64 support 2022-03-13 11:42:42 +00:00
Sébastien Marie
8982ae34e3 fix linux_arm64
- SYS_fork doesn't exist, uses SYS_clone
- properly cast AT_FDCWD to uintptr
2022-03-12 09:19:52 +00:00
Jason Kercher
b91c0ec715 Merge remote-tracking branch 'upstream/master' into os2_linux 2022-03-10 09:34:48 -05:00
jasonkercher
1f19610fd6 added _remove_all 2022-03-07 17:16:03 -05:00
jasonkercher
658a605c75 compiles 2022-03-04 17:11:53 -05:00
CiD-
e51bb4ef12 os2 linux begin 2022-03-03 10:16:36 -05:00
Sébastien Marie
5676c9e7eb initial OpenBSD support 2022-02-25 08:49:25 +00:00
gingerBill
3d7d347192 Convert ODIN_OS and ODIN_ARCH to use enums rather than use strings 2022-01-20 19:56:05 +00:00
gingerBill
29ebe0c3c9 Rename architecture 386 to i386 2022-01-15 17:40:00 +00:00
CiD-
38e5e13b3f add more Linux syscalls 2022-01-03 09:24:39 -05:00
Yawning Angel
61c581baeb core/sys/unix: Add syscalls_linux.odin
Linux is in the unfortunate situation where the system call number is
architecture specific.  This consolidates the system call number
definitions in a single location, adds some wrappers, and hopefully
fixes the existing non-portable invocations of the syscall intrinsic.
2021-11-17 14:00:00 +00:00
gingerBill
f38b7ebf42 Begin adding vendor:miniaudio 2021-09-17 12:57:52 +01:00
gingerBill
ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill
fe33a64b2e Remove #opaque usage in core library 2021-02-23 15:21:05 +00:00
gingerBill
fd453be831 Deprecate opaque in favour of #opaque in the core library 2020-12-04 18:49:39 +00:00
Christian Seibold
a13eed9894 Cleanup, check sched_param and SCHED_* constants in pthread_freebsd.odin 2020-09-15 01:34:01 -05:00
Christian Seibold
65787381c1 Change sizes of pthread types for freebsd 2020-09-14 16:48:55 -05:00
Christian Seibold
577be4a8ae Get Odin compiling and produced exe's running on FreeBSD 2020-09-14 15:22:35 -05:00
Clay Murray
83eabe2140 Fix pthread_t on Macos.
From some testing with directly using C code, pthread_t on macos is 8 bytes.
This is my test code:

```
#include <assert.h>
#include <stdio.h>

#include <pthread.h>



void* PosixThreadMainRoutine(void* data)

{

	// Do some work here.
	for (int i = 0; i < 2000000000; i++) {

	}



	return NULL;

}



pthread_t LaunchThread()

{

	// Create the thread using POSIX routines.

	pthread_attr_t  attr;

	pthread_t       posixThreadID;

	int             returnVal;



	returnVal = pthread_attr_init(&attr);

	assert(!returnVal);

	returnVal = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

	assert(!returnVal);



	int     threadError = pthread_create(&posixThreadID, &attr, &PosixThreadMainRoutine, NULL);



	returnVal = pthread_attr_destroy(&attr);

	assert(!returnVal);

	if (threadError != 0)

	{

		// Report an error.

	}

	return posixThreadID;

}

int main() {
	pthread_t t = LaunchThread();

	void ** ret;


	printf("%d, %d\n", sizeof(t), sizeof(pthread_t));

	int val = pthread_join(t, ret);


	printf("%d", val);
	return 0;
}
```
running this on macos reports `8, 8`. 
Then I made the proposed changes and errors I was having with threads completely went away.
2020-07-11 18:22:56 -06:00
gingerBill
858c5f8fd8 Update thread_unix logic 2020-06-27 11:36:48 +01:00
gingerBill
f92b4c7849 Update sys/unix; Rename thread.create_and_start 2020-06-27 11:26:38 +01:00
KTRosenberg
673879d1d2 added note about pthread_yield 2020-01-02 16:44:30 -05:00
KTRosenberg
d017b5de9d replaced pthread_yield with ssched_yield, fixed semaphore post:q 2020-01-02 16:25:48 -05:00
gingerBill
3bd00fd6b7 Add thread.Pool with example in demo.odin; Update linalg to support handness changes for projection matrices 2020-01-02 15:07:12 +00:00
Tetralux
99121d6ff2 Implement core:thread and core:sync on Unix using pthreads
Also do some cleanup and refactoring of the thread, sync and time APIs.

- remove 'semaphore_release' because 'post' and 'wait' is easier to understand

- change 'semaphore_wait' to '*_wait_for' to match Condition

- pthreads can be given a stack, but doing so requires the user to set up the guard
  pages manually. BE WARNED. The alignment requirements of the stack are also
  platform-dependant; it may need to be page size aligned on some systems.
  Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'.
  HOWEVER: I was unable to get custom stacks with guard pages working reliably,
  so while you can do it, the API does not support it.

- add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'.

- removed thread return values because windows and linux are not consistent; windows returns 'i32'
  and pthreads return 'void*'; besides which, if you really wanted to communicate how the
  thread exited, you probably wouldn't do it with the thread's exit code.

- fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'.

- moved time related stuff out of 'core:os' to 'core:time'.

- add 'mem.align_backward'

- fixed default allocator alignment
  The heap on Windows, and calloc on Linux, both have no facility to request alignment.
  It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes,
  and aligns things to at least 2.
  It does both of these things to ensure that there is at least two bytes before the payload,
  which it uses to store how much padding it needed to insert in order to fulfil the alignment
  requested.

- make conditions more sane by matching the Windows behaviour.
  The fact that they were signalled now lingers until a thread tries to wait,
  causing them to just pass by uninterrupted, without sleeping or locking the
  underlying mutex, as it would otherwise need to do.
  This means that a thread no longer has to be waiting in order to be signalled, which
  avoids timing bugs that causes deadlocks that are hard to debug and fix.
  See the comment on the `sync.Condition.flag` field.

- add thread priority: `thread.create(worker_proc, .High)`
2019-12-01 00:46:23 +00:00