Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
LabComm
Commits
e3c16fda
Commit
e3c16fda
authored
Feb 24, 2015
by
Anders Blomdell
Browse files
Changed 'labcomm' to 'labcomm2014' for C-code.
parent
f11ec7ba
Changes
53
Expand all
Hide whitespace changes
Inline
Side-by-side
compiler/2014/C_CodeGen.jrag
View file @
e3c16fda
This diff is collapsed.
Click to expand it.
examples/simple/example_decoder.c
View file @
e3c16fda
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<labcomm_fd_reader.h>
#include
<labcomm_default_error_handler.h>
#include
<labcomm_default_memory.h>
#include
<labcomm_default_scheduler.h>
#include
<labcomm
2014
_fd_reader.h>
#include
<labcomm
2014
_default_error_handler.h>
#include
<labcomm
2014
_default_memory.h>
#include
<labcomm
2014
_default_scheduler.h>
#include
"gen/simple.h"
#include
<stdio.h>
...
...
@@ -57,33 +57,33 @@ static void handle_simple_TwoFixedArrays(simple_TwoFixedArrays *d,void *context)
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
struct
labcomm_decoder
*
decoder
;
struct
labcomm
2014
_decoder
*
decoder
;
void
*
context
=
NULL
;
char
*
filename
=
argv
[
1
];
printf
(
"C decoder reading from %s
\n
"
,
filename
);
fd
=
open
(
filename
,
O_RDONLY
);
decoder
=
labcomm_decoder_new
(
labcomm_fd_reader_new
(
labcomm_default_memory
,
fd
,
1
),
labcomm_default_error_handler
,
labcomm_default_memory
,
labcomm_default_scheduler
);
decoder
=
labcomm
2014
_decoder_new
(
labcomm
2014
_fd_reader_new
(
labcomm
2014
_default_memory
,
fd
,
1
),
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
labcomm
2014
_default_scheduler
);
if
(
!
decoder
)
{
printf
(
"Failed to allocate decoder %s:%d
\n
"
,
__FUNCTION__
,
__LINE__
);
return
1
;
}
labcomm_decoder_register_simple_doavoid
(
decoder
,
handle_simple_doavoid
,
context
);
labcomm_decoder_register_simple_theTwoInts
(
decoder
,
handle_simple_theTwoInts
,
context
);
labcomm_decoder_register_simple_anotherTwoInts
(
decoder
,
handle_simple_anotherTwoInts
,
context
);
labcomm_decoder_register_simple_IntString
(
decoder
,
handle_simple_IntString
,
context
);
labcomm_decoder_register_simple_TwoArrays
(
decoder
,
handle_simple_TwoArrays
,
context
);
labcomm_decoder_register_simple_TwoFixedArrays
(
decoder
,
handle_simple_TwoFixedArrays
,
context
);
labcomm
2014
_decoder_register_simple_doavoid
(
decoder
,
handle_simple_doavoid
,
context
);
labcomm
2014
_decoder_register_simple_theTwoInts
(
decoder
,
handle_simple_theTwoInts
,
context
);
labcomm
2014
_decoder_register_simple_anotherTwoInts
(
decoder
,
handle_simple_anotherTwoInts
,
context
);
labcomm
2014
_decoder_register_simple_IntString
(
decoder
,
handle_simple_IntString
,
context
);
labcomm
2014
_decoder_register_simple_TwoArrays
(
decoder
,
handle_simple_TwoArrays
,
context
);
labcomm
2014
_decoder_register_simple_TwoFixedArrays
(
decoder
,
handle_simple_TwoFixedArrays
,
context
);
printf
(
"Decoding:
\n
"
);
labcomm_decoder_run
(
decoder
);
labcomm
2014
_decoder_run
(
decoder
);
printf
(
"--- End Of File ---:
\n
"
);
labcomm_decoder_free
(
decoder
);
labcomm
2014
_decoder_free
(
decoder
);
return
0
;
}
examples/simple/example_encoder.c
View file @
e3c16fda
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<labcomm_fd_writer.h>
#include
<labcomm_default_error_handler.h>
#include
<labcomm_default_memory.h>
#include
<labcomm_default_scheduler.h>
#include
<labcomm
2014
_fd_writer.h>
#include
<labcomm
2014
_default_error_handler.h>
#include
<labcomm
2014
_default_memory.h>
#include
<labcomm
2014
_default_scheduler.h>
#include
"gen/simple.h"
#include
<stdio.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
struct
labcomm_encoder
*
encoder
;
struct
labcomm
2014
_encoder
*
encoder
;
char
*
filename
=
argv
[
1
];
printf
(
"C encoder writing to %s
\n
"
,
filename
);
fd
=
open
(
filename
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
);
encoder
=
labcomm_encoder_new
(
labcomm_fd_writer_new
(
labcomm_default_memory
,
fd
,
1
),
labcomm_default_error_handler
,
labcomm_default_memory
,
labcomm_default_scheduler
);
labcomm_encoder_register_simple_doavoid
(
encoder
);
labcomm_encoder_register_simple_theTwoInts
(
encoder
);
labcomm_encoder_register_simple_anotherTwoInts
(
encoder
);
labcomm_encoder_register_simple_IntString
(
encoder
);
labcomm_encode_simple_doavoid
(
encoder
);
encoder
=
labcomm
2014
_encoder_new
(
labcomm
2014
_fd_writer_new
(
labcomm
2014
_default_memory
,
fd
,
1
),
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
labcomm
2014
_default_scheduler
);
labcomm
2014
_encoder_register_simple_doavoid
(
encoder
);
labcomm
2014
_encoder_register_simple_theTwoInts
(
encoder
);
labcomm
2014
_encoder_register_simple_anotherTwoInts
(
encoder
);
labcomm
2014
_encoder_register_simple_IntString
(
encoder
);
labcomm
2014
_encode_simple_doavoid
(
encoder
);
simple_IntString
is
;
is
.
x
=
24
;
is
.
s
=
"Hello, LabComm!"
;
printf
(
"Encoding IntString, x=%d, s=%s
\n
"
,
is
.
x
,
is
.
s
);
labcomm_encode_simple_IntString
(
encoder
,
&
is
);
labcomm
2014
_encode_simple_IntString
(
encoder
,
&
is
);
simple_theTwoInts
ti
;
ti
.
a
=
13
;
ti
.
b
=
37
;
printf
(
"Encoding theTwoInts, a=%d, b=%d
\n
"
,
ti
.
a
,
ti
.
b
);
labcomm_encode_simple_theTwoInts
(
encoder
,
&
ti
);
labcomm
2014
_encode_simple_theTwoInts
(
encoder
,
&
ti
);
simple_anotherTwoInts
ati
;
ati
.
a
=
23
;
ati
.
b
=
47
;
printf
(
"Encoding anotherTwoInts, a=%d, b=%d
\n
"
,
ati
.
a
,
ati
.
b
);
labcomm_encode_simple_anotherTwoInts
(
encoder
,
&
ati
);
labcomm
2014
_encode_simple_anotherTwoInts
(
encoder
,
&
ati
);
int
foo
[
20
];
labcomm_encoder_register_simple_TwoArrays
(
encoder
);
labcomm
2014
_encoder_register_simple_TwoArrays
(
encoder
);
simple_TwoArrays
ta
;
ta
.
fixed
.
a
[
0
]
=
17
;
...
...
@@ -61,12 +61,12 @@ int main(int argc, char *argv[]) {
}
printf
(
"Encoding TwoArrays...
\n
"
);
labcomm_encode_simple_TwoArrays
(
encoder
,
&
ta
);
labcomm
2014
_encode_simple_TwoArrays
(
encoder
,
&
ta
);
ti
.
a
=
23
;
ti
.
b
=
47
;
printf
(
"Encoding theTwoInts, a=%d, b=%d
\n
"
,
ti
.
a
,
ti
.
b
);
labcomm_encode_simple_theTwoInts
(
encoder
,
&
ti
);
labcomm
2014
_encode_simple_theTwoInts
(
encoder
,
&
ti
);
simple_TwoFixedArrays
tfa
;
...
...
@@ -82,8 +82,8 @@ int main(int argc, char *argv[]) {
tfa
.
b
.
a
[
1
][
2
]
=
63
;
printf
(
"Encoding TwoFixedArrays...
\n
"
);
labcomm_encoder_register_simple_TwoFixedArrays
(
encoder
);
labcomm_encode_simple_TwoFixedArrays
(
encoder
,
&
tfa
);
labcomm
2014
_encoder_register_simple_TwoFixedArrays
(
encoder
);
labcomm
2014
_encode_simple_TwoFixedArrays
(
encoder
,
&
tfa
);
return
0
;
}
examples/twoway/client.c
View file @
e3c16fda
...
...
@@ -36,12 +36,12 @@
#include
<sys/socket.h>
#include
<sys/types.h>
#include
<unistd.h>
#include
<labcomm.h>
#include
<labcomm_fd_reader.h>
#include
<labcomm_fd_writer.h>
#include
<labcomm_default_error_handler.h>
#include
<labcomm_default_memory.h>
#include
<labcomm_pthread_scheduler.h>
#include
<labcomm
2014
.h>
#include
<labcomm
2014
_fd_reader.h>
#include
<labcomm
2014
_fd_writer.h>
#include
<labcomm
2014
_default_error_handler.h>
#include
<labcomm
2014
_default_memory.h>
#include
<labcomm
2014
_pthread_scheduler.h>
#include
"decimating.h"
#include
"introspecting.h"
#include
"gen/types.h"
...
...
@@ -63,13 +63,13 @@ static void handle_Product(int32_t *value, void *context)
static
void
*
run_decoder
(
void
*
context
)
{
struct
labcomm_decoder
*
decoder
=
context
;
struct
labcomm
2014
_decoder
*
decoder
=
context
;
int
result
;
labcomm_decoder_register_types_Sum
(
decoder
,
handle_Sum
,
NULL
);
labcomm_decoder_register_types_Diff
(
decoder
,
handle_Diff
,
NULL
);
labcomm
2014
_decoder_register_types_Sum
(
decoder
,
handle_Sum
,
NULL
);
labcomm
2014
_decoder_register_types_Diff
(
decoder
,
handle_Diff
,
NULL
);
do
{
result
=
labcomm_decoder_decode_one
(
decoder
);
result
=
labcomm
2014
_decoder_decode_one
(
decoder
);
}
while
(
result
>=
0
);
return
NULL
;
}
...
...
@@ -87,10 +87,10 @@ int main(int argc, char *argv[])
struct
introspecting
*
introspecting
;
char
*
hostname
;
int
port
;
struct
labcomm_scheduler
*
scheduler
;
struct
labcomm_decoder
*
decoder
;
struct
labcomm_encoder
*
encoder
;
struct
labcomm_time
*
next
;
struct
labcomm
2014
_scheduler
*
scheduler
;
struct
labcomm
2014
_decoder
*
decoder
;
struct
labcomm
2014
_encoder
*
encoder
;
struct
labcomm
2014
_time
*
next
;
int32_t
i
,
j
;
hostname
=
argv
[
1
];
...
...
@@ -128,13 +128,13 @@ int main(int argc, char *argv[])
nodelay
=
1
;
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
&
nodelay
,
sizeof
(
nodelay
));
scheduler
=
labcomm_pthread_scheduler_new
(
labcomm_default_memory
);
decimating
=
decimating_new
(
labcomm_fd_reader_new
(
labcomm_default_memory
,
scheduler
=
labcomm
2014
_pthread_scheduler_new
(
labcomm
2014
_default_memory
);
decimating
=
decimating_new
(
labcomm
2014
_fd_reader_new
(
labcomm
2014
_default_memory
,
fd
,
1
),
labcomm_fd_writer_new
(
labcomm_default_memory
,
labcomm
2014
_fd_writer_new
(
labcomm
2014
_default_memory
,
fd
,
0
),
labcomm_default_error_handler
,
labcomm_default_memory
,
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
scheduler
);
if
(
decimating
==
NULL
)
{
/* Warning: might leak reader and writer at this point */
...
...
@@ -142,45 +142,45 @@ int main(int argc, char *argv[])
}
introspecting
=
introspecting_new
(
decimating
->
reader
,
decimating
->
writer
,
labcomm_default_error_handler
,
labcomm_default_memory
,
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
scheduler
);
if
(
introspecting
==
NULL
)
{
/* Warning: might leak reader and writer at this point */
goto
out
;
}
decoder
=
labcomm_decoder_new
(
introspecting
->
reader
,
labcomm_default_error_handler
,
labcomm_default_memory
,
decoder
=
labcomm
2014
_decoder_new
(
introspecting
->
reader
,
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
scheduler
);
encoder
=
labcomm_encoder_new
(
introspecting
->
writer
,
labcomm_default_error_handler
,
labcomm_default_memory
,
encoder
=
labcomm
2014
_encoder_new
(
introspecting
->
writer
,
labcomm
2014
_default_error_handler
,
labcomm
2014
_default_memory
,
scheduler
);
pthread_t
rdt
;
pthread_create
(
&
rdt
,
NULL
,
run_decoder
,
decoder
);
labcomm_encoder_register_types_A
(
encoder
);
labcomm_encoder_register_types_B
(
encoder
);
labcomm_encoder_register_types_Terminate
(
encoder
);
labcomm
2014
_encoder_register_types_A
(
encoder
);
labcomm
2014
_encoder_register_types_B
(
encoder
);
labcomm
2014
_encoder_register_types_Terminate
(
encoder
);
err
=
labcomm_decoder_ioctl_types_Sum
(
decoder
,
SET_DECIMATION
,
2
);
err
=
labcomm_decoder_ioctl_types_Diff
(
decoder
,
SET_DECIMATION
,
4
);
err
=
labcomm
2014
_decoder_ioctl_types_Sum
(
decoder
,
SET_DECIMATION
,
2
);
err
=
labcomm
2014
_decoder_ioctl_types_Diff
(
decoder
,
SET_DECIMATION
,
4
);
next
=
labcomm_scheduler_now
(
scheduler
);
next
=
labcomm
2014
_scheduler_now
(
scheduler
);
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
i
==
2
)
{
labcomm_decoder_register_types_Product
(
decoder
,
handle_Product
,
NULL
);
labcomm
2014
_decoder_register_types_Product
(
decoder
,
handle_Product
,
NULL
);
}
for
(
j
=
0
;
j
<
4
;
j
++
)
{
printf
(
"
\n
A=%d B=%d: "
,
i
,
j
);
labcomm_encode_types_A
(
encoder
,
&
i
);
labcomm_encode_types_B
(
encoder
,
&
j
);
labcomm_time_add_usec
(
next
,
100000
);
labcomm_scheduler_sleep
(
scheduler
,
next
);
labcomm
2014
_encode_types_A
(
encoder
,
&
i
);
labcomm
2014
_encode_types_B
(
encoder
,
&
j
);
labcomm
2014
_time_add_usec
(
next
,
100000
);
labcomm
2014
_scheduler_sleep
(
scheduler
,
next
);
}
}
printf
(
"
\n
"
);
labcomm_encode_types_Terminate
(
encoder
);
labcomm
2014
_encode_types_Terminate
(
encoder
);
out:
return
0
;
...
...
examples/twoway/decimating.c
View file @
e3c16fda
...
...
@@ -23,18 +23,18 @@
#include
<errno.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
"labcomm_private.h"
#include
"labcomm
2014
_private.h"
#include
"decimating.h"
#include
"gen/decimating_messages.h"
struct
decimating_private
{
struct
decimating
decimating
;
struct
labcomm_error_handler
*
error
;
struct
labcomm_memory
*
memory
;
struct
labcomm_scheduler
*
scheduler
;
struct
labcomm
2014
_error_handler
*
error
;
struct
labcomm
2014
_memory
*
memory
;
struct
labcomm
2014
_scheduler
*
scheduler
;
int
encoder_initialized
;
struct
labcomm_reader_action_context
reader_action_context
;
struct
labcomm_writer_action_context
writer_action_context
;
struct
labcomm
2014
_reader_action_context
reader_action_context
;
struct
labcomm
2014
_writer_action_context
writer_action_context
;
LABCOMM_SIGNATURE_ARRAY_DEF
(
writer_decimation
,
struct
decimation
{
int
n
;
...
...
@@ -50,25 +50,25 @@ static void set_decimation(
struct
decimating_private
*
decimating
=
context
;
struct
decimation
*
decimation
;
labcomm_scheduler_data_lock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_lock
(
decimating
->
scheduler
);
decimation
=
LABCOMM_SIGNATURE_ARRAY_REF
(
decimating
->
memory
,
decimating
->
writer_decimation
,
struct
decimation
,
value
->
signature_index
);
decimation
->
n
=
value
->
decimation
;
decimation
->
current
=
0
;
labcomm_scheduler_data_unlock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_unlock
(
decimating
->
scheduler
);
}
static
int
wrap_reader_alloc
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
)
struct
labcomm
2014
_reader
*
r
,
struct
labcomm
2014
_reader_action_context
*
action_context
)
{
struct
decimating_private
*
decimating
=
action_context
->
context
;
labcomm_decoder_register_decimating_messages_set_decimation
(
labcomm
2014
_decoder_register_decimating_messages_set_decimation
(
r
->
decoder
,
set_decimation
,
decimating
);
return
labcomm_reader_alloc
(
r
,
action_context
->
next
);
return
labcomm
2014
_reader_alloc
(
r
,
action_context
->
next
);
}
struct
send_set_decimation
{
...
...
@@ -80,11 +80,11 @@ struct send_set_decimation {
static
void
send_set_decimation
(
void
*
arg
)
{
struct
send_set_decimation
*
msg
=
arg
;
struct
labcomm_memory
*
memory
=
msg
->
decimating
->
memory
;
struct
labcomm
2014
_memory
*
memory
=
msg
->
decimating
->
memory
;
labcomm_encode_decimating_messages_set_decimation
(
labcomm
2014
_encode_decimating_messages_set_decimation
(
msg
->
decimating
->
decimating
.
writer
->
encoder
,
&
msg
->
set_decimation
);
labcomm_memory_free
(
memory
,
1
,
msg
);
labcomm
2014
_memory_free
(
memory
,
1
,
msg
);
}
static
void
enqueue_decimation
(
struct
decimating_private
*
decimating
,
...
...
@@ -92,21 +92,21 @@ static void enqueue_decimation(struct decimating_private *decimating,
int
amount
)
{
struct
send_set_decimation
*
msg
;
msg
=
labcomm_memory_alloc
(
decimating
->
memory
,
1
,
sizeof
(
*
msg
));
msg
=
labcomm
2014
_memory_alloc
(
decimating
->
memory
,
1
,
sizeof
(
*
msg
));
if
(
msg
)
{
msg
->
decimating
=
decimating
;
msg
->
set_decimation
.
decimation
=
amount
;
msg
->
set_decimation
.
signature_index
=
remote_index
;
labcomm_scheduler_enqueue
(
decimating
->
scheduler
,
0
,
labcomm
2014
_scheduler_enqueue
(
decimating
->
scheduler
,
0
,
send_set_decimation
,
msg
);
}
}
static
int
wrap_reader_start
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
struct
labcomm
2014
_reader
*
r
,
struct
labcomm
2014
_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm
2014
_signature
*
signature
,
void
*
value
)
{
struct
decimating_private
*
decimating
=
action_context
->
context
;
...
...
@@ -114,26 +114,26 @@ static int wrap_reader_start(
if
(
value
==
NULL
)
{
int
*
decimation
,
amount
;
labcomm_scheduler_data_lock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_lock
(
decimating
->
scheduler
);
decimation
=
LABCOMM_SIGNATURE_ARRAY_REF
(
decimating
->
memory
,
decimating
->
reader_decimation
,
int
,
local_index
);
amount
=
*
decimation
;
labcomm_scheduler_data_unlock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_unlock
(
decimating
->
scheduler
);
if
(
remote_index
!=
0
&&
amount
!=
0
)
{
enqueue_decimation
(
decimating
,
remote_index
,
amount
);
}
}
return
labcomm_reader_start
(
r
,
action_context
->
next
,
return
labcomm
2014
_reader_start
(
r
,
action_context
->
next
,
local_index
,
remote_index
,
signature
,
value
);
}
static
int
wrap_reader_ioctl
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
struct
labcomm
2014
_reader
*
r
,
struct
labcomm
2014
_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
const
struct
labcomm
2014
_signature
*
signature
,
uint32_t
action
,
va_list
args
)
{
struct
decimating_private
*
decimating
=
action_context
->
context
;
...
...
@@ -147,26 +147,26 @@ static int wrap_reader_ioctl(
amount
=
va_arg
(
va
,
int
);
va_end
(
va
);
labcomm_scheduler_data_lock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_lock
(
decimating
->
scheduler
);
decimation
=
LABCOMM_SIGNATURE_ARRAY_REF
(
decimating
->
memory
,
decimating
->
reader_decimation
,
int
,
local_index
);
*
decimation
=
amount
;
labcomm_scheduler_data_unlock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_unlock
(
decimating
->
scheduler
);
if
(
remote_index
)
{
enqueue_decimation
(
decimating
,
remote_index
,
amount
);
}
}
else
{
return
labcomm_reader_ioctl
(
r
,
action_context
->
next
,
return
labcomm
2014
_reader_ioctl
(
r
,
action_context
->
next
,
local_index
,
remote_index
,
signature
,
action
,
args
);
}
return
0
;
}
struct
labcomm_reader_action
decimating_reader_action
=
{
struct
labcomm
2014
_reader_action
decimating_reader_action
=
{
.
alloc
=
wrap_reader_alloc
,
.
free
=
NULL
,
.
start
=
wrap_reader_start
,
...
...
@@ -179,25 +179,25 @@ static void register_signatures(void *context)
{
struct
decimating_private
*
decimating
=
context
;
labcomm_encoder_register_decimating_messages_set_decimation
(
labcomm
2014
_encoder_register_decimating_messages_set_decimation
(
decimating
->
decimating
.
writer
->
encoder
);
}
static
int
wrap_writer_alloc
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
)
struct
labcomm
2014
_writer
*
w
,
struct
labcomm
2014
_writer_action_context
*
action_context
)
{
struct
decimating_private
*
decimating
=
action_context
->
context
;
labcomm_scheduler_enqueue
(
decimating
->
scheduler
,
labcomm
2014
_scheduler_enqueue
(
decimating
->
scheduler
,
0
,
register_signatures
,
decimating
);
return
labcomm_writer_alloc
(
w
,
action_context
->
next
);
return
labcomm
2014
_writer_alloc
(
w
,
action_context
->
next
);
}
static
int
wrap_writer_start
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
int
index
,
const
struct
labcomm_signature
*
signature
,
struct
labcomm
2014
_writer
*
w
,
struct
labcomm
2014
_writer_action_context
*
action_context
,
int
index
,
const
struct
labcomm
2014
_signature
*
signature
,
void
*
value
)
{
struct
decimating_private
*
decimating
=
action_context
->
context
;
...
...
@@ -207,7 +207,7 @@ static int wrap_writer_start(
if
(
index
<
LABCOMM_USER
)
{
result
=
0
;
}
else
{
labcomm_scheduler_data_lock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_lock
(
decimating
->
scheduler
);
decimation
=
LABCOMM_SIGNATURE_ARRAY_REF
(
decimating
->
memory
,
decimating
->
writer_decimation
,
struct
decimation
,
index
);
...
...
@@ -218,16 +218,16 @@ static int wrap_writer_start(
decimation
->
current
=
0
;
result
=
0
;
}
labcomm_scheduler_data_unlock
(
decimating
->
scheduler
);
labcomm
2014
_scheduler_data_unlock
(
decimating
->
scheduler
);
}
if
(
result
==
0
)
{
result
=
labcomm_writer_start
(
w
,
action_context
->
next
,
result
=
labcomm
2014
_writer_start
(
w
,
action_context
->
next
,
index
,
signature
,
value
);
}
return
result
;
}
struct
labcomm_writer_action
decimating_writer_action
=
{
struct
labcomm
2014
_writer_action
decimating_writer_action
=
{
.
alloc
=
wrap_writer_alloc
,
.
free
=
NULL
,
.
start
=
wrap_writer_start
,
...
...
@@ -237,11 +237,11 @@ struct labcomm_writer_action decimating_writer_action = {
};
struct
decimating
*
decimating_new
(
struct
labcomm_reader
*
reader
,
struct
labcomm_writer
*
writer
,
struct
labcomm_error_handler
*
error
,
struct
labcomm_memory
*
memory
,
struct
labcomm_scheduler
*
scheduler
)
struct
labcomm
2014
_reader
*
reader
,
struct
labcomm
2014
_writer
*
writer
,
struct
labcomm
2014
_error_handler
*
error
,
struct
labcomm
2014
_memory
*
memory
,
struct
labcomm
2014
_scheduler
*
scheduler
)
{
struct
decimating_private
*
result
;
...
...
examples/twoway/decimating.h
View file @
e3c16fda
#ifndef __DECIMATING_H__
#define __DECIMATING_H__
#include
<labcomm.h>
#include
<labcomm_ioctl.h>
#include
<labcomm
2014
.h>
#include
<labcomm
2014
_ioctl.h>
struct
decimating
{
struct
labcomm_reader
*
reader
;
struct
labcomm_writer
*
writer
;
struct
labcomm
2014
_reader
*
reader
;
struct
labcomm
2014
_writer
*
writer
;
};
extern
struct
decimating
*
decimating_new
(
struct
labcomm_reader
*
reader
,
struct
labcomm_writer
*
writer
,
struct
labcomm_error_handler
*
error
,
struct
labcomm_memory
*
memory
,
struct
labcomm_scheduler
*
scheduler
);
struct
labcomm
2014
_reader
*
reader
,
struct
labcomm
2014
_writer
*
writer
,
struct
labcomm
2014
_error_handler
*
error
,
struct
labcomm
2014
_memory
*
memory
,
struct
labcomm
2014
_scheduler
*
scheduler
);
#define SET_DECIMATION LABCOMM_IOSW('d',0,int)
...
...
examples/twoway/introspecting.c
View file @
e3c16fda
...
...
@@ -23,18 +23,18 @@
#include
<errno.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
"labcomm_private.h"
#include
"labcomm
2014
_private.h"
#include
"introspecting.h"
#include
"gen/introspecting_messages.h"
struct
introspecting_private
{
struct
introspecting
introspecting
;
struct
labcomm_error_handler
*
error
;
struct
labcomm_memory
*
memory
;
struct
labcomm_scheduler
*
scheduler
;
struct
labcomm
2014
_error_handler
*
error
;
struct
labcomm
2014
_memory
*
memory
;
struct
labcomm
2014
_scheduler
*
scheduler
;
struct
labcomm_reader_action_context
reader_action_context
;
struct
labcomm_writer_action_context
writer_action_context
;
struct
labcomm
2014
_reader_action_context
reader_action_context
;
struct
labcomm
2014
_writer_action_context
writer_action_context
;
LABCOMM_SIGNATURE_ARRAY_DEF
(
remote
,
struct
remote
{
char
*
name
;
...
...
@@ -44,13 +44,13 @@ struct introspecting_private {
LABCOMM_SIGNATURE_ARRAY_DEF
(
local
,
struct
local
{
enum
introspecting_status
status
;
const
struct
labcomm_signature
*
signature
;
const
struct
labcomm
2014
_signature
*
signature
;
});
};
static
struct
local
*
get_local
(
struct
introspecting_private
*
introspecting
,
int
index
,
const
struct
labcomm_signature
*
signature
)
const
struct
labcomm
2014
_signature
*
signature
)
{
/* Called with data_lock held */
struct
local
*
local
;
...
...
@@ -91,7 +91,7 @@ static void handles_signature(
struct
introspecting_private
*
introspecting
=
context
;
struct
remote
*
remote
;
labcomm_scheduler_data_lock
(
introspecting
->
scheduler
);
labcomm
2014
_scheduler_data_lock
(
introspecting
->
scheduler
);