I want to try build but i got:
Код:
In file included from /usr/include/dlfcn.h:22:0,
from libsource.c:60:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
Код:
/*
* Copyright (C) 2009 Seth Schultz
* Version 0.0.1
*
* Libsource.c is a shared library aimed at reducing the system call overhead
* of the Source Dedicated Server, thus reducing server sides latencies.
* Take this as my contribution to the community for always being helpful
* in my journey for higher and more stable server side fps. Please also
* take note that this is my first release, and I am sure there are things
* that can be done better.
*
* This software is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ----------------------------------------------------------------------------
* If you are able and willing to help me further develop this library,
* please contact me on IRC.
*
* Special thanks:
* Monk - Thank you for your brilliant blog,
* it inspired all of my initial work.
* Baz - Thank you for your kernel config help
* and all the field testing you have done for me.
* Hrg - Thank you for your direction and your wiki.
* SRCDS Forums - Thank you all for the positive encouragement.
*
* If I have forgotten anyone, I thank you and appreciate your previous
* and continued support!
*
* -DiSTANT
*
* Compile & Load
* ----------------
*
* 32-bit:
* gcc -shared -o libsource.so libsource.c -lrt
* LD_PRELOAD=./libsource.so ./srcds_run ...
*
* 64-bit:
* gcc -shared -m32 -o libsource.so libsource.c -lrt
* LD_PRELOAD_32=./libsource.so ./srcds_run ...
*
* Need Help? Join us on IRC.
* Server: irc.gamesurge.net
* Channel: #SourceKernel
*
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>
#include <sys/select.h>
#include <sys/time.h>
#define CLOCK_ID CLOCK_REALTIME
int
gettimeofday(struct timeval *tp, struct timezone *tzp)
{
struct timespec ts;
//Try to get CLOCK_MONOTONIC working (however, might add time scew)
clock_gettime(CLOCK_ID, &ts);
tp->tv_sec = ts.tv_sec;
tp->tv_usec = ts.tv_nsec / 1000;
return (0);
}
int
low_latency_sleep(unsigned long msec)
{
struct timespec req={0};
time_t sec=(int)(msec/1000);
msec = msec - (sec * 1000);
req.tv_sec=sec;
req.tv_nsec=msec*1000000L;
while(nanosleep(&req,&req)==-1)
continue;
return 1;
}
extern int
usleep (__useconds_t __usec)
{
low_latency_sleep(__usec/1000);
return (0);
}
extern int
select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
{
//Instead of using pselect can we use poll? (pselect may be adding unecessary overhead)
struct timespec ts;
ts.tv_sec = timeout->tv_sec / 1000;
ts.tv_nsec = timeout->tv_usec / 100000;
return pselect(nfds, readfds, writefds, errorfds, &ts, NULL);
}