fn add(lhs: usize, rhs: usize) -> usize {
return lhs + rhs;
}
fn sub(lhs: usize, rhs: usize) -> usize {
return lhs - rhs;
}
fn main() -> u8 {
let ptrs: fn(usize, usize)->usize[2] = [sub, add];
let value: usize;
// there're whoopsie daisies with other types than u8(segfault)
for let i: u8 = 0; i < 2; i = i + 1 {
value = ptrs[(i as usize)](i as usize, i as usize);
printf("%d", value);
}
return 0;
}
@Learath2 I didn't decide anything regarding enums but I added function pointers (edited)typedef struct {
const char *name;
Data *(*fn)(Data *);
} Macro;
typedef struct {
size_t size;
Macro macros[];
} Macros;
how to make such structs in rust?Macro macros[];
Macro macros[];
EHttpState::RUNNING
which was previously unused.
Closes #7811.
#[repr(C)]
struct Macros {
size: usize,
_macros: [Macro; 0],
}
trait GimmeMacros {
fn macros(&self) -> &[Macro];
}
impl GimmeMacros for *const Macros {
fn macros(&self) -> &[Macro] {
unsafe {
let skip_size = self.byte_add(size_of_val(&self.read().size));
std::slice::from_raw_parts(skip_size as *const Macro, self.read().size)
}
}
}
(edited)#[repr(C)]
struct Macros {
size: usize,
_macros: [Macro; 0],
}
trait GimmeMacros {
fn macros(&self) -> &[Macro];
}
impl GimmeMacros for *const Macros {
fn macros(&self) -> &[Macro] {
unsafe {
let skip_size = self.byte_add(size_of_val(&self.read().size));
std::slice::from_raw_parts(skip_size as *const Macro, self.read().size)
}
}
}
(edited)typedef struct {
const char *name;
Data *(*fn)(Data *);
} Macro;
typedef struct {
size_t size;
Macro macros[];
} Macros;
how to make such structs in rust? Macros
in shared object, and I had to get it somehowandroid:supportsRtl="true"
biggest lie in ddnet code android:supportsRtl="true"
biggest lie in ddnet code mold: fatal: ddnet_engine_shared-cd5af9afb6c5385a.1x1mslembt45wzvj8781d2swp.rcgu.o: incompatible file type: arm64 is expected but got x86_64
This is the err in newer NDK versions, so weirdmold: fatal: ddnet_engine_shared-cd5af9afb6c5385a.1x1mslembt45wzvj8781d2swp.rcgu.o: incompatible file type: arm64 is expected but got x86_64
This is the err in newer NDK versions, so weird mold: error: undefined symbol: __sendto_chk
man ndk 26 used to workANDROID_NDK_VERSION="$(cd "$ANDROID_HOME/ndk" && find . -maxdepth 1 | sort -n | tail -1)"
ANDROID_NDK_VERSION="${ANDROID_NDK_VERSION:2}"
# ANDROID_NDK_HOME must be exported for cargo-ndk
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION"
Seems like the build script currently uses the folder based on the sorting the filenames, so you can't easily use an older NDKmold: error: undefined symbol: __sendto_chk
man ndk 26 used to work Path for java installation '/usr/lib/jvm/openjdk-17' (Common Linux Locations) does not contain a java executable
Path for java installation '/usr/lib/jvm/openjdk-21' (Common Linux Locations) does not contain a java executable
DDNet
when you should have passed org.ddnet.client
I guessDoppelte Klasse: org.ddnet.client.NativeMain
public class NativeMain extends SDLActivity {
lmaoVK_SUBOPTIMAL_KHR
in vkQueuePresentKHR
and only handle it in vkAcquireNextImageKHR
VK_SUBOPTIMAL_KHR
to be emitted by the driver every frame.
I saw this in the rust vk backend, where the FPS was like 10FPS on Android.
I think the reason that it works in this version is, that we ignore VK_SUBOPTIMAL_KHR
from vkQueuePresentKHR
, but handle it in `vkAcquireNex...top5
is I'm guessing we've finally gone past the point where top5team
queries can end in a reasonable amount of timeLIMIT
a ?
but didn't add an argument to bind to itLIMIT
a ?
but didn't add an argument to bind to it SELECT name, time, ranking, teamsize
FROM (
SELECT teamsize, ranking, id, server
FROM (
SELECT Rank() over w AS ranking, count(*) AS teamsize, id, server
FROM (
SELECT *
FROM record_teamrace AS tr
INNER JOIN record_race AS rr
ON tr.map = rr.map
AND tr.name = rr.name
AND tr.time = rr.time
AND tr.timestamp = rr.timestamp )
WHERE map = 'Multeasymap'
GROUP BY id window w AS (ORDER BY min(time)) ) AS l1
WHERE server LIKE '%'
ORDER BY ranking ASC
LIMIT 0, 5) AS l2
INNER JOIN record_teamrace AS r
ON l2.id = r.id
ORDER BY ranking ASC, r.id, name ASC
(edited)SELECT Rank() over w AS ranking, count(*) AS teamsize, id, server
FROM (
SELECT *
FROM record_teamrace AS tr
INNER JOIN record_race AS rr
ON tr.map = rr.map
AND tr.name = rr.name
AND tr.time = rr.time
AND tr.timestamp = rr.timestamp
)
WHERE map = 'Multeasymap'
GROUP BY id window w AS (ORDER BY min(time))
This subquery is already wrong somehowtr.map
just in caseas b
and then b.map = '...'SELECT Rank() over w AS ranking, count(*) AS teamsize, id, server
FROM (
SELECT tr.map as map, tr.time as time, tr.id as id, rr.server as server
FROM record_teamrace AS tr
INNER JOIN record_race AS rr
ON tr.map = rr.map
AND tr.name = rr.name
AND tr.time = rr.time
AND tr.timestamp = rr.timestamp
) AS kek
WHERE kek.map = 'Multeasymap'
GROUP BY id window w AS (ORDER BY min(time))
MariaDB [teeworlds]> SELECT VERSION();
+-------------------------------+
| VERSION() |
+-------------------------------+
| 10.11.6-MariaDB-0+deb12u1-log |
+-------------------------------+
1 row in set (0.000 sec)
or if you want to mess around with debugging itfn printf(format: *i8, _: *i8) -> void;
fn main() -> u8 {
let lol: *i8 = gimme_points!();
printf("Player's points: %s", lol);
return 0;
}
Shared object file
Data Points(Data data, size_t _) {
char buf[256];
FILE *file = fopen("~/personal/c_playground/file", "r");
fread(buf, sizeof(buf), 1, file);
int n = strlen((const char *)buf);
char *str = (char *)malloc(n);
memcpy(str, buf, n);
// Overwrite '\n'
str[n - 1] = '\0';
return str;
}
Macros macros = {
.size = 1,
.macros = {
{"gimme_points", Points},
},
};
fn printf(format: *i8, _: *i8) -> void;
fn main() -> u8 {
let lol: *i8 = gimme_points!();
printf("Player's points: %s", lol);
return 0;
}
Shared object file
Data Points(Data data, size_t _) {
char buf[256];
FILE *file = fopen("~/personal/c_playground/file", "r");
fread(buf, sizeof(buf), 1, file);
int n = strlen((const char *)buf);
char *str = (char *)malloc(n);
memcpy(str, buf, n);
// Overwrite '\n'
str[n - 1] = '\0';
return str;
}
Macros macros = {
.size = 1,
.macros = {
{"gimme_points", Points},
},
};
int n = fread(buf, sizeof buf, 1, file);
buf[n - 1] = '\0';
char *str = malloc(n * sizeof *str);
memcpy(str, buf, n);
return str;
memcpy(str, buf, n);
// Overwrite '\n'
str[n - 1] = '\0';
that's one way to handle null termination (edited)numinous
: supernatural
/mysterious
or holy
/spiritual