/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* 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. */
"erl", "javadoc", "ksh", "ksh93", "ld", "perl", "perl5.8.4", "perl5.10",
static int
{
void *sym;
}
return (0);
}
static char *
my_execname(void)
{
static char *execname;
if (getcontext(&ctx) == 0)
if (s != NULL)
execname = ++s;
}
}
return (execname);
}
static time_t
time_constant(void)
{
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);
}