-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some generic code to handle most of the cases when pthreads is disabled. Apply those to oomtest.c so it will compile without pthreads. Signed-off-by: Corey Minyard <cminyard@mvista.com>
- Loading branch information
Showing
7 changed files
with
111 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
|
||
SUBDIRS = gensio | ||
|
||
noinst_HEADERS = pthread_handler.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* gensio - A library for abstracting stream I/O | ||
* Copyright (C) 2020 Corey Minyard <minyard@acm.org> | ||
* | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
/* | ||
* This allows a lot of pthread calls to be dummied out if pthreads is | ||
* disabled. | ||
*/ | ||
#ifdef USE_PTHREADS | ||
#include <pthread.h> | ||
#define lock_type pthread_mutex_t | ||
#define LOCK_INIT(l) pthread_mutex_init(l, NULL) | ||
#define LOCK_DESTROY(l) pthread_mutex_destroy(l) | ||
#define LOCK(l) pthread_mutex_lock(l) | ||
#define UNLOCK(l) pthread_mutex_unlock(l) | ||
#define LOCK_INITIALIZER PTHREAD_MUTEX_INITIALIZER | ||
#else | ||
#include <assert.h> | ||
#define lock_type int | ||
#define LOCK_INIT(l) do { *l = 0; } while(0) | ||
#define LOCK_DESTROY(l) do { assert(*l == 0); } while(0) | ||
#define LOCK(l) do { assert(*l == 0); *l = 1; } while(0) | ||
#define UNLOCK(l) do { assert(*l == 1); *l = 0; } while(0) | ||
#define LOCK_INITIALIZER 0 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.