]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/go/bytes/indexbyte.c
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / libgo / go / bytes / indexbyte.c
1 /* indexbyte.c -- implement bytes.IndexByte for Go.
2
3 Copyright 2009 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. */
6
7 #include <stddef.h>
8
9 #include "array.h"
10
11 /* This is in C so that the compiler can optimize it
12 appropriately. */
13
14 int IndexByte (struct __go_open_array, char)
15 asm ("libgo_bytes.bytes.IndexByte");
16
17 int
18 IndexByte (struct __go_open_array s, char b)
19 {
20 char *p;
21
22 p = __builtin_memchr (s.__values, b, s.__count);
23 if (p == NULL)
24 return -1;
25 return p - (char *) s.__values;
26 }