Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
0add2783
Commit
0add2783
authored
Jul 17, 2015
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace: librarize (and used twice) the previous commit
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
63dd85b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
shmem.h
userspace/libwr/include/libwr/shmem.h
+3
-0
shmem.c
userspace/libwr/shmem.c
+17
-0
snmp_shmem.c
userspace/snmpd/snmp_shmem.c
+2
-0
wr_mon.c
userspace/tools/wr_mon.c
+2
-11
No files found.
userspace/libwr/include/libwr/shmem.h
View file @
0add2783
...
...
@@ -44,6 +44,9 @@ struct wrs_shm_head {
void
*
wrs_shm_get
(
enum
wrs_shm_name
name_id
,
char
*
name
,
unsigned
long
flags
);
int
wrs_shm_put
(
void
*
headptr
);
/* A reader may wait for the writer (polling on version field) */
void
wrs_shm_wait
(
void
*
headptr
,
int
msec_step
,
int
retries
,
FILE
*
msg
);
/* The writer can allocate structures that live in the area itself */
void
*
wrs_shm_alloc
(
void
*
headptr
,
size_t
size
);
...
...
userspace/libwr/shmem.c
View file @
0add2783
...
...
@@ -113,6 +113,23 @@ int wrs_shm_put(void *headptr)
return
0
;
}
/* A reader may wait for the writer (polling on version field) */
void
wrs_shm_wait
(
void
*
headptr
,
int
msec_step
,
int
retries
,
FILE
*
msg
)
{
struct
wrs_shm_head
*
head
=
headptr
;
int
i
;
for
(
i
=
0
;
i
<
retries
&&
!
head
->
version
;
i
++
)
{
if
(
!
i
&&
msg
)
fprintf
(
msg
,
"Waiting for my peer..."
);
if
(
msg
)
fprintf
(
stderr
,
"."
);
usleep
(
1000
*
msec_step
);
}
if
(
i
&&
msg
)
fprintf
(
msg
,
"
\n
"
);
}
/* The writer can allocate structures that live in the area itself */
void
*
wrs_shm_alloc
(
void
*
headptr
,
size_t
size
)
{
...
...
userspace/snmpd/snmp_shmem.c
View file @
0add2783
...
...
@@ -26,6 +26,8 @@ static void init_shm_hal(void)
snmp_log
(
LOG_ERR
,
"unable to open shm for HAL!
\n
"
);
exit
(
-
1
);
}
wrs_shm_wait
(
hal_head
,
500
/* ms */
,
20
,
NULL
);
/* check hal's shm version */
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
snmp_log
(
LOG_ERR
,
"unknown hal's shm version %i "
...
...
userspace/tools/wr_mon.c
View file @
0add2783
...
...
@@ -99,23 +99,13 @@ void ppsi_connect_minipc()
void
init_shm
(
void
)
{
struct
hal_shmem_header
*
h
;
int
retr
,
maxretr
=
15
;
hal_head
=
wrs_shm_get
(
wrs_shm_hal
,
""
,
WRS_SHM_READ
);
if
(
!
hal_head
)
{
fprintf
(
stderr
,
"unable to open shm for HAL!
\n
"
);
exit
(
1
);
}
for
(
retr
=
0
;
retr
<
maxretr
&&
!
hal_head
->
version
;
retr
++
)
{
if
(
!
retr
)
fprintf
(
stderr
,
"Waiting for HAL.."
);
fprintf
(
stderr
,
"."
);
sleep
(
1
);
}
if
(
retr
)
fprintf
(
stderr
,
"
\n
"
);
/* check hal's shm version */
wrs_shm_wait
(
hal_head
,
500
/* ms */
,
20
,
stderr
);
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"wr_mon: unknown HAL's shm version %i "
"(known is %i)
\n
"
,
...
...
@@ -146,6 +136,7 @@ void init_shm(void)
fprintf
(
stderr
,
"unable to open shm for PPSI!
\n
"
);
exit
(
1
);
}
wrs_shm_wait
(
ppsi_head
,
500
/* ms */
,
20
,
stderr
);
/* check hal's shm version */
if
(
ppsi_head
->
version
!=
WRS_PPSI_SHMEM_VERSION
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment