Commit Graph

178 Commits

Author SHA1 Message Date
gingerBill f0683c9102 Merge branch 'master' into parser-experiments 2020-12-06 00:49:48 +00:00
gingerBill fd453be831 Deprecate opaque in favour of #opaque in the core library 2020-12-04 18:49:39 +00:00
Dan Bechard 58f768cb4f Update kernel32.odin
Fix typo in CreateProcessA/W mappings (https://github.com/odin-lang/Odin/issues/785)
2020-11-20 15:39:08 -08:00
gingerBill 7c5247f5fb Add package sys/cpu - implements processor feature detection 2020-11-06 00:39:09 +00:00
gingerBill 54fbdabc38 Add experimental -insert-semicolon functionality to tokenizer and parser 2020-11-01 15:10:06 +00:00
zhibog 05b58bdbb1 Fixed package name 2020-10-24 00:17:36 +02:00
zhibog 4c4112fbc7 Fixed getting windows version. The former function is no longer working on Windows 10. Also fixed the struct to use correct win32 names 2020-10-24 00:14:01 +02:00
gingerBill fa33476438 Improve default temp allocator; Fix filepath.abs behaviour on Windows 2020-10-13 14:40:13 +01:00
gingerBill 1818ceb4f2 Merge pull request #747 from Platin21/master
Fixes for MacOS 11 / Big Sur
2020-09-28 12:48:50 +01:00
gingerBill 9ae3879956 Add os.stat, os.lstat, os.fstat, filepath.walk 2020-09-28 12:28:02 +01:00
Platin21 a71cbd4087 Changed foreign imports to now use the System Framework 2020-09-27 21:57:27 +03:00
gingerBill 840af6825a Update packages os, path, and filepath 2020-09-26 16:02:03 +01:00
gingerBill 8cc5cd1494 Add package path/filepath; Add os.stat for windows (TODO: unix) 2020-09-25 20:20:53 +01:00
gingerBill fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
nakst c92860e142 update essence platform 2020-09-15 23:22:19 +01: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
gingerBill 7f48cf8405 [REFLECTION BREAKING] Modify the internals of the map type to increase performance 2020-09-07 11:41:42 +01:00
gingerBill 9cc20954a3 Add sys/windows/synchronization.odin 2020-08-02 15:07:52 +01:00
gingerBill 6d032e6f1a Update package sync 2020-08-02 15:01:17 +01: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 c4067372dd Fix double declaration 2020-07-10 22:28:48 +01:00
gingerBill 642afa4f88 Fix new package path 2020-07-10 08:42:22 +01:00
gingerBill f65fa0e4a6 Merge pull request #339 from dotbmp/master
"core:path" Path library and "core:strings" `split` Utilities
2020-07-10 08:25:24 +01: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
gingerBill 2b18f43b65 Update sys/windows; Add sync.Blocking_Mutex (windows only at the moment) 2020-06-27 00:59:40 +01:00
gingerBill 53e1512978 Add more exception handling stuff to sys/windows 2020-06-26 20:42:17 +01:00
gingerBill bb81d4869f Update sys/windows 2020-06-26 20:09:31 +01:00
gingerBill 6bd05ef5d7 Begin migration from sys/win32 to sys/windows 2020-06-26 19:11:34 +01:00
vassvik 9cccb20f49 Add some tests to test utf16_to_utf8 and wstring_to_utf8 2020-06-13 18:04:19 +02:00
vassvik 0056cdffa7 Reworked win32.utf16_to_utf8 and win32.wstring_to_utf8 to scan for zeros from the start of the string instead of from the end.
This is useful to correctly convert strings from a buffer possibly containing multiple multiple substrings.

The resulting utf8 string is not null terminated, even if the backing memory might be null terminated.
2020-06-13 15:19:41 +02:00
vassvik bbbf7168f1 Add wstring_to_utf8 to sys/win32 2020-06-12 21:06:21 +02:00
vassvik c15ed44f82 Fix off by one bug introduced in the previous commit. 2020-06-12 18:19:46 +02:00
gingerBill 58466a6f3b Add extra NUL termination check for string length in win32 general string convertors 2020-06-12 15:01:43 +01:00
gingerBill a3fa647bfd Add package sys/llvm to expose some of the LLVM intrinsics 2020-06-06 14:52:22 +01:00
gingerBill 117ade0700 Fix errors in package win32 2020-04-30 17:48:35 +01:00
Joe c83592629d Fixed duplicated WHITENESS value in BLACKNESS constant 2020-03-29 18:10:10 -04:00
Joe 2e3706e447 -Win32-
New
- Constants: WHITENESS & BLACKNESS, and WM_PAINT
- Methods: pat_blt, register_class_a, register_class_w, message_box_a, message_box_w, begin_paint, and end_paint
- Structs: Wnd_Class_A, Wnd_Class_W, Paint_Struct
Modified
- WM_INPUT : Capitalized alphabetical values for consistency with other values
2020-03-29 17:06:09 -04:00
gingerBill 2ce1f4ba9f Revert os_windows.odin behaviour 2020-03-12 23:37:24 +00:00
Tetralux 1181d7cf90 Fix os.read / os.read_entire_file
- DWORDs are NOT i32
- os.read didn't correctly read as much as it could
2020-03-12 22:31:00 +00:00
Tetralux 66d1656367 Add os.get_current_directory / os.set_current_directory 2020-01-20 14:28:31 +00: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
gingerBill 9db81498d8 Make the string type elements "immutable", akin to char const * in C
Allows for extra security and optimization benefits
2019-12-01 14:10:59 +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
nakst 22e982c8fb New Essence OS layer; cross-compiling improvements 2019-09-02 16:46:50 +01:00
gingerBill 2c5c8192f8 Fix parsing for procedure literals expression statements; improve assert performance; other minor fixes 2019-07-28 22:58:56 +01:00