Skip to content
Permalink
Browse files

Replace missing sys_main/{os} functions

  • Loading branch information...
Kangz committed Jan 27, 2015
1 parent b99a9e3 commit 006a66466193ca5c4554378028f61c3bc3f9660d
@@ -45,7 +45,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Indicates that a function does not return
#define NORETURN __attribute__((__noreturn__))
#define NORETURN_PTR __attribute__((__noreturn__))

// Expect printf-style arguments for a function: a is the index of the format
// string, and b is the index of the first variable argument
@@ -155,7 +154,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DEPRECATED __declspec(deprecated)
#define COLD
#define NORETURN __declspec(noreturn)
#define NORETURN_PTR
#define PRINTF_LIKE(n)
#define VPRINTF_LIKE(n)
#define PRINTF_TRANSLATE_ARG(a)
@@ -44,7 +44,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef INLINE
#undef DLLEXPORT
#undef NORETURN
#undef NORETURN_PTR
#include "../libs/nacl/native_client/src/shared/imc/nacl_imc_c.h"
#include "../libs/nacl/native_client/src/public/imc_types.h"
#include "../libs/nacl/native_client/src/trusted/service_runtime/nacl_config.h"
@@ -75,7 +75,11 @@ class DropErr: public std::runtime_error {
DropErr(const std::string& message)
: std::runtime_error(message) {}
};
NORETURN void Drop(Str::StringRef errorMessage);

#ifdef BUILD_VM
NORETURN
#endif
void Drop(Str::StringRef errorMessage);

// Variadic wrappers for Error and Drop
template<typename ... Args> void Error(Str::StringRef format, Args&& ... args)
@@ -86,8 +86,10 @@ namespace Log {

virtual bool Process(std::vector<Log::Event>& events) OVERRIDE {
for (Log::Event event : events) {
Sys_Print(event.text.c_str());
Sys_Print("\n");
CON_LogWrite(event.text.c_str());
CON_Print(event.text.c_str());
CON_LogWrite("\n");
CON_Print("\n");
}
return true;
}
@@ -170,7 +170,7 @@ void QDECL PRINTF_LIKE(1) Com_Printf( const char *fmt, ... )
va_end( argptr );
}

void QDECL Com_LogEvent( log_event_t *event, log_location_info_t *location )
void QDECL Com_LogEvent( log_event_t *event, log_location_info_t *)
{
switch (event->level)
{
@@ -257,7 +257,7 @@ do the appropriate things.
=============
*/
// *INDENT-OFF*
void QDECL PRINTF_LIKE(2) NORETURN Com_Error( int code, const char *fmt, ... )
void QDECL PRINTF_LIKE(2) Com_Error( int code, const char *fmt, ... )
{
char buf[ 4096 ];
va_list argptr;
@@ -1277,7 +1277,7 @@ sysEvent_t Com_GetEvent( void )
}

// check for console commands
s = Sys_ConsoleInput();
s = CON_Input();

if ( s )
{
@@ -1542,7 +1542,7 @@ Just throw a fatal error to
test error shutdown procedures
=============
*/
static void NORETURN Com_Error_f( void )
static void Com_Error_f( void )
{
if ( Cmd_Argc() > 1 )
{
@@ -1625,6 +1625,11 @@ void Com_SetRecommended( void )
}
}

void Com_In_Restart_f( void )
{
IN_Restart();
}

/*
=================
Com_Init
@@ -1713,7 +1718,7 @@ void Com_Init( char *commandLine )
s = va( "%s %s %s %s", Q3_VERSION, PLATFORM_STRING, ARCH_STRING, __DATE__ );
com_version = Cvar_Get( "version", s, CVAR_ROM | CVAR_SERVERINFO );

Sys_Init();
Cmd_AddCommand( "in_restart", Com_In_Restart_f );

// Pick a qport value that is nice and random.
// As machines get faster, Com_Milliseconds() can't be used
@@ -2006,7 +2011,7 @@ void Com_Frame()
while ( msec < minMsec )
{
//give cycles back to the OS
Sys_Sleep( std::min( minMsec - msec, 50 ) );
Sys::SleepFor(std::chrono::milliseconds(std::min(minMsec - msec, 50)));
IN_Frame();

com_frameTime = Com_EventLoop();
@@ -2161,18 +2166,25 @@ fills string array with len radom bytes, peferably from the OS randomizer
*/
void Com_RandomBytes( byte *string, int len )
{
int i;
static std::random_device rd;
static std::mt19937 prng(rd());
static std::uniform_int_distribution<uint32_t> dist;

if ( Sys_RandomBytes( string, len ) )
{
return;
while (len >= 4) {
*(uint32_t*)string = dist(prng);
string += 4;
len -= 4;
}

Com_Printf( "Com_RandomBytes: using weak randomization\n" );
if (len == 0) {
return;
}

for ( i = 0; i < len; i++ )
{
string[ i ] = ( unsigned char )( rand() % 255 );
uint32_t remainder = dist(prng);
while (len-->0) {
*string = uint8_t(remainder & 0xFF);
remainder >>= 8;
string ++;
}
}

This file was deleted.

@@ -100,7 +100,7 @@ typedef enum
} errorParm_t;

// this is only here so the functions in q_shared.c and bg_*.c can link
void QDECL NORETURN Com_Error( int level, const char *error, ... ) PRINTF_LIKE(2);
void QDECL Com_Error( int level, const char *error, ... ) PRINTF_LIKE(2);
void QDECL Com_Printf( const char *msg, ... ) PRINTF_LIKE(1);
void QDECL Com_DPrintf( const char *msg, ... ) PRINTF_LIKE(1);

@@ -546,6 +546,7 @@ INPUT

void IN_Frame();
void IN_FrameEnd();
void IN_Restart();
bool IN_IsNumLockDown();

/*
@@ -556,7 +557,23 @@ DOWNLOAD
==============================================================
*/

#include "dl_public.h"
typedef enum
{
DL_CONTINUE,
DL_DONE,
DL_FAILED
} dlStatus_t;

int DL_BeginDownload( const char *localName, const char *remoteName, int debug );
dlStatus_t DL_DownloadLoop( void );

void DL_Shutdown( void );

// bitmask
typedef enum
{
DL_FLAG_DISCON = 0
} dlFlags_t;

/*
==============================================================
@@ -946,7 +963,9 @@ char *Sys_DefaultLibPath( void );
char *Sys_DefaultHomePath( void );
char *Sys_Dirname( char *path );
char *Sys_Basename( char *path );
char *Sys_ConsoleInput( void );
char *CON_Input( void );
unsigned int CON_LogWrite(const char* text);
void CON_Print(const char* text);

void Sys_Sleep( int msec );

@@ -210,7 +210,7 @@ typedef struct
void ( QDECL *Printf )( int printLevel, const char *fmt, ... ) PRINTF_LIKE(2);

// abort the game
void ( QDECL *Error )( int errorLevel, const char *fmt, ... ) PRINTF_LIKE(2) NORETURN_PTR;
void ( QDECL *Error )( int errorLevel, const char *fmt, ... ) PRINTF_LIKE(2);

// milliseconds should only be used for profiling, never
// for anything game related. Get time from the refdef

0 comments on commit 006a664

Please sign in to comment.
You can’t perform that action at this time.