[PATCH] D60477: [TSan][libdispatch] Replace usage of NSMutableData with stack array

Julian Lettner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 11:15:12 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT358205: [TSan][libdispatch] Replace usage of NSMutableData with stack array (authored by yln, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60477?vs=194369&id=194724#toc

Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60477/new/

https://reviews.llvm.org/D60477

Files:
  test/tsan/Darwin/gcd-fd.mm
  test/tsan/Darwin/gcd-io-barrier-race.mm
  test/tsan/Darwin/gcd-io-barrier.mm
  test/tsan/Darwin/gcd-io-race.mm
  test/tsan/Darwin/gcd-io.mm


Index: test/tsan/Darwin/gcd-io.mm
===================================================================
--- test/tsan/Darwin/gcd-io.mm
+++ test/tsan/Darwin/gcd-io.mm
@@ -100,8 +100,8 @@
   sem = dispatch_semaphore_create(0);
   NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
   path = ns_path.fileSystemRepresentation;
-  NSData *ns_data = [NSMutableData dataWithLength:1000];
-  data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
   
   test_dispatch_io_write();
   test_dispatch_write();
Index: test/tsan/Darwin/gcd-io-barrier-race.mm
===================================================================
--- test/tsan/Darwin/gcd-io-barrier-race.mm
+++ test/tsan/Darwin/gcd-io-barrier-race.mm
@@ -21,8 +21,8 @@
   sem = dispatch_semaphore_create(0);
   NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
   path = ns_path.fileSystemRepresentation;
-  NSData *ns_data = [NSMutableData dataWithLength:1000];
-  data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
   
   dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
   if (! channel) abort();
Index: test/tsan/Darwin/gcd-fd.mm
===================================================================
--- test/tsan/Darwin/gcd-fd.mm
+++ test/tsan/Darwin/gcd-fd.mm
@@ -17,8 +17,8 @@
       0666, queue, ^(int error) { });
   dispatch_io_set_high_water(channel, 1);
 
-  NSData *ns_data = [NSMutableData dataWithLength:1000];
-  dispatch_data_t data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  char buf[1000];
+  dispatch_data_t data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
 
   my_global++;
   dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
Index: test/tsan/Darwin/gcd-io-barrier.mm
===================================================================
--- test/tsan/Darwin/gcd-io-barrier.mm
+++ test/tsan/Darwin/gcd-io-barrier.mm
@@ -17,8 +17,8 @@
   sem = dispatch_semaphore_create(0);
   NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
   path = ns_path.fileSystemRepresentation;
-  NSData *ns_data = [NSMutableData dataWithLength:1000];
-  data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
   
   dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
   if (! channel) abort();
Index: test/tsan/Darwin/gcd-io-race.mm
===================================================================
--- test/tsan/Darwin/gcd-io-race.mm
+++ test/tsan/Darwin/gcd-io-race.mm
@@ -23,8 +23,8 @@
   sem = dispatch_semaphore_create(0);
   NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
   path = ns_path.fileSystemRepresentation;
-  NSData *ns_data = [NSMutableData dataWithLength:1000];
-  data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
   
   dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
   if (! channel) abort();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60477.194724.patch
Type: text/x-patch
Size: 4007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190411/d8832dbb/attachment-0001.bin>


More information about the llvm-commits mailing list