1272343Sngie/*-
2272343Sngie * Copyright (c) 2014 The NetBSD Foundation, Inc.
3272343Sngie * All rights reserved.
4272343Sngie *
5272343Sngie * This code is derived from software contributed to The NetBSD Foundation
6272343Sngie * by Joerg Sonnenberger.
7272343Sngie *
8272343Sngie * Redistribution and use in source and binary forms, with or without
9272343Sngie * modification, are permitted provided that the following conditions
10272343Sngie * are met:
11272343Sngie * 1. Redistributions of source code must retain the above copyright
12272343Sngie *    notice, this list of conditions and the following disclaimer.
13272343Sngie * 2. Redistributions in binary form must reproduce the above copyright
14272343Sngie *    notice, this list of conditions and the following disclaimer in the
15272343Sngie *    documentation and/or other materials provided with the distribution.
16272343Sngie *
17272343Sngie * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18272343Sngie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19272343Sngie * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20272343Sngie * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21272343Sngie * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22272343Sngie * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23272343Sngie * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24272343Sngie * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25272343Sngie * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26272343Sngie * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27272343Sngie * POSSIBILITY OF SUCH DAMAGE.
28272343Sngie */
29272343Sngie
30272343Sngie#include <stdlib.h>
31272343Sngie#include <string.h>
32272343Sngie
33272343Sngiestatic int
34272343Sngieifunc1(void)
35272343Sngie{
36272343Sngie	return 0xdeadbeef;
37272343Sngie}
38272343Sngie
39272343Sngiestatic int
40272343Sngieifunc2(void)
41272343Sngie{
42272343Sngie	return 0xbeefdead;
43272343Sngie}
44272343Sngie
45272343Sngiestatic __attribute__((used))
46272343Sngieint (*resolve_ifunc(void))(void)
47272343Sngie{
48272343Sngie	const char *e = getenv("USE_IFUNC2");
49272343Sngie	return e && strcmp(e, "1") == 0 ? ifunc2 : ifunc1;
50272343Sngie}
51272343Sngie
52272343Sngie__ifunc(ifunc, resolve_ifunc);
53