다음 코드를 컴파일하여 LD_PRELOAD?와 작동하게하려면 어떻게해야합니까? 나는 나가에 코드 '분사'에 노력하고있어 프로그램을 열 때 'gcc -m32 -shared code.c
는'하지만, 그것은이 말한다에 오류하여 w/o 컴파일 관리 'symbol lookup error: ./fps.so: undefined symbol: clock_gettime
'리눅스에서 LD_PRELOAD를 사용하려면이 코드를 어떻게 컴파일합니까?
#include<unistd.h>
#include<time.h>
#define BUSY_WAIT 3000
/* We use clock_gettime because it's better than gettimeofday */
unsigned long long int fetch_clock()
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return (unsigned long long int)ts.tv_nsec + 1000000*ts.tv_sec;
}
int high_pres_usleep_untill(unsigned long long int end)
{
unsigned long long int busywait, start;
int sleep, delay;
start = fetch_clock();
delay = end - start;
sleep = (delay/BUSY_WAIT) - 1;
if(sleep > 0)
if(usleep(sleep*BUSY_WAIT))
return -1;
while(fetch_clock() < end)
;
return 0;
}
초에 몇 나노초가 있습니까? 그리고 여러분은 곱셈의 피연산자 중 하나를 나노초 값 이상으로 캐스팅해야합니다. –