/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*/
/*
* This compiles to a module that can be preloaded during a build. If this
* is preloaded, it interposes on time(2), gettimeofday(3C), and
* clock_gethrtime(3C) and returns a constant number of seconds since epoch
* when the execname matches one of the desired "programs" and TIME_CONSTANT
* contains an integer value to be returned.
*/
#include <stdlib.h>
#include <ucontext.h>
#include <dlfcn.h>
#include <strings.h>
#include <time.h>
/* The list of programs that we want to use a constant time. */
static char *programs[] = {
"autogen", "bash", "cpp", "cc1", "date", "doxygen",
"erl", "grops", "gs", "gtroff", "javadoc", "ksh", "ksh93", "ld",
};
static int
{
void *sym;
}
return (0);
}
static char *
{
static char *execname;
if (getcontext(&ctx) == 0)
if (s != NULL)
execname = ++s;
}
}
return (execname);
}
static time_t
{
int i;
static char *time_string;
if (time_string == NULL)
if (time_string != NULL)
break;
}
}
return (result);
}
{
return (result);
}
int
{
"gettimeofday");
}
return (result);
}
int
{
"clock_gettime");
}
return (result);
}