mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Render examples.
This commit is contained in:
+13
-12
@@ -1,17 +1,6 @@
|
|||||||
// A small `GZIP` unpacker.
|
|
||||||
package compress_gzip
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
A small `GZIP` unpacker.
|
||||||
Made available under Odin's BSD-3 license.
|
|
||||||
|
|
||||||
List of contributors:
|
|
||||||
Jeroen van Rijn: Initial implementation.
|
|
||||||
Ginger Bill: Cosmetic changes.
|
|
||||||
|
|
||||||
A small GZIP implementation as an example.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Example:
|
Example:
|
||||||
import "core:bytes"
|
import "core:bytes"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
@@ -88,4 +77,16 @@ Example:
|
|||||||
}
|
}
|
||||||
bytes.buffer_destroy(&buf)
|
bytes.buffer_destroy(&buf)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
package compress_gzip
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
|
Made available under Odin's BSD-3 license.
|
||||||
|
|
||||||
|
List of contributors:
|
||||||
|
Jeroen van Rijn: Initial implementation.
|
||||||
|
Ginger Bill: Cosmetic changes.
|
||||||
|
|
||||||
|
A small GZIP implementation as an example.
|
||||||
*/
|
*/
|
||||||
+12
-11
@@ -1,16 +1,6 @@
|
|||||||
// `Deflate` decompression of raw and `ZLIB`-type streams.
|
|
||||||
package compress_zlib
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
`Deflate` decompression of raw and `ZLIB`-type streams.
|
||||||
Made available under Odin's BSD-3 license.
|
|
||||||
|
|
||||||
List of contributors:
|
|
||||||
Jeroen van Rijn: Initial implementation.
|
|
||||||
|
|
||||||
An example of how to use `zlib.inflate`.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Example:
|
Example:
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -49,4 +39,15 @@ Example:
|
|||||||
fmt.printf("Input: %v bytes, output (%v bytes):\n%v\n", len(ODIN_DEMO), len(s), s)
|
fmt.printf("Input: %v bytes, output (%v bytes):\n%v\n", len(ODIN_DEMO), len(s), s)
|
||||||
assert(len(s) == OUTPUT_SIZE)
|
assert(len(s) == OUTPUT_SIZE)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
package compress_zlib
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
|
Made available under Odin's BSD-3 license.
|
||||||
|
|
||||||
|
List of contributors:
|
||||||
|
Jeroen van Rijn: Initial implementation.
|
||||||
|
|
||||||
|
An example of how to use `zlib.inflate`.
|
||||||
*/
|
*/
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// A dynamically-sized array of bits.
|
|
||||||
package container_dynamic_bit_array
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
A dynamically-sized array of bits.
|
||||||
|
|
||||||
The Bit Array can be used in several ways:
|
The Bit Array can be used in several ways:
|
||||||
|
|
||||||
By default you don't need to instantiate a Bit Array.
|
By default you don't need to instantiate a `Bit_Array`.
|
||||||
Example:
|
Example:
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@@ -21,11 +20,11 @@ Example:
|
|||||||
|
|
||||||
// returns `false`, `false`, because this Bit Array wasn't created to allow negative indices.
|
// returns `false`, `false`, because this Bit Array wasn't created to allow negative indices.
|
||||||
was_set, was_retrieved := get(&bits, -1)
|
was_set, was_retrieved := get(&bits, -1)
|
||||||
fmt.println(was_set, was_retrieved)
|
fmt.println(was_set, was_retrieved)
|
||||||
destroy(&bits)
|
destroy(&bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
A Bit Array can optionally allow for negative indices, if the minimum value was given during creation.
|
A `Bit_Array` can optionally allow for negative indices, if the minimum value was given during creation.
|
||||||
Example:
|
Example:
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@@ -51,4 +50,5 @@ Example:
|
|||||||
fmt.printf("Get(Negative_Test): %v, %v\n", get(bits, Foo.Negative_Test))
|
fmt.printf("Get(Negative_Test): %v, %v\n", get(bits, Foo.Negative_Test))
|
||||||
fmt.printf("Freed.\n")
|
fmt.printf("Freed.\n")
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
package container_dynamic_bit_array
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
// An intrusive doubly-linked list.
|
|
||||||
package container_intrusive_list
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Package list implements an intrusive doubly-linked list.
|
An intrusive doubly-linked list.
|
||||||
|
|
||||||
An intrusive container requires a `Node` to be embedded in your own structure, like this.
|
The intrusive container requires a `Node` to be embedded in your own structure, like this.
|
||||||
Example:
|
Example:
|
||||||
My_String :: struct {
|
My_String :: struct {
|
||||||
node: list.Node,
|
node: list.Node,
|
||||||
@@ -48,4 +45,5 @@ Example:
|
|||||||
Output:
|
Output:
|
||||||
Hello
|
Hello
|
||||||
World
|
World
|
||||||
*/
|
*/
|
||||||
|
package container_intrusive_list
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
// A dynamic array-like interface on a stack-allocated, fixed-size array.
|
|
||||||
package container_small_array
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The Small_Array type is optimal for scenarios where you need
|
A dynamic array-like interface on a stack-allocated, fixed-size array.
|
||||||
|
|
||||||
|
The `Small_Array` type is optimal for scenarios where you need
|
||||||
a container for a fixed number of elements of a specific type,
|
a container for a fixed number of elements of a specific type,
|
||||||
with the total number known at compile time but the exact
|
with the total number known at compile time but the exact
|
||||||
number to be used determined at runtime.
|
number to be used determined at runtime.
|
||||||
@@ -33,7 +32,7 @@ Example:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// the Small_Array can be an ordinary parameter 'generic' over
|
// the `Small_Array` can be an ordinary parameter 'generic' over
|
||||||
// the actual length to be usable with different sizes
|
// the actual length to be usable with different sizes
|
||||||
print_elements :: proc(arr: ^small_array.Small_Array($N, rune)) {
|
print_elements :: proc(arr: ^small_array.Small_Array($N, rune)) {
|
||||||
for r in small_array.slice(arr) {
|
for r in small_array.slice(arr) {
|
||||||
@@ -51,4 +50,5 @@ Output:
|
|||||||
|
|
||||||
Hellope
|
Hellope
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
package container_small_array
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// A reader for the Windows `PE` executable format for debug purposes.
|
|
||||||
package debug_pe
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// A reader for the Windows `PE` executable format for debug purposes.
|
||||||
package debug_pe
|
package debug_pe
|
||||||
|
|
||||||
PE_SIGNATURE_OFFSET_INDEX_POS :: 0x3c
|
PE_SIGNATURE_OFFSET_INDEX_POS :: 0x3c
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Stack trace library. Only works when debug symbols are enabled using `-debug`.
|
|
||||||
package debug_trace
|
|
||||||
/*
|
/*
|
||||||
|
Stack trace library. Only works when debug symbols are enabled using `-debug`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:debug/trace"
|
import "core:debug/trace"
|
||||||
@@ -47,4 +47,5 @@ Example:
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
package debug_trace
|
||||||
@@ -44,4 +44,4 @@ main :: proc() {
|
|||||||
fmt.println("84 - 13 =", sym.sub(84, 13))
|
fmt.println("84 - 13 =", sym.sub(84, 13))
|
||||||
fmt.println("hellope =", sym.hellope^)
|
fmt.println("hellope =", sym.hellope^)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
// `Base32` encoding and decoding, as specified in `RFC 4648`.
|
/*
|
||||||
|
`Base32` encoding and decoding, as specified in `RFC 4648`.
|
||||||
|
|
||||||
|
[[ RFC 4648; https://www.rfc-editor.org/rfc/rfc4648.html ]]
|
||||||
|
|
||||||
|
A secondary param can be used to supply a custom alphabet to `encode` and a matching decoding table to `decode`.
|
||||||
|
|
||||||
|
If none is supplied it just uses the standard Base32 alphabet.
|
||||||
|
In case your specific version does not use padding, you may
|
||||||
|
truncate it from the encoded output.
|
||||||
|
|
||||||
|
Error represents errors that can occur during base32 decoding operations.
|
||||||
|
As per RFC 4648:
|
||||||
|
- Section 3.3: Invalid character handling
|
||||||
|
- Section 3.2: Padding requirements
|
||||||
|
- Section 6: Base32 encoding specifics (including block size requirements)
|
||||||
|
*/
|
||||||
package encoding_base32
|
package encoding_base32
|
||||||
|
|
||||||
// Base32 encoding/decoding implementation as specified in RFC 4648.
|
|
||||||
// [[ More; https://www.rfc-editor.org/rfc/rfc4648.html ]]
|
|
||||||
|
|
||||||
|
|
||||||
// @note(zh): Encoding utility for Base32
|
|
||||||
// A secondary param can be used to supply a custom alphabet to
|
|
||||||
// @link(encode) and a matching decoding table to @link(decode).
|
|
||||||
// If none is supplied it just uses the standard Base32 alphabet.
|
|
||||||
// In case your specific version does not use padding, you may
|
|
||||||
// truncate it from the encoded output.
|
|
||||||
|
|
||||||
// Error represents errors that can occur during base32 decoding operations.
|
|
||||||
// As per RFC 4648:
|
|
||||||
// - Section 3.3: Invalid character handling
|
|
||||||
// - Section 3.2: Padding requirements
|
|
||||||
// - Section 6: Base32 encoding specifics (including block size requirements)
|
|
||||||
Error :: enum {
|
Error :: enum {
|
||||||
None,
|
None,
|
||||||
Invalid_Character, // Input contains characters outside the specified alphabet
|
Invalid_Character, // Input contains characters outside the specified alphabet
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
// `Base64` encoding and decoding.
|
/*
|
||||||
|
`Base64` encoding and decoding.
|
||||||
|
|
||||||
|
A secondary param can be used to supply a custom alphabet to `encode` and a matching decoding table to `decode`.
|
||||||
|
|
||||||
|
If none is supplied it just uses the standard Base64 alphabet.
|
||||||
|
In case your specific version does not use padding, you may
|
||||||
|
truncate it from the encoded output.
|
||||||
|
*/
|
||||||
package encoding_base64
|
package encoding_base64
|
||||||
|
|
||||||
import "core:io"
|
import "core:io"
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
|
||||||
// @note(zh): Encoding utility for Base64
|
|
||||||
// A secondary param can be used to supply a custom alphabet to
|
|
||||||
// @link(encode) and a matching decoding table to @link(decode).
|
|
||||||
// If none is supplied it just uses the standard Base64 alphabet.
|
|
||||||
// Incase your specific version does not use padding, you may
|
|
||||||
// truncate it from the encoded output.
|
|
||||||
|
|
||||||
ENC_TABLE := [64]byte {
|
ENC_TABLE := [64]byte {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Encoding and decoding types from/into `RCF 8949` compatible `CBOR` binary.
|
|
||||||
package encoding_cbor
|
|
||||||
/*
|
/*
|
||||||
Package cbor encodes, decodes, marshals and unmarshals types from/into RCF 8949 compatible CBOR binary.
|
Encodes and decodes types from/into `RCF 8949` compatible `CBOR` binary.
|
||||||
|
|
||||||
Also provided are conversion to and from JSON and the CBOR diagnostic format.
|
Also provided are conversion to and from JSON and the CBOR diagnostic format.
|
||||||
|
|
||||||
**Allocations:**
|
**Allocations:**
|
||||||
@@ -166,4 +165,5 @@ Output:
|
|||||||
"renamed :)": 123123.12500000,
|
"renamed :)": 123123.12500000,
|
||||||
"str": "Hello, World!"
|
"str": "Hello, World!"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
package encoding_cbor
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Encoding and decoding JSON in strict `JSON`, `JSON5` and `BitSquid` variants.
|
|
||||||
package encoding_json
|
|
||||||
|
|
||||||
import "core:strings"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
JSON
|
Encoding and decoding JSON in strict `JSON`, `JSON5` and `BitSquid` variants.
|
||||||
|
|
||||||
|
Using one of these `Specification`s.
|
||||||
|
JSON
|
||||||
strict JSON
|
strict JSON
|
||||||
JSON5
|
JSON5
|
||||||
pure superset of JSON and valid JavaScript
|
pure superset of JSON and valid JavaScript
|
||||||
https://json5.org/
|
https://json5.org/
|
||||||
|
|
||||||
* Object keys may be an ECMAScript 5.1 IdentifierName.
|
* Object keys may be an ECMAScript 5.1 IdentifierName.
|
||||||
* Objects may have a single trailing comma.
|
* Objects may have a single trailing comma.
|
||||||
* Arrays may have a single trailing comma.
|
* Arrays may have a single trailing comma.
|
||||||
@@ -22,17 +20,21 @@ import "core:strings"
|
|||||||
* Numbers may begin with an explicit plus sign.
|
* Numbers may begin with an explicit plus sign.
|
||||||
* Single and multi-line comments are allowed.
|
* Single and multi-line comments are allowed.
|
||||||
* Additional white space characters are allowed.
|
* Additional white space characters are allowed.
|
||||||
|
|
||||||
MJSON
|
MJSON
|
||||||
pure superset of JSON5, may not be valid JavaScript
|
pure superset of JSON5, may not be valid JavaScript
|
||||||
https://bitsquid.blogspot.com/2009/10/simplified-json-notation.html
|
https://bitsquid.blogspot.com/2009/10/simplified-json-notation.html
|
||||||
|
|
||||||
* All the same features as JSON5 plus extras.
|
* All the same features as JSON5 plus extras.
|
||||||
* Assume an object definition at the root level (no need to surround entire file with { } ).
|
* Assume an object definition at the root level (no need to surround entire file with { } ).
|
||||||
* Commas are optional, using comma insertion rules with newlines.
|
* Commas are optional, using comma insertion rules with newlines.
|
||||||
* Quotes around object keys are optional if the keys are valid identifiers.
|
* Quotes around object keys are optional if the keys are valid identifiers.
|
||||||
* : can be replaced with =
|
* : can be replaced with =
|
||||||
*/
|
*/
|
||||||
|
package encoding_json
|
||||||
|
|
||||||
|
import "core:strings"
|
||||||
|
|
||||||
Specification :: enum {
|
Specification :: enum {
|
||||||
JSON,
|
JSON,
|
||||||
JSON5, // https://json5.org/
|
JSON5, // https://json5.org/
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
`LEB128` variable integer encoding and decoding, as used by `DWARF` & `DEX` files.
|
`LEB128` variable integer encoding and decoding, as used by `DWARF` & `DEX` files.
|
||||||
|
|
||||||
Author of this Odin package: Jeroen van Rijn
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -24,4 +22,4 @@ Example:
|
|||||||
fmt.printf("Decoded as %v, using %v byte%v\n", decoded_val, decode_size, "" if decode_size == 1 else "s")
|
fmt.printf("Decoded as %v, using %v byte%v\n", decoded_val, decode_size, "" if decode_size == 1 else "s")
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
package encoding_varint
|
package encoding_varint
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package encoding_varint
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
Made available under Odin's BSD-3 license.
|
Made available under Odin's BSD-3 license.
|
||||||
@@ -6,8 +8,6 @@
|
|||||||
Jeroen van Rijn: Initial implementation.
|
Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package encoding_varint
|
|
||||||
|
|
||||||
// In theory we should use the bigint package. In practice, varints bigger than this indicate a corrupted file.
|
// In theory we should use the bigint package. In practice, varints bigger than this indicate a corrupted file.
|
||||||
// Instead we'll set limits on the values we'll encode/decode
|
// Instead we'll set limits on the values we'll encode/decode
|
||||||
// 18 * 7 bits = 126, which means that a possible 19th byte may at most be `0b0000_0011`.
|
// 18 * 7 bits = 126, which means that a possible 19th byte may at most be `0b0000_0011`.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
A parser for a useful subset of the `XML` specification.
|
A parser for a useful subset of the `XML` specification.
|
||||||
|
|
||||||
A from-scratch XML implementation, loosely modelled on the [[ spec; https://www.w3.org/TR/2006/REC-xml11-20060816 ]].
|
A from-scratch `XML` implementation, loosely modelled on the [[ spec; https://www.w3.org/TR/2006/REC-xml11-20060816 ]].
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
- Supports enough of the XML 1.0/1.1 spec to handle the 99.9% of XML documents in common current usage.
|
- Supports enough of the XML 1.0/1.1 spec to handle the 99.9% of XML documents in common current usage.
|
||||||
@@ -11,8 +11,8 @@ Caveats:
|
|||||||
- We do NOT support HTML in this package, as that may or may not be valid XML.
|
- We do NOT support HTML in this package, as that may or may not be valid XML.
|
||||||
If it works, great. If it doesn't, that's not considered a bug.
|
If it works, great. If it doesn't, that's not considered a bug.
|
||||||
|
|
||||||
- We do NOT support UTF-16. If you have a UTF-16 XML file, please convert it to UTF-8 first. Also, our condolences.
|
- We do NOT support `UTF-16`. If you have a `UTF-16` XML file, please convert it to `UTF-8` first. Also, our condolences.
|
||||||
- <[!ELEMENT and <[!ATTLIST are not supported, and will be either ignored or return an error depending on the parser options.
|
- `<[!ELEMENT` and `<[!ATTLIST` are not supported, and will be either ignored or return an error depending on the parser options.
|
||||||
|
|
||||||
MAYBE:
|
MAYBE:
|
||||||
- XML writer?
|
- XML writer?
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
package encoding_xml
|
||||||
/*
|
/*
|
||||||
|
An XML 1.0 / 1.1 parser
|
||||||
|
|
||||||
2021-2022 Jeroen van Rijn <nom@duclavier.com>.
|
2021-2022 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
available under Odin's BSD-3 license.
|
available under Odin's BSD-3 license.
|
||||||
|
|
||||||
@@ -6,9 +9,6 @@
|
|||||||
- Jeroen van Rijn: Initial implementation.
|
- Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package encoding_xml
|
|
||||||
// An XML 1.0 / 1.1 parser
|
|
||||||
|
|
||||||
import "core:bytes"
|
import "core:bytes"
|
||||||
import "core:encoding/entity"
|
import "core:encoding/entity"
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package xxhash
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
@@ -8,8 +10,6 @@
|
|||||||
Jeroen van Rijn: Initial implementation.
|
Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package xxhash
|
|
||||||
|
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package xxhash
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
@@ -8,8 +10,6 @@
|
|||||||
Jeroen van Rijn: Initial implementation.
|
Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package xxhash
|
|
||||||
|
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package xxhash
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
@@ -8,8 +10,6 @@
|
|||||||
Jeroen van Rijn: Initial implementation.
|
Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package xxhash
|
|
||||||
|
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package xxhash
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
@@ -8,8 +10,6 @@
|
|||||||
Jeroen van Rijn: Initial implementation.
|
Jeroen van Rijn: Initial implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package xxhash
|
|
||||||
|
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package png
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
Made available under Odin's BSD-2 license.
|
Made available under Odin's BSD-2 license.
|
||||||
@@ -9,8 +11,6 @@
|
|||||||
These are a few useful utility functions to work with PNG images.
|
These are a few useful utility functions to work with PNG images.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package png
|
|
||||||
|
|
||||||
import "core:image"
|
import "core:image"
|
||||||
import "core:compress/zlib"
|
import "core:compress/zlib"
|
||||||
import coretime "core:time"
|
import coretime "core:time"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#+vet !using-stmt
|
||||||
|
package png
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
|
||||||
Made available under Odin's BSD-3 license.
|
Made available under Odin's BSD-3 license.
|
||||||
@@ -7,10 +10,6 @@
|
|||||||
Ginger Bill: Cosmetic changes.
|
Ginger Bill: Cosmetic changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#+vet !using-stmt
|
|
||||||
package png
|
|
||||||
|
|
||||||
import "core:compress"
|
import "core:compress"
|
||||||
import "core:compress/zlib"
|
import "core:compress/zlib"
|
||||||
import "core:image"
|
import "core:image"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Profiling using the "`spall`" format.
|
Profiling using the "`spall`" format.
|
||||||
|
|
||||||
|
See: [[ https://gravitymoth.com/spall/ ]]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
+18
-17
@@ -23,9 +23,6 @@ Example:
|
|||||||
fmt.printfln("CPU cores: %vc/%vt", si.cpu.physical_cores, si.cpu.logical_cores)
|
fmt.printfln("CPU cores: %vc/%vt", si.cpu.physical_cores, si.cpu.logical_cores)
|
||||||
fmt.printfln("RAM: %#.1M", si.ram.total_ram)
|
fmt.printfln("RAM: %#.1M", si.ram.total_ram)
|
||||||
|
|
||||||
// fmt.printfln("Features: %v", si.cpu.features)
|
|
||||||
// fmt.printfln("MacOS version: %v", si.macos_version)
|
|
||||||
|
|
||||||
fmt.println()
|
fmt.println()
|
||||||
for gpu, i in si.gpus {
|
for gpu, i in si.gpus {
|
||||||
fmt.printfln("GPU #%v:", i)
|
fmt.printfln("GPU #%v:", i)
|
||||||
@@ -37,26 +34,30 @@ Example:
|
|||||||
|
|
||||||
- Example Windows output:
|
- Example Windows output:
|
||||||
|
|
||||||
Odin: dev-2022-09
|
Odin: dev-2025-10
|
||||||
OS: Windows 10 Professional (version: 20H2), build: 19042.1466
|
OS: Windows 10 Professional (version: 22H2), build: 19045.6396
|
||||||
OS: OS_Version{
|
OS: OS_Version{
|
||||||
platform = "Windows",
|
platform = "Windows",
|
||||||
major = 10,
|
_ = Version{
|
||||||
minor = 0,
|
major = 10,
|
||||||
patch = 0,
|
minor = 0,
|
||||||
|
patch = 0,
|
||||||
|
},
|
||||||
build = [
|
build = [
|
||||||
19042,
|
19045,
|
||||||
1466,
|
6396,
|
||||||
],
|
],
|
||||||
version = "20H2",
|
version = "22H2",
|
||||||
as_string = "Windows 10 Professional (version: 20H2), build: 19042.1466",
|
as_string = "Windows 10 Professional (version: 22H2), build: 19045.6396",
|
||||||
}
|
}
|
||||||
CPU: AMD Ryzen 7 1800X Eight-Core Processor
|
CPU: AMD Ryzen 9 5950X 16-Core Processor
|
||||||
RAM: 64.0 GiB
|
CPU cores: 16c/32t
|
||||||
|
RAM: 63.9 GiB
|
||||||
|
|
||||||
GPU #0:
|
GPU #0:
|
||||||
Vendor: Advanced Micro Devices, Inc.
|
Vendor: Advanced Micro Devices, Inc.
|
||||||
Model: Radeon RX Vega
|
Model: AMD Radeon RX 9070
|
||||||
VRAM: 8.0 GiB
|
VRAM: 15.9 GiB
|
||||||
|
|
||||||
- Example macOS output:
|
- Example macOS output:
|
||||||
|
|
||||||
|
|||||||
@@ -285,25 +285,26 @@ init_gpu_info :: proc "contextless" () {
|
|||||||
context = runtime.default_context()
|
context = runtime.default_context()
|
||||||
|
|
||||||
gpu_list: [dynamic]GPU
|
gpu_list: [dynamic]GPU
|
||||||
gpu_index: int
|
|
||||||
|
|
||||||
for {
|
// TODO: Use registry APIs to iterate over entries instead of trying 0000..0009.
|
||||||
|
for gpu_index in 0..<10 {
|
||||||
key := fmt.tprintf("%v\\%04d", GPU_INFO_BASE, gpu_index)
|
key := fmt.tprintf("%v\\%04d", GPU_INFO_BASE, gpu_index)
|
||||||
|
|
||||||
|
gpu: ^GPU
|
||||||
if vendor, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "ProviderName"); ok {
|
if vendor, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "ProviderName"); ok {
|
||||||
append(&gpu_list, GPU{vendor_name = vendor})
|
append(&gpu_list, GPU{vendor_name = vendor})
|
||||||
|
gpu = &gpu_list[len(gpu_list) - 1]
|
||||||
} else {
|
} else {
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if desc, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "DriverDesc"); ok {
|
if desc, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "DriverDesc"); ok {
|
||||||
gpu_list[gpu_index].model_name = desc
|
gpu.model_name = desc
|
||||||
}
|
}
|
||||||
|
|
||||||
if vram, ok := read_reg_i64(sys.HKEY_LOCAL_MACHINE, key, "HardwareInformation.qwMemorySize"); ok {
|
if vram, ok := read_reg_i64(sys.HKEY_LOCAL_MACHINE, key, "HardwareInformation.qwMemorySize"); ok {
|
||||||
gpu_list[gpu_index].total_ram = int(vram)
|
gpu.total_ram = int(vram)
|
||||||
}
|
}
|
||||||
gpu_index += 1
|
|
||||||
}
|
}
|
||||||
gpus = gpu_list[:]
|
gpus = gpu_list[:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Implementations of the `Orca` API that are defined as macros in Orca.
|
|
||||||
|
|
||||||
package orca
|
package orca
|
||||||
|
|
||||||
|
// Implementations of the `Orca` API that are defined as macros in Orca.
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Helpers for logging, asserting and aborting.
|
// Helpers for logging, asserting and aborting.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// File contains Odin specific helpers.
|
|
||||||
|
|
||||||
package orca
|
package orca
|
||||||
|
|
||||||
|
// File contains Odin specific helpers.
|
||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
|
|
||||||
create_odin_logger :: proc(lowest := runtime.Logger_Level.Debug, ident := "") -> runtime.Logger {
|
create_odin_logger :: proc(lowest := runtime.Logger_Level.Debug, ident := "") -> runtime.Logger {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// Bindings for the Orca platform
|
||||||
|
//
|
||||||
|
// See: [[ https://orca-app.dev ]]
|
||||||
package orca
|
package orca
|
||||||
|
|
||||||
import "core:c"
|
import "core:c"
|
||||||
|
|||||||
Reference in New Issue
Block a user