1 /* indexbyte.c -- implement strings.IndexByte for Go.
3 Copyright 2013 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
10 #include "go-string.h"
12 /* This is in C so that the compiler can optimize it appropriately.
13 We deliberately don't split the stack in case it does call the
14 library function, which shouldn't need much stack space. */
16 intgo
IndexByte (String
, char)
17 __asm__ (GOSYM_PREFIX
"strings.IndexByte")
18 __attribute__ ((no_split_stack
));
21 IndexByte (String s
, char b
)
25 p
= __builtin_memchr ((const char *) s
.str
, b
, s
.len
);
28 return p
- (const char *) s
.str
;