agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
vm_function.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 ykat UG (haftungsbeschraenkt) - All Rights Reserved
3  *
4  * Permission for non-commercial use is hereby granted,
5  * free of charge, without warranty of any kind.
6  */
7 #ifndef ZRTOS_VM_FUNCTION_H
8 #define ZRTOS_VM_FUNCTION_H
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 
14 #include <zrtos/types.h>
15 #include <zrtos/error.h>
16 
17 typedef size_t zrtos_vm_function_id_t;
19 
21  struct _zrtos_vm_t *vm
22  ,struct _zrtos_vm_function_t *fn
23 );
24 
25 typedef struct _zrtos_vm_function_t{
26  zrtos_vm_function_id_t id;
28  void *context;
30 
31 #define ZRTOS_VM_FUNCTION(id_,callback_,context_) \
32  { \
33  .id=id_ \
34  ,.callback=callback_ \
35  ,.context=context_ \
36  }
37 
38 int zrtos_vm_function__cmp(const void *aa,const void *bb){
39  const zrtos_vm_function_t *a = (const zrtos_vm_function_t *)aa;
40  const zrtos_vm_function_t *b = (const zrtos_vm_function_t *)bb;
41  return a->id - b->id;
42 }
43 
46 ){
47  return thiz->callback;
48 }
49 
52 ){
53  return thiz->context;
54 }
55 
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 #endif
zrtos_error_t(* zrtos_vm_function_callback_t)(struct _zrtos_vm_t *vm, struct _zrtos_vm_function_t *fn)
Definition: vm_function.h:20
struct _zrtos_vm_function_t zrtos_vm_function_t
zrtos_vm_function_callback_t callback
Definition: vm_function.h:27
zrtos_vm_function_callback_t zrtos_vm_function__get_callback(zrtos_vm_function_t *thiz)
Definition: vm_function.h:44
Definition: vm.h:79
void * zrtos_vm_function__get_context(zrtos_vm_function_t *thiz)
Definition: vm_function.h:50
int zrtos_vm_function__cmp(const void *aa, const void *bb)
Definition: vm_function.h:38
size_t zrtos_vm_function_id_t
Definition: vm_function.h:17
zrtos_error_t
Definition: error.h:20
zrtos_vm_function_id_t id
Definition: vm_function.h:26