Skip to content

Commit fa4e686

Browse files
committed
add bsd
1 parent 1037b22 commit fa4e686

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

include/aws/common/platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
# define AWS_OS_LINUX
3232
#endif
3333

34+
#if defined(__FreeBSD__) || defined(__NetBSD__)
35+
# define AWS_OS_BSD
36+
#endif
37+
3438
#if defined(__ANDROID__)
3539
# define AWS_OS_ANDROID
3640
#endif

include/aws/common/system_info.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ AWS_PUSH_SANE_WARNING_LEVEL
2121
* - AWS_PLATFORM_OS_TVOS → "tvOS" (Apple TV devices)
2222
* - AWS_PLATFORM_OS_WATCHOS → "watchOS" (Apple Watch devices)
2323
* - AWS_PLATFORM_OS_ANDROID → "Android" (Android)
24-
* - AWS_PLATFORM_OS_UNIX → "Unix" (Linux, BSD, other Unix-like)
24+
* - AWS_PLATFORM_OS_BSD → "BSD" (FreeBSD, NetBSD)
25+
* - AWS_PLATFORM_OS_UNIX → "Unix" (Linux, other Unix-like)
2526
*/
2627
enum aws_platform_os {
2728
AWS_PLATFORM_OS_WINDOWS,
@@ -30,6 +31,7 @@ enum aws_platform_os {
3031
AWS_PLATFORM_OS_TVOS,
3132
AWS_PLATFORM_OS_WATCHOS,
3233
AWS_PLATFORM_OS_ANDROID,
34+
AWS_PLATFORM_OS_BSD,
3335
AWS_PLATFORM_OS_UNIX,
3436
};
3537

source/posix/system_info.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ void aws_backtrace_log(int log_level) {
468468
enum aws_platform_os aws_get_platform_build_os(void) {
469469
#if defined(AWS_OS_MACOS)
470470
return AWS_PLATFORM_OS_MAC;
471-
// Other Apple platforms will be reported as iOS
472471
#elif defined(AWS_OS_IOS)
473472
return AWS_PLATFORM_OS_IOS;
474473
#elif defined(AWS_OS_TVOS)
@@ -477,6 +476,8 @@ enum aws_platform_os aws_get_platform_build_os(void) {
477476
return AWS_PLATFORM_OS_WATCHOS;
478477
#elif defined(AWS_OS_ANDROID)
479478
return AWS_PLATFORM_OS_ANDROID;
479+
#elif defined(AWS_OS_BSD)
480+
return AWS_PLATFORM_OS_BSD;
480481
#else
481482
return AWS_PLATFORM_OS_UNIX;
482483
#endif

source/system_info.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ size_t aws_system_environment_get_cpu_group_count(const struct aws_system_enviro
8484
* follow common industry conventions:
8585
* - "Windows" - Microsoft Windows family
8686
* - "macOS" - Apple macOS
87-
* - "iOS" - Apple iOS (or other unknown Apple platform)
87+
* - "iOS" - Apple iOS
88+
* - "tvOS" - Apple tvOS
89+
* - "watchOS" - Apple watchOS
8890
* - "Android" - Google Android mobile OS
89-
* - "Unix" - Unix-like systems (Linux, BSD, etc.)
91+
* - "BSD" - BSD family (FreeBSD, NetBSD, etc.)
92+
* - "Unix" - Unix-like systems (Linux, unix-like etc.)
9093
* - "Unknown" - Fallback for unrecognized platforms
9194
*/
9295

@@ -118,9 +121,13 @@ struct aws_byte_cursor aws_get_platform_build_os_string(void) {
118121
break;
119122
case AWS_PLATFORM_OS_WATCHOS:
120123
os_str = aws_byte_cursor_from_c_str("watchOS");
124+
break;
121125
case AWS_PLATFORM_OS_ANDROID:
122126
os_str = aws_byte_cursor_from_c_str("Android");
123127
break;
128+
case AWS_PLATFORM_OS_BSD:
129+
os_str = aws_byte_cursor_from_c_str("BSD");
130+
break;
124131
case AWS_PLATFORM_OS_UNIX:
125132
os_str = aws_byte_cursor_from_c_str("Unix");
126133
break;

tests/system_info_tests.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static int s_test_platform_build_os_fn(struct aws_allocator *allocator, void *ct
128128
ASSERT_INT_EQUALS(build_os, AWS_PLATFORM_OS_ANDROID);
129129
#elif defined(_WIN32)
130130
ASSERT_INT_EQUALS(build_os, AWS_PLATFORM_OS_WINDOWS);
131+
#elif defined(AWS_OS_BSD)
132+
ASSERT_INT_EQUALS(build_os, AWS_PLATFORM_OS_BSD);
131133
#else
132134
ASSERT_INT_EQUALS(build_os, AWS_PLATFORM_OS_UNIX);
133135
#endif
@@ -165,6 +167,8 @@ static int s_test_platform_build_os_string_fn(struct aws_allocator *allocator, v
165167
expected_os = aws_byte_cursor_from_c_str("Android-");
166168
#elif defined(AWS_OS_WINDOWS)
167169
expected_os = aws_byte_cursor_from_c_str("Windows-");
170+
#elif defined(AWS_OS_BSD)
171+
expected_os = aws_byte_cursor_from_c_str("BSD-");
168172
#else
169173
expected_os = aws_byte_cursor_from_c_str("Unix-");
170174
#endif
@@ -177,7 +181,7 @@ static int s_test_platform_build_os_string_fn(struct aws_allocator *allocator, v
177181
#if defined(AWS_ARCH_INTEL)
178182
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&os_string, "intel"));
179183
#elif defined(AWS_ARCH_INTEL_64)
180-
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&os_string, "intel_64"));
184+
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&os_string, "intel64"));
181185
#elif defined(AWS_ARCH_ARM64)
182186
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&os_string, "arm64"));
183187
#elif defined(AWS_ARCH_ARM32)

0 commit comments

Comments
 (0)