Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
9dd26ea5
Commit
9dd26ea5
authored
22 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added support for semaphore-attached ring buffers (automatically signaled on
each write), must define RINGBUF_SEM.
parent
0d58aca4
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
src/sbbs3/ringbuf.c
+11
-1
11 additions, 1 deletion
src/sbbs3/ringbuf.c
src/sbbs3/ringbuf.h
+9
-3
9 additions, 3 deletions
src/sbbs3/ringbuf.h
with
20 additions
and
4 deletions
src/sbbs3/ringbuf.c
+
11
−
1
View file @
9dd26ea5
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
0
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
3
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
...
...
@@ -93,6 +93,9 @@ int RINGBUFCALL RingBufInit( RingBuf* rb, DWORD size
rb
->
pHead
=
rb
->
pTail
=
rb
->
pStart
;
rb
->
pEnd
=
rb
->
pStart
+
size
;
rb
->
size
=
size
;
#ifdef RINGBUF_SEM
sem_init
(
&
rb
->
sem
,
0
,
0
);
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_init
(
&
rb
->
mutex
,
NULL
);
#endif
...
...
@@ -103,6 +106,10 @@ void RINGBUFCALL RingBufDispose( RingBuf* rb)
{
if
(
rb
->
pStart
!=
NULL
)
os_free
(
rb
->
pStart
);
#ifdef RINGBUF_SEM
sem_post
(
&
rb
->
sem
);
/* just incase someone's waiting */
sem_destroy
(
&
rb
->
sem
);
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_destroy
(
&
rb
->
mutex
);
#endif
...
...
@@ -182,6 +189,9 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src, DWORD cnt )
if
(
rb
->
pHead
>
rb
->
pEnd
)
rb
->
pHead
=
rb
->
pStart
;
#ifdef RINGBUF_SEM
sem_post
(
&
rb
->
sem
);
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_unlock
(
&
rb
->
mutex
);
#endif
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/ringbuf.h
+
9
−
3
View file @
9dd26ea5
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
0
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
3
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
...
...
@@ -43,6 +43,9 @@
#ifndef _RINGBUF_H_
#define _RINGBUF_H_
#ifdef RINGBUF_SEM
#include
"semwrap.h"
/* sem_t */
#endif
#ifdef RINGBUF_MUTEX
#include
"threadwrap.h"
/* pthread_mutex_t */
#endif
...
...
@@ -78,8 +81,11 @@ typedef struct {
BYTE
*
pTail
;
/* next byte to be consumed */
BYTE
*
pEnd
;
/* end of the buffer, used for wrap around */
DWORD
size
;
#ifdef RINGBUF_SEM
sem_t
sem
;
/* semaphore used to signal data waiting */
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
/* mutex used to protect ring buffer pointers */
#endif
}
RingBuf
;
...
...
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