mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-11 21:08:10 +00:00
Even more style fixes
This commit is contained in:
@@ -679,7 +679,7 @@ allocate_memory :: proc(a: ^WASM_Allocator, alignment: uint, size: uint, loc :=
|
||||
// but we just had a stale bit set to mark a populated bucket.
|
||||
// Reset the bit to update latest status so that we do not
|
||||
// redundantly look at this bucket again.
|
||||
a.free_region_buckets_used &= ~(BUCKET_BITMASK_T(1) << bucket_index)
|
||||
a.free_region_buckets_used &~= BUCKET_BITMASK_T(1) << bucket_index
|
||||
bucket_mask ~= 1
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, set_to: bool = true, allocator
|
||||
ba.max_index = max(idx, ba.max_index)
|
||||
|
||||
if set_to{ ba.bits[leg_index] |= 1 << uint(bit_index) }
|
||||
else { ba.bits[leg_index] &= ~(1 << uint(bit_index)) }
|
||||
else { ba.bits[leg_index] &~= 1 << uint(bit_index) }
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -253,7 +253,7 @@ Inputs:
|
||||
- index: Which bit in the array
|
||||
*/
|
||||
unsafe_unset :: proc(b: ^Bit_Array, bit: int) #no_bounds_check {
|
||||
b.bits[bit >> INDEX_SHIFT] &= ~(1 << uint(bit & INDEX_MASK))
|
||||
b.bits[bit >> INDEX_SHIFT] &~= 1 << uint(bit & INDEX_MASK)
|
||||
}
|
||||
/*
|
||||
A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative).
|
||||
|
||||
@@ -233,7 +233,7 @@ encode_into_encoder :: proc(e: Encoder, v: Value, loc := #caller_location) -> En
|
||||
|
||||
if .Self_Described_CBOR in e.flags {
|
||||
_encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag) or_return
|
||||
e.flags &~= { .Self_Described_CBOR }
|
||||
e.flags -= { .Self_Described_CBOR }
|
||||
}
|
||||
|
||||
switch v_spec in v {
|
||||
|
||||
@@ -85,7 +85,7 @@ marshal_into_encoder :: proc(e: Encoder, v: any, loc := #caller_location) -> (e
|
||||
|
||||
if .Self_Described_CBOR in e.flags {
|
||||
err_conv(_encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag)) or_return
|
||||
e.flags &~= { .Self_Described_CBOR }
|
||||
e.flags -= { .Self_Described_CBOR }
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
|
||||
@@ -1072,8 +1072,8 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d
|
||||
}
|
||||
|
||||
flags: strconv.Int_Flags
|
||||
if fi.hash && !fi.zero && start == 0 { flags |= {.Prefix} }
|
||||
if fi.plus { flags |= {.Plus} }
|
||||
if fi.hash && !fi.zero && start == 0 { flags += {.Prefix} }
|
||||
if fi.plus { flags += {.Plus} }
|
||||
s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags)
|
||||
prev_zero := fi.zero
|
||||
defer fi.zero = prev_zero
|
||||
@@ -1157,8 +1157,8 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i
|
||||
}
|
||||
|
||||
flags: strconv.Int_Flags
|
||||
if fi.hash && !fi.zero && start == 0 { flags |= {.Prefix} }
|
||||
if fi.plus { flags |= {.Plus} }
|
||||
if fi.hash && !fi.zero && start == 0 { flags += {.Prefix} }
|
||||
if fi.plus { flags += {.Plus} }
|
||||
s := strconv.append_bits_128(buf[start:], u, base, is_signed, bit_size, digits, flags)
|
||||
|
||||
if fi.hash && fi.zero && fi.indent == 0 {
|
||||
@@ -1460,13 +1460,10 @@ fmt_string :: proc(fi: ^Info, s: string, verb: rune) {
|
||||
if !fi.minus {
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
|
||||
if .info in options {
|
||||
options |= {.return_metadata, .do_not_decompress_image}
|
||||
options += {.return_metadata, .do_not_decompress_image}
|
||||
options -= {.info}
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
|
||||
options := options
|
||||
|
||||
if .info in options {
|
||||
options |= {.return_metadata, .do_not_decompress_image}
|
||||
options += {.return_metadata, .do_not_decompress_image}
|
||||
options -= {.info}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
|
||||
}
|
||||
|
||||
if .do_not_expand_channels in options {
|
||||
options |= {.do_not_expand_grayscale, .do_not_expand_indexed}
|
||||
options += {.do_not_expand_grayscale, .do_not_expand_indexed}
|
||||
}
|
||||
|
||||
if img == nil {
|
||||
|
||||
@@ -176,7 +176,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
|
||||
options := options
|
||||
|
||||
if .info in options {
|
||||
options |= {.return_metadata, .do_not_decompress_image}
|
||||
options += {.return_metadata, .do_not_decompress_image}
|
||||
options -= {.info}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
|
||||
}
|
||||
|
||||
if .info in options {
|
||||
options |= {.return_metadata, .do_not_decompress_image}
|
||||
options += {.return_metadata, .do_not_decompress_image}
|
||||
options -= {.info}
|
||||
}
|
||||
|
||||
|
||||
@@ -637,22 +637,20 @@ _internal_noise_4d_unskewed_base :: proc(seed: i64, coord: Vec4) -> (value: f32)
|
||||
|
||||
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
|
||||
score := 1.0 + ssi * (-1.0 / UNSKEW_4D) // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
|
||||
if si.x >= si.x && si.x >= si.z && si.x >= si.w && si.x >= score {
|
||||
switch {
|
||||
case si.x >= si.x && si.x >= si.z && si.x >= si.w && si.x >= score:
|
||||
svp.x += PRIME_X
|
||||
si.x -= 1
|
||||
ssi -= UNSKEW_4D
|
||||
}
|
||||
else if si.y > si.x && si.y >= si.z && si.y >= si.w && si.y >= score {
|
||||
case si.y > si.x && si.y >= si.z && si.y >= si.w && si.y >= score:
|
||||
svp.y += PRIME_Y
|
||||
si.y -= 1
|
||||
ssi -= UNSKEW_4D
|
||||
}
|
||||
else if si.z > si.x && si.z > si.y && si.z >= si.w && si.z >= score {
|
||||
case si.z > si.x && si.z > si.y && si.z >= si.w && si.z >= score:
|
||||
svp.z += PRIME_Z
|
||||
si.z -= 1
|
||||
ssi -= UNSKEW_4D
|
||||
}
|
||||
else if si.w > si.x && si.w > si.y && si.w > si.z && si.w >= score {
|
||||
case si.w > si.x && si.w > si.y && si.w > si.z && si.w >= score:
|
||||
svp.w += PRIME_W
|
||||
si.w -= 1
|
||||
ssi -= UNSKEW_4D
|
||||
|
||||
@@ -36,9 +36,9 @@ _release :: proc "contextless" (data: rawptr, size: uint) {
|
||||
_protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool {
|
||||
pflags: linux.Mem_Protection
|
||||
pflags = {}
|
||||
if .Read in flags { pflags |= {.READ} }
|
||||
if .Write in flags { pflags |= {.WRITE} }
|
||||
if .Execute in flags { pflags |= {.EXEC} }
|
||||
if .Read in flags { pflags += {.READ} }
|
||||
if .Write in flags { pflags += {.WRITE} }
|
||||
if .Execute in flags { pflags += {.EXEC} }
|
||||
errno := linux.mprotect(data, size, pflags)
|
||||
return errno == .NONE
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []
|
||||
state := Link_State{}
|
||||
|
||||
if .UP in ifaddr.flags {
|
||||
state |= {.Up}
|
||||
state += {.Up}
|
||||
}
|
||||
|
||||
/*if .DORMANT in ifaddr.flags {
|
||||
@@ -102,7 +102,7 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []
|
||||
}*/
|
||||
|
||||
if .LOOPBACK in ifaddr.flags {
|
||||
state |= {.Loopback}
|
||||
state += {.Loopback}
|
||||
}
|
||||
iface.link.state = state
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ _set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_E
|
||||
}
|
||||
|
||||
if should_block {
|
||||
flags &= ~int(os.O_NONBLOCK)
|
||||
flags &~= int(os.O_NONBLOCK)
|
||||
} else {
|
||||
flags |= int(os.O_NONBLOCK)
|
||||
}
|
||||
|
||||
@@ -377,9 +377,9 @@ _set_blocking :: proc(sock: Any_Socket, should_block: bool) -> (err: Network_Err
|
||||
return Set_Blocking_Error(errno)
|
||||
}
|
||||
if should_block {
|
||||
flags &= ~{.NONBLOCK}
|
||||
flags -= {.NONBLOCK}
|
||||
} else {
|
||||
flags |= {.NONBLOCK}
|
||||
flags += {.NONBLOCK}
|
||||
}
|
||||
errno = linux.fcntl(os_sock, linux.F_SETFL, flags)
|
||||
if errno != .NONE {
|
||||
|
||||
@@ -711,7 +711,7 @@ enumerated_array :: proc(ptr: ^$T) -> []intrinsics.type_elem_type(T)
|
||||
@(require_results)
|
||||
enum_slice_to_bitset :: proc(enums: []$E, $T: typeid/bit_set[E]) -> (bits: T) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E {
|
||||
for v in enums {
|
||||
bits |= {v}
|
||||
bits += {v}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1464,16 +1464,16 @@ Futex_Flags_Bits :: enum {
|
||||
Kind of operation on futex, see FUTEX_WAKE_OP
|
||||
*/
|
||||
Futex_Arg_Op :: enum {
|
||||
SET = 0, /* uaddr2 = oparg; */
|
||||
ADD = 1, /* uaddr2 += oparg; */
|
||||
OR = 2, /* uaddr2 |= oparg; */
|
||||
ANDN = 3, /* uaddr2 &= ~oparg; */
|
||||
XOR = 4, /* uaddr2 ^= oparg; */
|
||||
PO2_SET = 0, /* uaddr2 = 1<<oparg; */
|
||||
PO2_ADD = 1, /* uaddr2 += 1<<oparg; */
|
||||
PO2_OR = 2, /* uaddr2 |= 1<<oparg; */
|
||||
PO2_ANDN = 3, /* uaddr2 &= ~(1<<oparg); */
|
||||
PO2_XOR = 4, /* uaddr2 ^= 1<<oparg; */
|
||||
SET = 0, /* uaddr2 = oparg */
|
||||
ADD = 1, /* uaddr2 += oparg */
|
||||
OR = 2, /* uaddr2 |= oparg */
|
||||
ANDN = 3, /* uaddr2 &= ~oparg */
|
||||
XOR = 4, /* uaddr2 ^= oparg */
|
||||
PO2_SET = 0, /* uaddr2 = 1<<oparg */
|
||||
PO2_ADD = 1, /* uaddr2 += 1<<oparg */
|
||||
PO2_OR = 2, /* uaddr2 |= 1<<oparg */
|
||||
PO2_ANDN = 3, /* uaddr2 &~= 1<<oparg */
|
||||
PO2_XOR = 4, /* uaddr2 ^= 1<<oparg */
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
2
vendor/ENet/unix.odin
vendored
2
vendor/ENet/unix.odin
vendored
@@ -23,7 +23,7 @@ import "core:c"
|
||||
}
|
||||
|
||||
@(private="file") FD_CLR :: #force_inline proc(d: i32, s: ^fd_set) {
|
||||
s.fds_bits[d / (8 * size_of(c.long))] &= ~(c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong))))
|
||||
s.fds_bits[d / (8 * size_of(c.long))] &~= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
|
||||
}
|
||||
|
||||
@(private="file") FD_ISSET :: #force_inline proc(d: i32, s: ^fd_set) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user