Skip to content

Commit cae1c6c

Browse files
committed
commonizing some coroutine stuff
1 parent 3377755 commit cae1c6c

File tree

4 files changed

+53
-28
lines changed

4 files changed

+53
-28
lines changed

inc/coroutine.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,7 @@
1616
#ifndef COROUTINE_H
1717
#define COROUTINE_H
1818

19-
/**
20-
* @brief Token concatenation detail
21-
*/
22-
23-
#define TOKENCONCAT_DETAIL(x, y) x##y
24-
/**
25-
* @brief Concatenates two tokens
26-
*/
27-
28-
#define TOKENCONCAT(x, y) TOKENCONCAT_DETAIL(x, y)
29-
/**
30-
* @brief Generates an unique coroutine label with the __LINE__ macro
31-
*/
32-
#define CR_LABEL TOKENCONCAT(CR_, __LINE__)
19+
#include "sq_coro_common.h"
3320

3421
/**
3522
* @brief Start of coroutine

inc/coroutine.hpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,7 @@
1414
#ifndef COROUTINE_HPP
1515
#define COROUTINE_HPP
1616

17-
/**
18-
* @brief Token concatenation detail
19-
*/
20-
21-
#define TOKENCONCAT_DETAIL(x, y) x##y
22-
/**
23-
* @brief Concatenates two tokens
24-
*/
25-
26-
#define TOKENCONCAT(x, y) TOKENCONCAT_DETAIL(x, y)
27-
/**
28-
* @brief Generates an unique coroutine label with the __LINE__ macro
29-
*/
30-
#define CR_LABEL TOKENCONCAT(CR_, __LINE__)
17+
#include "sq_coro_common.h"
3118

3219
/**
3320
* @brief Coroutine state structure to be defined in class

inc/sq_coro_common.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
*
4+
* Copyright (c) 2023 Bart Bilos
5+
* For conditions of distribution and use, see LICENSE file
6+
*/
7+
/**
8+
*\file sq_coro_common.h
9+
*
10+
* contains common macros for coroutines
11+
*
12+
*/
13+
#ifndef SQ_CORO_COMMON_H
14+
#define SQ_CORO_COMMON_H
15+
16+
#include "sq_tokenconcat.h"
17+
18+
/**
19+
* @brief Generates an unique coroutine label with the __LINE__ macro
20+
*/
21+
#define CR_LABEL TOKENCONCAT(CR_, __LINE__)
22+
23+
#define CR_START cr_start /**< standard coroutine start */
24+
25+
#endif

inc/sq_tokenconcat.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
*
4+
* Copyright (c) 2023 Bart Bilos
5+
* For conditions of distribution and use, see LICENSE file
6+
*/
7+
/**
8+
*\file sq_tokenconcat.h
9+
*
10+
* Contains standard preprocessor token concatenation idiom
11+
*
12+
*/
13+
#ifndef SQ_TOKENCONCAT_H
14+
#define SQ_TOKENCONCAT_H
15+
16+
/**
17+
* @brief Token concatenation detail
18+
*/
19+
#define TOKENCONCAT_DETAIL(x, y) x##y
20+
21+
/**
22+
* @brief Concatenates two tokens
23+
*/
24+
#define TOKENCONCAT(x, y) TOKENCONCAT_DETAIL(x, y)
25+
26+
#endif

0 commit comments

Comments
 (0)