Skip to content

Commit c97b1e7

Browse files
committedJan 30, 2015
[Msan] Fix the shmctl unit tests to pass on FreeBSD
Differential Revision: http://reviews.llvm.org/D7253 llvm-svn: 227571
1 parent 07e6c00 commit c97b1e7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎compiler-rt/lib/msan/tests/msan_test.cc

+16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
#include "sanitizer/allocator_interface.h"
2222
#include "sanitizer/msan_interface.h"
2323

24+
#if defined(__FreeBSD__)
25+
# define _KERNEL // To declare 'shminfo' structure.
26+
# include <sys/shm.h>
27+
# undef _KERNEL
28+
extern "C" {
29+
// <sys/shm.h> doesn't declare these functions in _KERNEL mode.
30+
void *shmat(int, const void *, int);
31+
int shmget(key_t, size_t, int);
32+
int shmctl(int, int, struct shmid_ds *);
33+
int shmdt(const void *);
34+
}
35+
#endif
36+
2437
#include <inttypes.h>
2538
#include <stdlib.h>
2639
#include <stdarg.h>
@@ -1165,6 +1178,8 @@ TEST(MemorySanitizer, shmctl) {
11651178
ASSERT_GT(res, -1);
11661179
EXPECT_NOT_POISONED(ds);
11671180

1181+
// FreeBSD does not support shmctl(IPC_INFO) and shmctl(SHM_INFO).
1182+
#if !defined(__FreeBSD__)
11681183
struct shminfo si;
11691184
res = shmctl(id, IPC_INFO, (struct shmid_ds *)&si);
11701185
ASSERT_GT(res, -1);
@@ -1174,6 +1189,7 @@ TEST(MemorySanitizer, shmctl) {
11741189
res = shmctl(id, SHM_INFO, (struct shmid_ds *)&s_i);
11751190
ASSERT_GT(res, -1);
11761191
EXPECT_NOT_POISONED(s_i);
1192+
#endif
11771193

11781194
res = shmctl(id, IPC_RMID, 0);
11791195
ASSERT_GT(res, -1);

0 commit comments

Comments
 (0)