Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schmaus
emper
Commits
75bef808
Commit
75bef808
authored
4 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
export async functions to C
parent
f07625ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
emper/c_emper.cpp
+40
-0
40 additions, 0 deletions
emper/c_emper.cpp
emper/include/emper.h
+25
-0
25 additions, 0 deletions
emper/include/emper.h
with
65 additions
and
0 deletions
emper/c_emper.cpp
+
40
−
0
View file @
75bef808
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
#include
"BinaryPrivateSemaphore.hpp"
#include
"BinaryPrivateSemaphore.hpp"
#include
"CountingPrivateSemaphore.hpp"
#include
"CountingPrivateSemaphore.hpp"
#ifdef EMPER_ASYNC_LIB
#include
"AsyncLibrary.hpp"
#endif
runtime
*
init_runtime
(
void
)
{
runtime
*
init_runtime
(
void
)
{
Runtime
*
r
=
new
Runtime
();
Runtime
*
r
=
new
Runtime
();
return
reinterpret_cast
<
runtime
*>
(
r
);
return
reinterpret_cast
<
runtime
*>
(
r
);
...
@@ -96,3 +100,39 @@ void wait_cps(cps* sem) {
...
@@ -96,3 +100,39 @@ void wait_cps(cps* sem) {
countingPrivateSemaphore
->
wait
();
countingPrivateSemaphore
->
wait
();
}
}
#ifdef EMPER_ASYNC_NETWORK
int
async_recv
(
int
fd
,
unsigned
char
*
buff
,
int
buff_len
,
int
flags
)
{
bool
read_once
=
flags
&
READ_FULL_BUFFER
==
0
;
bool
fd_serialized
=
flags
&
UNSERIALIZED
==
0
;
return
io
::
async_recv
(
fd
,
buff
,
buff_len
,
read_once
,
fd_serialized
);
}
int
async_send
(
int
fd
,
unsigned
char
*
buff
,
int
buff_len
,
int
flags
)
{
bool
fd_serialized
=
flags
&
UNSERIALIZED
==
0
;
return
io
::
async_recv
(
fd
,
buff
,
buff_len
,
read_once
,
fd_serialized
);
}
int
async_connect
(
int
fd
,
sockaddr
*
sockaddress
,
socklen_t
len
,
int
flags
)
{
bool
fd_serialized
=
flags
&
UNSERIALIZED
==
0
;
return
io
::
async_connect
(
fd
,
sockaddress
,
len
,
fd_serialized
);
}
int
async_accept
(
int
fd
,
sockaddr
*
sockaddress
,
socklen_t
len
,
int
flags
)
{
bool
fd_serialized
=
flags
&
UNSERIALIZED
==
0
;
return
io
::
async_accept
(
fd
,
sockaddress
,
len
,
fd_serialized
);
}
#endif
#ifdef EMPER_ASYNC_DISK_IO
int
async_read_file
(
int
fd
,
unsigned
char
*
buff
,
size_t
count
,
off_t
offset
)
{
return
io
::
async_read_file
(
fd
,
buff
,
count
,
offset
);
}
int
async_write_file
(
int
fd
,
const
unsigned
char
*
buff
,
size_t
count
,
off_t
offset
)
{
return
io
::
async_write_file
(
fd
,
buff
,
count
,
offset
);
}
#endif
This diff is collapsed.
Click to expand it.
emper/include/emper.h
+
25
−
0
View file @
75bef808
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
#include
"emper-common.h"
#include
"emper-common.h"
#ifdef EMPER_ASYNC_NETWORK
#include
"sys/socket.h"
#endif
typedef
struct
runtime
runtime
;
typedef
struct
runtime
runtime
;
typedef
struct
fiber
fiber
;
typedef
struct
fiber
fiber
;
...
@@ -56,6 +60,27 @@ extern "C" {
...
@@ -56,6 +60,27 @@ extern "C" {
void
wait_cps
(
cps
*
sem
);
void
wait_cps
(
cps
*
sem
);
#ifdef EMPER_ASYNC_NETWORK
enum
EMPER_ASYNC_NETWORK_FLAGS
{
READ_FULL_BUFFER
=
1
,
UNSERIALIZED
=
2
,
};
int
async_recv
(
int
fd
,
unsigned
char
*
buff
,
int
buff_len
,
int
flags
);
int
async_send
(
int
fd
,
unsigned
char
*
buff
,
int
buff_len
,
int
flags
);
int
async_connect
(
int
fd
,
sockaddr
*
sockaddress
,
socklen_t
len
,
int
flags
);
int
async_accept
(
int
fd
,
sockaddr
*
sockaddress
,
socklen_t
len
,
int
flags
);
#endif
#ifdef EMPER_ASYNC_DISK_IO
int
async_read_file
(
int
fd
,
unsigned
char
*
buff
,
size_t
count
,
off_t
offset
);
int
async_write_file
(
int
fd
,
const
unsigned
char
*
buff
,
size_t
count
,
off_t
offset
);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment