Skip to content

Commit 186a99a

Browse files
authored
Merge pull request #11 from DavidingPlus/feature-liuzx-cross-space
Fix Problem When Running Unit Test With Util
2 parents 545ff3d + 7501ca6 commit 186a99a

File tree

20 files changed

+115
-37
lines changed

20 files changed

+115
-37
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
3+
#include "defs.h"
4+
#include "util.h"
5+
6+
7+
int main()
8+
{
9+
std::cout << nvmixCalcInodeBlocks(0) << std::endl; // 0
10+
std::cout << nvmixCalcInodeBlocks(1) << std::endl; // 8
11+
std::cout << nvmixCalcInodeBlocks(NVMIX_BLOCK_SIZE - 1) << std::endl; // 8
12+
std::cout << nvmixCalcInodeBlocks(NVMIX_BLOCK_SIZE) << std::endl; // 8
13+
std::cout << nvmixCalcInodeBlocks(NVMIX_BLOCK_SIZE + 1) << std::endl; // 16
14+
15+
16+
return 0;
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target ("CalcInodeBlocksTest")
2+
set_kind ("binary")
3+
add_files ("main.cpp")
4+
add_deps ("nvmix-cross-space")

src/defs.h renamed to src/cross-space/defs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#ifndef _NVMIX_DEFS_H_
1212
#define _NVMIX_DEFS_H_
1313

14+
#include "globalmacros.h"
15+
16+
17+
NVMIX_EXTERN_C_BEGIN
18+
1419

1520
/**
1621
* @brief 超级块的逻辑块号。
@@ -116,4 +121,7 @@ struct NvmixInode
116121
};
117122

118123

124+
NVMIX_EXTERN_C_END
125+
126+
119127
#endif

src/cross-space/globalmacros.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @file globalmacros.h
3+
* @author DavidingPlus (davidingplus@qq.com)
4+
* @brief 全局宏定义头文件。
5+
*
6+
* Copyright (c) 2025 电子科技大学 刘治学
7+
*
8+
*/
9+
10+
#ifndef _NVMIX_GLOBALMACROS_H_
11+
#define _NVMIX_GLOBALMACROS_H_
12+
13+
14+
#ifdef __cplusplus
15+
16+
#define NVMIX_EXTERN_C_BEGIN \
17+
extern "C" \
18+
{
19+
20+
#define NVMIX_EXTERN_C_END }
21+
22+
#else
23+
24+
#define NVMIX_EXTERN_C_BEGIN
25+
26+
#define NVMIX_EXTERN_C_END
27+
28+
#endif
29+
30+
31+
#endif
File renamed without changes.

src/util.h renamed to src/cross-space/util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
#ifndef _NVMIX_UTIL_H_
1212
#define _NVMIX_UTIL_H_
1313

14+
#include "globalmacros.h"
1415
#include "defs.h"
1516

1617

18+
NVMIX_EXTERN_C_BEGIN
19+
20+
1721
#define NVMIX_DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d))
1822

1923
// 通过 inode 对应目录项的大小转化为 inode->i_blocks 的值,注意 inode->i_blocks 以 512 B 为单位。
@@ -24,4 +28,7 @@
2428
unsigned long long nvmixCalcInodeBlocks(long long size);
2529

2630

31+
NVMIX_EXTERN_C_END
32+
33+
2734
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)