am 0f7ed163: Merge "Fix memchr with a zero length."
				
					
				
			* commit '0f7ed163cf6c1fe6d71a1d7e5fb6d0989213be85': Fix memchr with a zero length.
This commit is contained in:
		@@ -75,6 +75,7 @@ ENTRY(memchr)
 | 
				
			|||||||
	 * Magic constant 0x40100401 allows us to identify which lane matches
 | 
						 * Magic constant 0x40100401 allows us to identify which lane matches
 | 
				
			||||||
	 * the requested byte.
 | 
						 * the requested byte.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
						cbz	cntin, .Lzero_length
 | 
				
			||||||
	mov	wtmp2, #0x0401
 | 
						mov	wtmp2, #0x0401
 | 
				
			||||||
	movk	wtmp2, #0x4010, lsl #16
 | 
						movk	wtmp2, #0x4010, lsl #16
 | 
				
			||||||
	dup	vrepchr.16b, chrin
 | 
						dup	vrepchr.16b, chrin
 | 
				
			||||||
@@ -157,4 +158,8 @@ ENTRY(memchr)
 | 
				
			|||||||
	/* Select result or NULL */
 | 
						/* Select result or NULL */
 | 
				
			||||||
	csel	result, xzr, result, eq
 | 
						csel	result, xzr, result, eq
 | 
				
			||||||
	ret
 | 
						ret
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.Lzero_length:
 | 
				
			||||||
 | 
						mov	result, xzr
 | 
				
			||||||
 | 
						ret
 | 
				
			||||||
END(memchr)
 | 
					END(memchr)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -763,6 +763,14 @@ TEST(string, memchr) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST(string, memchr_zero) {
 | 
				
			||||||
 | 
					  uint8_t* buffer;
 | 
				
			||||||
 | 
					  ASSERT_EQ(0, posix_memalign(reinterpret_cast<void**>(&buffer), 64, 64));
 | 
				
			||||||
 | 
					  memset(buffer, 10, 64);
 | 
				
			||||||
 | 
					  ASSERT_TRUE(NULL == memchr(buffer, 5, 0));
 | 
				
			||||||
 | 
					  ASSERT_TRUE(NULL == memchr(buffer, 10, 0));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(string, memrchr) {
 | 
					TEST(string, memrchr) {
 | 
				
			||||||
  int seek_char = random() & 255;
 | 
					  int seek_char = random() & 255;
 | 
				
			||||||
  StringTestState<char> state(SMALL);
 | 
					  StringTestState<char> state(SMALL);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user